Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.
Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
#include "Contents/Configuration/GraphicsConfiguration.h"
|
|
#include "Contents/Configuration/OptionWriter.h"
|
|
#include "Contents/Configuration/ScriptOptions.h"
|
|
#include "Render/RenderAdapter.h"
|
|
#include "Script/LuaScript.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstring>
|
|
|
|
void GraphicsConfiguration::Load(LuaScript& script, ScriptOptions& options, int& screenWidth, int& screenHeight) {
|
|
const int resetPolicy = std::max(script.GlobalInteger("RenderSystemReset"), 0);
|
|
const int backendPolicy = std::max(script.GlobalInteger("RenderSystemDefault"), 0);
|
|
this->reset = options.Integer("RenderSystemReset", 1);
|
|
|
|
if (this->reset != resetPolicy) {
|
|
this->backend = backendPolicy;
|
|
this->reset = resetPolicy;
|
|
} else {
|
|
this->backend = options.Integer("RENDERSYSTEM", backendPolicy);
|
|
}
|
|
|
|
this->deviceGuid = options.Guid("DX9DEVICEID", GUID{});
|
|
const std::string name = options.String("DX9DEVICENAME", "");
|
|
strncpy_s(this->deviceName, sizeof(this->deviceName), name.c_str(), _TRUNCATE);
|
|
this->fullscreen = options.Integer("ISFULLSCREENMODE", 0);
|
|
this->width = options.Integer("WIDTH", 1024);
|
|
this->height = options.Integer("HEIGHT", 768);
|
|
this->oldWidth = options.Integer("OLD_WIDTH", 0);
|
|
this->oldHeight = options.Integer("OLD_HEIGHT", 0);
|
|
|
|
if (static_cast<unsigned>(this->height) < 664) {
|
|
this->width = 1024;
|
|
this->height = 768;
|
|
}
|
|
|
|
screenWidth = this->width;
|
|
screenHeight = this->height;
|
|
this->bitsPerPixel = options.Integer("BITPERPIXEL", 16);
|
|
OSVERSIONINFOA version{};
|
|
version.dwOSVersionInfoSize = sizeof(version);
|
|
GetVersionExA(&version);
|
|
|
|
if (version.dwMajorVersion >= 6 && version.dwMinorVersion >= 2) {
|
|
this->bitsPerPixel = 32;
|
|
}
|
|
}
|
|
|
|
AdapterConfiguration GraphicsConfiguration::Adapter() const {
|
|
return {this->backend, this->drawGuid, this->renderGuid, this->deviceGuid, this->deviceName};
|
|
}
|
|
|
|
void GraphicsConfiguration::Save(OptionWriter& output) const {
|
|
output.Integer("RenderSystemReset", this->reset);
|
|
output.Integer("RENDERSYSTEM", this->backend);
|
|
output.Guid("DX9DEVICEID", this->deviceGuid);
|
|
output.String("DX9DEVICENAME", this->deviceName);
|
|
output.Integer("ISFULLSCREENMODE", this->fullscreen);
|
|
output.Integer("WIDTH", this->width);
|
|
output.Integer("HEIGHT", this->height);
|
|
|
|
output.Integer("OLD_WIDTH", this->width);
|
|
output.Integer("OLD_HEIGHT", this->height);
|
|
output.Integer("BITPERPIXEL", this->bitsPerPixel);
|
|
}
|