minor refactor of help -- launch dialogs from help:: not dialogs::
This commit is contained in:
parent
47fe0aabd2
commit
ae58f715cd
6 changed files with 43 additions and 44 deletions
|
@ -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;
|
||||
|
|
|
@ -148,11 +148,6 @@ private:
|
|||
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);
|
||||
|
|
|
@ -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)
|
||||
|
|
33
src/help.cpp
33
src/help.cpp
|
@ -514,6 +514,39 @@ private:
|
|||
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.
|
||||
|
|
|
@ -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 @@ private:
|
|||
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.
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue