replay: added "skip animation" functionality

minor corrections for vc++ compile
This commit is contained in:
Jörg Hinrichs 2005-11-12 22:55:09 +00:00
parent 1f27469de1
commit dafeaad042
8 changed files with 77 additions and 34 deletions

View file

@ -13,7 +13,7 @@
image=play
title= _ "Play"
items=playreplay
rect="+2,=-1,+23,="
rect="+4,=-1,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
@ -23,7 +23,7 @@
image=pause
title= _ "Stop"
items=stopreplay
rect="+2,=,+23,="
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
@ -33,7 +33,7 @@
image=stop
title= _ "Reset"
items=resetreplay
rect="+2,=,+23,="
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
@ -43,7 +43,7 @@
image=fast-fwd
title= _ "Next Turn"
items=replaynextturn
rect="+2,=,+23,="
rect="+4,=,+23,="
xanchor=fixed
yanchor=bottom
[/menu]
@ -53,7 +53,7 @@
image=frame-fwd
title= _ "Next Side"
items=replaynextside
rect="+2,=,+60,="
rect="+4,=,+60,="
xanchor=fixed
yanchor=bottom
[/menu]
@ -62,7 +62,7 @@
type=checkbox
title= _ "Shroud"
items=replayswitchshroud
rect="+15,=,+60,+10"
rect="+30,=,+60,+10"
xanchor=fixed
yanchor=bottom
[/menu]
@ -71,7 +71,16 @@
type=checkbox
title= _ "Fog"
items=replayswitchfog
rect="+15,=,+60,+10"
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]

View file

@ -14,8 +14,17 @@
#ifndef DISABLE_4786_HPP_INCLUDED
#define DISABLE_4786_HPP_INCLUDED
//for windows compilers
#ifdef __MSVCRT__
#undef snprintf
#define snprintf _snprintf
#endif
#ifdef _MSC_VER
#undef snprintf
#define snprintf _snprintf
//disable the warning to let us know about 'this' being used in
//initializer list, since it's a common thing to want to do
//for callbacks, and there is no other way to easily workaround the warning

View file

@ -85,6 +85,7 @@ const struct {
{ 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_SKIP_ANIMATION, "replayskipanimation", N_("Skip animation"), false },
{ hotkey::HOTKEY_EDIT_SET_TERRAIN, "editsetterrain", N_("Set Terrain"),true },
{ hotkey::HOTKEY_EDIT_QUIT, "editquit", N_("Quit Editor"),true },
@ -686,6 +687,10 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
if (executor)
executor->replay_switch_fog();
break;
case HOTKEY_REPLAY_SKIP_ANIMATION:
if (executor)
executor->replay_skip_animation();
break;
default:
std::cerr << "command_executor: unknown command number " << command << ", ignoring.\n";
break;

View file

@ -43,7 +43,7 @@ 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_NEXT_SIDE, HOTKEY_REPLAY_SHROUD, HOTKEY_REPLAY_FOG, HOTKEY_REPLAY_SKIP_ANIMATION,
//editing specific commands
HOTKEY_EDIT_SET_TERRAIN,
@ -172,6 +172,7 @@ public:
virtual void replay_next_side() {}
virtual void replay_switch_shroud() {}
virtual void replay_switch_fog() {}
virtual void replay_skip_animation() {}
// Map editor stuff.
virtual void edit_set_terrain() {}

View file

@ -153,6 +153,10 @@ void replay_controller::replay_switch_shroud(){
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){
//if the recorder has no event, adds an "game start" event to the
//recorder, whose only goal is to initialize the RNG
@ -262,6 +266,7 @@ void replay_controller::initialize(CVideo& video, const std::vector<config*>& st
gui_->add_overlay(gamemap::location(**overlay),(**overlay)["image"], (**overlay)["halo"]);
}
game_events::fire("prestart");
gui_->begin_game();
gui_->adjust_colours(0,0,0);
@ -542,6 +547,7 @@ bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) cons
case hotkey::HOTKEY_REPLAY_NEXT_SIDE:
case hotkey::HOTKEY_REPLAY_FOG:
case hotkey::HOTKEY_REPLAY_SHROUD:
case hotkey::HOTKEY_REPLAY_SKIP_ANIMATION:
return true;
default:

View file

@ -52,6 +52,7 @@ public:
void replay_next_side();
void replay_switch_fog();
void replay_switch_shroud();
void replay_skip_animation();
std::vector<team> teams_, teams_start_;
private:

View file

@ -346,6 +346,7 @@ surface recolor_image(surface surf, Uint32 new_rgb, std::vector<Uint32> old_rgb)
(Uint16) new_green +
(Uint16) new_blue) / 3);
{
for(std::vector<Uint32>::const_iterator temp_rgb = old_rgb.begin();
temp_rgb!=old_rgb.end();temp_rgb++)
{
@ -371,7 +372,9 @@ surface recolor_image(surface surf, Uint32 new_rgb, std::vector<Uint32> old_rgb)
old_avg = old_grey;
}
}
}
{
for(std::vector<Uint32>::const_iterator temp_rgb = old_rgb.begin();
temp_rgb!=old_rgb.end();temp_rgb++)
{
@ -415,6 +418,7 @@ surface recolor_image(surface surf, Uint32 new_rgb, std::vector<Uint32> old_rgb)
++beg;
}
}
}
return create_optimized_surface(nsurf);
}

