From c3a6300bce93c4a146e71865e0663df4a1e0b886 Mon Sep 17 00:00:00 2001 From: Iris Morelle Date: Mon, 26 Mar 2018 00:59:45 -0300 Subject: [PATCH] Set a custom dialog caption for the synced debug command prompt This replaces the caption with something more apropos than the generic "Save Game" caption. It necessitates a minor API change though. --- src/savegame.cpp | 2 +- src/savegame.hpp | 8 ++++++-- src/synced_commands.cpp | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/savegame.cpp b/src/savegame.cpp index c7549776d829..288a9101952f 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -326,8 +326,8 @@ void loadgame::copy_era(config &cfg) savegame::savegame(saved_game& gamestate, const compression::format compress_saves, const std::string& title) : filename_() - , gamestate_(gamestate) , title_(title) + , gamestate_(gamestate) , error_message_(_("The game could not be saved: ")) , show_confirmation_(false) , compress_saves_(compress_saves) diff --git a/src/savegame.hpp b/src/savegame.hpp index 213b3b11b3fb..592036b2007d 100644 --- a/src/savegame.hpp +++ b/src/savegame.hpp @@ -204,6 +204,9 @@ class savegame /** Filename of the savegame file on disk */ std::string filename_; + /** Title of the savegame dialog */ + std::string title_; + private: /** Checks if a certain character is allowed in a savefile name. */ static bool is_illegal_file_char(char c); @@ -227,8 +230,6 @@ class savegame //before_save (write replay data) changes this so it cannot be const saved_game& gamestate_; - const std::string title_; /** Title of the savegame dialog */ - std::string error_message_; /** Error message to be displayed if the savefile could not be generated. */ bool show_confirmation_; /** Determines if a confirmation of successful saving the game is shown. */ @@ -281,6 +282,9 @@ class oos_savegame : public ingame_savegame public: oos_savegame(saved_game& gamestate, bool& ignore); + /** Customize the dialog's caption. */ + void set_title(const std::string& val) { title_ = val; } + private: /** Display the save game dialog. */ virtual int show_save_dialog(const std::string& message, DIALOG_TYPE dialog_type) override; diff --git a/src/synced_commands.cpp b/src/synced_commands.cpp index 86579c5fed6d..27e96c9ad6f2 100644 --- a/src/synced_commands.cpp +++ b/src/synced_commands.cpp @@ -402,6 +402,7 @@ namespace sbuilder << "The game detected the use of a debug command, maybe another player is cheating"; sbuilder << "\n\n" << "details:" << "\n\n" << VGETTEXT(message, {{"player", current_team.current_player()}}); savegame::oos_savegame save(controller.get_saved_game(), ignore); + save.set_title("Debug Command Used"); save.save_game_interactive(sbuilder.str(), savegame::savegame::YES_NO); // can throw quit_game_exception } else {