The Battle for Wesnoth  1.15.7+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 game_config_view;
30 class play_controller;
31 class team;
32 class unit_map;
33 class t_string;
34 
35 namespace events
36 {
37 class mouse_handler;
38 }
39 
41 {
43 };
44 
45 namespace events
46 {
47 class menu_handler : private chat_handler
48 {
49 public:
51  virtual ~menu_handler();
52 
53  gui::floating_textbox& get_textbox();
54  void set_gui(game_display* gui)
55  {
56  gui_ = gui;
57  }
58 
59  void objectives();
60  void show_statistics(int side_num);
61  void unit_list();
62  void status_table();
63  void save_map();
64  void preferences();
65  void show_chat_log();
66  void show_help();
67  void speak();
68  void whisper();
69  void shout();
70  void recruit(int side_num, const map_location& last_hex);
71  void repeat_recruit(int side_num, const map_location& last_hex);
72  void recall(int side_num, const map_location& last_hex);
73  void show_enemy_moves(bool ignore_units, int side_num);
74  void toggle_shroud_updates(int side_num);
75  void update_shroud_now(int side_num);
76  bool end_turn(int side_num);
77  void goto_leader(int side_num);
78  void unit_description();
79  void terrain_description(mouse_handler& mousehandler);
80  void rename_unit();
81  void create_unit(mouse_handler& mousehandler);
82  void change_side(mouse_handler& mousehandler);
83  void kill_unit(mouse_handler& mousehandler);
84  void label_terrain(mouse_handler& mousehandler, bool team_only);
85  void clear_labels();
86  void label_settings();
87  void continue_move(mouse_handler& mousehandler, int side_num);
88  void execute_gotos(mouse_handler& mousehandler, int side_num);
89  void toggle_ellipses();
90  void toggle_grid();
91  void unit_hold_position(mouse_handler& mousehandler, int side_num);
92  void end_unit_turn(mouse_handler& mousehandler, int side_num);
93  void search();
94  void request_control_change(int side_num, const std::string& player);
95  void user_command();
96  void custom_command();
97  void ai_formula();
98  void clear_messages();
99  std::vector<std::string> get_commands_list();
100 
101  unit_map::iterator current_unit();
103  {
104  return const_cast<menu_handler*>(this)->current_unit();
105  }
106 
107  void move_unit_to_loc(const unit_map::iterator& ui,
108  const map_location& target,
109  bool continue_move,
110  int side_num,
111  mouse_handler& mousehandler);
112 
113  ///@return If the recruit is possible, an empty string and set @a recruited_from; otherwise, return an error message string.
114  t_string can_recruit(const std::string& name, int side_num, map_location& target_hex, map_location& recruited_from);
115  ///@return Whether or not the recruit was successful
116  bool do_recruit(const std::string& name, int side_num, map_location& target_hex);
117  void do_speak();
118  void do_search(const std::string& new_search);
119  void do_command(const std::string& str);
120  void do_ai_formula(const std::string& str, int side_num, mouse_handler& mousehandler);
121  void send_to_server(const config& cfg) override;
122 
123  game_state& gamestate() const;
124  game_data& gamedata();
125  game_board& board() const;
126  unit_map& units();
127  std::vector<team>& teams() const;
128  const gamemap& map() const;
129 
130 protected:
131  void add_chat_message(const std::time_t& time,
132  const std::string& speaker,
133  int side,
134  const std::string& message,
136  void send_chat_message(const std::string& message, bool allies_only = false) override;
137 
138 private:
139  // console_handler is basically a sliced out part of menu_handler
140  // and as such needs access to menu_handler's privates
141  friend class console_handler;
142 
143  // void do_speak(const std::string& message, bool allies_only);
144  // std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m,unsigned int team);
145  bool has_friends() const;
146 
149 
151 
155 };
156 }
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:114
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:54
std::string str
Definition: statement.cpp:110
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_
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_
std::string name
Definition: sdl_ttf.cpp:70
Handling of system events.
Definition: manager.hpp:42
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:951
play_controller & pc_
Base class for exceptions that want to be thrown &#39;through&#39; lua.
unit_map::const_iterator current_unit() const