Project Alice
Loading...
Searching...
No Matches
game_scene.hpp
Go to the documentation of this file.
1#pragma once
2#include <functional>
3
4#include "economy_viewer.hpp"
5
6namespace game_scene {
7
8enum class scene_id : uint8_t {
16 count
17};
18
21};
22
23void on_rbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
24void on_lbutton_down(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
25void on_lbutton_up(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
26
27void switch_scene(sys::state& state, scene_id ui_scene);
28
31 dcon::nation_id nation,
32 dcon::province_id target,
34);
35
38 dcon::nation_id nation,
39 dcon::province_id target,
41);
42
46
47void select_units(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
48
49void start_dragging(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
50
52 dcon::nation_id nation,
53 dcon::province_id target,
55void do_nothing_screen(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod);
57
60
67
68
69void console_log_pick_nation(sys::state& state, std::string_view message);
70void console_log_other(sys::state& state, std::string_view message);
71
75
76
78
80
87
89
96
99
100void highlight_player_nation(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
101void highlight_given_province(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
102void highlight_defensive_positions(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province);
103
105
114
116
119
121
122 bool starting_scene = false;
123 bool final_scene = false;
124 bool enforced_pause = false;
125 bool based_on_map = true;
127 bool accept_events = false;
128 bool is_lobby = false;
129 bool game_in_progress = true;
130
132
133 std::function<void(
135 dcon::nation_id nation,
136 dcon::province_id target,
138 std::function<void(
140 dcon::nation_id nation,
141 dcon::province_id target,
143
144 //drag related
146 std::function<void(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod)>
148 std::function<void(sys::state& state, int32_t x, int32_t y, sys::key_modifiers mod)>
150
151 std::function<void(sys::state& state)>
153
154 //key presses related
157 std::function <void(sys::state& state, sys::virtual_key keycode, sys::key_modifiers mod)>
159
160 //logger
161 std::function <void(sys::state& state, std::string_view message)> console_log;
162
163 //render
164 std::function <void(sys::state& state)> render_ui = do_nothing;
166
167 //mouse probing
168 std::function <ui::mouse_probe(sys::state& state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)>
170 std::function <ui::mouse_probe(sys::state& state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)>
172
173 //clean up function which is supposed to keep ui "view" of the game state consistent
174 std::function <void(sys::state& state)> clean_up = do_nothing;
175
178
179 //other functions:
180
182
183 // graphics
184 std::function <void(sys::state& state, std::vector<uint32_t>& data, dcon::province_id selected_province)>
186};
187
188
190 return scene_properties{
192
193.get_root = root_pick_nation,
194
195.starting_scene = true,
196.enforced_pause = true,
197.overwrite_map_tooltip = true,
198.is_lobby = true,
199.game_in_progress = false,
200
201.rbutton_selected_units = do_nothing_province_target,
202.rbutton_province = do_nothing_province_target,
203.allow_drag_selection = false,
204.on_drag_start = do_nothing_screen,
205.drag_selection = do_nothing_screen,
207.keycode_mapping = replace_keycodes_map_movement,
208.handle_hotkeys = nation_picker_hotkeys,
209.console_log = console_log_other,
210.open_chat = open_chat_before_game,
211.update_highlight_texture = highlight_player_nation,
212 };
213}
214
216 return scene_properties{
218
219.get_root = root_game_basic,
220
221.accept_events = true,
222
223.rbutton_selected_units = selected_units_control,
224.rbutton_province = open_diplomacy,
225.allow_drag_selection = true,
226.on_drag_start = start_dragging,
227.drag_selection = select_units,
228.lbutton_up = do_nothing,
229.keycode_mapping = replace_keycodes_map_movement,
230.handle_hotkeys = in_game_hotkeys,
231.console_log = console_log_other,
232
233.render_ui = render_ui_ingame,
234
235.recalculate_mouse_probe = recalculate_mouse_probe_basic,
236.recalculate_tooltip_probe = recalculate_tooltip_probe_basic,
237
238.clean_up = clean_up_basic_game_scene,
239.on_game_state_update = update_basic_game_scene,
240.on_game_state_update_update_ui = update_ui_state_basic,
241 };
242}
243
246
247 .get_root = root_game_battleplanner,
248
249 .rbutton_selected_units = do_nothing_province_target,
250 .rbutton_province = do_nothing_province_target,
251 .allow_drag_selection = false,
252 .on_drag_start = do_nothing_screen,
253 .drag_selection = do_nothing_screen,
254 .lbutton_up = military_screen_on_lbutton_up,
255 .keycode_mapping = replace_keycodes_map_movement,
256 .handle_hotkeys = military_screen_hotkeys,
257 .console_log = console_log_other,
258
259 .render_ui = render_ui_military,
260
261 .recalculate_mouse_probe = recalculate_mouse_probe_military,
262
263 .on_game_state_update = update_military_game_scene,
264 .update_highlight_texture = highlight_defensive_positions
265 };
266}
267
269 return scene_properties{
271
273
274.rbutton_selected_units = do_nothing_province_target,
275.rbutton_province = do_nothing_province_target,
276.allow_drag_selection = true,
277.on_drag_start = start_dragging,
278.drag_selection = select_units,
279.lbutton_up = do_nothing,
280.keycode_mapping = replace_keycodes_map_movement,
281.handle_hotkeys = military_screen_hotkeys,
282.console_log = console_log_other,
283
284.render_ui = render_ui_selection_screen,
285
286.recalculate_mouse_probe = recalculate_mouse_probe_units_and_details,
287.recalculate_tooltip_probe = recalculate_tooltip_probe_units_and_details,
288
289.on_game_state_update = update_add_units_game_scene,
290.on_game_state_update_update_ui = update_ui_unit_details,
291.update_highlight_texture = highlight_defensive_positions
292 };
293}
294
296 return scene_properties{
298
299.get_root = root_game_economy_viewer,
300
301.rbutton_selected_units = do_nothing_province_target,
302.rbutton_province = do_nothing_province_target,
303.allow_drag_selection = false,
304.on_drag_start = do_nothing_screen,
305.drag_selection = do_nothing_screen,
306.lbutton_up = do_nothing,
307.keycode_mapping = replace_keycodes_map_movement,
308.handle_hotkeys = economy_screen_hotkeys,
309.console_log = console_log_other,
310
311.render_ui = economy_viewer::render,
312
313.on_game_state_update = generic_map_scene_update,
314.on_game_state_update_update_ui = economy_scene_update,
315.update_highlight_texture = highlight_given_province
316 };
317}
318
320 return scene_properties{
322
324
326
327.rbutton_selected_units = do_nothing_province_target,
328.rbutton_province = do_nothing_province_target,
329.allow_drag_selection = false,
330.on_drag_start = do_nothing_screen,
331.drag_selection = do_nothing_screen,
333.keycode_mapping = replace_keycodes_map_movement,
334.handle_hotkeys = state_selector_hotkeys,
335.console_log = console_log_other
336 };
337}
338
340 return scene_properties{
342
343.get_root = root_end_screen,
344
345.final_scene = true,
346.enforced_pause = true,
347.based_on_map = false,
348.game_in_progress = false,
349
350.rbutton_selected_units = do_nothing_province_target,
351.rbutton_province = do_nothing_province_target,
352.allow_drag_selection = false,
353.on_drag_start = do_nothing_screen,
354.drag_selection = do_nothing_screen,
355.lbutton_up = do_nothing,
356.keycode_mapping = replace_keycodes_identity,
357.handle_hotkeys = do_nothing_hotkeys,
358.console_log = console_log_other,
359
360.render_map = do_nothing,
361.on_game_state_update = do_nothing,
362 };
363}
364
365
366}
void render(sys::state &state)
void update_military_game_scene(sys::state &state)
void render_map_generic(sys::state &state)
Definition: game_scene.cpp:214
void in_game_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:635
scene_properties nation_picker()
Definition: game_scene.hpp:189
void select_wargoal_state_from_selected_province(sys::state &state)
Definition: game_scene.cpp:188
void on_lbutton_up(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:475
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:856
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:550
void on_rbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:278
void update_ui_state_basic(sys::state &state)
void select_player_nation_from_selected_province(sys::state &state)
Definition: game_scene.cpp:167
void render_ui_ingame(sys::state &state)
Definition: game_scene.cpp:780
void render_ui_military(sys::state &state)
Definition: game_scene.cpp:771
void update_ui_unit_details(sys::state &state)
ui::element_base * root_game_economy_viewer(sys::state &state)
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:86
scene_properties basic_game()
Definition: game_scene.hpp:215
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:730
ui::element_base * root_game_basic(sys::state &state)
scene_properties state_wargoal_selector()
Definition: game_scene.hpp:319
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:81
void open_diplomacy(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)
Definition: game_scene.cpp:153
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:938
void clean_up_selected_armies_and_navies(sys::state &state)
Definition: game_scene.cpp:912
scene_properties battleplan_editor_add_army()
Definition: game_scene.hpp:268
ui::mouse_probe recalculate_mouse_probe_identity(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:801
void state_selector_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:539
void on_key_down(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:721
sys::virtual_key replace_keycodes_map_movement(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:499
void military_screen_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:571
void console_log_pick_nation(sys::state &state, std::string_view message)
void nation_picker_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:528
void render_ui_selection_screen(sys::state &state)
Definition: game_scene.cpp:775
void do_nothing(sys::state &state)
Definition: game_scene.cpp:85
void do_nothing_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:716
void start_dragging(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:200
scene_properties battleplan_editor()
Definition: game_scene.hpp:244
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:843
void select_units(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:407
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:339
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:831
void economy_scene_update(sys::state &state)
void update_basic_game_scene(sys::state &state)
ui::mouse_probe recalculate_tooltip_probe_basic(sys::state &state, ui::mouse_probe mouse_probe, ui::mouse_probe tooltip_probe)
Definition: game_scene.cpp:896
scene_properties economy_viewer_scene()
Definition: game_scene.hpp:295
void selected_units_control(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)
Definition: game_scene.cpp:114
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:872
sys::virtual_key replace_keycodes_identity(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:514
ui::element_base * root_game_battleplanner_unit_selection(sys::state &state)
void economy_screen_hotkeys(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)
Definition: game_scene.cpp:605
void on_lbutton_down(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)
Definition: game_scene.cpp:297
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:181
std::function< void(sys::state &state, std::vector< uint32_t > &data, dcon::province_id selected_province)> update_highlight_texture
Definition: game_scene.hpp:185
std::function< void(sys::state &state)> on_game_state_update
Definition: game_scene.hpp:176
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:171
std::function< void(sys::state &state)> clean_up
Definition: game_scene.hpp:174
std::function< sys::virtual_key(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)> keycode_mapping
Definition: game_scene.hpp:156
borders_granularity borders
Definition: game_scene.hpp:131
std::function< void(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)> drag_selection
Definition: game_scene.hpp:149
std::function< void(sys::state &state)> on_game_state_update_update_ui
Definition: game_scene.hpp:177
std::function< void(sys::state &state, std::string_view message)> console_log
Definition: game_scene.hpp:161
std::function< void(sys::state &state, int32_t x, int32_t y, sys::key_modifiers mod)> on_drag_start
Definition: game_scene.hpp:147
std::function< void(sys::state &state, dcon::nation_id nation, dcon::province_id target, sys::key_modifiers mod)> rbutton_province
Definition: game_scene.hpp:142
std::function< void(sys::state &state)> render_map
Definition: game_scene.hpp:165
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:137
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:169
std::function< ui::element_base *(sys::state &state)> get_root
Definition: game_scene.hpp:120
std::function< void(sys::state &state)> lbutton_up
Definition: game_scene.hpp:152
std::function< void(sys::state &state, sys::virtual_key keycode, sys::key_modifiers mod)> handle_hotkeys
Definition: game_scene.hpp:158
std::function< void(sys::state &state)> render_ui
Definition: game_scene.hpp:164
Holds important data about the game world, state, and other data regarding windowing,...