zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gamestate.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <zeni_rest.h>
19 
20 #include <algorithm>
21 #include <cmath>
22 
23 #include <Zeni/Define.h>
24 
25 #if defined(_DEBUG) && defined(_WINDOWS)
26 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
27 #define new DEBUG_NEW
28 #endif
29 
30 namespace Zeni {
31 
32 #ifdef ANDROID
33  void Gamestate_Base::on_event(android_app &/*app*/, const AInputEvent &/*event*/) {
34  }
35 #else
37  switch(event.type) {
38 #if !SDL_VERSION_ATLEAST(2,0,0)
39  case SDL_ACTIVEEVENT:
40  on_active(event.active);
41  break;
42 #endif
43  case SDL_KEYDOWN:
44  case SDL_KEYUP:
45  on_key(event.key);
46  break;
47  case SDL_MOUSEMOTION:
48  on_mouse_motion(event.motion);
49  break;
51  case SDL_MOUSEBUTTONUP:
52  on_mouse_button(event.button);
53  break;
54 #if SDL_VERSION_ATLEAST(1,3,0)
55  case SDL_MOUSEWHEEL:
56  on_mouse_wheel(event.wheel);
57  break;
58 #endif
61  break;
65  break;
70  break;
71  case SDL_QUIT:
72  on_quit(event.quit);
73  break;
74 #if SDL_VERSION_ATLEAST(1,3,0)
75  case SDL_WINDOWEVENT:
76  on_window_event(event.window);
77  break;
78 #endif
79  case SDL_SYSWMEVENT:
81  break;
82 #if !SDL_VERSION_ATLEAST(2,0,0)
83  case SDL_VIDEORESIZE:
84  on_video_resize(event.resize);
85  break;
86  case SDL_VIDEOEXPOSE:
87  on_video_expose(event.expose);
88  break;
89 #endif
90  case SDL_USEREVENT:
91  on_user_event(event.user);
92  break;
93  default:
94  // Impossible
95  break;
96  }
97  }
98 
100  if(event.state == SDL_PRESSED && event.keysym.sym == SDLK_ESCAPE)
102  }
103 
105  }
106 
108  }
109 
110 #if SDL_VERSION_ATLEAST(1,3,0)
111  void Gamestate_Base::on_mouse_wheel(const SDL_MouseWheelEvent &) {
112  }
113 #endif
114 
116  }
117 
119  }
120 
122  }
123 
125  }
126 
128  }
129 
130 #if SDL_VERSION_ATLEAST(2,0,0)
131  void Gamestate_Base::on_window_event(const SDL_WindowEvent &event) {
132  if(event.event == SDL_WINDOWEVENT_RESIZED) {
134  Video::save();
135  return;
136  }
137 
139  return;
140 
141  const bool gain = event.event == SDL_WINDOWEVENT_FOCUS_GAINED;
142 #else
143  void Gamestate_Base::on_active(const SDL_ActiveEvent &event) {
144  if(!(event.state & SDL_APPINPUTFOCUS))
145  return;
146 
147  const bool gain = event.gain != 0;
148 #endif
149 
150  static Window::Mouse_State mouse_state = Window::MOUSE_NORMAL;
151  Window &wr = get_Window();
152 
153  if(gain) {
154  wr.set_mouse_state(mouse_state);
155 
156  get_Controllers().enable(true);
157  }
158  else {
159  get_Controllers().enable(false);
160 
161  mouse_state = wr.get_mouse_state();
163 
164  if(m_pausable)
166  }
167  }
168 
169 #if !SDL_VERSION_ATLEAST(2,0,0)
170  void Gamestate_Base::on_video_resize(const SDL_ResizeEvent &event) {
171  Video::change_resolution(Point2i(event.w, event.h));
172  Video::save();
173  }
174 #endif
175 
176 #if !SDL_VERSION_ATLEAST(1,3,0)
177  void Gamestate_Base::on_video_expose(const SDL_ExposeEvent &) {
178  }
179 #endif
180 
182  }
183 
185  Game &gr = get_Game();
186  const bool mod_caps = (ks.mod & KMOD_CAPS) != 0;
187  const bool mod_shift = gr.get_key_state(SDLK_LSHIFT) || gr.get_key_state(SDLK_RSHIFT);
188 
189  if(mod_caps ^ mod_shift)
190  switch(ks.sym) {
191  case SDLK_a: return 'A';
192  case SDLK_b: return 'B';
193  case SDLK_c: return 'C';
194  case SDLK_d: return 'D';
195  case SDLK_e: return 'E';
196  case SDLK_f: return 'F';
197  case SDLK_g: return 'G';
198  case SDLK_h: return 'H';
199  case SDLK_i: return 'I';
200  case SDLK_j: return 'J';
201  case SDLK_k: return 'K';
202  case SDLK_l: return 'L';
203  case SDLK_m: return 'M';
204  case SDLK_n: return 'N';
205  case SDLK_o: return 'O';
206  case SDLK_p: return 'P';
207  case SDLK_q: return 'Q';
208  case SDLK_r: return 'R';
209  case SDLK_s: return 'S';
210  case SDLK_t: return 'T';
211  case SDLK_u: return 'U';
212  case SDLK_v: return 'V';
213  case SDLK_w: return 'W';
214  case SDLK_x: return 'X';
215  case SDLK_y: return 'Y';
216  case SDLK_z: return 'Z';
217  default: break;
218  }
219  else
220  switch(ks.sym) {
221  case SDLK_a: return 'a';
222  case SDLK_b: return 'b';
223  case SDLK_c: return 'c';
224  case SDLK_d: return 'd';
225  case SDLK_e: return 'e';
226  case SDLK_f: return 'f';
227  case SDLK_g: return 'g';
228  case SDLK_h: return 'h';
229  case SDLK_i: return 'i';
230  case SDLK_j: return 'j';
231  case SDLK_k: return 'k';
232  case SDLK_l: return 'l';
233  case SDLK_m: return 'm';
234  case SDLK_n: return 'n';
235  case SDLK_o: return 'o';
236  case SDLK_p: return 'p';
237  case SDLK_q: return 'q';
238  case SDLK_r: return 'r';
239  case SDLK_s: return 's';
240  case SDLK_t: return 't';
241  case SDLK_u: return 'u';
242  case SDLK_v: return 'v';
243  case SDLK_w: return 'w';
244  case SDLK_x: return 'x';
245  case SDLK_y: return 'y';
246  case SDLK_z: return 'z';
247  default: break;
248  }
249 
250  if(ks.mod & KMOD_NUM)
251  switch(ks.sym) {
252 #if SDL_VERSION_ATLEAST(2,0,0)
253  case SDLK_KP_0: return '0';
254  case SDLK_KP_1: return '1';
255  case SDLK_KP_2: return '2';
256  case SDLK_KP_3: return '3';
257  case SDLK_KP_4: return '4';
258  case SDLK_KP_5: return '5';
259  case SDLK_KP_6: return '6';
260  case SDLK_KP_7: return '7';
261  case SDLK_KP_8: return '8';
262  case SDLK_KP_9: return '9';
263 #else
264  case SDLK_KP0: return '0';
265  case SDLK_KP1: return '1';
266  case SDLK_KP2: return '2';
267  case SDLK_KP3: return '3';
268  case SDLK_KP4: return '4';
269  case SDLK_KP5: return '5';
270  case SDLK_KP6: return '6';
271  case SDLK_KP7: return '7';
272  case SDLK_KP8: return '8';
273  case SDLK_KP9: return '9';
274 #endif
275  case SDLK_KP_MULTIPLY: return '*';
276  case SDLK_KP_PLUS: return '+';
277  case SDLK_KP_MINUS: return '-';
278  case SDLK_KP_PERIOD: return '.';
279  case SDLK_KP_DIVIDE: return '/';
280  case SDLK_KP_EQUALS: return '=';
281  case SDLK_KP_ENTER: return '\n';
282  default: break;
283  }
284 
285  switch(ks.sym) {
286  //case SDLK_BACKSPACE: return '\b';
287  case SDLK_TAB: return '\t';
288  case SDLK_RETURN: return '\n'; // '\r' is less sane, but another possibility
289  //case SDLK_ESCAPE: return 0x1B;
290  case SDLK_SPACE: return ' ';
291  case SDLK_EXCLAIM: return '!';
292  case SDLK_QUOTEDBL: return '"';
293  case SDLK_HASH: return '#';
294 #if SDL_VERSION_ATLEAST(1,3,0)
295  case SDLK_PERCENT: return '%';
296 #endif
297  case SDLK_DOLLAR: return '$';
298  case SDLK_AMPERSAND: return '&';
299  case SDLK_QUOTE: return mod_shift ? '"' : '\'';
300  case SDLK_LEFTPAREN: return '(';
301  case SDLK_RIGHTPAREN: return ')';
302  case SDLK_ASTERISK: return '*';
303  case SDLK_PLUS: return '+';
304  case SDLK_COMMA: return mod_shift ? '<' : ',';
305  case SDLK_MINUS: return mod_shift ? '_' : '-';
306  case SDLK_PERIOD: return mod_shift ? '>' : '.';
307  case SDLK_SLASH: return mod_shift ? '?' : '/';
308  case SDLK_0: return mod_shift ? ')' : '0';
309  case SDLK_1: return mod_shift ? '!' : '1';
310  case SDLK_2: return mod_shift ? '@' : '2';
311  case SDLK_3: return mod_shift ? '#' : '3';
312  case SDLK_4: return mod_shift ? '$' : '4';
313  case SDLK_5: return mod_shift ? '%' : '5';
314  case SDLK_6: return mod_shift ? '^' : '6';
315  case SDLK_7: return mod_shift ? '&' : '7';
316  case SDLK_8: return mod_shift ? '*' : '8';
317  case SDLK_9: return mod_shift ? '(' : '9';
318  case SDLK_COLON: return ':';
319  case SDLK_SEMICOLON: return mod_shift ? ':' : ';';
320  case SDLK_LESS: return '<';
321  case SDLK_EQUALS: return mod_shift ? '+' : '=';
322  case SDLK_GREATER: return '>';
323  case SDLK_QUESTION: return '?';
324  case SDLK_AT: return '@';
325  case SDLK_LEFTBRACKET: return mod_shift ? '{' : '[';
326  case SDLK_BACKSLASH: return mod_shift ? '|' : '\\';
327  case SDLK_RIGHTBRACKET: return mod_shift ? '}' : ']';
328  case SDLK_CARET: return '^';
329  case SDLK_UNDERSCORE: return '_';
330  case SDLK_BACKQUOTE: return mod_shift ? '~' : '`';
331  //case SDLK_DELETE: return 0x7F;
332  default: break;
333  }
334 
335  return '\0';
336  }
337 
339 
340 #define SC(name) if(text_version == #name) return name;
341 
342 #if SDL_VERSION_ATLEAST(1,3,0)
343 #define SC0(b)
344 #define SC1(a) SC(a)
345 #define SC10(a, b) SC(a)
346 #else
347 #define SC0(b) SC(b)
348 #define SC1(a)
349 #define SC10(a, b) SC(b)
350 #endif
351 
355 SC(SDLK_TAB)
356 SC(SDLK_SPACE)
359 SC(SDLK_HASH)
363 SC(SDLK_QUOTE)
367 SC(SDLK_PLUS)
368 SC(SDLK_COMMA)
369 SC(SDLK_MINUS)
371 SC(SDLK_SLASH)
372 SC(SDLK_0)
373 SC(SDLK_1)
374 SC(SDLK_2)
375 SC(SDLK_3)
376 SC(SDLK_4)
377 SC(SDLK_5)
378 SC(SDLK_6)
379 SC(SDLK_7)
380 SC(SDLK_8)
381 SC(SDLK_9)
382 SC(SDLK_COLON)
384 SC(SDLK_LESS)
388 SC(SDLK_AT)
392 SC(SDLK_CARET)
395 SC(SDLK_a)
396 SC(SDLK_b)
397 SC(SDLK_c)
398 SC(SDLK_d)
399 SC(SDLK_e)
400 SC(SDLK_f)
401 SC(SDLK_g)
402 SC(SDLK_h)
403 SC(SDLK_i)
404 SC(SDLK_j)
405 SC(SDLK_k)
406 SC(SDLK_l)
407 SC(SDLK_m)
408 SC(SDLK_n)
409 SC(SDLK_o)
410 SC(SDLK_p)
411 SC(SDLK_q)
412 SC(SDLK_r)
413 SC(SDLK_s)
414 SC(SDLK_t)
415 SC(SDLK_u)
416 SC(SDLK_v)
417 SC(SDLK_w)
418 SC(SDLK_x)
419 SC(SDLK_y)
420 SC(SDLK_z)
421 
423 
424 SC(SDLK_F1)
425 SC(SDLK_F2)
426 SC(SDLK_F3)
427 SC(SDLK_F4)
428 SC(SDLK_F5)
429 SC(SDLK_F6)
430 SC(SDLK_F7)
431 SC(SDLK_F8)
432 SC(SDLK_F9)
433 SC(SDLK_F10)
434 SC(SDLK_F11)
435 SC(SDLK_F12)
436 
437 SC10(SDLK_PRINTSCREEN, SDLK_PRINT)
438 #if SDL_VERSION_ATLEAST(2,0,0)
440 #else
441 SC(SDLK_SCROLLOCK)
442 #endif
443 SC(SDLK_PAUSE)
445 SC(SDLK_HOME)
448 SC(SDLK_END)
450 SC(SDLK_RIGHT)
451 SC(SDLK_LEFT)
452 SC(SDLK_DOWN)
453 SC(SDLK_UP)
454 
455 SC10(SDLK_NUMLOCKCLEAR, SDLK_NUMLOCK)
461 SC10(SDLK_KP_1, SDLK_KP1)
462 SC10(SDLK_KP_2, SDLK_KP2)
463 SC10(SDLK_KP_3, SDLK_KP3)
464 SC10(SDLK_KP_4, SDLK_KP4)
465 SC10(SDLK_KP_5, SDLK_KP5)
466 SC10(SDLK_KP_6, SDLK_KP6)
467 SC10(SDLK_KP_7, SDLK_KP7)
468 SC10(SDLK_KP_8, SDLK_KP8)
469 SC10(SDLK_KP_9, SDLK_KP9)
470 SC10(SDLK_KP_0, SDLK_KP0)
472 
473 SC10(SDLK_APPLICATION, SDLK_COMPOSE)
474 SC(SDLK_POWER)
476 SC(SDLK_F13)
477 SC(SDLK_F14)
478 SC(SDLK_F15)
479 SC1(SDLK_F16)
480 SC1(SDLK_F17)
481 SC1(SDLK_F18)
482 SC1(SDLK_F19)
483 SC1(SDLK_F20)
484 SC1(SDLK_F21)
485 SC1(SDLK_F22)
486 SC1(SDLK_F23)
487 SC1(SDLK_F24)
489 SC(SDLK_HELP)
490 SC(SDLK_MENU)
492 SC10(SDLK_STOP, SDLK_BREAK)
494 SC(SDLK_UNDO)
495 SC1(SDLK_CUT)
496 SC1(SDLK_COPY)
498 SC1(SDLK_FIND)
499 SC1(SDLK_MUTE)
504 
508 SC(SDLK_CLEAR)
512 SC1(SDLK_OUT)
513 SC1(SDLK_OPER)
517 
530 SC1(SDLK_KP_A)
531 SC1(SDLK_KP_B)
532 SC1(SDLK_KP_C)
533 SC1(SDLK_KP_D)
534 SC1(SDLK_KP_E)
535 SC1(SDLK_KP_F)
564 
565 SC(SDLK_LCTRL)
567 SC(SDLK_LALT)
568 SC1(SDLK_LGUI)
569 SC0(SDLK_LMETA)
570 SC0(SDLK_LSUPER)
571 SC(SDLK_RCTRL)
573 SC(SDLK_RALT)
574 SC1(SDLK_RGUI)
575 SC0(SDLK_RMETA)
576 SC0(SDLK_RSUPER)
577 
578 SC(SDLK_MODE)
579 
586 SC1(SDLK_WWW)
587 SC1(SDLK_MAIL)
597 
606 
607 SC0(SDLK_EURO)
608 SC0(SDLK_WORLD_0)
609 SC0(SDLK_WORLD_1)
610 SC0(SDLK_WORLD_2)
611 SC0(SDLK_WORLD_3)
612 SC0(SDLK_WORLD_4)
613 SC0(SDLK_WORLD_5)
614 SC0(SDLK_WORLD_6)
615 SC0(SDLK_WORLD_7)
616 SC0(SDLK_WORLD_8)
617 SC0(SDLK_WORLD_9)
618 SC0(SDLK_WORLD_10)
619 SC0(SDLK_WORLD_11)
620 SC0(SDLK_WORLD_12)
621 SC0(SDLK_WORLD_13)
622 SC0(SDLK_WORLD_14)
623 SC0(SDLK_WORLD_15)
624 SC0(SDLK_WORLD_16)
625 SC0(SDLK_WORLD_17)
626 SC0(SDLK_WORLD_18)
627 SC0(SDLK_WORLD_19)
628 SC0(SDLK_WORLD_20)
629 SC0(SDLK_WORLD_21)
630 SC0(SDLK_WORLD_22)
631 SC0(SDLK_WORLD_23)
632 SC0(SDLK_WORLD_24)
633 SC0(SDLK_WORLD_25)
634 SC0(SDLK_WORLD_26)
635 SC0(SDLK_WORLD_27)
636 SC0(SDLK_WORLD_28)
637 SC0(SDLK_WORLD_29)
638 SC0(SDLK_WORLD_30)
639 SC0(SDLK_WORLD_31)
640 SC0(SDLK_WORLD_32)
641 SC0(SDLK_WORLD_33)
642 SC0(SDLK_WORLD_34)
643 SC0(SDLK_WORLD_35)
644 SC0(SDLK_WORLD_36)
645 SC0(SDLK_WORLD_37)
646 SC0(SDLK_WORLD_38)
647 SC0(SDLK_WORLD_39)
648 SC0(SDLK_WORLD_40)
649 SC0(SDLK_WORLD_41)
650 SC0(SDLK_WORLD_42)
651 SC0(SDLK_WORLD_43)
652 SC0(SDLK_WORLD_44)
653 SC0(SDLK_WORLD_45)
654 SC0(SDLK_WORLD_46)
655 SC0(SDLK_WORLD_47)
656 SC0(SDLK_WORLD_48)
657 SC0(SDLK_WORLD_49)
658 SC0(SDLK_WORLD_50)
659 SC0(SDLK_WORLD_51)
660 SC0(SDLK_WORLD_52)
661 SC0(SDLK_WORLD_53)
662 SC0(SDLK_WORLD_54)
663 SC0(SDLK_WORLD_55)
664 SC0(SDLK_WORLD_56)
665 SC0(SDLK_WORLD_57)
666 SC0(SDLK_WORLD_58)
667 SC0(SDLK_WORLD_59)
668 SC0(SDLK_WORLD_60)
669 SC0(SDLK_WORLD_61)
670 SC0(SDLK_WORLD_62)
671 SC0(SDLK_WORLD_63)
672 SC0(SDLK_WORLD_64)
673 SC0(SDLK_WORLD_65)
674 SC0(SDLK_WORLD_66)
675 SC0(SDLK_WORLD_67)
676 SC0(SDLK_WORLD_68)
677 SC0(SDLK_WORLD_69)
678 SC0(SDLK_WORLD_70)
679 SC0(SDLK_WORLD_71)
680 SC0(SDLK_WORLD_72)
681 SC0(SDLK_WORLD_73)
682 SC0(SDLK_WORLD_74)
683 SC0(SDLK_WORLD_75)
684 SC0(SDLK_WORLD_76)
685 SC0(SDLK_WORLD_77)
686 SC0(SDLK_WORLD_78)
687 SC0(SDLK_WORLD_79)
688 SC0(SDLK_WORLD_80)
689 SC0(SDLK_WORLD_81)
690 SC0(SDLK_WORLD_82)
691 SC0(SDLK_WORLD_83)
692 SC0(SDLK_WORLD_84)
693 SC0(SDLK_WORLD_85)
694 SC0(SDLK_WORLD_86)
695 SC0(SDLK_WORLD_87)
696 SC0(SDLK_WORLD_88)
697 SC0(SDLK_WORLD_89)
698 SC0(SDLK_WORLD_90)
699 SC0(SDLK_WORLD_91)
700 SC0(SDLK_WORLD_92)
701 SC0(SDLK_WORLD_93)
702 SC0(SDLK_WORLD_94)
703 SC0(SDLK_WORLD_95)
704 
705 #undef SC10
706 #undef SC1
707 #undef SC0
708 #undef SC
709 
710  return SDLK_UNKNOWN;
711  }
712 
713 //static String to_text_part_2(const SDL_Keycode &keysym);
714 
716  switch(sym) {
717 
718 #define SC(name) case name: return #name;
719 
720 #if SDL_VERSION_ATLEAST(1,3,0)
721 #define SC0(b)
722 #define SC1(a) SC(a)
723 #define SC10(a, b) SC(a)
724 #else
725 #define SC0(b) SC(b)
726 #define SC1(a)
727 #define SC10(a, b) SC(b)
728 #endif
729 
733 SC(SDLK_TAB)
734 SC(SDLK_SPACE)
737 SC(SDLK_HASH)
741 SC(SDLK_QUOTE)
745 SC(SDLK_PLUS)
746 SC(SDLK_COMMA)
747 SC(SDLK_MINUS)
749 SC(SDLK_SLASH)
750 SC(SDLK_0)
751 SC(SDLK_1)
752 SC(SDLK_2)
753 SC(SDLK_3)
754 SC(SDLK_4)
755 SC(SDLK_5)
756 SC(SDLK_6)
757 SC(SDLK_7)
758 SC(SDLK_8)
759 SC(SDLK_9)
760 SC(SDLK_COLON)
762 SC(SDLK_LESS)
766 SC(SDLK_AT)
770 SC(SDLK_CARET)
773 SC(SDLK_a)
774 SC(SDLK_b)
775 SC(SDLK_c)
776 SC(SDLK_d)
777 SC(SDLK_e)
778 SC(SDLK_f)
779 SC(SDLK_g)
780 SC(SDLK_h)
781 SC(SDLK_i)
782 SC(SDLK_j)
783 SC(SDLK_k)
784 SC(SDLK_l)
785 SC(SDLK_m)
786 SC(SDLK_n)
787 SC(SDLK_o)
788 SC(SDLK_p)
789 SC(SDLK_q)
790 SC(SDLK_r)
791 SC(SDLK_s)
792 SC(SDLK_t)
793 SC(SDLK_u)
794 SC(SDLK_v)
795 SC(SDLK_w)
796 SC(SDLK_x)
797 SC(SDLK_y)
798 SC(SDLK_z)
799 
801 
802 SC(SDLK_F1)
803 SC(SDLK_F2)
804 SC(SDLK_F3)
805 SC(SDLK_F4)
806 SC(SDLK_F5)
807 SC(SDLK_F6)
808 SC(SDLK_F7)
809 SC(SDLK_F8)
810 SC(SDLK_F9)
811 SC(SDLK_F10)
812 SC(SDLK_F11)
813 SC(SDLK_F12)
814 
815 SC10(SDLK_PRINTSCREEN, SDLK_PRINT)
816 #if SDL_VERSION_ATLEAST(2,0,0)
818 #else
819 SC(SDLK_SCROLLOCK)
820 #endif
821 SC(SDLK_PAUSE)
823 SC(SDLK_HOME)
826 SC(SDLK_END)
828 SC(SDLK_RIGHT)
829 SC(SDLK_LEFT)
830 SC(SDLK_DOWN)
831 SC(SDLK_UP)
832 
833 SC10(SDLK_NUMLOCKCLEAR, SDLK_NUMLOCK)
839 SC10(SDLK_KP_1, SDLK_KP1)
840 SC10(SDLK_KP_2, SDLK_KP2)
841 SC10(SDLK_KP_3, SDLK_KP3)
842 SC10(SDLK_KP_4, SDLK_KP4)
843 SC10(SDLK_KP_5, SDLK_KP5)
844 SC10(SDLK_KP_6, SDLK_KP6)
845 SC10(SDLK_KP_7, SDLK_KP7)
846 SC10(SDLK_KP_8, SDLK_KP8)
847 SC10(SDLK_KP_9, SDLK_KP9)
848 SC10(SDLK_KP_0, SDLK_KP0)
850 
851 SC10(SDLK_APPLICATION, SDLK_COMPOSE)
852 SC(SDLK_POWER)
854 SC(SDLK_F13)
855 SC(SDLK_F14)
856 SC(SDLK_F15)
857 SC1(SDLK_F16)
858 SC1(SDLK_F17)
859 SC1(SDLK_F18)
860 SC1(SDLK_F19)
861 SC1(SDLK_F20)
862 SC1(SDLK_F21)
863 SC1(SDLK_F22)
864 SC1(SDLK_F23)
865 SC1(SDLK_F24)
867 SC(SDLK_HELP)
868 SC(SDLK_MENU)
870 SC10(SDLK_STOP, SDLK_BREAK)
872 SC(SDLK_UNDO)
873 SC1(SDLK_CUT)
874 SC1(SDLK_COPY)
876 SC1(SDLK_FIND)
877 SC1(SDLK_MUTE)
882 
886 SC(SDLK_CLEAR)
890 SC1(SDLK_OUT)
891 SC1(SDLK_OPER)
895 
908 SC1(SDLK_KP_A)
909 SC1(SDLK_KP_B)
910 SC1(SDLK_KP_C)
911 SC1(SDLK_KP_D)
912 SC1(SDLK_KP_E)
913 SC1(SDLK_KP_F)
942 
943 SC(SDLK_LCTRL)
945 SC(SDLK_LALT)
946 SC1(SDLK_LGUI)
947 SC0(SDLK_LMETA)
948 SC0(SDLK_LSUPER)
949 SC(SDLK_RCTRL)
951 SC(SDLK_RALT)
952 SC1(SDLK_RGUI)
953 SC0(SDLK_RMETA)
954 SC0(SDLK_RSUPER)
955 
956 SC(SDLK_MODE)
957 
964 SC1(SDLK_WWW)
965 SC1(SDLK_MAIL)
975 
984 
985 SC0(SDLK_EURO)
986 SC0(SDLK_WORLD_0)
987 SC0(SDLK_WORLD_1)
988 SC0(SDLK_WORLD_2)
989 SC0(SDLK_WORLD_3)
990 SC0(SDLK_WORLD_4)
991 SC0(SDLK_WORLD_5)
992 SC0(SDLK_WORLD_6)
993 SC0(SDLK_WORLD_7)
994 SC0(SDLK_WORLD_8)
995 SC0(SDLK_WORLD_9)
996 SC0(SDLK_WORLD_10)
997 SC0(SDLK_WORLD_11)
998 SC0(SDLK_WORLD_12)
999 SC0(SDLK_WORLD_13)
1000 SC0(SDLK_WORLD_14)
1001 SC0(SDLK_WORLD_15)
1002 SC0(SDLK_WORLD_16)
1003 SC0(SDLK_WORLD_17)
1004 SC0(SDLK_WORLD_18)
1005 SC0(SDLK_WORLD_19)
1006 SC0(SDLK_WORLD_20)
1007 SC0(SDLK_WORLD_21)
1008 SC0(SDLK_WORLD_22)
1009 SC0(SDLK_WORLD_23)
1010 SC0(SDLK_WORLD_24)
1011 SC0(SDLK_WORLD_25)
1012 SC0(SDLK_WORLD_26)
1013 SC0(SDLK_WORLD_27)
1014 SC0(SDLK_WORLD_28)
1015 SC0(SDLK_WORLD_29)
1016 SC0(SDLK_WORLD_30)
1017 SC0(SDLK_WORLD_31)
1018 SC0(SDLK_WORLD_32)
1019 SC0(SDLK_WORLD_33)
1020 SC0(SDLK_WORLD_34)
1021 SC0(SDLK_WORLD_35)
1022 SC0(SDLK_WORLD_36)
1023 SC0(SDLK_WORLD_37)
1024 SC0(SDLK_WORLD_38)
1025 SC0(SDLK_WORLD_39)
1026 SC0(SDLK_WORLD_40)
1027 SC0(SDLK_WORLD_41)
1028 SC0(SDLK_WORLD_42)
1029 SC0(SDLK_WORLD_43)
1030 SC0(SDLK_WORLD_44)
1031 SC0(SDLK_WORLD_45)
1032 SC0(SDLK_WORLD_46)
1033 SC0(SDLK_WORLD_47)
1034 SC0(SDLK_WORLD_48)
1035 SC0(SDLK_WORLD_49)
1036 SC0(SDLK_WORLD_50)
1037 SC0(SDLK_WORLD_51)
1038 SC0(SDLK_WORLD_52)
1039 SC0(SDLK_WORLD_53)
1040 SC0(SDLK_WORLD_54)
1041 SC0(SDLK_WORLD_55)
1042 SC0(SDLK_WORLD_56)
1043 SC0(SDLK_WORLD_57)
1044 SC0(SDLK_WORLD_58)
1045 SC0(SDLK_WORLD_59)
1046 SC0(SDLK_WORLD_60)
1047 SC0(SDLK_WORLD_61)
1048 SC0(SDLK_WORLD_62)
1049 SC0(SDLK_WORLD_63)
1050 SC0(SDLK_WORLD_64)
1051 SC0(SDLK_WORLD_65)
1052 SC0(SDLK_WORLD_66)
1053 SC0(SDLK_WORLD_67)
1054 SC0(SDLK_WORLD_68)
1055 SC0(SDLK_WORLD_69)
1056 SC0(SDLK_WORLD_70)
1057 SC0(SDLK_WORLD_71)
1058 SC0(SDLK_WORLD_72)
1059 SC0(SDLK_WORLD_73)
1060 SC0(SDLK_WORLD_74)
1061 SC0(SDLK_WORLD_75)
1062 SC0(SDLK_WORLD_76)
1063 SC0(SDLK_WORLD_77)
1064 SC0(SDLK_WORLD_78)
1065 SC0(SDLK_WORLD_79)
1066 SC0(SDLK_WORLD_80)
1067 SC0(SDLK_WORLD_81)
1068 SC0(SDLK_WORLD_82)
1069 SC0(SDLK_WORLD_83)
1070 SC0(SDLK_WORLD_84)
1071 SC0(SDLK_WORLD_85)
1072 SC0(SDLK_WORLD_86)
1073 SC0(SDLK_WORLD_87)
1074 SC0(SDLK_WORLD_88)
1075 SC0(SDLK_WORLD_89)
1076 SC0(SDLK_WORLD_90)
1077 SC0(SDLK_WORLD_91)
1078 SC0(SDLK_WORLD_92)
1079 SC0(SDLK_WORLD_93)
1080 SC0(SDLK_WORLD_94)
1081 SC0(SDLK_WORLD_95)
1082 
1083 #undef SC10
1084 #undef SC1
1085 #undef SC0
1086 #undef SC
1087 
1088 default: return "SDLK_UNKNOWN";
1089  }
1090  }
1091 #endif
1092 
1094  static Logo logo(Point2f(1.5f, 0.5f), 1.0f, Color(1.0f, 0.875f, 0.875f, 0.875f), Color(1.0f, 0.125f, 0.125f, 0.175f));
1095 
1096  get_Video().set_2d(std::make_pair(Point2f(), Point2f(4.0f, 2.0f)), true);
1097 
1098  logo.render();
1099  }
1100 
1102  }
1103 
1105  }
1106 
1108  }
1109 
1111  }
1112 
1114  if(m_state)
1115  m_state->decrement();
1116  }
1117 
1118 }
1119 
1120 #include <Zeni/Undefine.h>
Logo.
Definition: Logo.h:42
SDL_MouseMotionEvent motion
Definition: SDL_events.h:503
Mouse_State get_mouse_state() const
Find out if the mouse cursor is grabbed/hidden/relative.
Definition: Window.cpp:465
virtual void on_controller_axis(const SDL_ControllerAxisEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:115
Controllers & get_Controllers()
Get access to the singleton.
Definition: Controllers.cpp:59
SDL_ControllerAxisEvent caxis
Definition: SDL_events.h:511
The &quot;quit requested&quot; event.
Definition: SDL_events.h:447
Controller device event structure (event.cdevice.*)
Definition: SDL_events.h:373
virtual void render()
Then render. Called by Game as part of the main gameloop.
Definition: Gamestate.cpp:1093
virtual void on_video_expose(const SDL_ExposeEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:177
SDL_ControllerDeviceEvent cdevice
Definition: SDL_events.h:513
GLclampf f
Definition: glew.h:3390
virtual void on_quit(const SDL_QuitEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:124
static void change_resolution(const Point2i &resolution)
Definition: Video.cpp:366
static String to_text(const SDL_Keycode &sym)
Convert a sym to a text representation.
Definition: Gamestate.cpp:715
static SDL_Keycode to_sym(const String &text_version)
Convert a text representation to an actual sym.
Definition: Gamestate.cpp:338
bool get_key_state(const int &key) const
Get the state of a key.
Definition: Game.cpp:287
virtual void on_pop()
Called when the Gamestate is popped off the stack in Game.
Definition: Gamestate.cpp:1110
SDL_Keycode sym
Definition: SDL_pspevents.c:51
void enable(const bool &enable_)
Temporarily turn controller input on/off.
Definition: Controllers.cpp:92
void set_mouse_state(const Mouse_State &mouse_state)
Definition: Window.cpp:478
#define SC1(a)
The SDL keysym structure, used in key events.
Definition: SDL_keyboard.h:47
#define SC0(b)
void render()
Definition: Logo.cpp:63
Game controller axis motion event structure (event.caxis.*)
Definition: SDL_events.h:341
SDL_QuitEvent quit
Definition: SDL_events.h:514
virtual void on_system_wm_event(const SDL_SysWMEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:127
Sint32 SDL_Keycode
The SDL virtual key representation.
Definition: SDL_keycode.h:42
SDL_MouseWheelEvent wheel
Definition: SDL_events.h:505
Game & get_Game()
Get access to the singleton.
Definition: Game.cpp:58
The Gamestate Stack.
Definition: Game.h:71
static char to_char(const SDL_Keysym &ks)
Returns a character key corresponding to the current combination of keys pressed or the null characte...
Definition: Gamestate.cpp:184
virtual void on_key(const SDL_KeyboardEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:99
virtual void on_controller_device(const SDL_ControllerDeviceEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:121
void push_Popup_Pause_State()
Definition: Game.cpp:551
SDL_WindowEvent window
Definition: SDL_events.h:499
A user-defined event type (event.user.*)
Definition: SDL_events.h:465
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
virtual void on_controller_button(const SDL_ControllerButtonEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:118
void set_2d()
Set the default 2D view filling the entire display area.
Definition: Video.hxx:93
#define SC10(a, b)
virtual void on_mouse_motion(const SDL_MouseMotionEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:104
virtual void on_event(const SDL_Event &event)
First check for events. Called by Game as part of the main gameloop.
Definition: Gamestate.cpp:36
virtual void on_uncover()
Called when a Gamestate is popped off Game, making this Gamestate on top.
Definition: Gamestate.cpp:1107
SDL_Keysym keysym
Definition: SDL_events.h:185
static void save(const bool &backup=true)
Save options.
Definition: Video.cpp:389
#define SC(name)
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:251
Window state change event data (event.window.*)
Definition: SDL_events.h:160
Window & get_Window()
Get access to the singleton.
Definition: Window.cpp:392
Uint16 mod
Definition: SDL_keyboard.h:51
SDL_SysWMEvent syswm
Definition: SDL_events.h:516
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:218
Game controller button event structure (event.cbutton.*)
Definition: SDL_events.h:358
SDL_KeyboardEvent key
Definition: SDL_events.h:500
SDL_ControllerButtonEvent cbutton
Definition: SDL_events.h:512
Mouse button event structure (event.button.*)
Definition: SDL_events.h:234
A video driver dependent system event (event.syswm.*) This event is disabled by default, you can enable it with SDL_EventState()
Definition: SDL_events.h:485
virtual void on_active(const SDL_ActiveEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:143
virtual void on_user_event(const SDL_UserEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:181
SDL_Keycode sym
Definition: SDL_keyboard.h:50
SDL_MouseButtonEvent button
Definition: SDL_events.h:504
General event structure.
Definition: SDL_events.h:495
virtual void on_push()
Called when the Gamestate is pushed onto the stack in Game.
Definition: Gamestate.cpp:1101
SDL_UserEvent user
Definition: SDL_events.h:515
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
#define SDL_PRESSED
Definition: SDL_events.h:50
virtual void on_mouse_button(const SDL_MouseButtonEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:107
virtual void on_cover()
Called when a Gamestate is pushed on top of this Gamestate in Game.
Definition: Gamestate.cpp:1104
virtual void on_video_resize(const SDL_ResizeEvent &event)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Gamestate.cpp:170
A 2D Point represented with floats.
Definition: Coordinate.h:98
The Window Management Singleton.
Definition: Window.h:53
void push_Popup_Menu_State()
Definition: Game.cpp:547
Color.
Definition: Color.h:41
Uint32 type
Definition: SDL_events.h:497
cl_event event
Definition: glew.h:3556
A 2D Point represented with integers.
Definition: Coordinate.h:85