diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 1786ebc8aa76..d417a8b3e897 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -1450,7 +1450,7 @@ const unit_preview_pane::details units_list_preview_pane::get_details() const void units_list_preview_pane::process_event() { if (details_button_.pressed() && index_ >= 0 && index_ < int(size())) { - show_unit_description(*units_[index_]); + help::show_unit_description(*units_[index_]); } } @@ -1538,44 +1538,10 @@ void unit_types_preview_pane::process_event() if (details_button_.pressed() && index_ >= 0 && index_ < int(size())) { const unit_type* type = (*unit_types_)[index_]; if (type != NULL) - show_unit_description(*type); + help::show_unit_description(*type); } } - -void show_unit_description(const unit &u) -{ - show_unit_description(u.type()); -} - -void show_terrain_description(const terrain_type &t) -{ - help::show_terrain_help(*display::get_singleton(), t.id(), t.hide_in_editor() || t.is_combined()); -} - -void show_unit_description(const unit_type &t) -{ - std::string var_id = t.get_cfg()["variation_id"].str(); - if (var_id.empty()) - var_id = t.get_cfg()["variation_name"].str(); - bool hide_help = t.hide_help(); - bool use_variation = false; - if (!var_id.empty()) { - const unit_type *parent = unit_types.find(t.id()); - assert(parent); - if (hide_help) { - hide_help = parent->hide_help(); - } else { - use_variation = true; - } - } - - if (use_variation) - help::show_variation_help(*display::get_singleton(), t.id(), var_id, hide_help); - else - help::show_unit_help(*display::get_singleton(), t.id(), !t.variations().empty(), hide_help); -} - static network::connection network_data_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num, network::statistics (*get_stats)(network::connection handle)) { const size_t width = 300; diff --git a/src/dialogs.hpp b/src/dialogs.hpp index 01d40aae99f0..a6c044ad34f8 100644 --- a/src/dialogs.hpp +++ b/src/dialogs.hpp @@ -148,11 +148,6 @@ class unit_types_preview_pane : public dialogs::unit_preview_pane int side_; }; - -void show_unit_description(const unit_type &t); -void show_unit_description(const unit &u); -void show_terrain_description(const terrain_type& t); - network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0); network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0); network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port); diff --git a/src/editor/editor_controller.cpp b/src/editor/editor_controller.cpp index 0e8fcf323fde..1f62d0e2025c 100644 --- a/src/editor/editor_controller.cpp +++ b/src/editor/editor_controller.cpp @@ -1327,7 +1327,7 @@ void editor_controller::terrain_description() return; const terrain_type& type = context_manager_->get_map().get_terrain_info(loc); - dialogs::show_terrain_description(type); + help::show_terrain_description(type); } void editor_controller::process_keyup_event(const SDL_Event& event) diff --git a/src/help.cpp b/src/help.cpp index d47b68f1196d..0884795a72e2 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -514,6 +514,39 @@ class help_browser : public gui::widget topic const *shown_topic_; }; +void show_unit_description(const unit &u) +{ + help::show_unit_description(u.type()); +} + +void show_terrain_description(const terrain_type &t) +{ + help::show_terrain_help(*display::get_singleton(), t.id(), t.hide_in_editor() || t.is_combined()); +} + +void show_unit_description(const unit_type &t) +{ + std::string var_id = t.get_cfg()["variation_id"].str(); + if (var_id.empty()) + var_id = t.get_cfg()["variation_name"].str(); + bool hide_help = t.hide_help(); + bool use_variation = false; + if (!var_id.empty()) { + const unit_type *parent = unit_types.find(t.id()); + assert(parent); + if (hide_help) { + hide_help = parent->hide_help(); + } else { + use_variation = true; + } + } + + if (use_variation) + help::show_variation_help(*display::get_singleton(), t.id(), var_id, hide_help); + else + help::show_unit_help(*display::get_singleton(), t.id(), !t.variations().empty(), hide_help); +} + // Generator stuff below. Maybe move to a separate file? This one is // getting crowded. Dunno if much more is needed though so I'll wait and // see. diff --git a/src/help.hpp b/src/help.hpp index beca8c5f44ed..df50af9ebf9f 100644 --- a/src/help.hpp +++ b/src/help.hpp @@ -17,6 +17,8 @@ class config; class display; class gamemap; +class terrain_type; +class unit_type; #include "hotkey/command_executor.hpp" #include "construct_dialog.hpp" @@ -69,6 +71,9 @@ class help_button : public gui::dialog_button, public hotkey::command_executor { hotkey::basic_handler *help_hand_; }; +void show_unit_description(const unit_type &t); +void show_unit_description(const unit &u); +void show_terrain_description(const terrain_type& t); } // End namespace help. diff --git a/src/menu_events.cpp b/src/menu_events.cpp index db818afa4072..d3228796e9b8 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -894,7 +894,7 @@ void menu_handler::unit_description() { const unit_map::const_iterator un = current_unit(); if(un != units_.end()) { - dialogs::show_unit_description(*un); + help::show_unit_description(*un); } } @@ -907,7 +907,7 @@ void menu_handler::terrain_description(mouse_handler& mousehandler) const terrain_type& type = map_.get_terrain_info(loc); //const terrain_type& info = resources::gameboard->map().get_terrain_info(terrain); - dialogs::show_terrain_description(type); + help::show_terrain_description(type); } void menu_handler::rename_unit()