Author: jhinrichs
Date: Sat Mar 1 00:36:38 2008
New Revision: 24165
URL: http://svn.gna.org/viewcvs/wesnoth?rev=24165&view=rev
Log:
Fixes bug #4410 (Missing GUI elements after switching between windowed and
fullscreen).
Modified:
trunk/src/replay_controller.cpp
trunk/src/replay_controller.hpp
trunk/src/theme.cpp
trunk/src/theme.hpp
Modified: trunk/src/replay_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay_controller.cpp?rev=24165&r1=24164&r2=24165&view=diff
==============================================================================
--- trunk/src/replay_controller.cpp (original)
+++ trunk/src/replay_controller.cpp Sat Mar 1 00:36:38 2008
@@ -139,15 +139,22 @@
void replay_controller::init_replay_display(){
DBG_REPLAY << "initializing replay-display... " << (SDL_GetTicks() -
ticks_) << "\n";
+
+ rebuild_replay_theme();
+ gui_->get_theme().theme_reset().attach_handler(this);
+ DBG_REPLAY << "done initializing replay-display... " << (SDL_GetTicks()
- ticks_) << "\n";
+}
+
+void replay_controller::rebuild_replay_theme(){
const config* theme_cfg = get_theme(game_config_, level_["theme"]);
if (theme_cfg) {
const config* replay_theme_cfg =
theme_cfg->child("resolution")->child("replay");
if (NULL != replay_theme_cfg)
- gui_->get_theme().modify(replay_theme_cfg);
+ gui_->get_theme().modify(replay_theme_cfg);
+ //Make sure we get notified if the theme is redrawn completely.
That way we have
+ //a chance to restore the replay controls of the theme as well.
gui_->invalidate_theme();
}
-
- DBG_REPLAY << "done initializing replay-display... " << (SDL_GetTicks()
- ticks_) << "\n";
}
void replay_controller::reset_replay(){
@@ -395,6 +402,10 @@
menu_handler_.show_statistics(gui_->playing_team()+1);
}
+void replay_controller::handle_generic_event(const std::string& name){
+ rebuild_replay_theme();
+}
+
bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
int index) const
{
bool result = play_controller::can_execute_command(command,index);
Modified: trunk/src/replay_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay_controller.hpp?rev=24165&r1=24164&r2=24165&view=diff
==============================================================================
--- trunk/src/replay_controller.hpp (original)
+++ trunk/src/replay_controller.hpp Sat Mar 1 00:36:38 2008
@@ -57,6 +57,8 @@
void update_teams();
void update_gui();
void init_replay_display();
+ void rebuild_replay_theme();
+ void handle_generic_event(const std::string& name);
game_state gamestate_start_;
gamestatus status_start_;
Modified: trunk/src/theme.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/theme.cpp?rev=24165&r1=24164&r2=24165&view=diff
==============================================================================
--- trunk/src/theme.cpp (original)
+++ trunk/src/theme.cpp Sat Mar 1 00:36:38 2008
@@ -498,7 +498,9 @@
items_(utils::split(cfg["items"]))
{}
-theme::theme(const config& cfg, const SDL_Rect& screen) {
+theme::theme(const config& cfg, const SDL_Rect& screen) :
+ theme_reset_("theme_reset")
+{
config tmp;
expand_partialresolution(tmp, cfg);
do_resolve_rects(tmp, cfg_);
@@ -556,6 +558,9 @@
if (title_stash.find(m->get_id()) != title_stash.end())
m->set_title(title_stash[m->get_id()]);
}
+
+ theme_reset_.notify_observers();
+
return result;
}
Modified: trunk/src/theme.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/theme.hpp?rev=24165&r1=24164&r2=24165&view=diff
==============================================================================
--- trunk/src/theme.hpp (original)
+++ trunk/src/theme.hpp Sat Mar 1 00:36:38 2008
@@ -24,6 +24,7 @@
#include "SDL.h"
#include "config.hpp"
+#include "generic_event.hpp"
typedef struct { size_t x1,y1,x2,y2; } _rect;
@@ -220,11 +221,17 @@
const tborder& border() const { return border_; }
+ events::generic_event& theme_reset() { return theme_reset_; }
+
private:
theme::object& find_element(std::string id);
void add_object(const config& cfg);
void remove_object(std::string id);
void set_object_location(theme::object& element, std::string rect_str,
std::string ref_id);
+
+ //notify observers that the theme has been rebuilt completely
+ //atm this is used for replay_controller to add replay controls to the
standard theme
+ events::generic_event theme_reset_;
static std::map<std::string, config> known_themes;
std::string cur_theme;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits