remove display dependency from show_help()
help_button still needs a display& for regierting it in the hotkey code.
This commit is contained in:
parent
f7f4bc2707
commit
a953848dda
16 changed files with 67 additions and 70 deletions
|
@ -1058,7 +1058,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())) {
|
||||
help::show_unit_description(*units_->at(index_));
|
||||
help::show_unit_description(CVideo::get_singleton(), *units_->at(index_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ 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)
|
||||
help::show_unit_description(*type);
|
||||
help::show_unit_description(CVideo::get_singleton(), *type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -979,7 +979,7 @@ bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int i
|
|||
|
||||
void editor_controller::show_help()
|
||||
{
|
||||
help::show_help(*gui_, "..editor");
|
||||
help::show_help(gui_->video(), "..editor");
|
||||
}
|
||||
|
||||
void editor_controller::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp)
|
||||
|
@ -1089,9 +1089,9 @@ void editor_controller::unit_description()
|
|||
const unit_map & units = context_manager_->get_map_context().get_units();
|
||||
const unit_map::const_unit_iterator un = units.find(loc);
|
||||
if(un != units.end()) {
|
||||
help::show_unit_help(*gui_, un->type_id(), un->type().show_variations_in_help(), false);
|
||||
help::show_unit_help(gui_->video(), un->type_id(), un->type().show_variations_in_help(), false);
|
||||
} else {
|
||||
help::show_help(*gui_, "..units");
|
||||
help::show_help(gui_->video(), "..units");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ void editor_controller::terrain_description()
|
|||
return;
|
||||
|
||||
const terrain_type& type = context_manager_->get_map().get_terrain_info(loc);
|
||||
help::show_terrain_description(type);
|
||||
help::show_terrain_description(gui().video(), type);
|
||||
}
|
||||
|
||||
void editor_controller::process_keyup_event(const SDL_Event& event)
|
||||
|
|
|
@ -167,7 +167,7 @@ class editor_controller : public controller_base,
|
|||
/* controller_base overrides */
|
||||
void process_keyup_event(const SDL_Event& event);
|
||||
mouse_handler_base& get_mouse_handler_base() { return *this; }
|
||||
editor_display& get_display() {return *gui_;}
|
||||
editor_display& get_display() { return *gui_; }
|
||||
|
||||
/** Get the current mouse action */
|
||||
mouse_action* get_mouse_action();
|
||||
|
|
|
@ -61,11 +61,9 @@ taddon_connect::taddon_connect(std::string& host_name,
|
|||
register_text("host_name", false, host_name, true);
|
||||
}
|
||||
|
||||
void taddon_connect::help_button_callback(twindow& /*window*/)
|
||||
void taddon_connect::help_button_callback(twindow& window)
|
||||
{
|
||||
if(disp_) {
|
||||
help::show_help(*disp_, "installing_addons");
|
||||
}
|
||||
help::show_help(window.video(), "installing_addons");
|
||||
}
|
||||
|
||||
void taddon_connect::pre_show(CVideo& /*video*/, twindow& window)
|
||||
|
|
|
@ -261,7 +261,7 @@ void tunit_attack::profile_button_callback(const std::string& type)
|
|||
return;
|
||||
}
|
||||
|
||||
help::show_unit_help(*disp_, type);
|
||||
help::show_unit_help(disp_->video(), type);
|
||||
}
|
||||
|
||||
void tunit_attack::damage_calc_callback(twindow& window)
|
||||
|
|
|
@ -436,7 +436,7 @@ void tunit_create::profile_button_callback(twindow& window)
|
|||
const int selected_row
|
||||
= find_widget<tlistbox>(&window, "unit_type_list", false).get_selected_row();
|
||||
|
||||
help::show_unit_help(*disp_,
|
||||
help::show_unit_help(disp_->video(),
|
||||
units_[selected_row]->id(),
|
||||
units_[selected_row]->show_variations_in_help(), false);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "help.hpp"
|
||||
|
||||
#include "config.hpp" // for config, etc
|
||||
#include "display.hpp" // for display
|
||||
#include "events.hpp" // for raise_draw_event, pump, etc
|
||||
#include "font.hpp" // for relative_size
|
||||
#include "game_preferences.hpp"
|
||||
|
@ -58,17 +57,17 @@ static lg::log_domain log_help("help");
|
|||
|
||||
namespace help {
|
||||
|
||||
void show_unit_description(const unit &u)
|
||||
void show_unit_description(CVideo& video, const unit &u)
|
||||
{
|
||||
help::show_unit_description(u.type());
|
||||
help::show_unit_description(video, u.type());
|
||||
}
|
||||
|
||||
void show_terrain_description(const terrain_type &t)
|
||||
void show_terrain_description(CVideo& video, const terrain_type &t)
|
||||
{
|
||||
help::show_terrain_help(*display::get_singleton(), t.id(), t.hide_in_editor() || t.is_combined());
|
||||
help::show_terrain_help(video, t.id(), t.hide_in_editor() || t.is_combined());
|
||||
}
|
||||
|
||||
void show_unit_description(const unit_type &t)
|
||||
void show_unit_description(CVideo& video, const unit_type &t)
|
||||
{
|
||||
std::string var_id = t.get_cfg()["variation_id"].str();
|
||||
if (var_id.empty())
|
||||
|
@ -86,9 +85,9 @@ void show_unit_description(const unit_type &t)
|
|||
}
|
||||
|
||||
if (use_variation)
|
||||
help::show_variation_help(*display::get_singleton(), t.id(), var_id, hide_help);
|
||||
help::show_variation_help(video, t.id(), var_id, hide_help);
|
||||
else
|
||||
help::show_unit_help(*display::get_singleton(), t.id(), t.show_variations_in_help(), hide_help);
|
||||
help::show_unit_help(video, t.id(), t.show_variations_in_help(), hide_help);
|
||||
}
|
||||
|
||||
help_manager::help_manager(const config *cfg) //, gamemap *_map)
|
||||
|
@ -114,10 +113,10 @@ help_manager::~help_manager()
|
|||
*
|
||||
* If show_topic is the empty string, the default topic will be shown.
|
||||
*/
|
||||
void show_help(display &disp, const std::string& show_topic, int xloc, int yloc)
|
||||
void show_help(CVideo& video, const std::string& show_topic, int xloc, int yloc)
|
||||
{
|
||||
show_help(disp, toplevel, show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
show_help(video, toplevel, show_topic, xloc, yloc);
|
||||
video.flip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,11 +124,11 @@ void show_help(display &disp, 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(display &disp, const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
|
||||
void show_unit_help(CVideo& video, const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
|
||||
{
|
||||
show_help(disp, toplevel,
|
||||
show_help(video, toplevel,
|
||||
hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
video.flip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,10 +136,10 @@ void show_unit_help(display &disp, const std::string& show_topic, bool has_varia
|
|||
*
|
||||
* If show_topic is the empty string, the default topic will be shown.
|
||||
*/
|
||||
void show_terrain_help(display &disp, const std::string& show_topic, bool hidden, int xloc, int yloc)
|
||||
void show_terrain_help(CVideo& video, const std::string& show_topic, bool hidden, int xloc, int yloc)
|
||||
{
|
||||
show_help(disp, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
|
||||
disp.redraw_everything();
|
||||
show_help(video, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
|
||||
video.flip();
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,10 +147,10 @@ void show_terrain_help(display &disp, const std::string& show_topic, bool hidden
|
|||
/**
|
||||
* Open the help browser, show the variation of the unit matching.
|
||||
*/
|
||||
void show_variation_help(display &disp, const std::string& unit, const std::string &variation, bool hidden, int xloc, int yloc)
|
||||
void show_variation_help(CVideo& video, 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);
|
||||
disp.redraw_everything();
|
||||
show_help(video, toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
|
||||
video.flip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,7 +159,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,7 +167,7 @@ void show_help(display &disp, const section &toplevel_sec,
|
|||
const gui::dialog_manager manager;
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
CVideo& screen = disp.video();
|
||||
CVideo& screen = video;
|
||||
const surface& scr = screen.getSurface();
|
||||
|
||||
const int width = std::min<int>(font::relative_size(1250), scr->w - font::relative_size(20));
|
||||
|
@ -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,7 +19,7 @@ class display;
|
|||
class terrain_type;
|
||||
class unit;
|
||||
class unit_type;
|
||||
|
||||
class CVideo;
|
||||
#include <string>
|
||||
|
||||
namespace help {
|
||||
|
@ -33,29 +33,29 @@ 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
|
||||
/// 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(display &disp, const std::string& show_topic="", int xloc=-1, int yloc=-1);
|
||||
void show_help(CVideo& video, const std::string& show_topic="", int xloc=-1, int yloc=-1);
|
||||
|
||||
/// wrapper to add unit prefix and hiding symbol
|
||||
void show_unit_help(display &disp, const std::string& unit_id, bool has_variations=false,
|
||||
void show_unit_help(CVideo& video, const std::string& unit_id, bool has_variations=false,
|
||||
bool hidden = false, int xloc=-1, int yloc=-1);
|
||||
|
||||
/// wrapper to add variation prefix and hiding symbol
|
||||
void show_variation_help(display &disp, const std::string &unit_id, const std::string &variation,
|
||||
void show_variation_help(CVideo& video, const std::string &unit_id, const std::string &variation,
|
||||
bool hidden = false, int xloc=-1, int yloc=-1);
|
||||
|
||||
/// wrapper to add terrain prefix and hiding symbol
|
||||
void show_terrain_help(display &disp, const std::string& unit_id, bool hidden = false,
|
||||
void show_terrain_help(CVideo& video, const std::string& unit_id, bool hidden = false,
|
||||
int xloc = -1, int yloc = -1);
|
||||
|
||||
void show_unit_description(const unit_type &t);
|
||||
void show_unit_description(const unit &u);
|
||||
void show_terrain_description(const terrain_type& t);
|
||||
void show_unit_description(CVideo& video, const unit_type &t);
|
||||
void show_unit_description(CVideo& video, const unit &u);
|
||||
void show_terrain_description(CVideo& video, const terrain_type& t);
|
||||
|
||||
} // End namespace help.
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <iostream> // for operator<<, basic_ostream, etc
|
||||
#include "SDL_mouse.h" // for SDL_GetMouseState, etc
|
||||
#include "cursor.hpp" // for set, CURSOR_TYPE::HYPERLINK, etc
|
||||
#include "display.hpp" // for display
|
||||
#include "font.hpp" // for relative_size
|
||||
#include "gettext.hpp" // for _
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
|
@ -25,21 +24,23 @@
|
|||
#include "help_impl.hpp" // for find_topic, hidden_symbol, etc
|
||||
#include "key.hpp" // for CKey
|
||||
#include "log.hpp" // for log_scope
|
||||
#include "sdl/rect.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
struct SDL_Rect;
|
||||
|
||||
namespace help {
|
||||
|
||||
help_browser::help_browser(display &disp, const section &toplevel) :
|
||||
gui::widget(disp.video()),
|
||||
disp_(disp),
|
||||
menu_(disp.video(),
|
||||
help_browser::help_browser(CVideo& video, const section &toplevel) :
|
||||
gui::widget(video),
|
||||
menu_(video,
|
||||
toplevel),
|
||||
text_area_(disp.video(), toplevel), toplevel_(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 +151,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(CVideo::get_singleton(), "", msg.str());
|
||||
update_cursor();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "help_text_area.hpp" // for help_text_area
|
||||
#include "widgets/button.hpp" // for button
|
||||
#include "widgets/widget.hpp" // for widget
|
||||
class display; // lines 18-18
|
||||
class CVideo; // lines 18-18
|
||||
struct SDL_Rect;
|
||||
|
||||
namespace help {
|
||||
|
@ -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,6 @@ 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_;
|
||||
help_menu menu_;
|
||||
help_text_area text_area_;
|
||||
const section &toplevel_;
|
||||
|
|
|
@ -44,7 +44,7 @@ int help_button::action(gui::dialog_process_info &info) {
|
|||
|
||||
void help_button::show_help()
|
||||
{
|
||||
help::show_help(disp_, topic_);
|
||||
help::show_help(disp_.video(), topic_);
|
||||
}
|
||||
|
||||
bool help_button::can_execute_command(const hotkey::hotkey_command& cmd, int/*index*/) const
|
||||
|
|
|
@ -482,7 +482,7 @@ void menu_handler::show_chat_log()
|
|||
|
||||
void menu_handler::show_help()
|
||||
{
|
||||
help::show_help(*gui_);
|
||||
help::show_help(gui_->video());
|
||||
}
|
||||
|
||||
void menu_handler::speak()
|
||||
|
@ -861,7 +861,7 @@ void menu_handler::unit_description()
|
|||
{
|
||||
const unit_map::const_iterator un = current_unit();
|
||||
if(un != units().end()) {
|
||||
help::show_unit_description(*un);
|
||||
help::show_unit_description(pc_.get_display().video(), *un);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ void menu_handler::terrain_description(mouse_handler& mousehandler)
|
|||
|
||||
const terrain_type& type = map().get_terrain_info(loc);
|
||||
//const terrain_type& info = board().map().get_terrain_info(terrain);
|
||||
help::show_terrain_description(type);
|
||||
help::show_terrain_description(pc_.get_display().video(), type);
|
||||
}
|
||||
|
||||
void menu_handler::rename_unit()
|
||||
|
|
|
@ -1648,7 +1648,7 @@ int game_lua_kernel::intf_message(lua_State *L)
|
|||
int game_lua_kernel::intf_open_help(lua_State *L)
|
||||
{
|
||||
if (game_display_) {
|
||||
help::show_help(*game_display_, luaL_checkstring(L, 1));
|
||||
help::show_help(game_display_->video(), luaL_checkstring(L, 1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ private:
|
|||
void show_help()
|
||||
{
|
||||
if(topic_.empty() == false) {
|
||||
help::show_help(disp_,topic_);
|
||||
help::show_help(disp_.video(),topic_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ bool click(int mousex, int mousey)
|
|||
for(std::map<int, tooltip>::const_iterator i = tips.begin(); i != tips.end(); ++i) {
|
||||
if(!i->second.action.empty() && sdl::point_in_rect(mousex, mousey, i->second.rect)) {
|
||||
display* disp = resources::screen;
|
||||
help::show_help(*disp, i->second.action);
|
||||
help::show_help(disp->video(), i->second.action);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -824,7 +824,7 @@ static int do_gameloop(const std::vector<std::string>& args)
|
|||
continue;
|
||||
} else if(res == gui2::ttitle_screen::SHOW_HELP) {
|
||||
help::help_manager help_manager(&config_manager.game_config());
|
||||
help::show_help(game->disp());
|
||||
help::show_help(game->video());
|
||||
continue;
|
||||
} else if(res == gui2::ttitle_screen::GET_ADDONS) {
|
||||
// NOTE: we need the help_manager to get access to the Add-ons
|
||||
|
|
Loading…
Add table
Reference in a new issue