Skip to content

Commit

Permalink
Revert "Pass CVideo argument directly to certain help functions"
Browse files Browse the repository at this point in the history
This reverts commit cf8ff90.
  • Loading branch information
gfgtdf committed Jan 12, 2016
1 parent 9435744 commit f7f4bc2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
25 changes: 13 additions & 12 deletions src/help/help.cpp
Expand Up @@ -116,7 +116,7 @@ help_manager::~help_manager()
*/
void show_help(display &disp, const std::string& show_topic, int xloc, int yloc)
{
show_help(disp.video(), toplevel, show_topic, xloc, yloc);
show_help(disp, toplevel, show_topic, xloc, yloc);
disp.redraw_everything();
}

Expand All @@ -127,7 +127,7 @@ void show_help(display &disp, const std::string& show_topic, int xloc, int yloc)
*/
void show_unit_help(display &disp, const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
{
show_help(disp.video(), toplevel,
show_help(disp, toplevel,
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
disp.redraw_everything();
}
Expand All @@ -139,7 +139,7 @@ void show_unit_help(display &disp, const std::string& show_topic, bool has_varia
*/
void show_terrain_help(display &disp, const std::string& show_topic, bool hidden, int xloc, int yloc)
{
show_help(disp.video(), toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
show_help(disp, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
disp.redraw_everything();
}

Expand All @@ -150,7 +150,7 @@ void show_terrain_help(display &disp, const std::string& show_topic, bool hidden
*/
void show_variation_help(display &disp, const std::string& unit, const std::string &variation, bool hidden, int xloc, int yloc)
{
show_help(disp.video(), toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
show_help(disp, toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
disp.redraw_everything();
}

Expand All @@ -160,15 +160,16 @@ void show_variation_help(display &disp, const std::string& unit, const std::stri
* This allows for complete customization of the contents, although not in a
* very easy way.
*/
void show_help(CVideo& video, const section &toplevel_sec,
void show_help(display &disp, const section &toplevel_sec,
const std::string& show_topic,
int xloc, int yloc)
{
const events::event_context dialog_events_context;
const gui::dialog_manager manager;
const resize_lock prevent_resizing;

const surface& scr = video.getSurface();
CVideo& screen = disp.video();
const surface& scr = screen.getSurface();

const int width = std::min<int>(font::relative_size(1250), scr->w - font::relative_size(20));
const int height = std::min<int>(font::relative_size(850), scr->h - font::relative_size(150));
Expand All @@ -184,10 +185,10 @@ void show_help(CVideo& video, const section &toplevel_sec,
yloc = scr->h / 2 - height / 2;
}
std::vector<gui::button*> buttons_ptr;
gui::button close_button_(video, _("Close"));
gui::button close_button_(disp.video(), _("Close"));
buttons_ptr.push_back(&close_button_);

gui::dialog_frame f(video, _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
gui::dialog_frame f(disp.video(), _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
true, &buttons_ptr);
f.layout(xloc, yloc, width, height);
f.draw();
Expand All @@ -207,7 +208,7 @@ void show_help(CVideo& video, const section &toplevel_sec,
generate_contents();
}
try {
help_browser hb(video, toplevel_sec);
help_browser hb(disp, 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);
Expand All @@ -219,7 +220,7 @@ void show_help(CVideo& video, const section &toplevel_sec,
}
hb.set_dirty(true);
events::raise_draw_event();
video.flip();
disp.video().flip();
CKey key;
for (;;) {
events::pump();
Expand All @@ -237,14 +238,14 @@ void show_help(CVideo& video, const section &toplevel_sec,
return;
}
}
video.flip();
disp.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(video, "", msg.str());
gui2::show_transient_message(disp.video(), "", msg.str());
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/help/help.hpp
Expand Up @@ -19,7 +19,6 @@ class display;
class terrain_type;
class unit;
class unit_type;
class CVideo;

#include <string>

Expand All @@ -34,7 +33,7 @@ struct section;
/// 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(CVideo& video, const section &toplevel, const std::string& show_topic="",
void show_help(display &disp, const section &toplevel, const std::string& show_topic="",
int xloc=-1, int yloc=-1);

/// Open the help browser. The help browser will have the topic with id
Expand Down
17 changes: 9 additions & 8 deletions src/help/help_browser.cpp
Expand Up @@ -29,16 +29,17 @@ struct SDL_Rect;

namespace help {

help_browser::help_browser(CVideo& video, const section &toplevel) :
gui::widget(video),
video_(video),
menu_(video, toplevel),
text_area_(video, toplevel), toplevel_(toplevel),
help_browser::help_browser(display &disp, const section &toplevel) :
gui::widget(disp.video()),
disp_(disp),
menu_(disp.video(),
toplevel),
text_area_(disp.video(), toplevel), toplevel_(toplevel),
ref_cursor_(false),
back_topics_(),
forward_topics_(),
back_button_(video, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left"),
forward_button_(video, "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right"),
back_button_(disp.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left"),
forward_button_(disp.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right"),
shown_topic_(NULL)
{
// Hide the buttons at first since we do not have any forward or
Expand Down Expand Up @@ -149,7 +150,7 @@ void help_browser::handle_event(const SDL_Event &event)
if (t == NULL) {
std::stringstream msg;
msg << _("Reference to unknown topic: ") << "'" << ref << "'.";
gui2::show_transient_message(video_, "", msg.str());
gui2::show_transient_message(disp_.video(), "", msg.str());
update_cursor();
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/help/help_browser.hpp
Expand Up @@ -31,7 +31,7 @@ namespace help {
class help_browser : public gui::widget
{
public:
help_browser(CVideo& video, const section &toplevel);
help_browser(display &disp, const section &toplevel);

void adjust_layout();

Expand All @@ -54,7 +54,7 @@ class help_browser : public gui::widget
/// it in to. Pop at the fronts if the maximum number of elements is
/// exceeded.
void move_in_history(std::deque<const topic *> &from, std::deque<const topic *> &to);
CVideo& video_;
display &disp_;
help_menu menu_;
help_text_area text_area_;
const section &toplevel_;
Expand Down

0 comments on commit f7f4bc2

Please sign in to comment.