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