diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 54f1b4ca0..25376e526 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -6183,7 +6183,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,cons if(gameVer != glestVersionString && checkVersionComptability(gameVer, glestVersionString) == false) { char szBuf[8096]=""; snprintf(szBuf,8096,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str()); - throw megaglest_runtime_error(szBuf); + throw megaglest_runtime_error(szBuf,true); } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str()); @@ -6244,7 +6244,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,cons if(gameVer != glestVersionString && checkVersionComptability(gameVer, glestVersionString) == false) { char szBuf[8096]=""; snprintf(szBuf,8096,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str()); - throw megaglest_runtime_error(szBuf); + throw megaglest_runtime_error(szBuf,true); } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str()); diff --git a/source/glest_game/menu/menu_state_load_game.cpp b/source/glest_game/menu/menu_state_load_game.cpp index e5ed0cbde..77093e374 100644 --- a/source/glest_game/menu/menu_state_load_game.cpp +++ b/source/glest_game/menu/menu_state_load_game.cpp @@ -121,6 +121,10 @@ MenuStateLoadGame::MenuStateLoadGame(Program *program, MainMenu *mainMenu): listFiles(); slotsScrollBar.setElementCount(filenames.size()); + mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox"); + mainMessageBox.init(lang.get("Ok"),450); + mainMessageBox.setEnabled(false); + GraphicComponent::applyAllCustomProperties(containerName); } @@ -183,6 +187,8 @@ void MenuStateLoadGame::reloadUI() { deleteButton.setText(lang.get("Delete")); loadButton.setText(lang.get("LoadGame")); + mainMessageBox.init(lang.get("Ok"),450); + GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName); } @@ -191,6 +197,15 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){ CoreData &coreData= CoreData::getInstance(); SoundRenderer &soundRenderer= SoundRenderer::getInstance(); + if(mainMessageBox.getEnabled()) { + int button= 0; + if(mainMessageBox.mouseClick(x, y, button)) { + mainMessageBox.setEnabled(false); + + Lang &lang= Lang::getInstance(); + mainMessageBox.init(lang.get("Ok"),450); + } + } if(abortButton.mouseClick(x, y)) { soundRenderer.playFx(coreData.getClickSoundB()); mainMenu->setState(new MenuStateRoot(program, mainMenu)); @@ -245,7 +260,12 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){ snprintf(szBuf,8096,lang.get("LoadGameLoadingFile","",true).c_str(),filename.c_str()); console.addLineOnly(szBuf); - Game::loadGame(filename,program,false); + try { + Game::loadGame(filename,program,false); + } + catch(const megaglest_runtime_error &ex) { + showMessageBox(ex.what(), lang.get("Notice"), true); + } return; } //mainMenu->setState(new MenuStateRoot(program, mainMenu)); @@ -389,6 +409,9 @@ void MenuStateLoadGame::render(){ renderer.renderTextureQuad(550,slotLinesYBase-300+slotsLineHeight,400,300,previewTexture,1.0f); } + if(mainMessageBox.getEnabled()) { + renderer.renderMessageBox(&mainMessageBox); + } renderer.renderConsole(&console,false,false); if(program != NULL) program->renderProgramMsgBox(); @@ -423,4 +446,19 @@ void MenuStateLoadGame::keyDown(SDL_KeyboardEvent key) { } } +void MenuStateLoadGame::showMessageBox(const string &text, const string &header, bool toggle) { + if(toggle == false) { + mainMessageBox.setEnabled(false); + } + + if(mainMessageBox.getEnabled() == false) { + mainMessageBox.setText(text); + mainMessageBox.setHeader(header); + mainMessageBox.setEnabled(true); + } + else{ + mainMessageBox.setEnabled(false); + } +} + }}//end namespace diff --git a/source/glest_game/menu/menu_state_load_game.h b/source/glest_game/menu/menu_state_load_game.h index 54e873cb3..066b7f91e 100644 --- a/source/glest_game/menu/menu_state_load_game.h +++ b/source/glest_game/menu/menu_state_load_game.h @@ -45,6 +45,8 @@ private: GraphicLine lines[2]; + GraphicMessageBox mainMessageBox; + string saveGameDir; int slotLinesYBase; int slotsLineHeight; @@ -61,10 +63,14 @@ public: virtual void keyDown(SDL_KeyboardEvent key); void reloadUI(); + private: + void clearSlots(); void deleteSlot(int i); void listFiles(); + + void showMessageBox(const string &text, const string &header, bool toggle); }; diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 319d42d05..4abce0e35 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -4179,7 +4179,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction * // int deadCount; result->deadCount = unitNode->getAttribute("deadCount")->getIntValue(); // float progress; //between 0 and 1 - result->progress = unitNode->getAttribute("progress")->getIntValue(); + result->progress = unitNode->getAttribute("progress")->getFloatValue(); // float lastAnimProgress; //between 0 and 1 result->lastAnimProgress = unitNode->getAttribute("lastAnimProgress")->getFloatValue(); // float animProgress; //between 0 and 1