1 /* 2 globals.h: 3 4 Global variables, #defines, #includes, and prototypes. 5 6 Copyright 2000, 2003, 2007, 2008, 2009, 2010. 7 Authors: Sam Hart, Jesse Andrews, David Bruce. 8 9 Project email: <tux4kids-tuxtype-dev@lists.alioth.debian.org> 10 Project website: http://tux4kids.alioth.debian.org 11 12 globals.h is part of Tux Typing, a.k.a "tuxtype". 13 14 Tux Typing is free software: you can redistribute it and/or modify 15 it under the terms of the GNU General Public License as published by 16 the Free Software Foundation; either version 3 of the License, or 17 (at your option) any later version. 18 19 Tux Typing is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program. If not, see <http://www.gnu.org/licenses/>. 26 */ 27 28 29 30 #ifndef GLOBALS_H 31 #define GLOBALS_H 32 33 // Autoheader-derived defs in here: 34 #include "config.h" 35 36 // C library includes: 37 #include <string.h> 38 #include <wchar.h> 39 #include <math.h> 40 #include <time.h> 41 #include <stdio.h> 42 #include <stdlib.h> 43 #include <sys/stat.h> 44 #include <dirent.h> 45 #include <locale.h> 46 47 // SDL includes: 48 #include "SDL.h" 49 #include "SDL_image.h" 50 #include "SDL_mixer.h" 51 /* NOTE only SDL_extras.c/.h now knows about SDL_ttf or SDL_Pango. */ 52 53 // Translation stuff: 54 #include "gettext.h" 55 #include <locale.h> 56 #include <iconv.h> 57 #include <libintl.h> 58 #define _(String) gettext (String) 59 #define gettext_noop(String) String 60 #define N_(String) gettext_noop (String) 61 62 63 /* FIXME don't think this is needed (done elsewhere) */ 64 #ifdef WIN32 65 #undef DATA_PREFIX 66 #define DATA_PREFIX "./data" 67 #endif 68 69 #ifdef WIN32 70 #define TUXLOCALE "./locale" 71 #else 72 #define TUXLOCALE LOCALEDIR 73 #endif 74 75 // FIXME if we really need these, make them into functions rather than 76 // "evil" macros 77 #define to_upper(c) (((c) >= 'a' && (c) <= 'z') ? (c) -32 : (c)) 78 #define COL2RGB( col ) SDL_MapRGB( screen->format, col->r, col->g, col->b ) 79 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 80 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 81 82 83 84 #define FNLEN 256 85 86 87 /* (renamed from 'settings' to match tuxmath) */ 88 typedef struct game_option_type{ 89 char default_data_path[FNLEN]; // for static read-only data 90 char theme_data_path[FNLEN]; // read-only data for current theme 91 char var_data_path[FNLEN]; // for modifiable shared data (custom word lists, etc.) 92 char user_settings_path[FNLEN]; // per-user settings (under /home) 93 char global_settings_path[FNLEN]; // settings for all users (under /etc) 94 char theme_name[FNLEN]; 95 char lang[FNLEN]; 96 char theme_font_name[FNLEN]; 97 char theme_locale_name[FNLEN]; 98 int use_english; 99 int fullscreen; 100 int sys_sound; 101 int sfx_volume; 102 int mus_volume; 103 int menu_music; 104 int menu_sound; 105 int speed_up; 106 int show_tux4kids; 107 int debug_on; 108 int o_lives; 109 int sound_vol; 110 int hidden; // Read the README file in the image directory for info on this ;) 111 } game_option_type; 112 113 114 /* Default values for game_option_type struct */ 115 /* They can be changed in the struct to other values at run-time */ 116 #define DEFAULT_FONT_NAME "AndikaDesRevG.ttf" 117 #define DEFAULT_GAME_FONT "AndikaDesRevG.ttf" 118 #define DEFAULT_MENU_FONT_SIZE 20 119 #define GAME_FONT_SIZE 20 120 #define DEFAULT_LOCALE "en_US.UTF-8" 121 #define DEFAULT_USE_ENGLISH 1 122 #define DEFAULT_FULLSCREEN 1 123 #define DEFAULT_SYS_SOUND 1 124 #define DEFAULT_SFX_VOLUME 100 125 #define DEFAULT_MUS_VOLUME 100 126 #define DEFAULT_MENU_MUSIC 1 127 #define DEFAULT_MENU_SOUND 1 128 #define DEFAULT_SPEED_UP 0 129 #define DEFAULT_SHOW_TUX4KIDS 1 130 #define DEFAULT_DEBUG_ON 0 131 #define DEFAULT_O_LIVES 0 132 #define DEFAULT_SOUND_VOL 100 133 #define DEFAULT_HIDDEN 0 134 135 136 /* Goal is to have all global settings here */ 137 /* FIXME get rid of as much global data as possible, esp. pointers */ 138 extern game_option_type settings; 139 extern SDL_Surface* screen; 140 extern SDL_Event event; 141 142 /* these will store the resolution used by the OS when we start, so we */ 143 /* can run fullscreen at the user's preferred resolution: */ 144 extern int fs_res_x; 145 extern int fs_res_y; 146 147 148 149 /* #defines for run-time debugging output: 150 * 151 * - Use LOG if you want to output a string LOG( "Hello World"); 152 * 153 * - Use DOUT if you want to output a value of a variable and the 154 * name of the variable gives enough context: 155 * DOUT( specialCode ); would add to stderr: "specialCode = 1\n" or 156 * whatever value specialCode had 157 * 158 * - Use DEBUGCODE if you need to do something more complicated like 159 * DEBUGCODE { fprintf(stderr, "examining letter %d\n", x); } 160 * since DOUT(x) "x = 1\n" gives little information since x is used 161 * all over the place! 162 */ 163 164 #define LOG( str ) if (settings.debug_on) fprintf( stderr, str ); 165 #define DEBUGCODE if (settings.debug_on) 166 #define DOUT(x) if (settings.debug_on) fprintf(stderr, "%s = %d\n", #x, x); 167 168 169 170 171 /* Various preprocessor constants: ------------------------- */ 172 173 174 #define RES_X 640 175 #define RES_Y 480 176 #define BPP 32 177 178 /* Limits on word list size, word length, and on the number of distinct characters */ 179 /* that can be present within a word list: */ 180 #define MAX_NUM_WORDS 500 181 #define MAX_WORD_SIZE 30 182 #define MAX_WORD_LISTS 100 183 #define MAX_UNICODES 1024 184 185 #define WAIT_MS 2500 186 #define FRAMES_PER_SEC 15 187 #define FULL_CIRCLE 140 188 189 190 /* Title sequence constants */ 191 #define PRE_ANIM_FRAMES 10 192 #define PRE_FRAME_MULT 3 193 #define MENU_SEP 20 194 195 196 #define IMG_REGULAR 0x01 197 #define IMG_COLORKEY 0x02 198 #define IMG_ALPHA 0x04 199 #define IMG_MODES 0x07 200 201 #define IMG_NOT_REQUIRED 0x10 202 #define IMG_NO_THEME 0x20 203 204 /* Values for menu button drawing: */ 205 #define REG_RGBA 16,16,96,96 206 #define SEL_RGBA 16,16,128,128 207 208 #define MUSIC_FADE_OUT_MS 80 209 210 /* Menu Prototypes */ 211 enum Game_Type { 212 QUIT_GAME, CASCADE, OPTIONS, LESSONS, 213 INSTRUCT_CASCADE, CASCADE1, CASCADE2, CASCADE3, CASCADE4, 214 INSTRUCT_LASER, LASER1, LASER2, LASER3, LASER4, 215 PHRASE_TYPING, ASDF, ALL, MAIN, SET_LANGUAGE, PROJECT_INFO, NOT_CODED, 216 LEVEL1, LEVEL2, LEVEL3, LEVEL4, LASER, INSTRUCT, EDIT_WORDLIST, NONE}; 217 218 //Game difficulty levels 219 enum { EASY, MEDIUM, HARD, INSANE, INF_PRACT }; 220 #define NUM_LEVELS 4 221 222 enum 223 { 224 WIN_WAV, 225 BITE_WAV, 226 LOSE_WAV, 227 RUN_WAV, 228 SPLAT_WAV, 229 WINFINAL_WAV, 230 EXCUSEME_WAV, 231 PAUSE_WAV, 232 NUM_WAVES 233 }; 234 235 236 /* For TransWipe(): */ 237 enum 238 { 239 WIPE_BLINDS_VERT, 240 WIPE_BLINDS_HORIZ, 241 WIPE_BLINDS_BOX, 242 RANDOM_WIPE, 243 NUM_WIPES 244 }; 245 246 #endif 247 248