Author: silene
Date: Sun Apr 5 19:04:50 2009
New Revision: 34549
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34549&view=rev
Log:
Simplified code.
Modified:
trunk/src/config_adapter.cpp
trunk/src/config_adapter.hpp
trunk/src/editor2/editor_controller.cpp
trunk/src/play_controller.cpp
trunk/src/replay_controller.cpp
Modified: trunk/src/config_adapter.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config_adapter.cpp?rev=34549&r1=34548&r2=34549&view=diff
==============================================================================
--- trunk/src/config_adapter.cpp (original)
+++ trunk/src/config_adapter.cpp Sun Apr 5 19:04:50 2009
@@ -230,16 +230,17 @@
return result;
}
-const config* get_theme(const config& game_config, std::string theme_name)
+const config &get_theme(const config& game_config, std::string theme_name)
{
if (theme_name.empty()) theme_name = preferences::theme();
if (const config &c = game_config.find_child("theme", "name",
theme_name))
- return &c;
+ return c;
if (const config &c = game_config.find_child("theme", "name",
"default"))
- return &c;
-
- return NULL;
-}
-
+ return c;
+
+ static config empty;
+ return empty;
+}
+
Modified: trunk/src/config_adapter.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config_adapter.hpp?rev=34549&r1=34548&r2=34549&view=diff
==============================================================================
--- trunk/src/config_adapter.hpp (original)
+++ trunk/src/config_adapter.hpp Sun Apr 5 19:04:50 2009
@@ -36,7 +36,10 @@
std::string get_unique_saveid(const config& cfg, std::set<std::string>&
seen_save_ids);
int get_first_human_team(const config::child_list::const_iterator& cfg, const
config::child_list& unit_cfg);
void get_player_info(const config& cfg, game_state& gamestate, std::string
save_id, std::vector<team>& teams, const config& level, gamemap& map, unit_map&
units, gamestatus& game_status, bool snapshot);
-/** Return NULL if theme is not found. */
-const config* get_theme(const config& game_config, std::string theme_name);
+
+/**
+ * Returns the theme with the given @a theme_name, or an empty config
otherwise.
+ */
+const config &get_theme(const config& game_config, std::string theme_name);
#endif
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=34549&r1=34548&r2=34549&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Sun Apr 5 19:04:50 2009
@@ -153,10 +153,8 @@
void editor_controller::init_gui(CVideo& video)
{
- config dummy;
- const config* theme_cfg = get_theme(game_config_, "editor2");
- theme_cfg = theme_cfg ? theme_cfg : &dummy;
- gui_.reset(new editor_display(video, get_map(), *theme_cfg,
game_config_, config()));
+ const config &theme_cfg = get_theme(game_config_, "editor2");
+ gui_.reset(new editor_display(video, get_map(), theme_cfg,
game_config_, config()));
gui_->set_grid(preferences::grid());
prefs_disp_manager_.reset(new preferences::display_manager(&gui()));
gui_->add_redraw_observer(boost::bind(&editor_controller::display_redraw_callback,
this, _1));
Modified: trunk/src/play_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=34549&r1=34548&r2=34549&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Sun Apr 5 19:04:50 2009
@@ -147,11 +147,8 @@
loadscreen::global_loadscreen->set_progress(80, _("Initializing
display"));
LOG_NG << "initializing display... " << (SDL_GetTicks() - ticks_) <<
"\n";
- const config* theme_cfg = get_theme(game_config_, level_["theme"]);
- if (theme_cfg)
- gui_.reset(new
game_display(units_,video,map_,status_,teams_,*theme_cfg, game_config_,
level_));
- else
- gui_.reset(new
game_display(units_,video,map_,status_,teams_,config(), game_config_, level_));
+ const config &theme_cfg = get_theme(game_config_, level_["theme"]);
+ gui_.reset(new game_display(units_, video, map_, status_, teams_,
theme_cfg, game_config_, level_));
loadscreen::global_loadscreen->set_progress(90, _("Initializing
display"));
mouse_handler_.set_gui(gui_.get());
menu_handler_.set_gui(gui_.get());
Modified: trunk/src/replay_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay_controller.cpp?rev=34549&r1=34548&r2=34549&view=diff
==============================================================================
--- trunk/src/replay_controller.cpp (original)
+++ trunk/src/replay_controller.cpp Sun Apr 5 19:04:50 2009
@@ -141,11 +141,12 @@
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 (replay_theme_cfg)
+void replay_controller::rebuild_replay_theme()
+{
+ const config &theme_cfg = get_theme(game_config_, level_["theme"]);
+ if (const config &res = theme_cfg.child("resolution"))
+ {
+ if (const config &replay_theme_cfg = res.child("replay"))
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.
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits