mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Merge pull request #18 from blupi-games/issue/17-zoom
Add support for cli option to change the window size It's possible to use the `"zoom" property in the "config.json" file or the cli arguments `-f off -z 2` for example.
This commit is contained in:
commit
6d470acd93
@ -59,6 +59,7 @@ CDecor * g_pDecor = nullptr;
|
||||
std::thread * g_updateThread = nullptr;
|
||||
|
||||
bool g_bFullScreen = false; // false si mode de test
|
||||
Uint8 g_windowScale = 1;
|
||||
Sint32 g_speedRate = 1;
|
||||
Sint32 g_timerInterval = 50; // inverval = 50ms
|
||||
int g_rendererType = 0;
|
||||
@ -71,6 +72,7 @@ enum Settings {
|
||||
SETTING_SPEEDRATE = 1 << 1,
|
||||
SETTING_TIMERINTERVAL = 1 << 2,
|
||||
SETTING_RENDERER = 1 << 3,
|
||||
SETTING_ZOOM = 1 << 4,
|
||||
};
|
||||
|
||||
static int g_settingsOverload = 0;
|
||||
@ -152,6 +154,13 @@ ReadConfig ()
|
||||
g_bFullScreen = 1;
|
||||
}
|
||||
|
||||
if (!(g_settingsOverload & SETTING_ZOOM) && j.find ("zoom") != j.end ())
|
||||
{
|
||||
g_windowScale = j["zoom"].get<Uint8> ();
|
||||
if (g_windowScale != 1 && g_windowScale != 2)
|
||||
g_windowScale = 1;
|
||||
}
|
||||
|
||||
if (
|
||||
!(g_settingsOverload & SETTING_RENDERER) && j.find ("renderer") != j.end ())
|
||||
{
|
||||
@ -526,6 +535,10 @@ parseArgs (int argc, char * argv[], bool & exit)
|
||||
{"-f", "--fullscreen"},
|
||||
"load in fullscreen [on;off] (default: on)",
|
||||
1},
|
||||
{"zoom",
|
||||
{"-z", "--zoom"},
|
||||
"change the window scale (only if fullscreen is off) [1;2] (default: 1)",
|
||||
1},
|
||||
{"renderer",
|
||||
{"-r", "--renderer"},
|
||||
"set a renderer [auto;software;accelerated] (default: auto)",
|
||||
@ -587,6 +600,12 @@ parseArgs (int argc, char * argv[], bool & exit)
|
||||
g_settingsOverload |= SETTING_FULLSCREEN;
|
||||
}
|
||||
|
||||
if (args["zoom"])
|
||||
{
|
||||
g_windowScale = args["zoom"];
|
||||
g_settingsOverload |= SETTING_ZOOM;
|
||||
}
|
||||
|
||||
if (args["renderer"])
|
||||
{
|
||||
if (args["renderer"].as<std::string> () == "auto")
|
||||
@ -905,6 +924,8 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
||||
g_updateThread = new std::thread (CheckForUpdates);
|
||||
g_pEvent->SetFullScreen (g_bFullScreen);
|
||||
if (!g_bFullScreen)
|
||||
g_pEvent->SetWindowSize (g_windowScale);
|
||||
g_pEvent->ChangePhase (EV_PHASE_INTRO1);
|
||||
|
||||
g_bTermInit = true;
|
||||
|
@ -1667,6 +1667,33 @@ CEvent::SetFullScreen (bool bFullScreen)
|
||||
CEvent::PushUserEvent (EV_WARPMOUSE, coord);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Change the size of the window.
|
||||
*
|
||||
* We use an integer scale to be sure that the pixels are always well formed.
|
||||
*
|
||||
* \param[in] newScale - The new scale.
|
||||
*/
|
||||
void
|
||||
CEvent::SetWindowSize (Uint8 newScale)
|
||||
{
|
||||
if (newScale == m_WindowScale)
|
||||
return;
|
||||
|
||||
auto scale = m_WindowScale;
|
||||
m_WindowScale = newScale;
|
||||
switch (newScale)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
SetWindowSize (scale, m_WindowScale);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Change the size of the window.
|
||||
*
|
||||
|
@ -140,6 +140,7 @@ public:
|
||||
void IntroStep ();
|
||||
|
||||
Uint8 GetWindowScale ();
|
||||
void SetWindowSize (Uint8 newScale);
|
||||
void SetUpdateVersion (const std::string & version);
|
||||
|
||||
static void PushUserEvent (Sint32 code, void * data = nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user