Pass CVideo argument directly to certain help functions
This commit is contained in:
parent
aff6c1b998
commit
cf8ff909e1
4 changed files with 24 additions and 25 deletions
|
@ -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, toplevel, show_topic, xloc, yloc);
|
||||
show_help(disp.video(), toplevel, show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
}
|
||||
|
||||
|
@ -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, toplevel,
|
||||
show_help(disp.video(), toplevel,
|
||||
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
}
|
||||
|
@ -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, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
|
||||
show_help(disp.video(), toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
}
|
||||
|
||||
|
@ -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, toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
|
||||
show_help(disp.video(), toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ 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(display &disp, const section &toplevel_sec,
|
||||
void show_help(CVideo& video, const section &toplevel_sec,
|
||||
const std::string& show_topic,
|
||||
int xloc, int yloc)
|
||||
{
|
||||
|
@ -168,8 +168,7 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
const gui::dialog_manager manager;
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
CVideo& screen = disp.video();
|
||||
const surface& scr = screen.getSurface();
|
||||
const surface& scr = video.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));
|
||||
|
@ -185,10 +184,10 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
yloc = scr->h / 2 - height / 2;
|
||||
}
|
||||
std::vector<gui::button*> buttons_ptr;
|
||||
gui::button close_button_(disp.video(), _("Close"));
|
||||
gui::button close_button_(video, _("Close"));
|
||||
buttons_ptr.push_back(&close_button_);
|
||||
|
||||
gui::dialog_frame f(disp.video(), _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
|
||||
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();
|
||||
|
@ -208,7 +207,7 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
generate_contents();
|
||||
}
|
||||
try {
|
||||
help_browser hb(disp, toplevel_sec);
|
||||
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);
|
||||
|
@ -220,7 +219,7 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
}
|
||||
hb.set_dirty(true);
|
||||
events::raise_draw_event();
|
||||
disp.video().flip();
|
||||
video.flip();
|
||||
CKey key;
|
||||
for (;;) {
|
||||
events::pump();
|
||||
|
@ -238,14 +237,14 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
return;
|
||||
}
|
||||
}
|
||||
disp.video().flip();
|
||||
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(disp.video(), "", msg.str());
|
||||
gui2::show_transient_message(video, "", msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class display;
|
|||
class terrain_type;
|
||||
class unit;
|
||||
class unit_type;
|
||||
class CVideo;
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -33,7 +34,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(display &disp, const section &toplevel, const std::string& show_topic="",
|
||||
void show_help(CVideo& video, 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
|
||||
|
|
|
@ -29,17 +29,16 @@ struct SDL_Rect;
|
|||
|
||||
namespace help {
|
||||
|
||||
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),
|
||||
help_browser::help_browser(CVideo& video, const section &toplevel) :
|
||||
gui::widget(video),
|
||||
video_(video),
|
||||
menu_(video, toplevel),
|
||||
text_area_(video, toplevel), toplevel_(toplevel),
|
||||
ref_cursor_(false),
|
||||
back_topics_(),
|
||||
forward_topics_(),
|
||||
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"),
|
||||
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"),
|
||||
shown_topic_(NULL)
|
||||
{
|
||||
// Hide the buttons at first since we do not have any forward or
|
||||
|
@ -150,7 +149,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(disp_.video(), "", msg.str());
|
||||
gui2::show_transient_message(video_, "", msg.str());
|
||||
update_cursor();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace help {
|
|||
class help_browser : public gui::widget
|
||||
{
|
||||
public:
|
||||
help_browser(display &disp, const section &toplevel);
|
||||
help_browser(CVideo& video, const section &toplevel);
|
||||
|
||||
void adjust_layout();
|
||||
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
/// 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);
|
||||
display &disp_;
|
||||
CVideo& video_;
|
||||
help_menu menu_;
|
||||
help_text_area text_area_;
|
||||
const section &toplevel_;
|
||||
|
|
Loading…
Add table
Reference in a new issue