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