Skip to content

Commit

Permalink
Revert "split help_button out of help.hpp header"
Browse files Browse the repository at this point in the history
This reverts commit af34dc3.
  • Loading branch information
cbeck88 committed Nov 11, 2014
1 parent 38f892b commit dfedc6f
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 133 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -901,7 +901,6 @@ set(wesnoth-main_SRC
gui/dialogs/wml_message.cpp
halo.cpp
help/help.cpp
help/help_button.cpp
hotkey/hotkey_preferences_display.cpp
intro.cpp
leader_scroll_dialog.cpp
Expand Down
1 change: 0 additions & 1 deletion src/SConscript
Expand Up @@ -475,7 +475,6 @@ wesnoth_sources = Split("""
gui/widgets/window.cpp
halo.cpp
help/help.cpp
help/help_button.cpp
hotkey/hotkey_preferences_display.cpp
intro.cpp
leader_scroll_dialog.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/addon/manager_ui.cpp
Expand Up @@ -35,7 +35,7 @@
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/settings.hpp"
#include "help/help_button.hpp"
#include "help/help.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"
#include "wml_separators.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/dialogs.cpp
Expand Up @@ -30,7 +30,6 @@
#include "gui/widgets/window.hpp"
#include "gettext.hpp"
#include "help/help.hpp"
#include "help/help_button.hpp"
#include "language.hpp"
#include "log.hpp"
#include "map.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/game_initialization/multiplayer_lobby.cpp
Expand Up @@ -18,7 +18,6 @@

#include "global.hpp"

#include "construct_dialog.hpp"
#include "filesystem.hpp"
#include "game_preferences.hpp"
#include "lobby_preferences.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/gui/dialogs/lobby_main.cpp
Expand Up @@ -37,7 +37,6 @@
#include "gui/widgets/toggle_panel.hpp"
#include "gui/widgets/tree_view_node.hpp"

#include "construct_dialog.hpp"
#include "formula_string_utils.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
Expand Down
45 changes: 43 additions & 2 deletions src/help/help.cpp
Expand Up @@ -24,15 +24,13 @@
#include "help.hpp"

#include "about.hpp"
#include "construct_dialog.hpp"
#include "display.hpp"
#include "display_context.hpp"
#include "exceptions.hpp"
#include "game_config_manager.hpp" //solely to get terrain info from in some circumstances
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "hotkey/hotkey_command.hpp"
#include "language.hpp"
#include "log.hpp"
#include "map.hpp"
Expand Down Expand Up @@ -60,6 +58,49 @@ static lg::log_domain log_help("help");

namespace help {

help_button::help_button(display& disp, const std::string &help_topic)
: dialog_button(disp.video(), _("Help")), disp_(disp), topic_(help_topic), help_hand_(NULL)
{}

help_button::~help_button() {
delete help_hand_;
}

int help_button::action(gui::dialog_process_info &info) {
if(!topic_.empty()) {
show_help();
info.clear_buttons();
}
return gui::CONTINUE_DIALOG;
}

void help_button::show_help()
{
help::show_help(disp_, topic_);
}

bool help_button::can_execute_command(const hotkey::hotkey_command& cmd, int/*index*/) const
{
hotkey::HOTKEY_COMMAND command = cmd.id;
return (topic_.empty() == false && command == hotkey::HOTKEY_HELP) || command == hotkey::HOTKEY_SCREENSHOT;
}

void help_button::join() {
dialog_button::join();

//wait until we join the event context to start a hotkey handler
delete help_hand_;
help_hand_ = new hotkey::basic_handler(&disp_, this);
}

void help_button::leave() {
dialog_button::leave();

//now kill the hotkey handler
delete help_hand_;
help_hand_ = NULL;
}

/// Generate the help contents from the configurations given to the
/// manager.
static void generate_contents();
Expand Down
22 changes: 20 additions & 2 deletions src/help/help.hpp
Expand Up @@ -16,11 +16,12 @@

class config;
class display;
class gamemap;
class terrain_type;
class unit;
class unit_type;

#include <string>
#include "hotkey/command_executor.hpp"
#include "construct_dialog.hpp"

namespace help {

Expand Down Expand Up @@ -53,6 +54,23 @@ void show_variation_help(display &disp, const std::string &unit_id, const std::s
void show_terrain_help(display &disp, const std::string& unit_id, bool hidden = false,
int xloc = -1, int yloc = -1);

class help_button : public gui::dialog_button, public hotkey::command_executor {
public:
help_button(display& disp, const std::string &help_topic);
~help_button();
int action(gui::dialog_process_info &info);
std::string topic() const { return topic_; }
void join();
void leave();
private:
void show_help();
bool can_execute_command(const hotkey::hotkey_command& command, int/*index*/ =-1) const;

display &disp_;
const std::string topic_;
hotkey::basic_handler *help_hand_;
};

void show_unit_description(const unit_type &t);
void show_unit_description(const unit &u);
void show_terrain_description(const terrain_type& t);
Expand Down
72 changes: 0 additions & 72 deletions src/help/help_button.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions src/help/help_button.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/playsingle_controller.hpp
Expand Up @@ -17,8 +17,6 @@
#define PLAYSINGLE_CONTROLLER_H_INCLUDED

#include "play_controller.hpp"

#include "cursor.hpp"
#include "playturn_network_adapter.hpp"
#include "playturn.hpp"
#include "replay.hpp"
Expand Down
4 changes: 0 additions & 4 deletions src/show_dialog.cpp
Expand Up @@ -16,14 +16,10 @@

#define GETTEXT_DOMAIN "wesnoth-lib"

#include "show_dialog.hpp"

#include "construct_dialog.hpp"
#include "display.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/event/handler.hpp"
#include "help/help.hpp"
#include "hotkey/command_executor.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"

Expand Down

0 comments on commit dfedc6f

Please sign in to comment.