1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

Added window configs

This commit is contained in:
mole99 2018-05-19 16:25:34 +02:00
parent b77ca47fd4
commit 8d7cb91b60
3 changed files with 31 additions and 0 deletions

View File

@ -89,6 +89,16 @@ GameBase::GameBase(Logger &inlog, int argc, char *argv[]) :
throw std::runtime_error(config.getParseResult().what());
}
if (!vm.count("width")) {
w = config.getWindowWidth();
}
if (!vm.count("height")) {
h = config.getWindowHeight();
}
if (!vm.count("fullscreen")) {
fullscreen = config.getWindowFullscreen();
}
if (SDL_Init(SDL_INIT_VIDEO) < 0)
throw std::runtime_error("Failed to initialize SDL2!");

View File

@ -218,6 +218,7 @@ GameConfig::ParseResult GameConfig::parseConfig(GameConfig::ParseType srcType,
auto deft = StringTranslator();
auto boolt = BoolTranslator();
auto patht = PathTranslator();
auto intt = IntTranslator();
// Add new configuration parameters here.
// Additionally, add them to the unit test.
@ -229,6 +230,10 @@ GameConfig::ParseResult GameConfig::parseConfig(GameConfig::ParseType srcType,
read_config("input.invert_y", this->m_inputInvertY, false, boolt);
read_config("window.width", this->m_windowWidth, 800, intt);
read_config("window.height", this->m_windowHeight, 600, intt);
read_config("window.fullscreen", this->m_windowFullscreen, false, boolt);
// Build the unknown key/value map from the correct source
switch (srcType) {
case ParseType::FILE:

View File

@ -222,6 +222,15 @@ public:
bool getInputInvertY() const {
return m_inputInvertY;
}
int getWindowWidth() const {
return m_windowWidth;
}
int getWindowHeight() const {
return m_windowHeight;
}
bool getWindowFullscreen() const {
return m_windowFullscreen;
}
static rwfs::path getDefaultConfigPath();
private:
@ -256,6 +265,13 @@ private:
/// Invert the y axis for camera control.
bool m_inputInvertY;
/// Size of the window
int m_windowWidth;
int m_windowHeight;
/// Set the window to fullscreen
bool m_windowFullscreen;
};
#endif