prevents replay buttons appearing in main menu

places replay panel above the map
adds chat message support for replays
This commit is contained in:
Jörg Hinrichs 2005-11-16 19:18:56 +00:00
parent 678863e7a3
commit c7b60eee9b
5 changed files with 196 additions and 179 deletions

View file

@ -43,9 +43,21 @@ height=768
yanchor=fixed
[/panel]
[panel]
id=replay-panel
image=misc/top-bg.png
ref=top-panel
rect="=,+0,+882,+26"
xanchor=left
yanchor=fixed
[/panel]
{themes/macros.cfg}
{REPLAY_THEME}
[main_map]
id=main-map
rect="=,+0,+882,742"
ref=replay-panel
rect="=,+0,+882,768"
xanchor=left
yanchor=top
[/main_map]
@ -54,21 +66,21 @@ height=768
[panel]
id=top-right-panel
image=misc/rightside.png
rect="+0,=-1,1024,+284"
rect="+0,=-27,1024,+284"
xanchor=right
yanchor=fixed
[/panel]
[panel]
id=middle-right-panel
image=misc/rightside-bg.png
rect="=,+0,=,+395"
rect="=,+0,=,+421"
xanchor=right
yanchor=top
[/panel]
[panel]
id=bottom-right-panel
image=misc/rightside-bottom.png
rect="=,+0,=,742"
rect="=,+0,=,768"
xanchor=right
yanchor=bottom
[/panel]
@ -429,16 +441,6 @@ height=768
[/unit_status]
[/status]
[panel]
id=bottom-panel
image=misc/top-bg.png
ref=main-map
rect="=,742,1024,768"
xanchor=left
yanchor=bottom
[/panel]
{themes/macros.cfg}
{REPLAY_THEME}
[/resolution]
[partialresolution]

View file

@ -2,86 +2,86 @@
[label]
id=replay-label
text= _ "Replay"
ref=bottom-panel
ref=replay-panel
rect="=+3,=+1,+60,=-4"
xanchor=fixed
yanchor=bottom
yanchor=fixed
[/label]
[menu]
id=button-playreplay
type=image
image=play
title= _ "Play"
items=playreplay
rect="+4,=-1,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=button-stopreplay
type=image
image=pause
title= _ "Stop"
items=stopreplay
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=button-resetreplay
type=image
image=stop
title= _ "Reset"
items=resetreplay
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=button-nextturn
type=image
image=fast-fwd
title= _ "Next Turn"
items=replaynextturn
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=button-nextside
type=image
image=frame-fwd
title= _ "Next Side"
items=replaynextside
rect="+4,=,+60,="
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=check-shroud
type=checkbox
title= _ "Shroud"
items=replayswitchshroud
rect="+30,=,+60,+10"
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=check-fog
type=checkbox
title= _ "Fog"
items=replayswitchfog
rect="+50,=,+60,+10"
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=skip-animation
type=checkbox
title= _ "Skip animation"
items=replayskipanimation
rect="+50,=,+60,+10"
xanchor=fixed
yanchor=bottom
[/menu]
[menu]
id=button-playreplay
type=image
image=play
title= _ "Play"
items=playreplay
rect="+4,=-1,+23,="
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=button-stopreplay
type=image
image=pause
title= _ "Stop"
items=stopreplay
rect="+4,=,+23,="
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=button-resetreplay
type=image
image=stop
title= _ "Reset"
items=resetreplay
rect="+4,=,+23,="
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=button-nextturn
type=image
image=fast-fwd
title= _ "Next Turn"
items=replaynextturn
rect="+4,=,+23,="
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=button-nextside
type=image
image=frame-fwd
title= _ "Next Side"
items=replaynextside
rect="+4,=,+60,="
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=check-shroud
type=checkbox
title= _ "Shroud"
items=replayswitchshroud
rect="+30,=+3,+60,+10"
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=check-fog
type=checkbox
title= _ "Fog"
items=replayswitchfog
rect="+50,=,+60,+10"
xanchor=fixed
yanchor=fixed
[/menu]
[menu]
id=skip-animation
type=checkbox
title= _ "Skip animation"
items=replayskipanimation
rect="+50,=,+60,+10"
xanchor=fixed
yanchor=fixed
[/menu]
#enddef

View file

