The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
menu_events.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2016 by Joerg Hinrichs <[email protected]>
3  wesnoth playturn Copyright (C) 2003 by David White <[email protected]>
4  Part of the Battle for Wesnoth Project http://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 #ifndef MENU_EVENTS_H_INCLUDED
17 #define MENU_EVENTS_H_INCLUDED
18 
19 #include "global.hpp"
20 #include "chat_events.hpp"
21 #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 gamemap;
31 class play_controller;
32 class team;
33 class unit_map;
34 
35 namespace events {
36  class mouse_handler;
37 }
38 
40 
41 namespace events {
42 
43 class menu_handler : private chat_handler {
44 public:
46  const config& game_config);
47  virtual ~menu_handler();
48 
50  void set_gui(game_display* gui) { gui_ = gui; }
51 
52  std::string get_title_suffix(int side_num);
53  void objectives(int side_num);
54  void show_statistics(int side_num);
55  void unit_list();
56  void status_table(int selected=0);
57  void save_map();
58  void preferences();
59  void show_chat_log();
60  void show_help();
61  void speak();
62  void whisper();
63  void shout();
64  void recruit(int side_num, const map_location &last_hex);
65  void repeat_recruit(int side_num, const map_location &last_hex);
66  void recall(int side_num, const map_location& last_hex);
67  void show_enemy_moves(bool ignore_units, int side_num);
68  void toggle_shroud_updates(int side_num);
69  void update_shroud_now(int side_num);
70  bool end_turn(int side_num);
71  void goto_leader(int side_num);
72  void unit_description();
73  void terrain_description(mouse_handler& mousehandler);
74  void rename_unit();
75  void create_unit(mouse_handler& mousehandler);
76  void change_side(mouse_handler& mousehandler);
77  void kill_unit(mouse_handler& mousehandler);
78  void label_terrain(mouse_handler& mousehandler, bool team_only);
79  void clear_labels();
80  void label_settings();
81  void continue_move(mouse_handler &mousehandler, int side_num);
82  void execute_gotos(mouse_handler &mousehandler, int side_num);
83  void toggle_ellipses();
84  void toggle_grid();
85  void unit_hold_position(mouse_handler &mousehandler, int side_num);
86  void end_unit_turn(mouse_handler &mousehandler, int side_num);
87  void search();
88  void request_control_change(int side_num, const std::string &player);
89  void user_command();
90  void custom_command();
91  void ai_formula();
92  void clear_messages();
93  std::vector<std::string> get_commands_list();
94 
97  { return const_cast<menu_handler *>(this)->current_unit(); }
99  bool continue_move, int side_num, mouse_handler &mousehandler);
100  ///@return Whether or not the recruit was successful
101  bool do_recruit(const std::string& name, int side_num, const map_location& last_hex);
102  void do_speak();
103  void do_search(const std::string& new_search);
104  void do_command(const std::string &str);
105  void do_ai_formula(const std::string &str, int side_num, mouse_handler &mousehandler);
106  void send_to_server(const config& cfg) override;
107 protected:
108  void add_chat_message(const time_t& time, const std::string& speaker,
109  int side, const std::string& message,
111  void send_chat_message(const std::string& message, bool allies_only=false);
112 private:
113  //console_handler is basically a sliced out part of menu_handler
114  //and as such needs access to menu_handler's privates
115  friend class console_handler;
116 
117  //void do_speak(const std::string& message, bool allies_only);
118 // std::vector<std::string> create_unit_table(const statistics::stats::str_int_map& m,unsigned int team);
119  bool has_friends() const;
120  void scenario_settings_table(int selected=0);
121 
124 
125  game_state & gamestate() const;
126  game_data & gamedata();
127  game_board & board() const;
128  unit_map& units();
129  std::vector<team>& teams() const;
130  const gamemap& map();
131 
133 
137 };
138 
139 }
140 #endif
void label_terrain(mouse_handler &mousehandler, bool team_only)
unit_map::const_iterator current_unit() const
Definition: menu_events.hpp:96
void do_search(const std::string &new_search)
Game board class.
Definition: game_board.hpp:55
game_data & gamedata()
void goto_leader(int side_num)
map_location last_search_hit_
const gamemap & map()
menu_handler(game_display *gui, play_controller &pc, const config &game_config)
Definition: menu_events.cpp:94
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
void add_chat_message(const time_t &time, const std::string &speaker, int side, const std::string &message, events::chat_handler::MESSAGE_TYPE type=events::chat_handler::MESSAGE_PRIVATE)
void do_command(const std::string &str)
gui::floating_textbox & get_textbox()
General purpose widgets.
void request_control_change(int side_num, const std::string &player)
void set_gui(game_display *gui)
Definition: menu_events.hpp:50
std::string get_title_suffix(int side_num)
void update_shroud_now(int side_num)
void create_unit(mouse_handler &mousehandler)
Creates a unit (in debug mode via hotkey or context menu).
void show_statistics(int side_num)
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
bool end_turn(int side_num)
game_display * gui_
void toggle_shroud_updates(int side_num)
game_board & board() const
void recall(int side_num, const map_location &last_hex)
void status_table(int selected=0)
std::string selected
Definition: game_config.cpp:84
const config & game_config_
void end_unit_turn(mouse_handler &mousehandler, int side_num)
Encapsulates the map of the game.
Definition: map.hpp:37
void recruit(int side_num, const map_location &last_hex)
std::vector< team > & teams() const
game_state & gamestate() const
bool do_recruit(const std::string &name, int side_num, const map_location &last_hex)
Encapsulates the map of the game.
Definition: location.hpp:38
void continue_move(mouse_handler &mousehandler, int side_num)
void execute_gotos(mouse_handler &mousehandler, int side_num)
std::string last_search_
Game configuration data as global variables.
Definition: build_info.cpp:38
void terrain_description(mouse_handler &mousehandler)
void unit_hold_position(mouse_handler &mousehandler, int side_num)
void change_side(mouse_handler &mousehandler)
void objectives(int side_num)
void kill_unit(mouse_handler &mousehandler)
void scenario_settings_table(int selected=0)
Handling of system events.
Definition: manager.hpp:42
GLuint const GLchar * name
Definition: glew.h:1782
bool has_friends() const
unit_map::iterator current_unit()
void show_enemy_moves(bool ignore_units, int side_num)
Container associating units to locations.
Definition: map.hpp:90
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
gui::floating_textbox textbox_info_
void send_to_server(const config &cfg) override
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
std::vector< std::string > get_commands_list()
void send_chat_message(const std::string &message, bool allies_only=false)
void repeat_recruit(int side_num, const map_location &last_hex)
void move_unit_to_loc(const unit_map::iterator &ui, const map_location &target, bool continue_move, int side_num, mouse_handler &mousehandler)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
play_controller & pc_
GLenum target
Definition: glew.h:5190
void do_ai_formula(const std::string &str, int side_num, mouse_handler &mousehandler)