1 /*
2    t4k_main.c
3    Functions used to initialize the t4k_common library
4 
5    Copyright 2009, 2010.
6    Authors: Boleslaw Kulbabinski Brendan Luchen
7    Project email: <tuxmath-devel@lists.sourceforge.net>
8    Project website: http://tux4kids.alioth.debian.org
9 
10 t4k_main.c is part of the t4k_common library.
11 
12 t4k_common is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
16 
17 t4k_common is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
24 
25 
26 
27 #include "t4k_common.h"
28 #include "t4k_globals.h"
29 int debug_status;
30 
31 
32 SDL_Color black;
33 SDL_Color gray;
34 SDL_Color dark_blue;
35 SDL_Color red;
36 SDL_Color white;
37 SDL_Color yellow;
38 SDL_Color bright_green;
39 
40 
41 /* set global variables */
42 /* TODO look into support for locale switching at runtime
43 ** http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490115
44 ** TODO seems like SDL_Init and friends should be done here...
45 **
46 */
InitT4KCommon(int debug_flags)47 void InitT4KCommon(int debug_flags)
48 {
49   printf("Initializing " PACKAGE_STRING "\n");
50 
51   debug_status = debug_flags;
52 
53   black.r       = 0x00; black.g       = 0x00; black.b       = 0x00;
54   red.r         = 0xff; red.g         = 0x00; red.b         = 0x00;
55   white.r       = 0xff; white.g       = 0xff; white.b       = 0xff;
56   yellow.r      = 0xff; yellow.g      = 0xff; yellow.b      = 0x00;
57 
58   T4K_InitBlitQueue();
59 }
60 
T4K_HandleStdEvents(const SDL_Event * event)61 int T4K_HandleStdEvents (const SDL_Event* event)
62 {
63   int ret = 0;
64 
65   if (event->type != SDL_KEYDOWN)
66     return 0;
67 
68   SDLKey key = event->key.keysym.sym;
69 
70   /* Toggle screen mode: */
71   if (key == SDLK_F10)
72   {
73 //    Opts_SetGlobalOpt(FULLSCREEN, !Opts_GetGlobalOpt(FULLSCREEN) );
74     T4K_SwitchScreenMode();
75 //    game_recalc_positions();
76     ret = 1;
77   }
78 
79   /* Toggle music: */
80 #ifndef NOSOUND
81   else if (key == SDLK_F11)
82   {
83     T4K_AudioToggle();
84   }
85 #endif
86 
87   return ret;
88 }
89