Help: removed code to show old GUI1 help browser
Attempting to launch it crashes the game (probably to do with a null video surface), and since it's being replaced there's no point in restoring it to functionality. The implementation details (help_menu, etc) have been left for now. Will remove soon. This also means the GUI2 help browser is shown by default now.
This commit is contained in:
parent
ee82387c3d
commit
e6c0064755
2 changed files with 15 additions and 91 deletions
|
@ -67,7 +67,7 @@ namespace help {
|
|||
* doesn't already exist, that would likely destroy the referenced object at
|
||||
* the point that this function exited.
|
||||
*/
|
||||
void show_with_toplevel(const section &toplevel, const std::string& show_topic="", int xloc=-1, int yloc=-1);
|
||||
void show_with_toplevel(const section &toplevel, const std::string& show_topic="");
|
||||
|
||||
|
||||
void show_unit_description(const unit &u)
|
||||
|
@ -139,10 +139,10 @@ help_manager::~help_manager()
|
|||
*
|
||||
* If show_topic is the empty string, the default topic will be shown.
|
||||
*/
|
||||
void show_help(const std::string& show_topic, int xloc, int yloc)
|
||||
void show_help(const std::string& show_topic)
|
||||
{
|
||||
auto cache_lifecycle = ensure_cache_lifecycle();
|
||||
show_with_toplevel(default_toplevel, show_topic, xloc, yloc);
|
||||
show_with_toplevel(default_toplevel, show_topic);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,11 +150,11 @@ void show_help(const std::string& show_topic, int xloc, int yloc)
|
|||
*
|
||||
* If show_topic is the empty string, the default topic will be shown.
|
||||
*/
|
||||
void show_unit_help(const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
|
||||
void show_unit_help(const std::string& show_topic, bool has_variations, bool hidden)
|
||||
{
|
||||
auto cache_lifecycle = ensure_cache_lifecycle();
|
||||
show_with_toplevel(default_toplevel,
|
||||
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
|
||||
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,19 +162,19 @@ void show_unit_help(const std::string& show_topic, bool has_variations, bool hid
|
|||
*
|
||||
* If show_topic is the empty string, the default topic will be shown.
|
||||
*/
|
||||
void show_terrain_help(const std::string& show_topic, bool hidden, int xloc, int yloc)
|
||||
void show_terrain_help(const std::string& show_topic, bool hidden)
|
||||
{
|
||||
auto cache_lifecycle = ensure_cache_lifecycle();
|
||||
show_with_toplevel(default_toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
|
||||
show_with_toplevel(default_toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the help browser, show the variation of the unit matching.
|
||||
*/
|
||||
void show_variation_help(const std::string& unit, const std::string &variation, bool hidden, int xloc, int yloc)
|
||||
void show_variation_help(const std::string& unit, const std::string &variation, bool hidden)
|
||||
{
|
||||
auto cache_lifecycle = ensure_cache_lifecycle();
|
||||
show_with_toplevel(default_toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
|
||||
show_with_toplevel(default_toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation);
|
||||
}
|
||||
|
||||
void init_help() {
|
||||
|
@ -202,84 +202,9 @@ void init_help() {
|
|||
* This allows for complete customization of the contents, although not in a
|
||||
* very easy way.
|
||||
*/
|
||||
void show_with_toplevel(const section &toplevel_sec,
|
||||
const std::string& show_topic,
|
||||
int xloc, int yloc)
|
||||
void show_with_toplevel(const section &toplevel_sec, const std::string& show_topic)
|
||||
{
|
||||
if(gui2::new_widgets) {
|
||||
gui2::dialogs::help_browser::display(toplevel_sec, show_topic);
|
||||
return;
|
||||
}
|
||||
|
||||
const events::event_context dialog_events_context;
|
||||
const gui::dialog_manager manager;
|
||||
|
||||
point canvas_size = video::game_canvas_size();
|
||||
|
||||
const int width = std::min<int>(font::relative_size(1200), canvas_size.x - font::relative_size(20));
|
||||
const int height = std::min<int>(font::relative_size(850), canvas_size.y - font::relative_size(150));
|
||||
const int left_padding = font::relative_size(10);
|
||||
const int right_padding = font::relative_size(10);
|
||||
const int top_padding = font::relative_size(10);
|
||||
const int bot_padding = font::relative_size(10);
|
||||
|
||||
// If not both locations were supplied, put the dialog in the middle
|
||||
// of the screen.
|
||||
if (yloc <= -1 || xloc <= -1) {
|
||||
xloc = canvas_size.x / 2 - width / 2;
|
||||
yloc = canvas_size.y / 2 - height / 2;
|
||||
}
|
||||
std::vector<gui::button*> buttons_ptr;
|
||||
gui::button close_button_(_("Close"));
|
||||
buttons_ptr.push_back(&close_button_);
|
||||
|
||||
gui::dialog_frame f(
|
||||
_("Help"), gui::dialog_frame::default_style, &buttons_ptr
|
||||
);
|
||||
f.layout(xloc, yloc, width, height);
|
||||
|
||||
init_help();
|
||||
try {
|
||||
help_browser hb(toplevel_sec);
|
||||
hb.set_location(xloc + left_padding, yloc + top_padding);
|
||||
hb.set_width(width - left_padding - right_padding);
|
||||
hb.set_height(height - top_padding - bot_padding);
|
||||
if (!show_topic.empty()) {
|
||||
hb.show_topic(show_topic);
|
||||
}
|
||||
else {
|
||||
hb.show_topic(default_show_topic);
|
||||
}
|
||||
hb.queue_redraw();
|
||||
events::draw();
|
||||
CKey key;
|
||||
for (;;) {
|
||||
events::pump();
|
||||
events::raise_process_event();
|
||||
if (key[SDLK_ESCAPE]) {
|
||||
// Escape quits from the dialog.
|
||||
return;
|
||||
}
|
||||
for (std::vector<gui::button*>::iterator button_it = buttons_ptr.begin();
|
||||
button_it != buttons_ptr.end(); ++button_it) {
|
||||
if ((*button_it)->pressed()) {
|
||||
// There is only one button, close.
|
||||
return;
|
||||
}
|
||||
}
|
||||
// This also rate limits to vsync
|
||||
events::draw();
|
||||
}
|
||||
}
|
||||
catch (const parse_error& e) {
|
||||
ERR_HELP << _("Parse error when parsing help text:") << " " << e.message;
|
||||
#if 0
|
||||
// Displaying in the UI is disabled due to issue #2587
|
||||
std::stringstream msg;
|
||||
msg << _("Parse error when parsing help text:") << " '" << e.message << "'";
|
||||
gui2::show_transient_message("", msg.str());
|
||||
#endif
|
||||
}
|
||||
gui2::dialogs::help_browser::display(toplevel_sec, show_topic);
|
||||
}
|
||||
|
||||
} // End namespace help.
|
||||
|
|
|
@ -66,19 +66,18 @@ void init_help();
|
|||
*@pre game_config_manager has been initialised, or the instance of help_manager
|
||||
* has been created with an alternative config.
|
||||
*/
|
||||
void show_help(const std::string& show_topic="", int xloc=-1, int yloc=-1);
|
||||
void show_help(const std::string& show_topic="");
|
||||
|
||||
/** wrapper to add unit prefix and hiding symbol */
|
||||
void show_unit_help(const std::string& unit_id, bool has_variations=false,
|
||||
bool hidden = false, int xloc=-1, int yloc=-1);
|
||||
bool hidden = false);
|
||||
|
||||
/** wrapper to add variation prefix and hiding symbol */
|
||||
void show_variation_help(const std::string &unit_id, const std::string &variation,
|
||||
bool hidden = false, int xloc=-1, int yloc=-1);
|
||||
bool hidden = false);
|
||||
|
||||
/** wrapper to add terrain prefix and hiding symbol */
|
||||
void show_terrain_help(const std::string& unit_id, bool hidden = false,
|
||||
int xloc = -1, int yloc = -1);
|
||||
void show_terrain_help(const std::string& unit_id, bool hidden = false);
|
||||
|
||||
void show_unit_description(const unit_type &t);
|
||||
void show_unit_description(const unit &u);
|
||||
|
|
Loading…
Add table
Reference in a new issue