The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
menu_events.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2006 - 2025
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
26class game_state;
27class game_data;
28class game_board;
30class play_controller;
31class t_string;
32
33namespace events
34{
35class mouse_handler;
36}
37
47
48namespace events
49{
51{
52public:
54 virtual ~menu_handler();
55
58 {
59 gui_ = gui;
60 }
61
62 void objectives();
63 void show_statistics(int side_num);
64 void unit_list();
65 void status_table();
66 void save_map();
67 void preferences();
68 void show_chat_log();
69 void show_help();
70 void speak();
71 void whisper();
72 void shout();
73 void recruit(int side_num, const map_location& last_hex);
74 void repeat_recruit(int side_num, const map_location& last_hex);
75 void recall(int side_num, const map_location& last_hex);
76 void show_enemy_moves(bool ignore_units, int side_num);
77 void toggle_shroud_updates(int side_num);
78 void update_shroud_now(int side_num);
79 bool end_turn(int side_num);
80 void goto_leader(int side_num);
81 void unit_description();
82 void terrain_description(mouse_handler& mousehandler);
83 void rename_unit();
84 void create_unit(mouse_handler& mousehandler);
85 void change_side(mouse_handler& mousehandler);
86 void kill_unit(mouse_handler& mousehandler);
87 void label_terrain(mouse_handler& mousehandler, bool team_only);
88 void clear_labels();
89 void label_settings();
90 void continue_move(mouse_handler& mousehandler, int side_num);
91 void execute_gotos(mouse_handler& mousehandler, int side_num);
92 void toggle_ellipses();
93 void toggle_grid();
94 void unit_hold_position(mouse_handler& mousehandler, int side_num);
95 void end_unit_turn(mouse_handler& mousehandler, int side_num);
96 void search();
97 void request_control_change(int side_num, const std::string& player);
98 void user_command();
99 void custom_command();
100 void ai_formula();
101 virtual void clear_messages() override;
102 std::vector<std::string> get_commands_list();
103
106 {
107 return const_cast<menu_handler*>(this)->current_unit();
108 }
109
111 const map_location& target,
112 bool continue_move,
113 int side_num,
114 mouse_handler& mousehandler);
115
116 /** @return Whether or not the recruit was successful */
117 bool do_recruit(const std::string& type, int side_num, const map_location& target_hex);
118 bool 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;
126 game_board& board() const;
127
128protected:
129 void add_chat_message(const std::chrono::system_clock::time_point& 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
136private:
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 bool has_friends() const;
143
146
148
150 std::string last_search_;
152};
153}
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
void do_ai_formula(const std::string &str, int side_num, mouse_handler &mousehandler)
void show_enemy_moves(bool ignore_units, int side_num)
void label_terrain(mouse_handler &mousehandler, bool team_only)
game_board & board() const
gui::floating_textbox & get_textbox()
void update_shroud_now(int side_num)
void request_control_change(int side_num, const std::string &player)
virtual void clear_messages() override
const game_config_view & game_config_
void goto_leader(int side_num)
void execute_gotos(mouse_handler &mousehandler, int side_num)
void recall(int side_num, const map_location &last_hex)
void add_chat_message(const std::chrono::system_clock::time_point &time, const std::string &speaker, int side, const std::string &message, events::chat_handler::MESSAGE_TYPE type=events::chat_handler::MESSAGE_PRIVATE) override
void do_command(const std::string &str)
void create_unit(mouse_handler &mousehandler)
Creates a unit (in debug mode via hotkey or context menu).
unit_map::const_iterator current_unit() const
void unit_hold_position(mouse_handler &mousehandler, int side_num)
void end_unit_turn(mouse_handler &mousehandler, int side_num)
void change_side(mouse_handler &mousehandler)
void terrain_description(mouse_handler &mousehandler)
game_data & gamedata()
void send_chat_message(const std::string &message, bool allies_only=false) override
gui::floating_textbox textbox_info_
void toggle_shroud_updates(int side_num)
void show_statistics(int side_num)
map_location last_search_hit_
void recruit(int side_num, const map_location &last_hex)
play_controller & pc_
void continue_move(mouse_handler &mousehandler, int side_num)
void repeat_recruit(int side_num, const map_location &last_hex)
void kill_unit(mouse_handler &mousehandler)
void do_search(const std::string &new_search)
void set_gui(game_display *gui)
std::vector< std::string > get_commands_list()
void send_to_server(const config &cfg) override
game_display * gui_
bool has_friends() const
game_state & gamestate() const
bool do_recruit(const std::string &type, int side_num, const map_location &target_hex)
unit_map::iterator current_unit()
bool end_turn(int side_num)
void move_unit_to_loc(const unit_map::iterator &ui, const map_location &target, bool continue_move, int side_num, mouse_handler &mousehandler)
Game board class.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Base class for exceptions that want to be thrown 'through' lua.
void store() const noexcept
Stores a copy the current exception to be rethrown.
const config * cfg
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from lua_jailbreak_exception.
Handling of system events.
General purpose widgets.
Encapsulates the map of the game.
Definition location.hpp:46