From cabbede63a8ddfe8e29493772cbc92b1942e4ecf Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Tue, 2 Jun 2015 19:07:26 +0200 Subject: [PATCH] replace "Team1" option with "First human team" in replay viewer. Fixes https://gna.org/bugs/index.php?22628 --- src/hotkey/hotkey_command.cpp | 2 +- src/replay_controller.cpp | 38 +++++++++++++---------------------- src/replay_controller.hpp | 10 ++++++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/hotkey/hotkey_command.cpp b/src/hotkey/hotkey_command.cpp index dac84329c318..09f31c5d48b6 100644 --- a/src/hotkey/hotkey_command.cpp +++ b/src/hotkey/hotkey_command.cpp @@ -103,7 +103,7 @@ hotkey::hotkey_command_temp hotkey_list_[] = { { hotkey::HOTKEY_REPLAY_NEXT_MOVE, "replaynextmove", N_("Next Move"), false, scope_game, "" }, { hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING, "replayshoweverything", N_("Full Map"), false, scope_game, "" }, { hotkey::HOTKEY_REPLAY_SHOW_EACH, "replayshoweach", N_("Each Team"), false, scope_game, "" }, - { hotkey::HOTKEY_REPLAY_SHOW_TEAM1, "replayshowteam1", N_("Team 1"), false, scope_game, "" }, + { hotkey::HOTKEY_REPLAY_SHOW_TEAM1, "replayshowteam1", N_("Human Team"), false, scope_game, "" }, { hotkey::HOTKEY_REPLAY_SKIP_ANIMATION, "replayskipanimation", N_("Skip Animation"), false, scope_game, "" }, // Whiteboard commands // TRANSLATORS: whiteboard menu entry: toggle planning mode diff --git a/src/replay_controller.cpp b/src/replay_controller.cpp index edbe851b8c36..6a67e8d5ad1d 100644 --- a/src/replay_controller.cpp +++ b/src/replay_controller.cpp @@ -115,8 +115,7 @@ replay_controller::replay_controller(const config& level, , gameboard_start_(gamestate_.board_) , tod_manager_start_(level) , is_playing_(false) - , show_everything_(false) - , show_team_(state_of_game.classification().campaign_type == game_classification::MULTIPLAYER ? 0 : 1) + , vision_(state_of_game.classification().campaign_type == game_classification::MULTIPLAYER ? CURRENT_TEAM : HUMAN_TEAM) { hotkey_handler_.reset(new hotkey_handler(*this, saved_game_)); //upgrade hotkey handler to the replay controller version @@ -149,11 +148,7 @@ void replay_controller::init_gui(){ DBG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n"; play_controller::init_gui(); - if (show_team_) - gui_->set_team(show_team_ - 1, show_everything_); - else - gui_->set_team(0, show_everything_); - + gui_->set_team(vision_ == HUMAN_TEAM ? gamestate_.first_human_team_ : 0, vision_ == SHOW_ALL); gui_->scroll_to_leader(player_number_, display::WARP); update_locker lock_display((*gui_).video(),false); BOOST_FOREACH(const team & t, gamestate_.board_.teams()) { @@ -423,23 +418,23 @@ void replay_controller::process_oos(const std::string& msg) const } } -void replay_controller::replay_show_everything(){ - show_everything_ = true; - show_team_ = 0; +void replay_controller::replay_show_everything() +{ + vision_ = SHOW_ALL; update_teams(); update_gui(); } -void replay_controller::replay_show_each(){ - show_everything_ = false; - show_team_ = 0; +void replay_controller::replay_show_each() +{ + vision_ = CURRENT_TEAM; update_teams(); update_gui(); } -void replay_controller::replay_show_team1(){ - show_everything_ = false; - show_team_ = 1; +void replay_controller::replay_show_team1() +{ + vision_ = HUMAN_TEAM; update_teams(); update_gui(); } @@ -557,18 +552,13 @@ void replay_controller::play_move_or_side(bool one_move) { void replay_controller::update_teams() { - int next_team = player_number_; if(static_cast(next_team) > gamestate_.board_.teams().size()) { next_team = 1; } - - if ( show_team_ == 0 ) { - gui_->set_team(next_team - 1, show_everything_); - } else { - gui_->set_team(show_team_ - 1, show_everything_); - } - + + gui_->set_team(vision_ == HUMAN_TEAM ? gamestate_.first_human_team_ : next_team - 1, vision_ == SHOW_ALL); + gui_->set_playing_team(next_team - 1); gui_->invalidate_all(); } diff --git a/src/replay_controller.hpp b/src/replay_controller.hpp index 7075ac944db5..babdfa64a9e3 100644 --- a/src/replay_controller.hpp +++ b/src/replay_controller.hpp @@ -60,6 +60,12 @@ class replay_controller : public play_controller virtual void init_gui(); private: + enum REPLAY_VISION + { + HUMAN_TEAM, + CURRENT_TEAM, + SHOW_ALL, + }; void init(); void play_turn(); void play_move_or_side(bool one_move = false); @@ -95,9 +101,7 @@ class replay_controller : public play_controller unsigned int last_replay_action; bool is_playing_; - - bool show_everything_; - unsigned int show_team_; + REPLAY_VISION vision_; };