diff --git a/source/code/global.hpp b/source/code/global.hpp index b9a4b8b..825e72d 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp @@ -33,6 +33,7 @@ http://www.blockattack.net #include "sago/SagoTextField.hpp" void MainMenu(); +void SafeModeMenu(); void ResetFullscreen(); void RunGameState(sago::GameStateInterface& state ); diff --git a/source/code/main.cpp b/source/code/main.cpp index dd88d1f..a91665f 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -944,6 +944,10 @@ int main(int argc, char* argv[]) { PhysFsSetSearchPath(config.search_paths, config.savepath); //Os create folders must be after the parameters because they can change the home folder PhysFsCreateFolders(); + bool gameShutdownProperly = true; + if (sago::FileExists("gameRunning")) { + gameShutdownProperly = false; + } sago::WriteFileContent("gameRunning", "Started"); globalData.SoundEnabled = true; globalData.MusicEnabled = true; @@ -1075,6 +1079,10 @@ int main(int argc, char* argv[]) { if (configSettings->getInt("always-software")) { config.softwareRenderer = true; } + if (!gameShutdownProperly) { + std::cerr << "Game not shotdown. Using software renderer.\n"; + config.softwareRenderer = true; + } // "Block Attack - Rise of the Blocks" SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); @@ -1147,6 +1155,9 @@ int main(int argc, char* argv[]) { RunGameState(rp); } else { + if (!gameShutdownProperly) { + SafeModeMenu(); + } //game loop MainMenu(); } diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index 182072d..68670da 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp @@ -438,6 +438,24 @@ static void SinglePlayerMenu() { RunGameState(m); } +void SafeModeMenu() { + if (Config::getInstance()->getInt("always-software")) { + return; + } + InitMenues(); + Menu safeMode(globalData.screen, _("Game did not shutdown as it should"), true); + Button bOnce; + Button bAlways; + bOnce.setLabel(_("Use software renderer this time")); + bAlways.setLabel(_("Always use software renderer")); + bOnce.setPopOnRun(true); + bAlways.setAction([]() {Config::getInstance()->setInt("always-software", 1); }); + bAlways.setPopOnRun(true); + safeMode.addButton(&bOnce); + safeMode.addButton(&bAlways); + RunGameState(safeMode); +} + void MainMenu() { InitMenues(); Menu m(globalData.screen,_("Block Attack - Rise of the blocks"),false);