The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
help_button.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "help_button.hpp"
16 
17 #include "help.hpp"
18 #include "gettext.hpp"
19 #include "config.hpp"
20 
22 
23 #include <string>
24 
25 namespace help {
26 
27 help_button::help_button(CVideo& video, const std::string &help_topic)
28  : dialog_button(video, _("Help")), video_(video), topic_(help_topic), help_hand_(nullptr)
29 {}
30 
32  delete help_hand_;
33 }
34 
36  if(!topic_.empty()) {
37  show_help();
38  info.clear_buttons();
39  }
40  return gui::CONTINUE_DIALOG;
41 }
42 
44 {
46 }
47 
48 bool help_button::can_execute_command(const hotkey::hotkey_command& cmd, int/*index*/) const
49 {
50  hotkey::HOTKEY_COMMAND command = cmd.id;
51  return (topic_.empty() == false && command == hotkey::HOTKEY_HELP) || command == hotkey::HOTKEY_SCREENSHOT;
52 }
53 
56 
57  //wait until we join the event context to start a hotkey handler
58  delete help_hand_;
60 }
61 
63  dialog_button::leave();
64 
65  //now kill the hotkey handler
66  delete help_hand_;
67  help_hand_ = nullptr;
68 }
69 
70 } // end namespace help
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:117
help_button(CVideo &video, const std::string &help_topic)
Definition: help_button.cpp:27
logger & info()
Definition: log.cpp:91
Definition: video.hpp:58
Stores all information related to functions that can be bound to hotkeys.
Definitions for the interface to Wesnoth Markup Language (WML).
hotkey::basic_handler * help_hand_
Definition: help_button.hpp:41
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
const std::string topic_
Definition: help_button.hpp:40
int action(gui::dialog_process_info &info)
Definition: help_button.cpp:35
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
bool can_execute_command(const hotkey::hotkey_command &command, int=-1) const
Definition: help_button.cpp:48
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
Definition: help.cpp:57
GLsizei const GLcharARB ** string
Definition: glew.h:4503