2 Copyright (C) 2004 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program 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.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 void showCheatConfig()
25 SDL_FillRect(graphics.screen, NULL, graphics.black);
28 SDL_Surface *header = graphics.getSprite("cheatHeader", true)->image[0];
29 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
30 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
32 if (!engine.loadWidgets(_("data/cheatWidgets")))
34 graphics.showErrorAndExit(ERR_FILE, _("data/cheatWidgets"));
39 engine.setWidgetVariable("health", &engine.cheatHealth);
40 engine.setWidgetVariable("extras", &engine.cheatExtras);
41 engine.setWidgetVariable("fuel", &engine.cheatFuel);
42 engine.setWidgetVariable("rate", &engine.cheatReload);
43 engine.setWidgetVariable("blood", &engine.cheatBlood);
44 engine.setWidgetVariable("invulnerable", &engine.cheatInvulnerable);
45 engine.setWidgetVariable("speed", &engine.cheatSpeed);
46 engine.setWidgetVariable("levels", &engine.cheatLevels);
47 engine.setWidgetVariable("skip", &engine.cheatSkipLevel);
48 engine.setWidgetVariable("confirm", &done);
50 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
51 graphics.blit(header, 320, 25, graphics.screen, true);
61 graphics.updateScreen();
64 audio.playMenuSound(menuSound);
69 menuSound = engine.processWidgets();
73 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
74 graphics.blit(header, 320, 25, graphics.screen, true);
78 if (engine.keyState[SDLK_ESCAPE])
88 audio.playMenuSound(2);
90 SDL_FillRect(graphics.screen, NULL, graphics.black);
93 if (!engine.loadWidgets(_("data/optionWidgets")))
95 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
98 engine.highlightWidget("cheats");
103 SDL_FillRect(graphics.screen, NULL, graphics.black);
106 if (!engine.loadWidgets(_("data/keyboardWidgets")))
108 graphics.showErrorAndExit(ERR_FILE, _("data/keyboardWidgets"));
111 SDL_Surface *header = graphics.getSprite("keyHeader", true)->image[0];
112 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
113 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
118 engine.setWidgetVariable("left", &config.keyboard.control[CONTROL::LEFT]);
119 engine.setWidgetVariable("right", &config.keyboard.control[CONTROL::RIGHT]);
120 engine.setWidgetVariable("down", &config.keyboard.control[CONTROL::DOWN]);
121 engine.setWidgetVariable("fire", &config.keyboard.control[CONTROL::FIRE]);
122 engine.setWidgetVariable("jump", &config.keyboard.control[CONTROL::JUMP]);
123 engine.setWidgetVariable("pause", &config.keyboard.control[CONTROL::PAUSE]);
125 engine.setWidgetVariable("jetpack", &config.keyboard.control[CONTROL::JETPACK]);
126 engine.setWidgetVariable("map", &config.keyboard.control[CONTROL::MAP]);
128 engine.setWidgetVariable("defaults", &defaults);
129 engine.setWidgetVariable("confirm", &done);
131 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
132 graphics.blit(header, 320, 25, graphics.screen, true);
140 engine.allowJoypad = false;
144 graphics.updateScreen();
148 audio.playMenuSound(menuSound);
154 menuSound = engine.processWidgets();
156 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
157 graphics.blit(header, 320, 25, graphics.screen, true);
162 config.restoreKeyDefaults();
166 if (engine.keyState[SDLK_ESCAPE])
176 engine.allowJoypad = true;
178 config.saveKeyConfig();
180 audio.playMenuSound(2);
182 SDL_FillRect(graphics.screen, NULL, graphics.black);
185 if (!engine.loadWidgets(_("data/optionWidgets")))
187 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
190 engine.highlightWidget("keys");
193 void showJoystickConfig()
195 SDL_FillRect(graphics.screen, NULL, graphics.black);
198 if (!engine.loadWidgets(_("data/joystickWidgets")))
199 graphics.showErrorAndExit(ERR_FILE, _("data/joystickWidgets"));
201 SDL_Surface *header = graphics.getSprite("joystickHeader", true)->image[0];
202 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
203 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
206 int sensitivity = (config.joystick.sensitivity / 100);
208 engine.setWidgetVariable("left", &config.joystick.control[CONTROL::LEFT]);
209 engine.setWidgetVariable("right", &config.joystick.control[CONTROL::RIGHT]);
210 engine.setWidgetVariable("up", &config.joystick.control[CONTROL::UP]);
211 engine.setWidgetVariable("down", &config.joystick.control[CONTROL::DOWN]);
212 engine.setWidgetVariable("fire", &config.joystick.control[CONTROL::FIRE]);
213 engine.setWidgetVariable("jump", &config.joystick.control[CONTROL::JUMP]);
214 engine.setWidgetVariable("pause", &config.joystick.control[CONTROL::PAUSE]);
216 engine.setWidgetVariable("jetpack", &config.joystick.control[CONTROL::JETPACK]);
217 engine.setWidgetVariable("map", &config.joystick.control[CONTROL::MAP]);
219 engine.setWidgetVariable("sensitivity", &sensitivity);
221 engine.setWidgetVariable("confirm", &done);
223 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
224 graphics.blit(header, 320, 25, graphics.screen, true);
232 engine.allowJoypad = false;
236 graphics.updateScreen();
239 audio.playMenuSound(menuSound);
244 menuSound = engine.processWidgets();
246 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
247 graphics.blit(header, 320, 25, graphics.screen, true);
250 if (engine.keyState[SDLK_ESCAPE])
260 config.joystick.sensitivity = (sensitivity * 100);
262 engine.allowJoypad = true;
264 config.saveJoystickConfig();
266 audio.playMenuSound(2);
268 SDL_FillRect(graphics.screen, NULL, graphics.black);
271 if (!engine.loadWidgets(_("data/optionWidgets")))
273 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
276 engine.highlightWidget("joysticks");
283 SDL_FillRect(graphics.screen, NULL, graphics.black);
286 if (!engine.loadWidgets(_("data/optionWidgets")))
288 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
291 SDL_Surface *header = graphics.getSprite("optionsHeader", true)->image[0];
292 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
293 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
300 engine.setWidgetVariable("fullscreen", &engine.fullScreen);
301 engine.setWidgetVariable("soundvol", &game.soundVol);
302 engine.setWidgetVariable("musicvol", &game.musicVol);
303 engine.setWidgetVariable("output", &game.output);
304 engine.setWidgetVariable("autosave", &game.autoSave);
305 engine.setWidgetVariable("gamma", &game.brightness);
306 engine.setWidgetVariable("gore", &game.gore);
307 engine.setWidgetVariable("keys", &keys);
308 engine.setWidgetVariable("joysticks", &joysticks);
309 engine.setWidgetVariable("cheats", &cheats);
310 engine.setWidgetVariable("confirm", &done);
312 if (!engine.useAudio)
314 engine.enableWidget("soundvol", false);
315 engine.enableWidget("musicvol", false);
316 engine.enableWidget("output", false);
319 if (SDL_NumJoysticks() == 0)
321 engine.enableWidget("joysticks", false);
324 engine.showWidget("cheats", engine.cheats);
326 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
327 graphics.blit(header, 320, 25, graphics.screen, true);
337 graphics.updateScreen();
340 audio.playMenuSound(menuSound);
345 if (engine.compareLastKeyInputs())
349 audio.playSound(SND_CHEAT, CH_ANY);
350 engine.clearCheatVars();
353 engine.showWidget("cheats", engine.cheats);
357 menuSound = engine.processWidgets();
361 if (engine.widgetChanged("soundvol"))
362 audio.setSoundVolume(game.soundVol);
364 if (engine.widgetChanged("musicvol"))
365 audio.setMusicVolume(game.musicVol);
367 if (engine.widgetChanged("fullscreen"))
368 SDL_WM_ToggleFullScreen(graphics.screen);
370 if (engine.widgetChanged("gamma"))
372 brightness = game.brightness;
373 if (brightness > 0) {
375 SDL_SetGamma(brightness, brightness, brightness);
379 if ((joysticks) || (cheats) || (keys))
381 audio.playMenuSound(2);
386 showJoystickConfig();
397 joysticks = keys = cheats = 0;
399 engine.setWidgetVariable("fullscreen", &engine.fullScreen);
400 engine.setWidgetVariable("soundvol", &game.soundVol);
401 engine.setWidgetVariable("musicvol", &game.musicVol);
402 engine.setWidgetVariable("output", &game.output);
403 engine.setWidgetVariable("autosave", &game.autoSave);
404 engine.setWidgetVariable("gamma", &game.brightness);
405 engine.setWidgetVariable("gore", &game.gore);
406 engine.setWidgetVariable("keys", &keys);
407 engine.setWidgetVariable("joysticks", &joysticks);
408 engine.setWidgetVariable("cheats", &cheats);
409 engine.setWidgetVariable("confirm", &done);
411 if (!engine.useAudio)
413 engine.enableWidget("soundvol", false);
414 engine.enableWidget("musicvol", false);
415 engine.enableWidget("output", false);
418 if (SDL_NumJoysticks() == 0)
420 engine.enableWidget("joysticks", false);
423 engine.showWidget("cheats", engine.cheats);
426 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
427 graphics.blit(header, 320, 25, graphics.screen, true);
431 if (engine.keyState[SDLK_ESCAPE])
442 if (audio.output != game.output)
444 audio.output = game.output;
449 audio.stopAmbiance();
454 audio.playAmbiance();
458 audio.playMenuSound(2);
460 SDL_FillRect(graphics.screen, NULL, graphics.black);