Colobot
event.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 #include "common/key.h"
28 #include "common/make_unique.h"
29 
30 #include "common/thread/sdl_mutex_wrapper.h"
31 
32 #include "math/point.h"
33 #include "math/vector.h"
34 
35 #include <memory>
36 
42 {
43 
44 // TODO: document the meaning of each value
45 
48 
49  // System events (originating in CApplication)
50 
53 
56 
69 
76 
83 
88 
90  EVENT_SYS_MAX,
91 
92 
93  /* Events sent/received in game and user interface */
94 
96  EVENT_QUIT = 20,
97  EVENT_UPDINTERFACE = 21,
98  EVENT_WIN = 30,
99  EVENT_LOST = 31,
100 
103 
104  EVENT_BUTTON_OK = 40,
105  EVENT_BUTTON_CANCEL = 41,
106  EVENT_BUTTON_NEXT = 42,
107  EVENT_BUTTON_PREV = 43,
108 
109  EVENT_BUTTON0 = 50,
110  EVENT_BUTTON1 = 51,
111  EVENT_BUTTON2 = 52,
112  EVENT_BUTTON3 = 53,
113  EVENT_BUTTON4 = 54,
114  EVENT_BUTTON5 = 55,
115  EVENT_BUTTON6 = 56,
116  EVENT_BUTTON7 = 57,
117  EVENT_BUTTON8 = 58,
118  EVENT_BUTTON9 = 59,
119  EVENT_BUTTON10 = 60,
120  EVENT_BUTTON11 = 61,
121  EVENT_BUTTON12 = 62,
122  EVENT_BUTTON13 = 63,
123  EVENT_BUTTON14 = 64,
124  EVENT_BUTTON15 = 65,
125  EVENT_BUTTON16 = 66,
126  EVENT_BUTTON17 = 67,
127  EVENT_BUTTON18 = 68,
128  EVENT_BUTTON19 = 69,
129 
130  EVENT_EDIT0 = 70,
131  EVENT_EDIT1 = 71,
132  EVENT_EDIT2 = 72,
133  EVENT_EDIT3 = 73,
134  EVENT_EDIT4 = 74,
135  EVENT_EDIT5 = 75,
136  EVENT_EDIT6 = 76,
137  EVENT_EDIT7 = 77,
138  EVENT_EDIT8 = 78,
139  EVENT_EDIT9 = 79,
140 
151 
152  EVENT_LABEL0 = 90,
153  EVENT_LABEL1 = 91,
154  EVENT_LABEL2 = 92,
155  EVENT_LABEL3 = 93,
156  EVENT_LABEL4 = 94,
157  EVENT_LABEL5 = 95,
158  EVENT_LABEL6 = 96,
159  EVENT_LABEL7 = 97,
160  EVENT_LABEL8 = 98,
161  EVENT_LABEL9 = 99,
162  EVENT_LABEL10 = 100,
163  EVENT_LABEL11 = 101,
164  EVENT_LABEL12 = 102,
165  EVENT_LABEL13 = 103,
166  EVENT_LABEL14 = 104,
167  EVENT_LABEL15 = 105,
168  EVENT_LABEL16 = 106,
169  EVENT_LABEL17 = 107,
170  EVENT_LABEL18 = 108,
171  EVENT_LABEL19 = 109,
172 
173  EVENT_LIST0 = 110,
174  EVENT_LIST1 = 111,
175  EVENT_LIST2 = 112, // list of resolutions
176  EVENT_LIST3 = 113,
177  EVENT_LIST4 = 114,
178  EVENT_LIST5 = 115,
179  EVENT_LIST6 = 116,
180  EVENT_LIST7 = 117,
181  EVENT_LIST8 = 118,
182  EVENT_LIST9 = 119,
183 
184  EVENT_LOADING = 120,
185 
186  EVENT_TOOLTIP = 200,
187 
188  EVENT_DIALOG_OK = 300,
189  EVENT_DIALOG_CANCEL = 301,
190  EVENT_DIALOG_LABEL = 302,
191  EVENT_DIALOG_LABEL1 = 303,
192  EVENT_DIALOG_LABEL2 = 304,
193  EVENT_DIALOG_LABEL3 = 305,
194  EVENT_DIALOG_LIST = 306,
195  EVENT_DIALOG_EDIT = 307,
196  EVENT_DIALOG_CHECK1 = 308,
197  EVENT_DIALOG_CHECK2 = 309,
198 
199  EVENT_INTERFACE_TRAINER = 400,
200  EVENT_INTERFACE_DEFI = 401,
201  EVENT_INTERFACE_MISSION = 402,
202  EVENT_INTERFACE_FREE = 403,
203  EVENT_INTERFACE_CODE_BATTLES = 404,
204  EVENT_INTERFACE_NAME = 405,
205  EVENT_INTERFACE_SETUP = 406,
206  EVENT_INTERFACE_QUIT = 407,
207  EVENT_INTERFACE_BACK = 408,
208  EVENT_INTERFACE_AGAIN = 409,
209  EVENT_INTERFACE_WRITE = 410,
210  EVENT_INTERFACE_READ = 411,
211  EVENT_INTERFACE_ABORT = 412,
212  EVENT_INTERFACE_USER = 413,
213  EVENT_INTERFACE_SATCOM = 414,
214 
215  EVENT_INTERFACE_CHAP = 420,
216  EVENT_INTERFACE_LIST = 421,
217  EVENT_INTERFACE_RESUME = 422,
218  EVENT_INTERFACE_PLAY = 423,
219 
220  EVENT_INTERFACE_SETUPd = 430,
221  EVENT_INTERFACE_SETUPg = 431,
222  EVENT_INTERFACE_SETUPp = 432,
223  EVENT_INTERFACE_SETUPc = 433,
224  EVENT_INTERFACE_SETUPs = 434,
225 
226  EVENT_INTERFACE_DEVICE = 440,
227  EVENT_INTERFACE_RESOL = 441,
228  EVENT_INTERFACE_FULL = 442,
229  EVENT_INTERFACE_APPLY = 443,
230 
231  EVENT_INTERFACE_SHADOW_SPOTS = 451,
232  EVENT_INTERFACE_DIRTY = 452,
233  EVENT_INTERFACE_LIGHT = 457,
234  EVENT_INTERFACE_PARTI = 458,
235  EVENT_INTERFACE_CLIP = 459,
236  EVENT_INTERFACE_RAIN = 462,
237  EVENT_INTERFACE_GLINT = 463,
238  EVENT_INTERFACE_TOOLTIP = 464,
239  EVENT_INTERFACE_MOVIES = 465,
240  EVENT_INTERFACE_SCROLL = 467,
241  EVENT_INTERFACE_INVERTX = 468,
242  EVENT_INTERFACE_INVERTY = 469,
243  EVENT_INTERFACE_EFFECT = 470,
244  EVENT_INTERFACE_BGPAUSE = 471,
245  EVENT_INTERFACE_FOG = 474,
246  EVENT_INTERFACE_EDITMODE= 476,
247  EVENT_INTERFACE_EDITVALUE= 477,
248  EVENT_INTERFACE_SOLUCE4 = 478,
249  EVENT_INTERFACE_BLOOD = 479,
250  EVENT_INTERFACE_AUTOSAVE_ENABLE = 780,
251  EVENT_INTERFACE_AUTOSAVE_INTERVAL = 781,
252  EVENT_INTERFACE_AUTOSAVE_SLOTS = 782,
253  EVENT_INTERFACE_TEXTURE_FILTER = 783,
254  EVENT_INTERFACE_TEXTURE_MIPMAP = 784,
255  EVENT_INTERFACE_TEXTURE_ANISOTROPY = 785,
256  EVENT_INTERFACE_MSAA = 786,
257  EVENT_INTERFACE_SHADOW_MAPPING = 787,
258  EVENT_INTERFACE_SHADOW_MAPPING_QUALITY = 788,
259  EVENT_INTERFACE_SHADOW_MAPPING_BUFFER = 789,
260  EVENT_INTERFACE_LANGUAGE = 790,
261 
262  EVENT_INTERFACE_KINFO1 = 500,
263  EVENT_INTERFACE_KINFO2 = 501,
264  EVENT_INTERFACE_KGROUP = 502,
265  EVENT_INTERFACE_KSCROLL = 503,
266  EVENT_INTERFACE_KDEF = 504,
267  // Reserved space for keybindings
268  // This is not the nicest solution, but it'll have to work like that until we move to CEGUI
269  EVENT_INTERFACE_KEY = 505,
270  EVENT_INTERFACE_KEY_END = 539,
271 
272  EVENT_INTERFACE_MIN = 540,
273  EVENT_INTERFACE_NORM = 541,
274  EVENT_INTERFACE_MAX = 542,
275 
276  EVENT_INTERFACE_VOLSOUND= 550,
277  EVENT_INTERFACE_VOLMUSIC= 551,
278  EVENT_INTERFACE_SILENT = 552,
279  EVENT_INTERFACE_NOISY = 553,
280 
281  EVENT_INTERFACE_JOYSTICK= 560,
282  EVENT_INTERFACE_SOLUCE = 561,
283  EVENT_INTERFACE_JOYSTICK_X = 562,
284  EVENT_INTERFACE_JOYSTICK_Y = 563,
285  EVENT_INTERFACE_JOYSTICK_Z = 564,
286  EVENT_INTERFACE_JOYSTICK_X_INVERT = 565,
287  EVENT_INTERFACE_JOYSTICK_Y_INVERT = 566,
288  EVENT_INTERFACE_JOYSTICK_Z_INVERT = 567,
289  EVENT_INTERFACE_JOYSTICK_DEADZONE = 568,
290 
291  EVENT_INTERFACE_GLINTl = 570,
292  EVENT_INTERFACE_GLINTr = 571,
293  EVENT_INTERFACE_GLINTu = 572,
294  EVENT_INTERFACE_GLINTb = 573,
295 
296  EVENT_INTERFACE_NEDIT = 580,
297  EVENT_INTERFACE_NLIST = 581,
298  EVENT_INTERFACE_NOK = 582,
299  EVENT_INTERFACE_NDELETE = 584,
300  EVENT_INTERFACE_NLABEL = 585,
301 
302  EVENT_INTERFACE_IOWRITE = 600,
303  EVENT_INTERFACE_IOREAD = 601,
304  EVENT_INTERFACE_IOLIST = 602,
305  EVENT_INTERFACE_IONAME = 603,
306  EVENT_INTERFACE_IOLABEL = 604,
307  EVENT_INTERFACE_IOIMAGE = 605,
308  EVENT_INTERFACE_IODELETE= 606,
309 
310  EVENT_INTERFACE_PERSO = 620,
311  EVENT_INTERFACE_POK = 621,
312  EVENT_INTERFACE_PCANCEL = 622,
313  EVENT_INTERFACE_PDEF = 623,
314  EVENT_INTERFACE_PHEAD = 624,
315  EVENT_INTERFACE_PBODY = 625,
316  EVENT_INTERFACE_PLROT = 626,
317  EVENT_INTERFACE_PRROT = 627,
318  EVENT_INTERFACE_PC0a = 640,
319  EVENT_INTERFACE_PC1a = 641,
320  EVENT_INTERFACE_PC2a = 642,
321  EVENT_INTERFACE_PC3a = 643,
322  EVENT_INTERFACE_PC4a = 644,
323  EVENT_INTERFACE_PC5a = 645,
324  EVENT_INTERFACE_PC6a = 646,
325  EVENT_INTERFACE_PC7a = 647,
326  EVENT_INTERFACE_PC8a = 648,
327  EVENT_INTERFACE_PC9a = 649,
328  EVENT_INTERFACE_PCRa = 650,
329  EVENT_INTERFACE_PCGa = 651,
330  EVENT_INTERFACE_PCBa = 652,
331  EVENT_INTERFACE_PC0b = 660,
332  EVENT_INTERFACE_PC1b = 661,
333  EVENT_INTERFACE_PC2b = 662,
334  EVENT_INTERFACE_PC3b = 663,
335  EVENT_INTERFACE_PC4b = 664,
336  EVENT_INTERFACE_PC5b = 665,
337  EVENT_INTERFACE_PC6b = 666,
338  EVENT_INTERFACE_PC7b = 667,
339  EVENT_INTERFACE_PC8b = 668,
340  EVENT_INTERFACE_PC9b = 669,
341  EVENT_INTERFACE_PCRb = 670,
342  EVENT_INTERFACE_PCGb = 671,
343  EVENT_INTERFACE_PCBb = 672,
344  EVENT_INTERFACE_PFACE1 = 680,
345  EVENT_INTERFACE_PFACE2 = 681,
346  EVENT_INTERFACE_PFACE3 = 682,
347  EVENT_INTERFACE_PFACE4 = 683,
348  EVENT_INTERFACE_PGLASS0 = 690,
349  EVENT_INTERFACE_PGLASS1 = 691,
350  EVENT_INTERFACE_PGLASS2 = 692,
351  EVENT_INTERFACE_PGLASS3 = 693,
352  EVENT_INTERFACE_PGLASS4 = 694,
353  EVENT_INTERFACE_PGLASS5 = 695,
354  EVENT_INTERFACE_PGLASS6 = 696,
355  EVENT_INTERFACE_PGLASS7 = 697,
356  EVENT_INTERFACE_PGLASS8 = 698,
357  EVENT_INTERFACE_PGLASS9 = 699,
358 
359  EVENT_DT_GROUP0 = 700,
360  EVENT_DT_GROUP1 = 701,
361  EVENT_DT_GROUP2 = 702,
362  EVENT_DT_GROUP3 = 703,
363  EVENT_DT_GROUP4 = 704,
364  EVENT_DT_LABEL0 = 710,
365  EVENT_DT_LABEL1 = 711,
366  EVENT_DT_LABEL2 = 712,
367  EVENT_DT_LABEL3 = 713,
368  EVENT_DT_LABEL4 = 714,
369  EVENT_DT_VISIT0 = 720,
370  EVENT_DT_VISIT1 = 721,
371  EVENT_DT_VISIT2 = 722,
372  EVENT_DT_VISIT3 = 723,
373  EVENT_DT_VISIT4 = 724,
374  EVENT_DT_END = 725,
375 
376  EVENT_CMD = 800,
377  EVENT_SPEED = 801,
378 
379  EVENT_HYPER_PREV = 900,
380  EVENT_HYPER_NEXT = 901,
381  EVENT_HYPER_HOME = 902,
382  EVENT_HYPER_COPY = 903,
383  EVENT_HYPER_SIZE1 = 904,
384  EVENT_HYPER_SIZE2 = 905,
385  EVENT_HYPER_SIZE3 = 906,
386  EVENT_HYPER_SIZE4 = 907,
387  EVENT_HYPER_SIZE5 = 908,
388 
389  EVENT_SATCOM_HUSTON = 920,
390  EVENT_SATCOM_SAT = 921,
391  EVENT_SATCOM_LOADING = 922,
392  EVENT_SATCOM_OBJECT = 923,
393  EVENT_SATCOM_PROG = 924,
394  EVENT_SATCOM_SOLUCE = 925,
395 
396  EVENT_OBJECT_DESELECT = 1000,
397  EVENT_OBJECT_LEFT = 1001,
398  EVENT_OBJECT_RIGHT = 1002,
399  EVENT_OBJECT_UP = 1003,
400  EVENT_OBJECT_DOWN = 1004,
401  EVENT_OBJECT_GASUP = 1005,
402  EVENT_OBJECT_GASDOWN = 1006,
403  EVENT_OBJECT_HTAKE = 1020,
404  EVENT_OBJECT_MTAKE = 1021,
405  EVENT_OBJECT_MFRONT = 1022,
406  EVENT_OBJECT_MBACK = 1023,
407  EVENT_OBJECT_MPOWER = 1024,
408  EVENT_OBJECT_BHELP = 1040,
409  EVENT_OBJECT_BTAKEOFF = 1041,
410  EVENT_OBJECT_BDESTROY = 1042,
411  EVENT_OBJECT_BDERRICK = 1050,
412  EVENT_OBJECT_BSTATION = 1051,
413  EVENT_OBJECT_BFACTORY = 1052,
414  EVENT_OBJECT_BCONVERT = 1053,
415  EVENT_OBJECT_BTOWER = 1054,
416  EVENT_OBJECT_BREPAIR = 1055,
417  EVENT_OBJECT_BRESEARCH = 1056,
418  EVENT_OBJECT_BRADAR = 1057,
419  EVENT_OBJECT_BENERGY = 1058,
420  EVENT_OBJECT_BLABO = 1059,
421  EVENT_OBJECT_BNUCLEAR = 1060,
422  EVENT_OBJECT_BPARA = 1061,
423  EVENT_OBJECT_BINFO = 1062,
424  EVENT_OBJECT_BDESTROYER = 1063,
425  EVENT_OBJECT_GFLAT = 1070,
426  EVENT_OBJECT_FCREATE = 1071,
427  EVENT_OBJECT_FDELETE = 1072,
428  EVENT_OBJECT_FCOLORb = 1073,
429  EVENT_OBJECT_FCOLORr = 1074,
430  EVENT_OBJECT_FCOLORg = 1075,
431  EVENT_OBJECT_FCOLORy = 1076,
432  EVENT_OBJECT_FCOLORv = 1077,
433  EVENT_OBJECT_FACTORYwa = 1080,
434  EVENT_OBJECT_FACTORYta = 1081,
435  EVENT_OBJECT_FACTORYfa = 1082,
436  EVENT_OBJECT_FACTORYia = 1083,
437  EVENT_OBJECT_FACTORYwc = 1084,
438  EVENT_OBJECT_FACTORYtc = 1085,
439  EVENT_OBJECT_FACTORYfc = 1086,
440  EVENT_OBJECT_FACTORYic = 1087,
441  EVENT_OBJECT_FACTORYwi = 1088,
442  EVENT_OBJECT_FACTORYti = 1089,
443  EVENT_OBJECT_FACTORYfi = 1090,
444  EVENT_OBJECT_FACTORYii = 1091,
445  EVENT_OBJECT_FACTORYws = 1092,
446  EVENT_OBJECT_FACTORYts = 1093,
447  EVENT_OBJECT_FACTORYfs = 1094,
448  EVENT_OBJECT_FACTORYis = 1095,
449  EVENT_OBJECT_FACTORYrt = 1096,
450  EVENT_OBJECT_FACTORYrc = 1097,
451  EVENT_OBJECT_FACTORYrr = 1098,
452  EVENT_OBJECT_FACTORYrs = 1099,
453  EVENT_OBJECT_FACTORYsa = 1100,
454  EVENT_OBJECT_SEARCH = 1200,
455  EVENT_OBJECT_TERRAFORM = 1201,
456  EVENT_OBJECT_FIRE = 1202,
457  EVENT_OBJECT_FIREANT = 1203,
458  EVENT_OBJECT_SPIDEREXPLO= 1204,
459  EVENT_OBJECT_RECOVER = 1220,
460  EVENT_OBJECT_BEGSHIELD = 1221,
461  EVENT_OBJECT_ENDSHIELD = 1222,
462  EVENT_OBJECT_RTANK = 1223,
463  EVENT_OBJECT_RFLY = 1224,
464  EVENT_OBJECT_RTHUMP = 1225,
465  EVENT_OBJECT_RCANON = 1226,
466  EVENT_OBJECT_RTOWER = 1227,
467  EVENT_OBJECT_RPHAZER = 1228,
468  EVENT_OBJECT_RSHIELD = 1229,
469  EVENT_OBJECT_RATOMIC = 1230,
470  EVENT_OBJECT_RiPAW = 1231,
471  EVENT_OBJECT_RiGUN = 1232,
472  EVENT_OBJECT_RESET = 1233,
473  EVENT_OBJECT_DIMSHIELD = 1234,
474  EVENT_OBJECT_TARGET = 1235,
475  EVENT_OBJECT_DELSEARCH = 1236, // delete mark on ground
476  EVENT_OBJECT_PROGLIST = 1310,
477  EVENT_OBJECT_PROGRUN = 1311,
478  EVENT_OBJECT_PROGEDIT = 1312,
479  EVENT_OBJECT_PROGSTART = 1313,
480  EVENT_OBJECT_PROGSTOP = 1314,
481  EVENT_OBJECT_PROGADD = 1315,
482  EVENT_OBJECT_PROGREMOVE = 1316,
483  EVENT_OBJECT_PROGCLONE = 1317,
484  EVENT_OBJECT_PROGMOVEUP = 1318,
485  EVENT_OBJECT_PROGMOVEDOWN = 1319,
486  EVENT_OBJECT_INFOOK = 1340,
487  EVENT_OBJECT_DELETE = 1350,
488  EVENT_OBJECT_GENERGY = 1360,
489  EVENT_OBJECT_GSHIELD = 1361,
490  EVENT_OBJECT_GRANGE = 1362,
491  EVENT_OBJECT_MAP = 1364,
492  EVENT_OBJECT_MAPZOOM = 1365,
493  EVENT_OBJECT_GPROGRESS = 1366,
494  EVENT_OBJECT_GRADAR = 1367,
495  EVENT_OBJECT_GINFO = 1368,
496  EVENT_OBJECT_TYPE = 1369,
497  EVENT_OBJECT_CROSSHAIR = 1370,
498  EVENT_OBJECT_CORNERul = 1371,
499  EVENT_OBJECT_CORNERur = 1372,
500  EVENT_OBJECT_CORNERdl = 1373,
501  EVENT_OBJECT_CORNERdr = 1374,
502  EVENT_OBJECT_MAPi = 1375,
503  EVENT_OBJECT_MAPg = 1376,
504  EVENT_OBJECT_CAMERA = 1400,
505  EVENT_OBJECT_HELP = 1401,
506  EVENT_OBJECT_SOLUCE = 1402,
507  EVENT_OBJECT_CAMERAleft = 1403,
508  EVENT_OBJECT_CAMERAright= 1404,
509  EVENT_OBJECT_CAMERAnear = 1405,
510  EVENT_OBJECT_CAMERAaway = 1406,
511  EVENT_OBJECT_SHORTCUT_MODE = 1500,
512  EVENT_OBJECT_SHORTCUT = 1501,
513  EVENT_OBJECT_SHORTCUT_MAX = 1549,
514  EVENT_OBJECT_MOVIELOCK = 1550,
515  EVENT_OBJECT_EDITLOCK = 1551,
516  EVENT_OBJECT_SAVING = 1552,
517  EVENT_OBJECT_LIMIT = 1560,
518 
519  EVENT_OBJECT_PEN0 = 1570,
520  EVENT_OBJECT_PEN1 = 1571,
521  EVENT_OBJECT_PEN2 = 1572,
522  EVENT_OBJECT_PEN3 = 1573,
523  EVENT_OBJECT_PEN4 = 1574,
524  EVENT_OBJECT_PEN5 = 1575,
525  EVENT_OBJECT_PEN6 = 1576,
526  EVENT_OBJECT_PEN7 = 1577,
527  EVENT_OBJECT_PEN8 = 1578,
528  EVENT_OBJECT_REC = 1580,
529  EVENT_OBJECT_STOP = 1581,
530 
531  EVENT_STUDIO_OK = 2000,
532  EVENT_STUDIO_CANCEL = 2001,
533  EVENT_STUDIO_EDIT = 2002,
534  EVENT_STUDIO_LIST = 2003,
535  EVENT_STUDIO_CLONE = 2004,
536  EVENT_STUDIO_NEW = 2010,
537  EVENT_STUDIO_OPEN = 2011,
538  EVENT_STUDIO_SAVE = 2012,
539  EVENT_STUDIO_UNDO = 2013,
540  EVENT_STUDIO_CUT = 2014,
541  EVENT_STUDIO_COPY = 2015,
542  EVENT_STUDIO_PASTE = 2016,
543  EVENT_STUDIO_SIZE = 2017,
544  EVENT_STUDIO_TOOL = 2018,
545  EVENT_STUDIO_HELP = 2019,
546  EVENT_STUDIO_COMPILE = 2050,
547  EVENT_STUDIO_RUN = 2051,
548  EVENT_STUDIO_REALTIME = 2052,
549  EVENT_STUDIO_STEP = 2053,
550 
552 
555 
558 
559  EVENT_USER = 10000,
560  EVENT_FORCE_LONG = 0x7fffffff
561 };
562 
567 struct EventData
568 {
569  virtual ~EventData()
570  {}
571 
572  virtual std::unique_ptr<EventData> Clone() const = 0;
573 };
574 
579 struct KeyEventData : public EventData
580 {
581  std::unique_ptr<EventData> Clone() const override
582  {
583  return MakeUnique<KeyEventData>(*this);
584  }
585 
587  bool virt = false;
589  unsigned int key = 0;
591  InputSlot slot = INPUT_SLOT_MAX;
592 };
593 
598  struct TextInputData : public EventData
599  {
600  std::unique_ptr<EventData> Clone() const override
601  {
602  return MakeUnique<TextInputData>(*this);
603  }
604 
606  std::string text = "";
607  };
608 
616 {
617  MOUSE_BUTTON_LEFT = (1<<1),
618  MOUSE_BUTTON_MIDDLE = (1<<2),
619  MOUSE_BUTTON_RIGHT = (1<<3),
622 };
623 
629 {
630  std::unique_ptr<EventData> Clone() const override
631  {
632  return MakeUnique<MouseButtonEventData>(*this);
633  }
634 
636  MouseButton button = MOUSE_BUTTON_LEFT;
637 };
638 
644 {
645  std::unique_ptr<EventData> Clone() const override
646  {
647  return MakeUnique<MouseWheelEventData>(*this);
648  }
649 
651  signed int y = 0;
653  signed int x = 0;
654 };
655 
661 {
662  std::unique_ptr<EventData> Clone() const override
663  {
664  return MakeUnique<JoyAxisEventData>(*this);
665  }
666 
668  unsigned char axis = 0;
670  int value = 0;
671 };
672 
678 {
679  std::unique_ptr<EventData> Clone() const override
680  {
681  return MakeUnique<JoyButtonEventData>(*this);
682  }
683 
685  unsigned char button = 0;
686 };
687 
699 struct Event
700 {
701  explicit Event(EventType type = EVENT_NULL)
702  : type(type),
703  rTime(0.0f),
704  kmodState(0),
705  mouseButtonsState(0),
706  customParam(0)
707  {}
708 
709  Event(const Event&) = delete;
710  Event& operator=(const Event&) = delete;
711 
712  // Workaround for MSVC2013
713  Event(Event&& other)
714  : type(std::move(other.type)),
715  rTime(std::move(other.rTime)),
716  motionInput(std::move(other.motionInput)),
717  cameraInput(std::move(other.cameraInput)),
718  kmodState(std::move(other.kmodState)),
719  mousePos(std::move(other.mousePos)),
720  mouseButtonsState(std::move(other.mouseButtonsState)),
721  customParam(std::move(other.customParam)),
722  data(std::move(other.data))
723  {}
724 
725  Event& operator=(Event&& other)
726  {
727  type = std::move(other.type);
728  rTime = std::move(other.rTime);
729  motionInput = std::move(other.motionInput);
730  cameraInput = std::move(other.cameraInput);
731  kmodState = std::move(other.kmodState);
732  mousePos = std::move(other.mousePos);
733  mouseButtonsState = std::move(other.mouseButtonsState);
734  customParam = std::move(other.customParam);
735  data = std::move(other.data);
736  return *this;
737  }
738 
740  template<typename EventDataSubclass>
741  EventDataSubclass* GetData()
742  {
743  return static_cast<EventDataSubclass*>(data.get());
744  }
745 
747  template<typename EventDataSubclass>
748  const EventDataSubclass* GetData() const
749  {
750  return static_cast<EventDataSubclass*>(data.get());
751  }
752 
754  Event Clone() const
755  {
756  Event clone;
757 
758  clone.type = type;
759  clone.rTime = rTime;
760  clone.motionInput = motionInput;
761  clone.cameraInput = cameraInput;
762  clone.kmodState = kmodState;
763  clone.mousePos = mousePos;
764  clone.mouseButtonsState = mouseButtonsState;
765  clone.customParam = customParam;
766 
767  if (data != nullptr)
768  {
769  clone.data = data->Clone();
770  }
771 
772  return clone;
773  }
774 
777 
780  // TODO: gradually replace the usage of this with new CApplication's time functions
781  float rTime;
782 
786 
790 
793  unsigned int kmodState;
794 
798 
801  unsigned int mouseButtonsState;
802 
806 
808  std::unique_ptr<EventData> data;
809 };
810 
811 
814 
817 
819 std::string ParseEventType(EventType eventType);
820 
831 {
832 public:
834  static const int MAX_EVENT_QUEUE = 100;
835 
836 public:
838  CEventQueue();
840  ~CEventQueue();
841 
843  bool IsEmpty();
845  bool AddEvent(Event&& event);
847  Event GetEvent();
848 
849 protected:
850  CSDLMutexWrapper m_mutex;
851  Event m_fifo[MAX_EVENT_QUEUE];
852  int m_head;
853  int m_tail;
854  int m_total;
855 };
Event sent on user quit request.
Definition: event.h:96
Additional data for joystick button event.
Definition: event.h:677
CDisplayText.
Definition: event.h:143
float rTime
Definition: event.h:781
MouseButton
Mouse button.
Definition: event.h:615
void InitializeEventTypeTexts()
Initializes static array with event type strings.
Definition: event.cpp:40
(unused)
Definition: event.h:149
InputSlot
Available slots for input bindings NOTE: When adding new values, remember to also update keyTable in ...
Definition: key.h:79
Additional data for mouse wheel event.
Definition: event.h:643
code battle interface
Definition: event.h:147
Additional data mouse button event.
Definition: event.h:628
Point struct and related functions.
CDisplayInfo.
Definition: event.h:145
Base class for additional event data.
Definition: event.h:567
std::string ParseEventType(EventType eventType)
Parses event type to string.
Definition: event.cpp:523
Event sent after releasing a mouse button.
Definition: event.h:60
Event sent after releasing a joystick button.
Definition: event.h:82
std::unique_ptr< EventData > data
Additional data for some events.
Definition: event.h:808
Math::Vector cameraInput
Definition: event.h:789
Event sent when mouse enters the window.
Definition: event.h:66
button that starts the code battle
Definition: event.h:553
Maximum value of standard events.
Definition: event.h:557
Event sent after moving joystick axes.
Definition: event.h:78
Additional data for text input event.
Definition: event.h:598
Global event queue.
Definition: event.h:830
Wrapper for safe creation/deletion of SDL_mutex.
Definition: sdl_mutex_wrapper.h:28
Additional data for keyboard event.
Definition: event.h:579
unsigned int kmodState
Definition: event.h:793
Event sent after pressing a mouse button.
Definition: event.h:58
Event sent when the app winddow gains focus.
Definition: event.h:85
const EventDataSubclass * GetData() const
Convenience function for getting appropriate EventData subclass.
Definition: event.h:748
Math::Vector motionInput
Definition: event.h:785
Event Clone() const
Returns a clone of this event.
Definition: event.h:754
CMainMap.
Definition: event.h:142
unsigned int mouseButtonsState
Definition: event.h:801
(unused)
Definition: event.h:148
Event sent after releasing a key.
Definition: event.h:73
2D point
Definition: point.h:50
CMainDialog and CStudio file selector.
Definition: event.h:150
Key-related macros and enums.
Additional data for joystick axis event.
Definition: event.h:660
EventType type
Type of event.
Definition: event.h:776
Event sent when mouse leaves the window.
Definition: event.h:68
Event sent on system quit request.
Definition: event.h:52
EventDataSubclass * GetData()
Convenience function for getting appropriate EventData subclass.
Definition: event.h:741
button that controls the code battle spectator camera
Definition: event.h:554
Vector struct and related functions.
object interface (CObjectInterface + CAuto classes)
Definition: event.h:141
Event sent after pressing a joystick button.
Definition: event.h:80
indicates end of writing scene (writing screenshot image)
Definition: event.h:551
all menu windows
Definition: event.h:146
Invalid event / no event.
Definition: event.h:47
Event sent after moving the mouse.
Definition: event.h:64
3D (3x1) vector
Definition: vector.h:53
long customParam
Definition: event.h:805
Frame update event.
Definition: event.h:55
Event sent when the app winddow loses focus.
Definition: event.h:87
Event sent after moving mouse wheel up or down.
Definition: event.h:62
There may be additional mouse buttons >= this value.
Definition: event.h:621
EventType GetUniqueEventType()
Returns an unique event type (above the standard IDs)
Definition: event.cpp:32
Event sent when user inputs some character.
Definition: event.h:75
EventType
Type of event message.
Definition: event.h:41
Event sent by system, interface or game.
Definition: event.h:699
Event sent after pressing a key.
Definition: event.h:71
CStudio.
Definition: event.h:144
CEdit focus.
Definition: event.h:102
Math::Point mousePos
Definition: event.h:797