2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 void showCheatConfig()
26 SDL_FillRect(graphics.screen, NULL, graphics.black);
29 SDL_Surface *header = graphics.getSprite("cheatHeader", true)->image[0];
30 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
31 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
33 if (!engine.loadWidgets(_("data/cheatWidgets")))
35 graphics.showErrorAndExit(ERR_FILE, _("data/cheatWidgets"));
40 engine.setWidgetVariable("health", &engine.cheatHealth);
41 engine.setWidgetVariable("extras", &engine.cheatExtras);
42 engine.setWidgetVariable("fuel", &engine.cheatFuel);
43 engine.setWidgetVariable("rate", &engine.cheatReload);
44 engine.setWidgetVariable("blood", &engine.cheatBlood);
45 engine.setWidgetVariable("invulnerable", &engine.cheatInvulnerable);
46 engine.setWidgetVariable("speed", &engine.cheatSpeed);
47 engine.setWidgetVariable("levels", &engine.cheatLevels);
48 engine.setWidgetVariable("skip", &engine.cheatSkipLevel);
49 engine.setWidgetVariable("confirm", &done);
51 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
52 graphics.blit(header, 320, 25, graphics.screen, true);
62 graphics.updateScreen();
65 audio.playMenuSound(menuSound);
70 menuSound = engine.processWidgets();
74 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
75 graphics.blit(header, 320, 25, graphics.screen, true);
79 if (engine.keyState[SDL_SCANCODE_ESCAPE])
89 audio.playMenuSound(2);
91 SDL_FillRect(graphics.screen, NULL, graphics.black);
94 if (!engine.loadWidgets(_("data/optionWidgets")))
96 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
99 engine.highlightWidget("cheats");
104 SDL_FillRect(graphics.screen, NULL, graphics.black);
107 if (!engine.loadWidgets(_("data/keyboardWidgets")))
109 graphics.showErrorAndExit(ERR_FILE, _("data/keyboardWidgets"));
112 SDL_Surface *header = graphics.getSprite("keyHeader", true)->image[0];
113 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
114 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
119 engine.setWidgetVariable("left", &config.keyboard.control[CONTROL::LEFT]);
120 engine.setWidgetVariable("right", &config.keyboard.control[CONTROL::RIGHT]);
121 engine.setWidgetVariable("down", &config.keyboard.control[CONTROL::DOWN]);
122 engine.setWidgetVariable("fire", &config.keyboard.control[CONTROL::FIRE]);
123 engine.setWidgetVariable("jump", &config.keyboard.control[CONTROL::JUMP]);
124 engine.setWidgetVariable("pause", &config.keyboard.control[CONTROL::PAUSE]);
126 engine.setWidgetVariable("jetpack", &config.keyboard.control[CONTROL::JETPACK]);
127 engine.setWidgetVariable("map", &config.keyboard.control[CONTROL::MAP]);
129 engine.setWidgetVariable("defaults", &defaults);
130 engine.setWidgetVariable("confirm", &done);
132 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
133 graphics.blit(header, 320, 25, graphics.screen, true);
141 engine.allowJoypad = false;
145 graphics.updateScreen();
149 audio.playMenuSound(menuSound);
155 menuSound = engine.processWidgets();
157 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
158 graphics.blit(header, 320, 25, graphics.screen, true);
163 config.restoreKeyDefaults();
167 if (engine.keyState[SDL_SCANCODE_ESCAPE])
177 engine.allowJoypad = true;
179 config.saveKeyConfig();
181 audio.playMenuSound(2);
183 SDL_FillRect(graphics.screen, NULL, graphics.black);
186 if (!engine.loadWidgets(_("data/optionWidgets")))
188 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
191 engine.highlightWidget("keys");
194 void showJoystickConfig()
196 SDL_FillRect(graphics.screen, NULL, graphics.black);
199 if (!engine.loadWidgets(_("data/joystickWidgets")))
200 graphics.showErrorAndExit(ERR_FILE, _("data/joystickWidgets"));
202 SDL_Surface *header = graphics.getSprite("joystickHeader", true)->image[0];
203 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
204 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
207 int sensitivity = (config.joystick.sensitivity / 100);
209 engine.setWidgetVariable("left", &config.joystick.control[CONTROL::LEFT]);
210 engine.setWidgetVariable("right", &config.joystick.control[CONTROL::RIGHT]);
211 engine.setWidgetVariable("up", &config.joystick.control[CONTROL::UP]);
212 engine.setWidgetVariable("down", &config.joystick.control[CONTROL::DOWN]);
213 engine.setWidgetVariable("fire", &config.joystick.control[CONTROL::FIRE]);
214 engine.setWidgetVariable("jump", &config.joystick.control[CONTROL::JUMP]);
215 engine.setWidgetVariable("pause", &config.joystick.control[CONTROL::PAUSE]);
217 engine.setWidgetVariable("jetpack", &config.joystick.control[CONTROL::JETPACK]);
218 engine.setWidgetVariable("map", &config.joystick.control[CONTROL::MAP]);
220 engine.setWidgetVariable("sensitivity", &sensitivity);
222 engine.setWidgetVariable("confirm", &done);
224 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
225 graphics.blit(header, 320, 25, graphics.screen, true);
233 engine.allowJoypad = false;
237 graphics.updateScreen();
240 audio.playMenuSound(menuSound);
245 menuSound = engine.processWidgets();
247 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
248 graphics.blit(header, 320, 25, graphics.screen, true);
251 if (engine.keyState[SDL_SCANCODE_ESCAPE])
261 config.joystick.sensitivity = (sensitivity * 100);
263 engine.allowJoypad = true;
265 config.saveJoystickConfig();
267 audio.playMenuSound(2);
269 SDL_FillRect(graphics.screen, NULL, graphics.black);
272 if (!engine.loadWidgets(_("data/optionWidgets")))
274 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
277 engine.highlightWidget("joysticks");
284 SDL_FillRect(graphics.screen, NULL, graphics.black);
287 if (!engine.loadWidgets(_("data/optionWidgets")))
289 graphics.showErrorAndExit(ERR_FILE, _("data/optionWidgets"));
292 SDL_Surface *header = graphics.getSprite("optionsHeader", true)->image[0];
293 SDL_Surface *optionsBackground = graphics.getSprite("optionsBackground", true)->image[0];
294 SDL_SetColorKey(optionsBackground, 0, SDL_MapRGB(optionsBackground->format, 0, 0, 0));
301 engine.setWidgetVariable("fullscreen", &engine.fullScreen);
302 engine.setWidgetVariable("soundvol", &game.soundVol);
303 engine.setWidgetVariable("musicvol", &game.musicVol);
304 engine.setWidgetVariable("output", &game.output);
305 engine.setWidgetVariable("autosave", &game.autoSave);
306 engine.setWidgetVariable("gamma", &game.brightness);
307 engine.setWidgetVariable("gore", &game.gore);
308 engine.setWidgetVariable("keys", &keys);
309 engine.setWidgetVariable("joysticks", &joysticks);
310 engine.setWidgetVariable("cheats", &cheats);
311 engine.setWidgetVariable("confirm", &done);
313 if (!engine.useAudio)
315 engine.enableWidget("soundvol", false);
316 engine.enableWidget("musicvol", false);
317 engine.enableWidget("output", false);
320 if (SDL_NumJoysticks() == 0)
322 engine.enableWidget("joysticks", false);
325 engine.showWidget("cheats", engine.cheats);
327 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
328 graphics.blit(header, 320, 25, graphics.screen, true);
338 graphics.updateScreen();
341 audio.playMenuSound(menuSound);
346 if (engine.compareLastKeyInputs())
350 audio.playSound(SND_CHEAT, CH_ANY);
351 engine.clearCheatVars();
354 engine.showWidget("cheats", engine.cheats);
358 menuSound = engine.processWidgets();
362 if (engine.widgetChanged("soundvol"))
363 audio.setSoundVolume(game.soundVol);
365 if (engine.widgetChanged("musicvol"))
366 audio.setMusicVolume(game.musicVol);
368 if (engine.widgetChanged("fullscreen"))
369 SDL_SetWindowFullscreen(graphics.window, engine.fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
371 if (engine.widgetChanged("gamma"))
373 brightness = game.brightness;
374 if (brightness > 0) {
377 SDL_CalculateGammaRamp(brightness, ramp);
378 SDL_SetWindowGammaRamp(graphics.window, ramp, ramp, ramp);
382 if ((joysticks) || (cheats) || (keys))
384 audio.playMenuSound(2);
389 showJoystickConfig();
400 joysticks = keys = cheats = 0;
402 engine.setWidgetVariable("fullscreen", &engine.fullScreen);
403 engine.setWidgetVariable("soundvol", &game.soundVol);
404 engine.setWidgetVariable("musicvol", &game.musicVol);
405 engine.setWidgetVariable("output", &game.output);
406 engine.setWidgetVariable("autosave", &game.autoSave);
407 engine.setWidgetVariable("gamma", &game.brightness);
408 engine.setWidgetVariable("gore", &game.gore);
409 engine.setWidgetVariable("keys", &keys);
410 engine.setWidgetVariable("joysticks", &joysticks);
411 engine.setWidgetVariable("cheats", &cheats);
412 engine.setWidgetVariable("confirm", &done);
414 if (!engine.useAudio)
416 engine.enableWidget("soundvol", false);
417 engine.enableWidget("musicvol", false);
418 engine.enableWidget("output", false);
421 if (SDL_NumJoysticks() == 0)
423 engine.enableWidget("joysticks", false);
426 engine.showWidget("cheats", engine.cheats);
429 graphics.blit(optionsBackground, 0, 0, graphics.screen, false);
430 graphics.blit(header, 320, 25, graphics.screen, true);
434 if (engine.keyState[SDL_SCANCODE_ESCAPE])
445 if (audio.output != game.output)
447 audio.output = game.output;
452 audio.stopAmbiance();
457 audio.playAmbiance();
461 audio.playMenuSound(2);
463 SDL_FillRect(graphics.screen, NULL, graphics.black);