22 #ifndef NUVIE_CORE_EVENT_H 23 #define NUVIE_CORE_EVENT_H 25 #include "ultima/shared/std/containers.h" 26 #include "ultima/shared/std/string.h" 27 #include "ultima/nuvie/misc/call_back.h" 28 #include "ultima/nuvie/keybinding/keys_enum.h" 29 #include "ultima/nuvie/core/obj_manager.h" 54 #define NUVIE_INTERVAL 50 55 #define PUSH_FROM_PLAYER false 56 #define PUSH_FROM_OBJECT true 58 #define BUTTON_MASK(MB) (1 << ((int)(MB) - 1)) 81 extern uint32 nuvieGameCounter;
84 #define EVENTINPUT_MAPCOORD 0 85 #define EVENTINPUT_KEY 1 86 #define EVENTINPUT_STRING 2 87 #define EVENTINPUT_OBJECT 3 88 #define EVENTINPUT_MAPCOORD_DIR 4 89 #define EVENTINPUT_SPELL_NUM 5 94 const Common::KeyCode FIRST_JOY = (Common::KeyCode)400;
95 const Common::KeyCode JOY_UP = FIRST_JOY;
96 const Common::KeyCode JOY_DOWN = (Common::KeyCode)(FIRST_JOY + 1);
97 const Common::KeyCode JOY_LEFT = (Common::KeyCode)(FIRST_JOY + 2);
98 const Common::KeyCode JOY_RIGHT = (Common::KeyCode)(FIRST_JOY + 3);
99 const Common::KeyCode JOY_RIGHTUP = (Common::KeyCode)(FIRST_JOY + 4);
100 const Common::KeyCode JOY_RIGHTDOWN = (Common::KeyCode)(FIRST_JOY + 5);
101 const Common::KeyCode JOY_LEFTUP = (Common::KeyCode)(FIRST_JOY + 6);
102 const Common::KeyCode JOY_LEFTDOWN = (Common::KeyCode)(FIRST_JOY + 7);
103 const Common::KeyCode JOY_UP2 = (Common::KeyCode)(FIRST_JOY + 8);
104 const Common::KeyCode JOY_DOWN2 = (Common::KeyCode)(FIRST_JOY + 9);
105 const Common::KeyCode JOY_LEFT2 = (Common::KeyCode)(FIRST_JOY + 10);
106 const Common::KeyCode JOY_RIGHT2 = (Common::KeyCode)(FIRST_JOY + 11);
107 const Common::KeyCode JOY_RIGHTUP2 = (Common::KeyCode)(FIRST_JOY + 12);
108 const Common::KeyCode JOY_RIGHTDOWN2 = (Common::KeyCode)(FIRST_JOY + 13);
109 const Common::KeyCode JOY_LEFTUP2 = (Common::KeyCode)(FIRST_JOY + 14);
110 const Common::KeyCode JOY_LEFTDOWN2 = (Common::KeyCode)(FIRST_JOY + 15);
111 const Common::KeyCode JOY_UP3 = (Common::KeyCode)(FIRST_JOY + 16);
112 const Common::KeyCode JOY_DOWN3 = (Common::KeyCode)(FIRST_JOY + 17);
113 const Common::KeyCode JOY_LEFT3 = (Common::KeyCode)(FIRST_JOY + 18);
114 const Common::KeyCode JOY_RIGHT3 = (Common::KeyCode)(FIRST_JOY + 19);
115 const Common::KeyCode JOY_RIGHTUP3 = (Common::KeyCode)(FIRST_JOY + 20);
116 const Common::KeyCode JOY_RIGHTDOWN3 = (Common::KeyCode)(FIRST_JOY + 21);
117 const Common::KeyCode JOY_LEFTUP3 = (Common::KeyCode)(FIRST_JOY + 22);
118 const Common::KeyCode JOY_LEFTDOWN3 = (Common::KeyCode)(FIRST_JOY + 23);
119 const Common::KeyCode JOY_UP4 = (Common::KeyCode)(FIRST_JOY + 24);
120 const Common::KeyCode JOY_DOWN4 = (Common::KeyCode)(FIRST_JOY + 25);
121 const Common::KeyCode JOY_LEFT4 = (Common::KeyCode)(FIRST_JOY + 26);
122 const Common::KeyCode JOY_RIGHT4 = (Common::KeyCode)(FIRST_JOY + 27);
123 const Common::KeyCode JOY_RIGHTUP4 = (Common::KeyCode)(FIRST_JOY + 28);
124 const Common::KeyCode JOY_RIGHTDOWN4 = (Common::KeyCode)(FIRST_JOY + 29);
125 const Common::KeyCode JOY_LEFTUP4 = (Common::KeyCode)(FIRST_JOY + 30);
126 const Common::KeyCode JOY_LEFTDOWN4 = (Common::KeyCode)(FIRST_JOY + 31);
127 const Common::KeyCode JOY_HAT_UP = (Common::KeyCode)(FIRST_JOY + 32);
128 const Common::KeyCode JOY_HAT_DOWN = (Common::KeyCode)(FIRST_JOY + 33);
129 const Common::KeyCode JOY_HAT_LEFT = (Common::KeyCode)(FIRST_JOY + 34);
130 const Common::KeyCode JOY_HAT_RIGHT = (Common::KeyCode)(FIRST_JOY + 35);
131 const Common::KeyCode JOY_HAT_RIGHTUP = (Common::KeyCode)(FIRST_JOY + 36);
132 const Common::KeyCode JOY_HAT_RIGHTDOWN = (Common::KeyCode)(FIRST_JOY + 37);
133 const Common::KeyCode JOY_HAT_LEFTUP = (Common::KeyCode)(FIRST_JOY + 38);
134 const Common::KeyCode JOY_HAT_LEFTDOWN = (Common::KeyCode)(FIRST_JOY + 39);
135 const Common::KeyCode JOY0 = (Common::KeyCode)(FIRST_JOY + 40);
136 const Common::KeyCode JOY1 = (Common::KeyCode)(FIRST_JOY + 41);
137 const Common::KeyCode JOY2 = (Common::KeyCode)(FIRST_JOY + 42);
138 const Common::KeyCode JOY3 = (Common::KeyCode)(FIRST_JOY + 43);
139 const Common::KeyCode JOY4 = (Common::KeyCode)(FIRST_JOY + 44);
140 const Common::KeyCode JOY5 = (Common::KeyCode)(FIRST_JOY + 45);
141 const Common::KeyCode JOY6 = (Common::KeyCode)(FIRST_JOY + 46);
142 const Common::KeyCode JOY7 = (Common::KeyCode)(FIRST_JOY + 47);
143 const Common::KeyCode JOY8 = (Common::KeyCode)(FIRST_JOY + 48);
144 const Common::KeyCode JOY9 = (Common::KeyCode)(FIRST_JOY + 49);
145 const Common::KeyCode JOY10 = (Common::KeyCode)(FIRST_JOY + 50);
146 const Common::KeyCode JOY11 = (Common::KeyCode)(FIRST_JOY + 51);
147 const Common::KeyCode JOY12 = (Common::KeyCode)(FIRST_JOY + 52);
148 const Common::KeyCode JOY13 = (Common::KeyCode)(FIRST_JOY + 53);
149 const Common::KeyCode JOY14 = (Common::KeyCode)(FIRST_JOY + 54);
150 const Common::KeyCode JOY15 = (Common::KeyCode)(FIRST_JOY + 55);
151 const Common::KeyCode JOY16 = (Common::KeyCode)(FIRST_JOY + 56);
152 const Common::KeyCode JOY17 = (Common::KeyCode)(FIRST_JOY + 57);
153 const Common::KeyCode JOY18 = (Common::KeyCode)(FIRST_JOY + 58);
154 const Common::KeyCode JOY19 = (Common::KeyCode)(FIRST_JOY + 59);
162 ActionKeyType action_key_type;
167 EventInput_s() : loc(0), str(0), obj(0), actor(0), get_direction(
false), get_text(
false),
168 target_init(0), select_from_inventory(
false), select_range(0), key(Common::KEYCODE_INVALID),
169 action_key_type(ActionKeyType::CANCEL_ACTION_KEY), spell_num(0), type(0) {
178 bool select_from_inventory;
204 EventMode mode, last_mode;
209 uint16 active_alt_code;
210 uint8 alt_code_input_num;
215 sint32 drop_x, drop_y;
223 bool showingQuitDialog;
224 bool ignore_timeleft;
225 bool move_in_inventory;
226 bool in_control_cheat;
227 bool looking_at_spellbook;
228 bool direction_selects_target;
229 bool _keymapperStateBeforeKEYINPUT;
231 uint32 fps_timestamp;
241 inline uint32 TimeLeft();
243 uint16 callback(uint16 msg,
CallBack *caller,
void *data =
nullptr)
override;
245 const char *print_mode(EventMode mode);
246 void try_next_attack();
265 return gamemenu_dialog;
271 return game_time_queue;
273 EventMode get_mode()
const {
276 EventMode get_last_mode()
const {
279 void set_mode(EventMode new_mode);
281 bool is_direction_selecting_targets()
const {
282 return direction_selects_target;
284 void set_direction_selects_target(
bool val) {
285 direction_selects_target = val;
302 bool using_pickpocket_cheat;
304 void update_timers();
309 void request_input(
CallBack *caller,
void *user_data =
nullptr);
311 void close_spellbook();
316 void get_scroll_input(
const char *allowed =
nullptr,
bool can_escape =
true,
bool using_target_cursor =
false,
bool set_numbers_only_to_true =
true);
317 void get_inventory_obj(
Actor *actor,
bool getting_target =
true);
318 void get_spell_num(
Actor *caster,
Obj *spell_container);
320 void get_direction(
const char *prompt);
321 void get_direction(
const MapCoord &from,
const char *prompt);
322 void get_target(
const char *prompt);
323 void get_target(
const MapCoord &init,
const char *prompt);
325 void display_portrait(
Actor *actor,
const char *name =
nullptr);
327 bool newAction(EventMode new_mode);
332 void endAction(
bool prompt =
false);
334 bool select_obj(
Obj *obj,
Actor *actor =
nullptr);
335 bool select_view_obj(
Obj *obj,
Actor *actor);
336 bool select_actor(
Actor *actor);
337 bool select_direction(sint16 rel_x, sint16 rel_y);
338 bool select_target(uint16 x, uint16 y, uint8 z = 0);
339 bool select_party_member(uint8 num);
340 bool select_spell_num(sint16 spell_num);
346 void key_redirect(
CallBack *caller,
void *user_data);
347 void cancel_key_redirect();
350 bool move(sint16 rel_x, sint16 rel_y);
353 bool use(sint16 rel_x, sint16 rel_y);
356 bool use(
Actor *actor, uint16 x, uint16 y);
360 bool get(sint16 rel_x, sint16 rel_y);
361 bool perform_get(
Obj *obj,
Obj *container_obj =
nullptr,
Actor *actor =
nullptr);
364 bool lookAtCursor(
bool delayed =
false, uint16 x = 0, uint16 y = 0, uint8 z = 0,
Obj *obj =
nullptr,
Actor *actor =
nullptr);
366 bool look(
Actor *actor);
367 bool search(
Obj *obj);
371 bool talk(
Actor *actor);
373 bool perform_talk(
Actor *actor);
378 bool pushFrom(
Obj *obj);
379 bool pushFrom(sint16 rel_x, sint16 rel_y);
380 bool pushFrom(
const MapCoord &target);
381 bool pushTo(
Obj *obj,
Actor *actor);
382 bool pushTo(sint16 rel_x, sint16 rel_y,
bool push_from = PUSH_FROM_PLAYER);
384 void solo_mode(uint32 actor_num);
386 bool toggle_combat();
388 bool ready(
Obj *obj,
Actor *actor =
nullptr);
389 bool unready(
Obj *obj);
392 bool drop_select(
Obj *obj, uint16 qty = 0);
393 bool drop_count(uint16 qty);
395 void set_drop_from_key(
bool closing_gumps) {
396 drop_from_key = closing_gumps;
398 bool drop(
Obj *obj, uint16 qty, uint16 x, uint16 y);
399 bool drop(uint16 x, uint16 y) {
400 return (drop(drop_obj, drop_qty, x, y));
402 void set_drop_target(uint16 x, uint16 y) {
406 bool can_move_obj_between_actors(
Obj *obj,
Actor *src_actor,
Actor *target_actor,
bool display_name =
false);
407 void display_not_aboard_vehicle(
bool show_prompt =
true);
408 void display_move_text(
Actor *target_actor,
Obj *obj);
409 bool can_get_to_actor(
const Actor *actor, uint16 x, uint16 y);
410 bool using_control_cheat()
const {
411 return in_control_cheat;
413 void set_control_cheat(
bool control_cheat) {
414 in_control_cheat = control_cheat;
416 bool is_looking_at_spellbook()
const {
417 return looking_at_spellbook;
419 void set_looking_at_spellbook(
bool looking) {
420 looking_at_spellbook = looking;
424 bool rest_input(uint16 input);
426 void cast_spell_directly(uint8 spell_num);
427 bool can_target_icon();
430 void walk_to_mouse_cursor(uint32 mx, uint32 my);
431 void multiuse(uint16 wx, uint16 wy);
433 void alt_code(
int c);
434 void alt_code_input(
const char *in);
435 void clear_alt_code() { altCodeVal = 0; }
437 void toggleAltCodeMode(
bool enable);
438 void appendAltCode(
int code);
440 bool alt_code_teleport(
const char *location_string);
441 void alt_code_infostring();
442 void alt_code_teleport_menu(uint32 selection);
443 bool alt_code_teleport_to_person(uint32 npc);
446 void set_ignore_timeleft(
bool newsetting) {
447 ignore_timeleft = newsetting;
449 EventInput *get_input() {
455 void moveCursorToMapWindow(
bool ToggleCursor =
false);
456 void moveCursorToInventory();
458 void toggleFpsDisplay();
460 bool do_not_show_target_cursor;
461 bool dont_show_target_cursor()
const;
462 bool input_really_needs_directon()
const;
464 void gameMenuDialog();
466 bool actor_exists(
const Actor *a)
const;
474 static Events *
get() {
return g_events; }
477 extern bool shouldQuit();
byte getButtonState() const
Definition: events.h:298
Definition: map_window.h:73
Definition: configuration.h:61
Definition: usecode.h:151
EventType
Definition: events.h:49
Definition: game_clock.h:49
Definition: gui_dialog.h:36
Definition: detection.h:27
Definition: timed_event.h:45
Definition: call_back.h:50
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: obj_manager.h:75
Common::Point getMousePos() const
Definition: events.h:291
Definition: fps_counter.h:33
Definition: view_manager.h:57
Definition: converse.h:81