Skip to content

Commit

Permalink
Set a custom dialog caption for the synced debug command prompt
Browse files Browse the repository at this point in the history
This replaces the caption with something more apropos than the generic
"Save Game" caption. It necessitates a minor API change though.
  • Loading branch information
irydacea committed Mar 26, 2018
1 parent 6a91de4 commit c3a6300
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/savegame.cpp
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/savegame.hpp
Expand Up @@ -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);
Expand All @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/synced_commands.cpp
Expand Up @@ -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 {
Expand Down

0 comments on commit c3a6300

Please sign in to comment.