2 Copyright © 2004 Parallel Realities
3 Copyright © 2007-2008 Kővágó Zoltán <DirtY.iCE.hu@gmail.com>
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 #include "CGraphics.h"
25 #include "gettext.hpp"
28 void showCheatConfig()
30 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
31 //graphics.delay(500);
33 SDL_Surface
*header
= graphics
.getSprite("cheatHeader", true)->image
[0];
34 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
35 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
37 if (!engine
.loadWidgets("data/cheatWidgets"))
39 graphics
.showErrorAndExit(ERR_FILE
, "data/cheatWidgets");
44 engine
.setWidgetVariable("health", &engine
.cheatHealth
);
45 engine
.setWidgetVariable("extras", &engine
.cheatExtras
);
46 engine
.setWidgetVariable("fuel", &engine
.cheatFuel
);
47 engine
.setWidgetVariable("rate", &engine
.cheatReload
);
48 engine
.setWidgetVariable("blood", &engine
.cheatBlood
);
49 engine
.setWidgetVariable("invulnerable", &engine
.cheatInvulnerable
);
50 engine
.setWidgetVariable("speed", &engine
.cheatSpeed
);
51 engine
.setWidgetVariable("levels", &engine
.cheatLevels
);
52 engine
.setWidgetVariable("skip", &engine
.cheatSkipLevel
);
53 engine
.setWidgetVariable("no_out", &engine
.cheat_no_out
);
54 engine
.setWidgetVariable("confirm", &done
);
56 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
57 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
67 graphics
.updateScreen();
70 audio
.playMenuSound(menuSound
);
74 menuSound
= engine
.processWidgets();
78 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
79 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
83 if (engine
.keyState
[SDLK_ESCAPE
])
93 audio
.playMenuSound(2);
95 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
96 //graphics.delay(500);
98 if (!engine
.loadWidgets("data/optionWidgets"))
100 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
103 engine
.highlightWidget("cheats");
108 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
109 //graphics.delay(500);
111 if (!engine
.loadWidgets("data/keyboardWidgets"))
113 graphics
.showErrorAndExit(ERR_FILE
, "data/keyboardWidgets");
116 SDL_Surface
*header
= graphics
.getSprite("keyHeader", true)->image
[0];
117 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
118 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
123 engine
.setWidgetVariable("left", &engine
.keyboard
.left
);
124 engine
.setWidgetVariable("right", &engine
.keyboard
.right
);
125 engine
.setWidgetVariable("down", &engine
.keyboard
.down
);
126 engine
.setWidgetVariable("fire", &engine
.keyboard
.fire
);
127 engine
.setWidgetVariable("jump", &engine
.keyboard
.jump
);
128 engine
.setWidgetVariable("pause", &engine
.keyboard
.pause
);
130 engine
.setWidgetVariable("jetpack", &engine
.keyboard
.jetpack
);
131 engine
.setWidgetVariable("map", &engine
.keyboard
.map
);
133 engine
.setWidgetVariable("defaults", &defaults
);
134 engine
.setWidgetVariable("confirm", &done
);
136 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
137 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
145 engine
.allowJoypad
= false;
149 graphics
.updateScreen();
153 audio
.playMenuSound(menuSound
);
158 menuSound
= engine
.processWidgets();
160 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
161 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
166 engine
.restoreKeyDefaults();
170 if (engine
.keyState
[SDLK_ESCAPE
])
180 engine
.allowJoypad
= true;
182 engine
.saveKeyConfig();
184 audio
.playMenuSound(2);
186 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
187 //graphics.delay(500);
189 if (!engine
.loadWidgets("data/optionWidgets"))
191 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
194 engine
.highlightWidget("keys");
197 void showJoystickConfig()
199 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
200 //graphics.delay(500);
202 if (!engine
.loadWidgets("data/joystickWidgets"))
203 graphics
.showErrorAndExit(ERR_FILE
, "data/joystickWidgets");
205 SDL_Surface
*header
= graphics
.getSprite("joystickHeader", true)->image
[0];
206 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
207 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
211 engine
.setWidgetVariable("left", &engine
.joypad
.left
);
212 engine
.setWidgetVariable("right", &engine
.joypad
.right
);
213 engine
.setWidgetVariable("up", &engine
.joypad
.up
);
214 engine
.setWidgetVariable("down", &engine
.joypad
.down
);
215 engine
.setWidgetVariable("fire", &engine
.joypad
.fire
);
216 engine
.setWidgetVariable("jump", &engine
.joypad
.jump
);
217 engine
.setWidgetVariable("pause", &engine
.joypad
.pause
);
219 engine
.setWidgetVariable("jetpack", &engine
.joypad
.jetpack
);
220 engine
.setWidgetVariable("map", &engine
.joypad
.map
);
222 engine
.setWidgetVariable("confirm", &done
);
224 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
225 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
233 engine
.allowJoypad
= false;
237 graphics
.updateScreen();
240 audio
.playMenuSound(menuSound
);
244 menuSound
= engine
.processWidgets();
246 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
247 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
250 if (engine
.keyState
[SDLK_ESCAPE
])
260 engine
.allowJoypad
= true;
262 engine
.saveJoystickConfig();
264 audio
.playMenuSound(2);
266 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
267 //graphics.delay(500);
269 if (!engine
.loadWidgets("data/optionWidgets"))
271 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
274 engine
.highlightWidget("joysticks");
281 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
282 //graphics.delay(500);
284 if (!engine
.loadWidgets("data/optionWidgets"))
286 graphics
.showErrorAndExit(ERR_FILE
, "data/optionWidgets");
289 SDL_Surface
*header
= graphics
.getSprite("optionsHeader", true)->image
[0];
290 SDL_Surface
*optionsBackground
= graphics
.getSprite("optionsBackground", true)->image
[0];
291 SDL_SetColorKey(optionsBackground
, 0, SDL_MapRGB(optionsBackground
->format
, 0, 0, 0));
298 engine
.setWidgetVariable("fullscreen", &engine
.fullScreen
);
299 engine
.setWidgetVariable("soundvol", &game
.soundVol
);
300 engine
.setWidgetVariable("musicvol", &game
.musicVol
);
301 engine
.setWidgetVariable("output", &game
.output
);
302 engine
.setWidgetVariable("autosave", &game
.autoSave
);
303 engine
.setWidgetVariable("gamma", &game
.brightness
);
304 engine
.setWidgetVariable("gore", &game
.gore
);
305 engine
.setWidgetVariable("keys", &keys
);
306 engine
.setWidgetVariable("joysticks", &joysticks
);
307 engine
.setWidgetVariable("cheats", &cheats
);
308 engine
.setWidgetVariable("confirm", &done
);
310 if (!engine
.useAudio
)
312 engine
.enableWidget("soundvol", false);
313 engine
.enableWidget("musicvol", false);
314 engine
.enableWidget("output", false);
317 if (SDL_NumJoysticks() == 0)
319 engine
.enableWidget("joysticks", false);
322 engine
.showWidget("cheats", engine
.cheats
);
324 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
325 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
335 graphics
.updateScreen();
338 audio
.playMenuSound(menuSound
);
342 if (engine
.compareLastKeyInputs())
346 audio
.playSound(SND_CHEAT
, CH_ANY
);
347 engine
.clearCheatVars();
350 engine
.showWidget("cheats", engine
.cheats
);
354 menuSound
= engine
.processWidgets();
358 if (engine
.widgetChanged("soundvol"))
359 audio
.setSoundVolume(game
.soundVol
);
361 if (engine
.widgetChanged("musicvol"))
362 audio
.setMusicVolume(game
.musicVol
);
364 if (engine
.widgetChanged("fullscreen"))
365 SDL_WM_ToggleFullScreen(graphics
.screen
);
367 if (engine
.widgetChanged("gamma"))
369 brightness
= game
.brightness
;
370 if (brightness
> 0) {
372 SDL_SetGamma(brightness
, brightness
, brightness
);
376 if ((joysticks
) || (cheats
) || (keys
))
378 audio
.playMenuSound(2);
383 showJoystickConfig();
394 joysticks
= keys
= cheats
= 0;
396 engine
.setWidgetVariable("fullscreen", &engine
.fullScreen
);
397 engine
.setWidgetVariable("soundvol", &game
.soundVol
);
398 engine
.setWidgetVariable("musicvol", &game
.musicVol
);
399 engine
.setWidgetVariable("output", &game
.output
);
400 engine
.setWidgetVariable("autosave", &game
.autoSave
);
401 engine
.setWidgetVariable("gamma", &game
.brightness
);
402 engine
.setWidgetVariable("gore", &game
.gore
);
403 engine
.setWidgetVariable("keys", &keys
);
404 engine
.setWidgetVariable("joysticks", &joysticks
);
405 engine
.setWidgetVariable("cheats", &cheats
);
406 engine
.setWidgetVariable("confirm", &done
);
408 if (!engine
.useAudio
)
410 engine
.enableWidget("soundvol", false);
411 engine
.enableWidget("musicvol", false);
412 engine
.enableWidget("output", false);
415 if (SDL_NumJoysticks() == 0)
417 engine
.enableWidget("joysticks", false);
420 engine
.showWidget("cheats", engine
.cheats
);
423 graphics
.blit(optionsBackground
, bx
, by
, graphics
.screen
, false);
424 graphics
.blit(header
, bx
+ 320, by
+ 25, graphics
.screen
, true);
428 if (engine
.keyState
[SDLK_ESCAPE
])
439 if (audio
.output
!= game
.output
)
441 audio
.output
= game
.output
;
446 audio
.stopAmbiance();
451 audio
.playAmbiance();
455 audio
.playMenuSound(2);
457 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
458 //graphics.delay(500);