Skip to content

Commit

Permalink
Help: removed code to show old GUI1 help browser
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Vultraz authored and CelticMinstrel committed Oct 24, 2018
1 parent bfe5f4a commit a4beeee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 92 deletions.
95 changes: 10 additions & 85 deletions src/help/help.cpp
Expand Up @@ -115,38 +115,38 @@ 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)
{
show_help(default_toplevel, show_topic, xloc, yloc);
show_help(default_toplevel, show_topic);
}

/**
* Open the help browser, show unit with id unit_id.
*
* 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)
{
show_help(default_toplevel,
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic);
}

/**
* Open the help browser, show terrain with id terrain_id.
*
* 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)
{
show_help(default_toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
show_help(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)
{
show_help(default_toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
show_help(default_toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation);
}

void init_help() {
Expand All @@ -172,84 +172,9 @@ void init_help() {
* This allows for complete customization of the contents, although not in a
* very easy way.
*/
void show_help(const section &toplevel_sec,
const std::string& show_topic,
int xloc, int yloc)
void show_help(const section &toplevel_sec, const std::string& show_topic)
{
CVideo& video = CVideo::get_singleton();

if(gui2::new_widgets) {
gui2::dialogs::help_browser::display(video, toplevel_sec, show_topic);
return;
}

const events::event_context dialog_events_context;
const gui::dialog_manager manager;

SDL_Rect screen_area = video.screen_area();

const int width = std::min<int>(font::relative_size(1200), screen_area.w - font::relative_size(20));
const int height = std::min<int>(font::relative_size(850), screen_area.h - 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 = screen_area.w / 2 - width / 2;
yloc = screen_area.h / 2 - height / 2;
}
std::vector<gui::button*> buttons_ptr;
gui::button close_button_(video, _("Close"));
buttons_ptr.push_back(&close_button_);

gui::dialog_frame f(video, _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
true, &buttons_ptr);
f.layout(xloc, yloc, width, height);
f.draw();

init_help();
try {
help_browser hb(video, 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.set_dirty(true);
events::raise_draw_event();
CKey key;
for (;;) {
events::pump();
events::raise_process_event();
f.draw();
events::raise_draw_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;
}
}
video.flip();
CVideo::delay(10);
}
}
catch (parse_error& e) {
std::stringstream msg;
msg << _("Parse error when parsing help text: ") << "'" << e.message << "'";
gui2::show_transient_message("", msg.str());
}
gui2::dialogs::help_browser::display(toplevel_sec, show_topic);
}

} // End namespace help.
12 changes: 5 additions & 7 deletions src/help/help.hpp
Expand Up @@ -34,25 +34,23 @@ void init_help();
/// Open a help dialog using a toplevel other than the default. This
/// allows for complete customization of the contents, although not in a
/// very easy way.
void show_help(const section &toplevel, const std::string& show_topic="",
int xloc=-1, int yloc=-1);
void show_help(const section &toplevel, const std::string& show_topic="");

/// Open the help browser. The help browser will have the topic with id
/// show_topic open if it is not the empty string. The default topic
/// will be shown if show_topic is the empty string.
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);
Expand Down

0 comments on commit a4beeee

Please sign in to comment.