Fixed window position config storage and command line parsing

This commit is contained in:
Bart Trzynadlowski 2023-03-04 11:59:49 -08:00 committed by trzy
parent 83144f80b7
commit ae5af4c036

View file

@ -1087,14 +1087,9 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In
SDL_SetWindowTitle(s_window, baseTitleStr);
SDL_SetWindowSize(s_window, totalXRes, totalYRes);
if (!s_runtime_config["WindowXPosition"].Empty() && !s_runtime_config["WindowYPosition"].Empty())
{
SDL_SetWindowPosition(s_window, s_runtime_config["WindowXPosition"].ValueAs<unsigned>(), s_runtime_config["WindowYPosition"].ValueAs<unsigned>());
}
else
{
SDL_SetWindowPosition(s_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
int xpos = s_runtime_config["WindowXPosition"].Exists() ? s_runtime_config["WindowXPosition"].ValueAs<int>() : SDL_WINDOWPOS_CENTERED;
int ypos = s_runtime_config["WindowYPosition"].Exists() ? s_runtime_config["WindowYPosition"].ValueAs<int>() : SDL_WINDOWPOS_CENTERED;
SDL_SetWindowPosition(s_window, xpos, ypos);
if (s_runtime_config["BorderlessWindow"].ValueAs<bool>())
{
@ -1642,8 +1637,8 @@ static Util::Config::Node DefaultConfig()
config.Set("QuadRendering", false);
config.Set("XResolution", "496");
config.Set("YResolution", "384");
config.Set("WindowXPosition", "NA");
config.Set("WindowYPosition", "NA");
config.SetEmpty("WindowXPosition");
config.SetEmpty("WindowYPosition");
config.Set("FullScreen", false);
config.Set("BorderlessWindow", false);
@ -1966,13 +1961,11 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv)
}
else
{
unsigned x, y;
if (2 == sscanf(&argv[i][4], "=%u,%u", &x, &y))
int xpos, ypos;
if (2 == sscanf(&argv[i][11], "=%d,%d", &xpos, &ypos))
{
std::string xres = Util::Format() << x;
std::string yres = Util::Format() << y;
cmd_line.config.Set("WindowXPosition", xres);
cmd_line.config.Set("WindowYPosition", yres);
cmd_line.config.Set("WindowXPosition", xpos);
cmd_line.config.Set("WindowYPosition", ypos);
}
else
{