@ -2289,6 +2289,7 @@ void display::clear_chat_messages()
void display::prune_chat_messages(bool remove_all)
{
const unsigned int message_ttl = remove_all ? 0 : 1200000;
int ticks = SDL_GetTicks();
if(chat_messages_.empty() == false && (chat_messages_.front().created_at+message_ttl < SDL_GetTicks() || chat_messages_.size() > max_chat_messages)) {
const int movement = font::get_floating_label_rect(chat_messages_.front().handle).h;

View file

@ -45,8 +45,7 @@ LEVEL_RESULT play_replay_level(const game_data& gameinfo, const config& game_con
try{
const int ticks = SDL_GetTicks();
const int num_turns = atoi((*level)["turns"].c_str());
replay_controller replaycontroller(*level, gameinfo, state_of_game, ticks, num_turns, game_config);
replaycontroller.initialize(video, story);
replay_controller replaycontroller(*level, gameinfo, state_of_game, ticks, num_turns, game_config, video, story);
//replay event-loop
for (;;){
@ -60,7 +59,8 @@ LEVEL_RESULT play_replay_level(const game_data& gameinfo, const config& game_con
}
replay_controller::replay_controller(const config& level, const game_data& gameinfo, game_state& state_of_game,
const int ticks, const int num_turns, const config& game_config) :
const int ticks, const int num_turns, const config& game_config,
CVideo& video, const std::vector<config*>& story) :
level_(level), gameinfo_(gameinfo), gamestate_(state_of_game), gamestate_start_(state_of_game), ticks_(ticks),
status_(level, num_turns), status_start_(level, num_turns), map_(game_config, level["map_data"]),
game_config_(game_config), team_manager_(teams_), xp_modifier_(atoi(level["experience_modifier"].c_str())),
@ -75,89 +75,15 @@ replay_controller::replay_controller(const config& level, const game_data& gamei
if(first_player_ < 0 || first_player_ >= int(teams_.size())) {
first_player_ = 0;
}
init(video, story);
}
std::vector<team>& replay_controller::get_teams(){
return teams_;
replay_controller::~replay_controller(){
delete gui_;
delete labels_manager_;
}
unit_map replay_controller::get_units(){
return units_;
}
display& replay_controller::get_gui(){
return *gui_;
}
gamemap& replay_controller::get_map(){
return map_;
}
const gamestatus& replay_controller::get_status(){
return status_;
}
const int replay_controller::get_player_number(){
return player_number_;
}
const bool replay_controller::is_loading_game(){
return loading_game_;
}
void replay_controller::reset_replay(){
is_playing_ = false;
current_turn_ = 1;
recorder.start_replay();
units_ = *(new unit_map(units_start_));
status_ = *(new gamestatus(status_start_));
gamestate_ = *(new game_state(gamestate_start_));
teams_ = team_manager_.clone(teams_start_);
(*gui_).invalidate_all();
(*gui_).draw();
}
void replay_controller::stop_replay(){
is_playing_ = false;
}
void replay_controller::replay_next_turn(){
is_playing_ = true;
play_turn();
is_playing_ = false;
}
void replay_controller::replay_next_side(){
is_playing_ = true;
play_side(player_number_ - 1);
if (player_number_ > teams_.size()){
player_number_ = 1;
current_turn_++;
}
is_playing_ = false;
}
void replay_controller::replay_switch_fog(){
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_fog(!t->uses_fog());
}
update_teams();
update_gui();
}
void replay_controller::replay_switch_shroud(){
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_shroud(!t->uses_shroud());
}
update_teams();
update_gui();
}
void replay_controller::replay_skip_animation(){
recorder.set_skip(!recorder.is_skipping());
}
void replay_controller::initialize(CVideo& video, const std::vector<config*>& story){
void replay_controller::init(CVideo& video, const std::vector<config*>& story){
//if the recorder has no event, adds an "game start" event to the
//recorder, whose only goal is to initialize the RNG
if(recorder.empty()) {
@ -174,7 +100,9 @@ void replay_controller::initialize(CVideo& video, const std::vector<config*>& st
const cursor::setter cursor_setter(cursor::NORMAL);
const int ticks = SDL_GetTicks();
LOG_NG << "in play_replay_level()...\n";
LOG_NG << "in replay_controller::init()...\n";
init_managers();
const statistics::scenario_context statistics_context(level_["name"]);
@ -298,6 +226,90 @@ void replay_controller::initialize(CVideo& video, const std::vector<config*>& st
teams_start_ = team_manager_.clone(teams_);
}
void replay_controller::init_managers(){
labels_manager_ = new font::floating_label_context();
}
std::vector<team>& replay_controller::get_teams(){
return teams_;
}
unit_map replay_controller::get_units(){
return units_;
}
display& replay_controller::get_gui(){
return *gui_;
}
gamemap& replay_controller::get_map(){
return map_;
}
const gamestatus& replay_controller::get_status(){
return status_;
}
const int replay_controller::get_player_number(){
return player_number_;
}
const bool replay_controller::is_loading_game(){
return loading_game_;
}
void replay_controller::reset_replay(){
is_playing_ = false;
current_turn_ = 1;
recorder.start_replay();
units_ = *(new unit_map(units_start_));
status_ = *(new gamestatus(status_start_));
gamestate_ = *(new game_state(gamestate_start_));
teams_ = team_manager_.clone(teams_start_);
(*gui_).invalidate_all();
(*gui_).draw();
}
void replay_controller::stop_replay(){
is_playing_ = false;
}
void replay_controller::replay_next_turn(){
is_playing_ = true;
play_turn();
is_playing_ = false;
}
void replay_controller::replay_next_side(){
is_playing_ = true;
play_side(player_number_ - 1);
if (player_number_ > teams_.size()){
player_number_ = 1;
current_turn_++;
}
is_playing_ = false;
}
void replay_controller::replay_switch_fog(){
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_fog(!t->uses_fog());
}
update_teams();
update_gui();
}
void replay_controller::replay_switch_shroud(){
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
t->set_shroud(!t->uses_shroud());
}
update_teams();
update_gui();
}
void replay_controller::replay_skip_animation(){
recorder.set_skip(!recorder.is_skipping());
}
void replay_controller::play_replay(){
try{
is_playing_ = true;

View file

@ -28,7 +28,9 @@ class replay_controller : public hotkey::command_executor, public events::handle
{
public:
replay_controller(const config& level, const game_data& gameinfo, game_state& state_of_game,
const int ticks, const int num_turns, const config& game_config);
const int ticks, const int num_turns, const config& game_config, CVideo& video,
const std::vector<config*>& story);
~replay_controller();
void handle_event(const SDL_Event& event);
void replay_slice();
@ -42,8 +44,6 @@ public:
const int get_player_number();
const bool is_loading_game();
void initialize(CVideo& video, const std::vector<config*>& story);
//event handlers
void play_replay();
void reset_replay();
@ -56,6 +56,8 @@ public:
std::vector<team> teams_, teams_start_;
private:
void init(CVideo& video, const std::vector<config*>& story);
void init_managers();
void play_turn();
void play_side(int team_index);
void update_teams();