Nothing else works, so restart the game on resolution change
Fixes #339 for now, but we'll need alternative solution laterdev-mp
parent
c9eb3ce5c5
commit
26376c652d
|
@ -113,6 +113,7 @@ CApplication::CApplication()
|
|||
m_exitCode = 0;
|
||||
m_active = false;
|
||||
m_debugModes = 0;
|
||||
m_restart = false;
|
||||
|
||||
m_windowTitle = "COLOBOT: Gold Edition";
|
||||
|
||||
|
@ -675,6 +676,17 @@ void CApplication::Destroy()
|
|||
SDL_Quit();
|
||||
}
|
||||
|
||||
void CApplication::Restart()
|
||||
{
|
||||
m_restart = true;
|
||||
m_eventQueue->AddEvent(Event(EVENT_SYS_QUIT));
|
||||
}
|
||||
|
||||
bool CApplication::IsRestarting()
|
||||
{
|
||||
return m_restart;
|
||||
}
|
||||
|
||||
bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
|
||||
{
|
||||
static bool restore = false;
|
||||
|
|
|
@ -227,6 +227,11 @@ public:
|
|||
|
||||
//! Cleans up before exit
|
||||
void Destroy();
|
||||
|
||||
//! Restart
|
||||
void Restart();
|
||||
//! Should we restart after app quits?
|
||||
bool IsRestarting();
|
||||
|
||||
//! Returns a list of possible video modes
|
||||
VideoQueryResult GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
|
||||
|
@ -413,6 +418,8 @@ protected:
|
|||
bool m_active;
|
||||
//! Bit array of active debug modes
|
||||
long m_debugModes;
|
||||
//! If we are restarting the app
|
||||
bool m_restart;
|
||||
|
||||
//! Message to be displayed as error to the user
|
||||
std::string m_errorMessage;
|
||||
|
|
|
@ -86,43 +86,47 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
|||
InitializeRestext();
|
||||
InitializeEventTypeTexts();
|
||||
|
||||
CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
systemUtils->Init();
|
||||
|
||||
logger.Info("Colobot starting\n");
|
||||
|
||||
CApplication* app = new CApplication(); // single instance of the application
|
||||
|
||||
ParseArgsStatus status = app->ParseArguments(argc, argv);
|
||||
if (status == PARSE_ARGS_FAIL)
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
|
||||
return app->GetExitCode();
|
||||
}
|
||||
else if (status == PARSE_ARGS_HELP)
|
||||
{
|
||||
return app->GetExitCode();
|
||||
}
|
||||
|
||||
|
||||
int code = 0;
|
||||
while(true) {
|
||||
CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
systemUtils->Init();
|
||||
|
||||
CApplication* app = new CApplication(); // single instance of the application
|
||||
|
||||
if (! app->Create())
|
||||
{
|
||||
app->Destroy(); // ensure a clean exit
|
||||
code = app->GetExitCode();
|
||||
if ( code != 0 && !app->GetErrorMessage().empty() )
|
||||
ParseArgsStatus status = app->ParseArguments(argc, argv);
|
||||
if (status == PARSE_ARGS_FAIL)
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
|
||||
return app->GetExitCode();
|
||||
}
|
||||
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
|
||||
return code;
|
||||
else if (status == PARSE_ARGS_HELP)
|
||||
{
|
||||
return app->GetExitCode();
|
||||
}
|
||||
|
||||
|
||||
if (! app->Create())
|
||||
{
|
||||
app->Destroy(); // ensure a clean exit
|
||||
code = app->GetExitCode();
|
||||
if ( code != 0 && !app->GetErrorMessage().empty() )
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
|
||||
}
|
||||
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = app->Run();
|
||||
bool restarting = app->IsRestarting();
|
||||
|
||||
delete app;
|
||||
delete systemUtils;
|
||||
if(!restarting) break;
|
||||
}
|
||||
|
||||
code = app->Run();
|
||||
|
||||
delete app;
|
||||
delete systemUtils;
|
||||
|
||||
logger.Info("Exiting with code %d\n", code);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -4677,7 +4677,13 @@ void CMainDialog::ChangeDisplay()
|
|||
bFull = pc->TestState(STATE_CHECK);
|
||||
m_setupFull = bFull;
|
||||
|
||||
SetupMemorize();
|
||||
|
||||
#if !PLATFORM_LINUX
|
||||
// Windows causes problems, so we'll restart the game
|
||||
// Mac OS was not tested so let's restart just to be sure
|
||||
m_app->Restart();
|
||||
#else
|
||||
std::vector<Math::IntPoint> modes;
|
||||
m_app->GetVideoResolutionList(modes, true, true);
|
||||
|
||||
|
@ -4685,6 +4691,7 @@ void CMainDialog::ChangeDisplay()
|
|||
config.size = modes[m_setupSelMode];
|
||||
config.fullScreen = bFull;
|
||||
m_app->ChangeVideoConfig(config);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue