Make replays to not reveal all information by default.

Include a menu for choosing the point of view: team 1, each team, full
map.

This design is per https://gna.org/bugs/index.php?6946 but doesn't yet 
implement the combo box or menu entries for teams other than number 1.
This commit is contained in:
Tuukka Hastrup 2007-07-04 00:00:06 +00:00
parent 631e21c8de
commit c03c4ab064
7 changed files with 67 additions and 64 deletions

View file

@ -129,24 +129,12 @@
[/add]
[add]
[menu]
id=check-shroud
id=show-what
ref=button-nextside
type=checkbox
title= _ "Shroud"
items=replayswitchshroud
rect="+15,=+3,+180,+10"
xanchor=fixed
yanchor=fixed
[/menu]
[/add]
[add]
[menu]
id=check-fog
ref=check-shroud
type=checkbox
title= _ "Fog"
items=replayswitchfog
rect="+5,=,+80,+10"
image=lite
title= _ "Point of view"
items=replayshowteam1,replayshoweach,replayshoweverything
rect="+15,=+2,+100,+10"
xanchor=fixed
yanchor=fixed
[/menu]
@ -154,11 +142,11 @@
[add]
[menu]
id=skip-animation
ref=check-fog
ref=show-what
type=checkbox
title= _ "Skip animation"
items=replayskipanimation
rect="+5,=,+80,+10"
rect="+15,=+1,+80,+10"
xanchor=fixed
yanchor=fixed
[/menu]

View file

