The Battle for Wesnoth  1.15.2+dev
menu_events.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2018 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
3  wesnoth playturn Copyright (C) 2003 by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "chat_events.hpp"
19 #include "floating_textbox.hpp"
21 #include "units/map.hpp"
22 
23 #include <vector>
24 
25 class game_state;
26 class gamemap;
27 class game_data;
28 class game_board;
29 class play_controller;
30 class team;
31 class unit_map;
32 class t_string;
33 
34 namespace events
35 {
36 class mouse_handler;
37 }
38 
40 {
42 };
43 
44 namespace events
45 {
46 class menu_handler : private chat_handler
47 {
48 public:
50  virtual ~menu_handler();
51 
52  gui::floating_textbox& get_textbox();
53  void set_gui(game_display* gui)
54  {
55  gui_ = gui;
56  }
57 
58  void objectives();
59  void show_statistics(int side_num);
60  void unit_list();
61  void status_table();
62  void save_map();
63  void preferences();
64  void show_chat_log();
65  void show_help();
66  void speak();
67  void whisper();
68  void shout();
69  void recruit(int side_num, const map_location& last_hex);
70  void repeat_recruit(int side_num, const map_location& last_hex);
71  void recall(int side_num, const map_location& last_hex);
72  void show_enemy_moves(bool ignore_units, int side_num);
73  void toggle_shroud_updates(int side_num);
74  void update_shroud_now(int side_num);
75  bool end_turn(int side_num);
76  void goto_leader(int side_num);
77  void unit_description();
78  void terrain_description(mouse_handler& mousehandler);
79  void rename_unit();
80  void create_unit(mouse_handler& mousehandler);
81  void change_side(mouse_handler& mousehandler);
82  void kill_unit(mouse_handler& mousehandler);
83  void label_terrain(mouse_handler& mousehandler, bool team_only);
84  void clear_labels();
85  void label_settings();
86  void continue_move(mouse_handler& mousehandler, int side_num);
87  void execute_gotos(mouse_handler& mousehandler, int side_num);
88  void toggle_ellipses();
89  void toggle_grid();
90  void unit_hold_position(mouse_handler& mousehandler, int side_num);
91  void end_unit_turn(mouse_handler& mousehandler, int side_num);
92  void search();
93  void request_control_change(int side_num, const std::string& player);
94  void user_command();
95  void custom_command();
96  void ai_formula();
97  void clear_messages();
98  std::vector<std::string> get_commands_list();
99 
100  unit_map::iterator current_unit();
102  {
103  return const_cast<menu_handler*>(this)->current_unit();
104  }
105 
106  void move_unit_to_loc(const unit_map::iterator& ui,
107  const map_location& target,
108  bool continue_move,
109  int side_num,
110  mouse_handler& mousehandler);
111 
112  ///@return If the recruit is possible, an empty string and set @a recruited_from; otherwise, return an error message string.
113  t_string can_recruit(const std::string& name, int side_num, map_location& target_hex, map_location& recruited_from);
114  ///@return Whether or not the recruit was successful
115  bool do_recruit(const std::string& name, int side_num, map_location& target_hex);
116  void do_speak();
117  void do_search(const std::string& new_search);
118  void do_command(const std::string& str);
119  void do_ai_formula(const std::string& str, int side_num, mouse_handler& mousehandler);
120  void send_to_server(const config& cfg) override;
121 
122  game_state& gamestate() const;
123  game_data& gamedata();
124  game_board& board() const;
125  unit_map& units();
126  std::vector<team>& teams() const;
127  const gamemap& map() const;
128 
129 protected:
130  void add_chat_message(const std::time_t& time,
131  const std::string& speaker,
132  int side,
133  const std::string& message,
135  void send_chat_message(const std::string& message, bool allies_only = false) override;
136 
137 private:
138  // console_handler is basically a sliced out part of menu_handler
139  // and as such needs access to menu_handler's privates
140  friend class console_handler;
141 
142  // void do_speak(const std::string& message, bool allies_only);
143  // std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m,unsigned int team);
144  bool has_friends() const;
145 
148 
150 
152  std::string last_search_;
154 };
155 }
Game board class.
Definition: game_board.hpp:50
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:115
map_location last_search_hit_
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from lua_jailbreak_exception.
General purpose widgets.
void set_gui(game_display *gui)
Definition: menu_events.hpp:53
game_data * gamedata
Definition: resources.cpp:22
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
game_display * gui_
const config & game_config_
Encapsulates the map of the game.
Definition: map.hpp:36
Modify, read and display user preferences.
Encapsulates the map of the game.
Definition: location.hpp:42
std::string last_search_
Handling of system events.
Definition: manager.hpp:41
Container associating units to locations.
Definition: map.hpp:99
gui::floating_textbox textbox_info_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
std::string custom_command()
Definition: game.cpp:962
play_controller & pc_
Base class for exceptions that want to be thrown &#39;through&#39; lua.
unit_map::const_iterator current_unit() const