View file

@ -664,13 +664,17 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
std::vector<unsigned char> flag_red_,flag_green_,flag_blue_;
std::vector<std::string> flag_string_ = utils::split(cfg["flag_red"]);
{
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
flag_red_.push_back(atoi(c->c_str()));
}
}
flag_string_ = utils::split(cfg["flag_green"]);
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
flag_green_.push_back(atoi(c->c_str()));
}
{
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
flag_green_.push_back(atoi(c->c_str()));
}
}
flag_string_ = utils::split(cfg["flag_blue"]);
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
flag_blue_.push_back(atoi(c->c_str()));
@ -691,31 +695,35 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
}//size of green=red=blue
//construct rgb values;
for(int i=0;i!=flag_red_.size();i++){
//stolen from display.cpp, but don't want to include header
//for such a simple function
flag_rgb_.push_back(Uint32 (0xFF000000 | (flag_red_[i] << 16) | (flag_green_[i] << 8) | flag_blue_[i]) );
{
for(int i = 0; i != flag_red_.size(); i++){
//stolen from display.cpp, but don't want to include header
//for such a simple function
flag_rgb_.push_back(Uint32 (0xFF000000 | (flag_red_[i] << 16) | (flag_green_[i] << 8) | flag_blue_[i]) );
}
}
flag_string_ = utils::split(cfg["flag_rgb"]);
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
int r,g,b;
r=(atoi(c->c_str()));
c++;
if(c!=flag_string_.end()){
g=(atoi(c->c_str()));
}else{
LOG_STREAM(err, config) <<"Missing Green in flag_rgb:"<<id();
g=0;
}
c++;
if(c!=flag_string_.end()){
b=(atoi(c->c_str()));
}else{
LOG_STREAM(err, config) <<"Missing Blue in flag_rgb:"<<id();
b=0;
}
flag_rgb_.push_back(Uint32 (0xFF000000 | (r << 16) | (g << 8) | b) );
}
{
for(std::vector<std::string>::iterator c=flag_string_.begin();c!=flag_string_.end();c++){
int r,g,b;
r=(atoi(c->c_str()));
c++;
if(c!=flag_string_.end()){
g=(atoi(c->c_str()));
}else{
LOG_STREAM(err, config) <<"Missing Green in flag_rgb:"<<id();
g=0;
}
c++;
if(c!=flag_string_.end()){
b=(atoi(c->c_str()));
}else{
LOG_STREAM(err, config) <<"Missing Blue in flag_rgb:"<<id();
b=0;
}
flag_rgb_.push_back(Uint32 (0xFF000000 | (r << 16) | (g << 8) | b) );
}
}
}
unit_type::~unit_type()