Fixed a help font bug (was using normal fonts, instead of the small ones).
[supertux.git] / src / globals.cpp
1 //
2 // C Implementation: globals
3 //
4 // Description:
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #include "globals.h"
14
15 /** The datadir prefix prepended when loading game data file */
16 std::string datadir;
17
18 SDL_Surface * screen;
19 Text* black_text;
20 Text* gold_text;
21 Text* blue_text;
22 Text* red_text;
23 Text* yellow_nums;
24 Text* white_text;
25 Text* white_small_text;
26 Text* white_big_text;
27
28 MouseCursor * mouse_cursor;
29
30 bool use_gl;
31 bool use_joystick;
32 bool use_fullscreen;
33 bool debug_mode;
34 bool show_fps;
35 float game_speed = 1.0f;
36
37 int joystick_num = 0;
38 char* level_startup_file = 0;
39 bool launch_worldmap_mode = false;
40
41 /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
42 char *st_dir, *st_save_dir;
43
44 SDL_Joystick * js;
45
46 /* Returns 1 for every button event, 2 for a quit event and 0 for no event. */
47 int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_delay, bool empty_events)
48 {
49   int i;
50   Timer maxdelay;
51   Timer mindelay;
52   
53   maxdelay.init(false);
54   mindelay.init(false);
55
56   if(max_delay < min_delay)
57     max_delay = min_delay;
58
59   maxdelay.start(max_delay);
60   mindelay.start(min_delay);
61
62   if(empty_events)
63     while (SDL_PollEvent(&event))
64     {}
65
66   /* Handle events: */
67
68   for(i = 0; maxdelay.check() || !i; ++i)
69     {
70       while (SDL_PollEvent(&event))
71         {
72           if(!mindelay.check())
73             {
74               if (event.type == SDL_QUIT)
75                 {
76                   /* Quit event - quit: */
77                   return 2;
78                 }
79               else if (event.type == SDL_KEYDOWN)
80                 {
81                   /* Keypress - skip intro: */
82
83                   return 1;
84                 }
85               else if (event.type == SDL_JOYBUTTONDOWN)
86                 {
87                   /* Fire button - skip intro: */
88
89                   return 1;
90                 }
91               else if (event.type == SDL_MOUSEBUTTONDOWN)
92                 {
93                   /* Mouse button - skip intro: */
94                   return 1;
95                 }
96             }
97         }
98       SDL_Delay(10);
99     }
100
101   return 0;
102 }