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