@ -1200,11 +1200,11 @@ const std::string game_display::current_team_name() const
return std::string();
}
void game_display::set_team(size_t teamindex)
void game_display::set_team(size_t teamindex, bool observe)
{
wassert(teamindex < teams_.size());
currentTeam_ = teamindex;
if (!is_observer())
if (!is_observer() && !observe)
{
labels().set_team(&teams_[teamindex]);
viewpoint_ = &teams_[teamindex];

View file

@ -138,7 +138,7 @@ public:
//set_team sets the team controlled by the player using the computer,
//and it is this team whose data is displayed in the game status.
//set_playing_team sets the team whose turn it currently is
void set_team(size_t team);
void set_team(size_t team, bool observe=false);
void set_playing_team(size_t team);
const std::vector<team>& get_teams() {return teams_;};

View file

@ -91,8 +91,12 @@ const struct {
{ hotkey::HOTKEY_STOP_REPLAY, "stopreplay", N_("Stop"), false },
{ hotkey::HOTKEY_REPLAY_NEXT_TURN, "replaynextturn", N_("Next Turn"), false },
{ hotkey::HOTKEY_REPLAY_NEXT_SIDE, "replaynextside", N_("Next Side"), false },
{ hotkey::HOTKEY_REPLAY_SHROUD, "replayswitchshroud", N_("Shroud"), false },
{ hotkey::HOTKEY_REPLAY_FOG, "replayswitchfog", N_("Fog"), false },
{ hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING, "replayshoweverything",
N_("Full map"), false },
{ hotkey::HOTKEY_REPLAY_SHOW_EACH, "replayshoweach",
N_("Each team"), false },
{ hotkey::HOTKEY_REPLAY_SHOW_TEAM1, "replayshowteam1",
N_("Team 1"), false },
{ hotkey::HOTKEY_REPLAY_SKIP_ANIMATION, "replayskipanimation", N_("Skip animation"), false },
{ hotkey::HOTKEY_EDIT_SET_TERRAIN, "editsetterrain", N_("Set Terrain"),true },
@ -707,11 +711,14 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
case HOTKEY_REPLAY_NEXT_SIDE:
replay_next_side();
break;
case HOTKEY_REPLAY_SHROUD:
replay_switch_shroud();
case HOTKEY_REPLAY_SHOW_EVERYTHING:
replay_show_everything();
break;
case HOTKEY_REPLAY_FOG:
replay_switch_fog();
case HOTKEY_REPLAY_SHOW_EACH:
replay_show_each();
break;
case HOTKEY_REPLAY_SHOW_TEAM1:
replay_show_team1();
break;
case HOTKEY_REPLAY_SKIP_ANIMATION:
replay_skip_animation();

View file

@ -44,7 +44,9 @@ enum HOTKEY_COMMAND {
HOTKEY_SEARCH, HOTKEY_SPEAK_ALLY, HOTKEY_SPEAK_ALL, HOTKEY_HELP,
HOTKEY_CHAT_LOG, HOTKEY_LANGUAGE,
HOTKEY_PLAY_REPLAY, HOTKEY_RESET_REPLAY, HOTKEY_STOP_REPLAY, HOTKEY_REPLAY_NEXT_TURN,
HOTKEY_REPLAY_NEXT_SIDE, HOTKEY_REPLAY_SHROUD, HOTKEY_REPLAY_FOG, HOTKEY_REPLAY_SKIP_ANIMATION,
HOTKEY_REPLAY_NEXT_SIDE, HOTKEY_REPLAY_SHOW_EVERYTHING,
HOTKEY_REPLAY_SHOW_EACH, HOTKEY_REPLAY_SHOW_TEAM1,
HOTKEY_REPLAY_SKIP_ANIMATION,
//editing specific commands
HOTKEY_EDIT_SET_TERRAIN,
@ -193,8 +195,9 @@ public:
virtual void stop_replay() {}
virtual void replay_next_turn() {}
virtual void replay_next_side() {}
virtual void replay_switch_shroud() {}
virtual void replay_switch_fog() {}
virtual void replay_show_everything() {}
virtual void replay_show_each() {}
virtual void replay_show_team1() {}
virtual void replay_skip_animation() {}
// Map editor stuff.

View file

@ -69,6 +69,8 @@ replay_controller::replay_controller(const config& level, const game_data& gamei
current_turn_ = 1;
delay_ = 0;
is_playing_ = false;
show_everything_ = false;
show_team_ = 1;
init();
gamestate_start_ = gamestate_;
}
@ -100,21 +102,16 @@ void replay_controller::init_gui(){
LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
play_controller::init_gui();
if (show_team_)
gui_->set_team(show_team_ - 1, show_everything_);
gui_->scroll_to_leader(units_, player_number_);
update_locker lock_display((*gui_).video(),false);
init_shroudfog_controls(teams_.begin());
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->reset_objectives_changed();
}
}
void replay_controller::init_shroudfog_controls(const std::vector<team>::iterator t){
gui::button* b = gui_->find_button("check-fog");
if (b != NULL) { b->set_check(t->uses_fog()); }
b = gui_->find_button("check-shroud");
if (b != NULL) { b->set_check(t->uses_shroud()); }
}
void replay_controller::init_replay_display(){
LOG_NG << "initializing replay-display... " << (SDL_GetTicks() - ticks_) << "\n";
const config* theme_cfg = get_theme(game_config_, level_["theme"]);
@ -147,7 +144,6 @@ void replay_controller::reset_replay(){
events_manager_ = new game_events::manager(level_,*gui_,map_, *soundsources_manager_,
units_,teams_, gamestate_,status_,gameinfo_);
}
init_shroudfog_controls(teams_.begin());
fire_prestart(true);
fire_start(!loading_game_);
(*gui_).invalidate_all();
@ -165,6 +161,7 @@ void replay_controller::stop_replay(){
void replay_controller::replay_next_turn(){
is_playing_ = true;
play_turn();
gui_->scroll_to_leader(units_, player_number_);
is_playing_ = false;
gui::button* b = gui_->find_button("button-nextturn");
if (b != NULL) { b->release(); }
@ -178,25 +175,32 @@ void replay_controller::replay_next_side(){
player_number_ = 1;
current_turn_++;
}
gui_->scroll_to_leader(units_, player_number_);
is_playing_ = false;
gui::button* b = gui_->find_button("button-nextside");
if (b != NULL) { b->release(); }
}
void replay_controller::replay_switch_fog(){
gui::button* b = gui_->find_button("check-fog");
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_fog(b->checked());
}
void replay_controller::replay_show_everything(){
show_everything_ = true;
show_team_ = 0;
update_teams();
update_gui();
}
void replay_controller::replay_switch_shroud(){
gui::button* b = gui_->find_button("check-shroud");
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_shroud(b->checked());
}
void replay_controller::replay_show_each(){
show_everything_ = false;
show_team_ = 0;
update_teams();
update_gui();
}
void replay_controller::replay_show_team1(){
show_everything_ = false;
show_team_ = 1;
gui_->set_team(show_team_ - 1, show_everything_);
update_teams();
update_gui();
}
@ -295,16 +299,13 @@ void replay_controller::play_side(const unsigned int team_index, bool){
void replay_controller::update_teams(){
int next_team = player_number_;
if ((size_t)next_team > teams_.size()) { next_team = 1; }
if (teams_[next_team - 1].uses_fog()){
gui_->set_team(next_team - 1);
::clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_, next_team - 1);
}
if (teams_[next_team - 1].uses_shroud()){
gui_->set_team(next_team - 1);
recalculate_fog(map_, status_, gameinfo_, units_, teams_, next_team - 1);
}
if (!show_team_)
gui_->set_team(next_team - 1, show_everything_);
::clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_,
next_team - 1);
gui_->set_playing_team(next_team - 1);
//(*gui_).scroll_to_leader(units_, next_team);
gui_->invalidate_all();
}
@ -338,8 +339,9 @@ bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
case hotkey::HOTKEY_STOP_REPLAY:
case hotkey::HOTKEY_REPLAY_NEXT_TURN:
case hotkey::HOTKEY_REPLAY_NEXT_SIDE:
case hotkey::HOTKEY_REPLAY_FOG:
case hotkey::HOTKEY_REPLAY_SHROUD:
case hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING:
case hotkey::HOTKEY_REPLAY_SHOW_EACH:
case hotkey::HOTKEY_REPLAY_SHOW_TEAM1:
case hotkey::HOTKEY_REPLAY_SKIP_ANIMATION:
return true;

View file

@ -48,15 +48,15 @@ public:
void stop_replay();
void replay_next_turn();
void replay_next_side();
void replay_switch_fog();
void replay_switch_shroud();
void replay_show_everything();
void replay_show_each();
void replay_show_team1();
void replay_skip_animation();
std::vector<team> teams_start_;
protected:
virtual void init_gui();
void init_shroudfog_controls(const std::vector<team>::iterator);
private:
void init();
@ -73,6 +73,9 @@ private:
unsigned int current_turn_;
int delay_;
bool is_playing_;
bool show_everything_;
unsigned int show_team_;
};