Project Alice
Loading...
Searching...
No Matches
game_scene.hpp
Go to the documentation of this file.
1#pragma once
2#include <functional>
3
4namespace game_scene {
5
6enum class scene_id : uint8_t {
13 count
14};
15
18};
19
20void on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
21void on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
22void on_lbutton_up(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
23
24void switch_scene(sys::state& state, scene_id ui_scene);
25
28 dcon::nation_id nation,
29 dcon::province_id target,
31);
32
35 dcon::nation_id nation,
36 dcon::province_id target,
38);
39
43
44void select_units(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
45
46void start_dragging(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
47
49 dcon::nation_id nation,
50 dcon::province_id target,
52void do_nothing_screen(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
54
57
63
64void console_log_pick_nation(sys::state& state, std::string_view message);
65void console_log_other(sys::state& state, std::string_view message);
66
70
71
73
75
82
84
91
94
95void highlight_player_nation(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
96void highlight_given_province(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
97void highlight_defensive_positions(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
98
100
108
111
113
114 bool starting_scene = false;
115 bool final_scene = false;
116 bool enforced_pause = false;
117 bool based_on_map = true;
119 bool accept_events = false;
120 bool is_lobby = false;
121 bool game_in_progress = true;
122
124
125 std::function<void(
127 dcon::nation_id nation,
128 dcon::province_id target,
130 std::function<void(
132 dcon::nation_id nation,
133 dcon::province_id target,
135
136 //drag related
138 std::function<void(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod)>
140 std::function<void(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod)>
142
143 std::function<void(sys::state& state)>
145
146 //key presses related
149 std::function <void(sys::state& state, sys::virtual_key keycode, sys::key_modifiers mod)>
151
152 //logger
153 std::function <void(sys::state& state, std::string_view message)> console_log;
154
155 //render
156 std::function <void(sys::state& state)> render_ui = do_nothing;
158
159 //mouse probing
160 std::function <ui::mouse_probe(sys::state& state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)>
162 std::function <ui::mouse_probe(sys::state& state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)>
164
165 //clean up function which is supposed to keep ui "view" of the game state consistent
166 std::function <void(sys::state& state)> clean_up = do_nothing;
167
170
171 //other functions:
172
174
175 // graphics
176 std::function <void(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province)>
178};
179
180
182 return scene_properties{
184
185.get_root = root_pick_nation,
186
187.starting_scene = true,
188.enforced_pause = true,
189.overwrite_map_tooltip = true,
190.is_lobby = true,
191.game_in_progress = false,
192
193.rbutton_selected_units = do_nothing_province_target,
194.rbutton_province = do_nothing_province_target,
195.allow_drag_selection = false,
196.on_drag_start = do_nothing_screen,
197.drag_selection = do_nothing_screen,
199.keycode_mapping = replace_keycodes_map_movement,
200.handle_hotkeys = nation_picker_hotkeys,
201.console_log = console_log_pick_nation,
202.open_chat = open_chat_before_game,
203.update_highlight_texture = highlight_player_nation,
204 };
205}
206
208 return scene_properties{
210
211.get_root = root_game_basic,
212
213.accept_events = true,
214
215.rbutton_selected_units = selected_units_control,
216.rbutton_province = open_diplomacy,
217.allow_drag_selection = true,
218.on_drag_start = start_dragging,
219.drag_selection = select_units,
220.lbutton_up = do_nothing,
221.keycode_mapping = replace_keycodes_map_movement,
222.handle_hotkeys = in_game_hotkeys,
223.console_log = console_log_other,
224
225.render_ui = render_ui_ingame,
226
227.recalculate_mouse_probe = recalculate_mouse_probe_basic,
228.recalculate_tooltip_probe = recalculate_tooltip_probe_basic,
229
230.clean_up = clean_up_basic_game_scene,
231.on_game_state_update = update_basic_game_scene,
232.on_game_state_update_update_ui = update_ui_state_basic,
233 };
234}
235
238
239 .get_root = root_game_battleplanner,
240
241 .rbutton_selected_units = do_nothing_province_target,
242 .rbutton_province = do_nothing_province_target,
243 .allow_drag_selection = false,
244 .on_drag_start = do_nothing_screen,
245 .drag_selection = do_nothing_screen,
246 .lbutton_up = military_screen_on_lbutton_up,
247 .keycode_mapping = replace_keycodes_map_movement,
248 .handle_hotkeys = military_screen_hotkeys,
249 .console_log = console_log_other,
250
251 .render_ui = render_ui_military,
252
253 .recalculate_mouse_probe = recalculate_mouse_probe_military,
254
255 .on_game_state_update = update_military_game_scene,
256 .update_highlight_texture = highlight_defensive_positions
257 };
258}
259
261 return scene_properties{
263
265
266.rbutton_selected_units = do_nothing_province_target,
267.rbutton_province = do_nothing_province_target,
268.allow_drag_selection = true,
269.on_drag_start = start_dragging,
270.drag_selection = select_units,
271.lbutton_up = do_nothing,
272.keycode_mapping = replace_keycodes_map_movement,
273.handle_hotkeys = military_screen_hotkeys,
274.console_log = console_log_other,
275
276.render_ui = render_ui_selection_screen,
277
278.recalculate_mouse_probe = recalculate_mouse_probe_units_and_details,
279.recalculate_tooltip_probe = recalculate_tooltip_probe_units_and_details,
280
281.on_game_state_update = update_add_units_game_scene,
282.on_game_state_update_update_ui = update_ui_unit_details,
283.update_highlight_texture = highlight_defensive_positions
284 };
285}
286
288 return scene_properties{
290
292
294
295.rbutton_selected_units = do_nothing_province_target,
296.rbutton_province = do_nothing_province_target,
297.allow_drag_selection = false,
298.on_drag_start = do_nothing_screen,
299.drag_selection = do_nothing_screen,
301.keycode_mapping = replace_keycodes_map_movement,
302.handle_hotkeys = state_selector_hotkeys,
303.console_log = console_log_other
304 };
305}
306
308 return scene_properties{
310
311.get_root = root_end_screen,
312
313.final_scene = true,
314.enforced_pause = true,
315.based_on_map = false,
316.game_in_progress = false,
317
318.rbutton_selected_units = do_nothing_province_target,
319.rbutton_province = do_nothing_province_target,
320.allow_drag_selection = false,
321.on_drag_start = do_nothing_screen,
322.drag_selection = do_nothing_screen,
323.lbutton_up = do_nothing,
324.keycode_mapping = replace_keycodes_identity,
325.handle_hotkeys = do_nothing_hotkeys,
326.console_log = console_log_other,
327
328.render_map = do_nothing,
329.on_game_state_update = do_nothing,
330 };
331}
332
333
334}
void update_military_game_scene(sys::state &state)
void render_map_generic(sys::state &state)
Definition: game_scene.cpp:209
void in_game_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:611
scene_properties nation_picker()
Definition: game_scene.hpp:181
void select_wargoal_state_from_selected_province(sys::state &state)
Definition: game_scene.cpp:183
void on_lbutton_up(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:462
void highlight_given_province(sys::state &state, std::vector< uint32_t > &data, dcon::province_id selected_province)
ui::mouse_probe recalculate_mouse_probe_military(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:824
void switch_scene(sys::state &state, scene_id ui_scene)
Definition: game_scene.cpp:13
void military_screen_on_lbutton_up(sys::state &state)
Definition: game_scene.cpp:537
void on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:273
void update_ui_state_basic(sys::state &state)
Definition: game_scene.cpp:980
void select_player_nation_from_selected_province(sys::state &state)
Definition: game_scene.cpp:162
void render_ui_ingame(sys::state &state)
Definition: game_scene.cpp:748
void render_ui_military(sys::state &state)
Definition: game_scene.cpp:739
void update_ui_unit_details(sys::state &state)
Definition: game_scene.cpp:971
void highlight_defensive_positions(sys::state &state, std::vector< uint32_t > &data, dcon::province_id selected_province)
void do_nothing_screen(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:81
scene_properties basic_game()
Definition: game_scene.hpp:207
ui::element_base * root_end_screen(sys::state &state)
void highlight_player_nation(sys::state &state, std::vector< uint32_t > &data, dcon::province_id selected_province)
void console_log_other(sys::state &state, std::string_view message)
Definition: game_scene.cpp:715
ui::element_base * root_game_basic(sys::state &state)
scene_properties state_wargoal_selector()
Definition: game_scene.hpp:287
void open_chat_before_game(sys::state &state)
ui::element_base * root_game_wargoal_state_selection(sys::state &state)
void do_nothing_province_target(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)
Definition: game_scene.cpp:76
void open_diplomacy(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)
Definition: game_scene.cpp:148
void generic_map_scene_update(sys::state &state)
void update_add_units_game_scene(sys::state &state)
void clean_up_basic_game_scene(sys::state &state)
Definition: game_scene.cpp:905
void clean_up_selected_armies_and_navies(sys::state &state)
Definition: game_scene.cpp:879
scene_properties battleplan_editor_add_army()
Definition: game_scene.hpp:260
ui::mouse_probe recalculate_mouse_probe_identity(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:769
void state_selector_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:526
void on_key_down(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:695
sys::virtual_key replace_keycodes_map_movement(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:486
void military_screen_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:558
void console_log_pick_nation(sys::state &state, std::string_view message)
Definition: game_scene.cpp:704
void nation_picker_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:515
void render_ui_selection_screen(sys::state &state)
Definition: game_scene.cpp:743
void do_nothing(sys::state &state)
Definition: game_scene.cpp:80
void do_nothing_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:690
void start_dragging(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:195
scene_properties battleplan_editor()
Definition: game_scene.hpp:236
ui::element_base * root_game_battleplanner(sys::state &state)
ui::mouse_probe recalculate_mouse_probe_basic(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:811
void select_units(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:394
ui::element_base * root_game_battleplanner_add_army(sys::state &state)
ui::element_base * root_pick_nation(sys::state &state)
void open_chat_during_game(sys::state &state)
scene_properties end_screen()
Definition: game_scene.hpp:307
ui::mouse_probe recalculate_mouse_probe_units_and_details(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:799
void update_basic_game_scene(sys::state &state)
Definition: game_scene.cpp:993
ui::mouse_probe recalculate_tooltip_probe_basic(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:863
void selected_units_control(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)
Definition: game_scene.cpp:109
ui::mouse_probe recalculate_tooltip_probe_units_and_details(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:840
sys::virtual_key replace_keycodes_identity(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:501
ui::element_base * root_game_battleplanner_unit_selection(sys::state &state)
void on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:288
virtual_key
Definition: constants.hpp:5
key_modifiers
Definition: constants.hpp:156
uchar uint8_t
std::function< void(sys::state &state)> open_chat
Definition: game_scene.hpp:173
std::function< void(sys::state &state, std::vector< uint32_t > &data, dcon::province_id selected_province)> update_highlight_texture
Definition: game_scene.hpp:177
std::function< void(sys::state &state)> on_game_state_update
Definition: game_scene.hpp:168
std::function< ui::mouse_probe(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)> recalculate_tooltip_probe
Definition: game_scene.hpp:163
std::function< void(sys::state &state)> clean_up
Definition: game_scene.hpp:166
std::function< sys::virtual_key(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)> keycode_mapping
Definition: game_scene.hpp:148
borders_granularity borders
Definition: game_scene.hpp:123
std::function< void(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)> drag_selection
Definition: game_scene.hpp:141
std::function< void(sys::state &state)> on_game_state_update_update_ui
Definition: game_scene.hpp:169
std::function< void(sys::state &state, std::string_view message)> console_log
Definition: game_scene.hpp:153
std::function< void(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)> on_drag_start
Definition: game_scene.hpp:139
std::function< void(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)> rbutton_province
Definition: game_scene.hpp:134
std::function< void(sys::state &state)> render_map
Definition: game_scene.hpp:157
std::function< void(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)> rbutton_selected_units
Definition: game_scene.hpp:129
std::function< ui::mouse_probe(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)> recalculate_mouse_probe
Definition: game_scene.hpp:161
std::function< ui::element_base *(sys::state &state)> get_root
Definition: game_scene.hpp:112
std::function< void(sys::state &state)> lbutton_up
Definition: game_scene.hpp:144
std::function< void(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)> handle_hotkeys
Definition: game_scene.hpp:150
std::function< void(sys::state &state)> render_ui
Definition: game_scene.hpp:156