Fixes bug #6935 (reproducible replay mode fog glitches).
Also makes the appearance of replay buttons (pressed/released) more consistent.
This commit is contained in:
parent
08b4ad5df7
commit
93b3494f2a
8 changed files with 63 additions and 14 deletions
|
@ -2368,6 +2368,14 @@ theme& display::get_theme()
|
|||
return theme_;
|
||||
}
|
||||
|
||||
gui::button* display::find_button(const std::string& id){
|
||||
gui::button* res = NULL;
|
||||
for (std::vector<gui::button>::iterator b = buttons_.begin(); b != buttons_.end(); ++b){
|
||||
if (b->id() == id) { res = b; }
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const theme::menu* display::menu_pressed()
|
||||
{
|
||||
|
||||
|
@ -2411,6 +2419,7 @@ void display::create_buttons()
|
|||
const std::vector<theme::menu>& buttons = theme_.menus();
|
||||
for(std::vector<theme::menu>::const_iterator i = buttons.begin(); i != buttons.end(); ++i) {
|
||||
gui::button b(screen_,i->title(),string_to_button_type(i->type()),i->image());
|
||||
b.set_id(i->get_id());
|
||||
const SDL_Rect& loc = i->location(screen_area());
|
||||
b.set_location(loc.x,loc.y);
|
||||
if (!i->tooltip().empty()){
|
||||
|
|
|
@ -329,6 +329,7 @@ public:
|
|||
const std::string current_team_name() const;
|
||||
|
||||
theme& get_theme();
|
||||
gui::button* find_button(const std::string& id);
|
||||
|
||||
const theme::menu* menu_pressed();
|
||||
|
||||
|
|
|
@ -101,13 +101,19 @@ void replay_controller::init_gui(){
|
|||
|
||||
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->set_fog(false);
|
||||
t->set_shroud(false);
|
||||
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"]);
|
||||
|
@ -150,6 +156,10 @@ const bool replay_controller::is_loading_game(){
|
|||
}
|
||||
|
||||
void replay_controller::reset_replay(){
|
||||
gui::button* b = gui_->find_button("button-playreplay");
|
||||
if (b != NULL) { b->release(); }
|
||||
b = gui_->find_button("button-stopreplay");
|
||||
if (b != NULL) { b->release(); }
|
||||
is_playing_ = false;
|
||||
player_number_ = 1;
|
||||
current_turn_ = 1;
|
||||
|
@ -164,20 +174,27 @@ 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();
|
||||
(*gui_).draw();
|
||||
b = gui_->find_button("button-resetreplay");
|
||||
if (b != NULL) { b->release(); }
|
||||
}
|
||||
|
||||
void replay_controller::stop_replay(){
|
||||
is_playing_ = false;
|
||||
gui::button* b = gui_->find_button("button-playreplay");
|
||||
if (b != NULL) { b->release(); }
|
||||
}
|
||||
|
||||
void replay_controller::replay_next_turn(){
|
||||
is_playing_ = true;
|
||||
play_turn();
|
||||
is_playing_ = false;
|
||||
gui::button* b = gui_->find_button("button-nextturn");
|
||||
if (b != NULL) { b->release(); }
|
||||
}
|
||||
|
||||
void replay_controller::replay_next_side(){
|
||||
|
@ -189,19 +206,23 @@ void replay_controller::replay_next_side(){
|
|||
current_turn_++;
|
||||
}
|
||||
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(!t->uses_fog());
|
||||
t->set_fog(b->checked());
|
||||
}
|
||||
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(!t->uses_shroud());
|
||||
t->set_shroud(b->checked());
|
||||
}
|
||||
update_teams();
|
||||
update_gui();
|
||||
|
@ -213,6 +234,8 @@ void replay_controller::replay_skip_animation(){
|
|||
}
|
||||
|
||||
void replay_controller::play_replay(){
|
||||
gui::button* b = gui_->find_button("button-stopreplay");
|
||||
if (b != NULL) { b->release(); }
|
||||
if (recorder.at_end()){
|
||||
return;
|
||||
}
|
||||
|
@ -308,7 +331,7 @@ void replay_controller::update_teams(){
|
|||
recalculate_fog(map_, status_, gameinfo_, units_, teams_, next_team - 1);
|
||||
}
|
||||
gui_->set_playing_team(next_team - 1);
|
||||
(*gui_).scroll_to_leader(units_, next_team);
|
||||
//(*gui_).scroll_to_leader(units_, next_team);
|
||||
}
|
||||
|
||||
void replay_controller::update_gui(){
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void init_gui();
|
||||
void init_shroudfog_controls(const std::vector<team>::iterator);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
|
|
@ -266,16 +266,15 @@ void button::mouse_motion(SDL_MouseMotionEvent const &event)
|
|||
void button::mouse_down(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT && type_ != TYPE_CHECK){
|
||||
if (type_ != TYPE_IMAGE){
|
||||
state_ = PRESSED;
|
||||
}
|
||||
else{
|
||||
if (state_ == PRESSED) { state_ = ACTIVE; }
|
||||
else { state_ = PRESSED; }
|
||||
}
|
||||
state_ = PRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
void button::release(){
|
||||
state_ = NORMAL;
|
||||
draw_contents();
|
||||
}
|
||||
|
||||
void button::mouse_up(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (!(hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT))
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
bool pressed();
|
||||
bool hit(int x, int y) const;
|
||||
virtual void enable(bool new_val=true);
|
||||
void release();
|
||||
|
||||
protected:
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
|
|
|
@ -26,14 +26,14 @@ widget::widget(const widget &o)
|
|||
: events::handler(), video_(o.video_), restorer_(o.restorer_), rect_(o.rect_),
|
||||
focus_(o.focus_), needs_restore_(o.needs_restore_), state_(o.state_), hidden_override_(o.hidden_override_),
|
||||
enabled_(o.enabled_), clip_(o.clip_), clip_rect_(o.clip_rect_), volatile_(o.volatile_),
|
||||
help_text_(o.help_text_), help_string_(o.help_string_), align_(o.align_)
|
||||
help_text_(o.help_text_), help_string_(o.help_string_), align_(o.align_), id_(o.id_)
|
||||
{
|
||||
}
|
||||
|
||||
widget::widget(CVideo& video, const bool auto_join)
|
||||
: handler(auto_join), video_(&video), rect_(EmptyRect), focus_(true), needs_restore_(false),
|
||||
state_(UNINIT), hidden_override_(false), enabled_(true), clip_(false), volatile_(false),
|
||||
help_string_(0), align_(RIGHT_ALIGN)
|
||||
help_string_(0), align_(RIGHT_ALIGN), id_()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,18 @@ bool widget::dirty() const
|
|||
return state_ == DIRTY;
|
||||
}
|
||||
|
||||
const std::string& widget::id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
void widget::set_id(const std::string& id)
|
||||
{
|
||||
if (id_.empty()){
|
||||
id_ = id;
|
||||
}
|
||||
}
|
||||
|
||||
void widget::bg_update()
|
||||
{
|
||||
for(std::vector< surface_restorer >::iterator i = restorer_.begin(),
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
|
||||
void set_dirty(bool dirty=true);
|
||||
bool dirty() const;
|
||||
const std::string& id() const;
|
||||
void set_id(const std::string& id);
|
||||
|
||||
void set_help_string(const std::string& str);
|
||||
|
||||
|
@ -118,6 +120,7 @@ private:
|
|||
std::string help_text_;
|
||||
int help_string_;
|
||||
ALIGN align_; //limited support, use position
|
||||
std::string id_;
|
||||
|
||||
friend class scrollpane;
|
||||
friend class dialog;
|
||||
|
|
Loading…
Add table
Reference in a new issue