2 Copyright (C) 2004 Parallel Realities
3 Copyright (C) 2007 Kővágó Zoltán
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.
23 #include "gettext.hpp"
25 void showCheatConfig()
27 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
28 //graphics.delay(500);
30 SDL_Surface
*header
= graphics
.getSprite("cheatHeader", true)->image
[0];
31 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
32 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
34 if (!engine
.loadWidgets("data/cheatWidgets"))
36 graphics
.showErrorAndExit(ERR_FILE
, "data/cheatWidgets");
41 engine
.setWidgetVariable("health", &engine
.cheatHealth
);
42 engine
.setWidgetVariable("extras", &engine
.cheatExtras
);
43 engine
.setWidgetVariable("fuel", &engine
.cheatFuel
);
44 engine
.setWidgetVariable("rate", &engine
.cheatReload
);
45 engine
.setWidgetVariable("blood", &engine
.cheatBlood
);
46 engine
.setWidgetVariable("invulnerable", &engine
.cheatInvulnerable
);
47 engine
.setWidgetVariable("speed", &engine
.cheatSpeed
);
48 engine
.setWidgetVariable("levels", &engine
.cheatLevels
);
49 engine
.setWidgetVariable("skip", &engine
.cheatSkipLevel
);
50 engine
.setWidgetVariable("confirm", &done
);
52 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
53 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
63 graphics
.updateScreen();
66 audio
.playMenuSound(menuSound
);
70 menuSound
= engine
.processWidgets();
74 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
75 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
79 if (engine
.keyState
[SDLK_ESCAPE
])
89 audio
.playMenuSound(2);
91 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
92 //graphics.delay(500);
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
);
105 //graphics.delay(500);
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", &engine
.keyboard
.left
);
120 engine
.setWidgetVariable("right", &engine
.keyboard
.right
);
121 engine
.setWidgetVariable("down", &engine
.keyboard
.down
);
122 engine
.setWidgetVariable("fire", &engine
.keyboard
.fire
);
123 engine
.setWidgetVariable("jump", &engine
.keyboard
.jump
);
124 engine
.setWidgetVariable("pause", &engine
.keyboard
.pause
);
126 engine
.setWidgetVariable("jetpack", &engine
.keyboard
.jetpack
);
127 engine
.setWidgetVariable("map", &engine
.keyboard
.map
);
129 engine
.setWidgetVariable("defaults", &defaults
);
130 engine
.setWidgetVariable("confirm", &done
);
132 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
133 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
141 engine
.allowJoypad
= false;
145 graphics
.updateScreen();
149 audio
.playMenuSound(menuSound
);
154 menuSound
= engine
.processWidgets();
156 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
157 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
162 engine
.restoreKeyDefaults();
166 if (engine
.keyState
[SDLK_ESCAPE
])
176 engine
.allowJoypad
= true;
178 engine
.saveKeyConfig();
180 audio
.playMenuSound(2);
182 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
183 //graphics.delay(500);
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
);
196 //graphics.delay(500);
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));
207 engine
.setWidgetVariable("left", &engine
.joypad
.left
);
208 engine
.setWidgetVariable("right", &engine
.joypad
.right
);
209 engine
.setWidgetVariable("up", &engine
.joypad
.up
);
210 engine
.setWidgetVariable("down", &engine
.joypad
.down
);
211 engine
.setWidgetVariable("fire", &engine
.joypad
.fire
);
212 engine
.setWidgetVariable("jump", &engine
.joypad
.jump
);
213 engine
.setWidgetVariable("pause", &engine
.joypad
.pause
);
215 engine
.setWidgetVariable("jetpack", &engine
.joypad
.jetpack
);
216 engine
.setWidgetVariable("map", &engine
.joypad
.map
);
218 engine
.setWidgetVariable("confirm", &done
);
220 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
221 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
229 engine
.allowJoypad
= false;
233 graphics
.updateScreen();
236 audio
.playMenuSound(menuSound
);
240 menuSound
= engine
.processWidgets();
242 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
243 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
246 if (engine
.keyState
[SDLK_ESCAPE
])
256 engine
.allowJoypad
= true;
258 engine
.saveJoystickConfig();
260 audio
.playMenuSound(2);
262 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
263 //graphics.delay(500);
265 if (!engine
.loadWidgets("data/optionWidgets"))
267 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
270 engine
.highlightWidget("joysticks");
277 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
278 //graphics.delay(500);
280 if (!engine
.loadWidgets("data/optionWidgets"))
282 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
285 SDL_Surface
*header
= graphics
.getSprite("optionsHeader", true)->image
[0];
286 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
287 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
294 engine
.setWidgetVariable("fullscreen", &engine
.fullScreen
);
295 engine
.setWidgetVariable("soundvol", &game
.soundVol
);
296 engine
.setWidgetVariable("musicvol", &game
.musicVol
);
297 engine
.setWidgetVariable("output", &game
.output
);
298 engine
.setWidgetVariable("autosave", &game
.autoSave
);
299 engine
.setWidgetVariable("gamma", &game
.brightness
);
300 engine
.setWidgetVariable("gore", &game
.gore
);
301 engine
.setWidgetVariable("keys", &keys
);
302 engine
.setWidgetVariable("joysticks", &joysticks
);
303 engine
.setWidgetVariable("cheats", &cheats
);
304 engine
.setWidgetVariable("confirm", &done
);
306 if (!engine
.useAudio
)
308 engine
.enableWidget("soundvol", false);
309 engine
.enableWidget("musicvol", false);
310 engine
.enableWidget("output", false);
313 if (SDL_NumJoysticks() == 0)
315 engine
.enableWidget("joysticks", false);
318 engine
.showWidget("cheats", engine
.cheats
);
320 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
321 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
331 graphics
.updateScreen();
334 audio
.playMenuSound(menuSound
);
338 if (engine
.compareLastKeyInputs())
342 audio
.playSound(SND_CHEAT
, CH_ANY
);
343 engine
.clearCheatVars();
346 engine
.showWidget("cheats", engine
.cheats
);
350 menuSound
= engine
.processWidgets();
354 if (engine
.widgetChanged("soundvol"))
355 audio
.setSoundVolume(game
.soundVol
);
357 if (engine
.widgetChanged("musicvol"))
358 audio
.setMusicVolume(game
.musicVol
);
360 if (engine
.widgetChanged("fullscreen"))
361 SDL_WM_ToggleFullScreen(graphics
.screen
);
363 if (engine
.widgetChanged("gamma"))
365 brightness
= game
.brightness
;
366 if (brightness
> 0) {
368 SDL_SetGamma(brightness
, brightness
, brightness
);
372 if ((joysticks
) || (cheats
) || (keys
))
374 audio
.playMenuSound(2);
379 showJoystickConfig();
390 joysticks
= keys
= cheats
= 0;
392 engine
.setWidgetVariable("fullscreen", &engine
.fullScreen
);
393 engine
.setWidgetVariable("soundvol", &game
.soundVol
);
394 engine
.setWidgetVariable("musicvol", &game
.musicVol
);
395 engine
.setWidgetVariable("output", &game
.output
);
396 engine
.setWidgetVariable("autosave", &game
.autoSave
);
397 engine
.setWidgetVariable("gamma", &game
.brightness
);
398 engine
.setWidgetVariable("gore", &game
.gore
);
399 engine
.setWidgetVariable("keys", &keys
);
400 engine
.setWidgetVariable("joysticks", &joysticks
);
401 engine
.setWidgetVariable("cheats", &cheats
);
402 engine
.setWidgetVariable("confirm", &done
);
404 if (!engine
.useAudio
)
406 engine
.enableWidget("soundvol", false);
407 engine
.enableWidget("musicvol", false);
408 engine
.enableWidget("output", false);
411 if (SDL_NumJoysticks() == 0)
413 engine
.enableWidget("joysticks", false);
416 engine
.showWidget("cheats", engine
.cheats
);
419 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
420 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
424 if (engine
.keyState
[SDLK_ESCAPE
])
435 if (audio
.output
!= game
.output
)
437 audio
.output
= game
.output
;
442 audio
.stopAmbiance();
447 audio
.playAmbiance();
451 audio
.playMenuSound(2);
453 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
454 //graphics.delay(500);