Skip to content

Commit

Permalink
tgame_load: always enable Show Replay if selected save is a replay
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Dec 17, 2015
1 parent b52867e commit a653c0c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/gui/dialogs/game_load.cpp
Expand Up @@ -36,6 +36,7 @@
#include "gui/widgets/minimap.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/text_box.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"
#include "language.hpp"
#include "preferences_display.hpp"
Expand All @@ -44,6 +45,12 @@
#include <cctype>
#include <boost/bind.hpp>

/* Helper function for determining if the selected save is a replay */
static bool is_replay_save(const config& cfg)
{
return cfg["replay"].to_bool() && !cfg["snapshot"].to_bool(true);
}

namespace gui2
{

Expand Down Expand Up @@ -277,6 +284,15 @@ void tgame_load::display_savegame(twindow& window)
str << game.format_time_local();
evaluate_summary_string(str, summary);

// Always toggle show_replay on if the save is a replay
ttoggle_button& replay_toggle =
find_widget<ttoggle_button>(&window, "show_replay", false);

const bool& is_replay = is_replay_save(summary);

replay_toggle.set_value(is_replay);
replay_toggle.set_active(!is_replay);

find_widget<tlabel>(&window, "lblSummary", false).set_label(str.str());

// TODO: Find a better way to change the label width
Expand Down Expand Up @@ -343,8 +359,7 @@ void tgame_load::evaluate_summary_string(std::stringstream& str,

str << "\n";

if(cfg_summary["replay"].to_bool()
&& !cfg_summary["snapshot"].to_bool(true)) {
if(is_replay_save(cfg_summary)) {
str << _("Replay");
} else if(!cfg_summary["turn"].empty()) {
str << _("Turn") << " " << cfg_summary["turn"];
Expand Down

0 comments on commit a653c0c

Please sign in to comment.