1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "backends/keymapper/action.h"
24 #include "backends/keymapper/hardware-input.h"
25 #include "backends/keymapper/keymap.h"
26 #include "backends/keymapper/keymapper.h"
27 
28 #include "common/keyboard.h"
29 
30 #include "asylum/views/menu.h"
31 
32 #include "asylum/resources/actor.h"
33 #include "asylum/resources/worldstats.h"
34 
35 #include "asylum/system/cursor.h"
36 #include "asylum/system/graphics.h"
37 #include "asylum/system/savegame.h"
38 #include "asylum/system/screen.h"
39 #include "asylum/system/text.h"
40 
41 #include "asylum/views/scene.h"
42 #include "asylum/views/video.h"
43 
44 #include "asylum/respack.h"
45 #include "asylum/staticres.h"
46 
47 #include "asylum/asylum.h"
48 
49 namespace Asylum {
50 
Menu(AsylumEngine * vm)51 Menu::Menu(AsylumEngine *vm): _vm(vm) {
52 	_initGame = false;
53 
54 	_activeScreen   = kMenuNone;
55 	_soundResourceId = kResourceNone;
56 	_musicResourceId = kResourceNone;
57 	_gameStarted = false;
58 	_currentIcon = kMenuNone;
59 	_selectedShortcutIndex = -1;
60 	_dword_455C74 = 0;
61 	_dword_455C78 = false;
62 	_dword_455C80 = false;
63 	_dword_455D4C = false;
64 	_dword_455D5C = false;
65 	_isEditingSavegameName = false;
66 	_testSoundsPlaying = false;
67 	_dword_456288 = 0;
68 	_caretBlink = 0;
69 	_startIndex = 0;
70 	_creditsFrameIndex = 0;
71 	_showMovie = false;
72 	memset(&_iconFrames, 0, sizeof(_iconFrames));
73 
74 	// Movies
75 	_movieCount = 0;
76 	_movieIndex = 0;
77 	memset(&_movieList, 0 , sizeof(_movieList));
78 
79 	// Savegames
80 	_prefixWidth = 0;
81 }
82 
83 //////////////////////////////////////////////////////////////////////////
84 // Loading and setup
85 //////////////////////////////////////////////////////////////////////////
show()86 void Menu::show() {
87 	getSharedData()->setFlag(kFlagSkipDrawScene, true);
88 	getScreen()->clear();
89 
90 	// Set ourselves as the current event handler
91 	_vm->switchEventHandler(this);
92 
93 	getSound()->stopAll();
94 
95 	_activeScreen = kMenuShowCredits;
96 	_soundResourceId = kResourceNone;
97 	_musicResourceId = kResourceNone;
98 	_gameStarted = false;
99 
100 	_startIndex = 480;
101 	_creditsFrameIndex = 0;
102 
103 	setup();
104 }
105 
setup()106 void Menu::setup() {
107 	getScreen()->clear();
108 	// Original fills the screen with black
109 
110 	getCursor()->hide();
111 
112 	getSharedData()->setFlag(kFlag1, true);
113 
114 	if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
115 		getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 32));
116 		getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 31));
117 		getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 31));
118 		getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 34),
119 		                                 MAKE_RESOURCE(kResourcePackShared, 35),
120 		                                 MAKE_RESOURCE(kResourcePackShared, 36),
121 		                                 MAKE_RESOURCE(kResourcePackShared, 37));
122 		getScreen()->selectTransTable(1);
123 
124 		_dword_455D4C = false;
125 		_dword_455D5C = false;
126 
127 		getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 56), false, Config.voiceVolume);
128 	} else {
129 		getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 25));
130 		getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
131 		getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 26));
132 		getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 27),
133 		                                 MAKE_RESOURCE(kResourcePackShared, 28),
134 		                                 MAKE_RESOURCE(kResourcePackShared, 29),
135 		                                 MAKE_RESOURCE(kResourcePackShared, 30));
136 		getScreen()->selectTransTable(1);
137 
138 		getSound()->playMusic(kResourceNone, 0);
139 		getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
140 	}
141 }
142 
leave()143 void Menu::leave() {
144 	_activeScreen = kMenuNone;
145 	getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
146 	getText()->loadFont(kFontYellow);
147 }
148 
switchFont(bool condition)149 void Menu::switchFont(bool condition) {
150 	getText()->loadFont((condition) ? kFontYellow : kFontBlue);
151 }
152 
closeCredits()153 void Menu::closeCredits() {
154 	getScreen()->clear();
155 	// Original fills the screen with black
156 
157 	getCursor()->show();
158 	getSharedData()->setFlag(kFlag1, false);
159 
160 	getText()->loadFont(kFontYellow);
161 	getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
162 	getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
163 	getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
164 	                                 MAKE_RESOURCE(kResourcePackShared, 19),
165 	                                 MAKE_RESOURCE(kResourcePackShared, 20),
166 	                                 MAKE_RESOURCE(kResourcePackShared, 21));
167 	getScreen()->selectTransTable(1);
168 
169 	getSound()->playMusic(kResourceNone, 0);
170 	getSound()->playMusic(_musicResourceId);
171 
172 	if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
173 		if (!_dword_455D4C) {
174 			_dword_455D4C = true;
175 			getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 56));
176 		}
177 	}
178 
179 	leave();
180 }
181 
findMousePosition()182 Menu::MenuScreen Menu::findMousePosition() {
183 	for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
184 		if (_vm->rectContains(&menuRects[i], getCursor()->position()))
185 			return (MenuScreen)i;
186 
187 	return kMenuNone;
188 }
189 
playTestSounds()190 void Menu::playTestSounds() {
191 	_testSoundsPlaying = true;
192 	getSound()->playSound(kAmbientSound, true, Config.ambientVolume);
193 	getSound()->playSound(kSfxSound, true, Config.sfxVolume);
194 	getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
195 }
196 
stopTestSounds()197 void Menu::stopTestSounds() {
198 	_testSoundsPlaying = false;
199 	getSound()->stop(kAmbientSound);
200 	getSound()->stop(kSfxSound);
201 	getSound()->stop(kVoiceSound);
202 }
203 
adjustMasterVolume(int32 delta) const204 void Menu::adjustMasterVolume(int32 delta) const {
205 	int32 *volume = NULL;
206 	int32 volumeIndex = 1;
207 
208 	do {
209 		switch (volumeIndex) {
210 		default:
211 			error("[Menu::adjustMasterVolume] Invalid volume index (%d)", volumeIndex);
212 
213 		case 1:
214 			volume = &Config.musicVolume;
215 			break;
216 
217 		case 2:
218 			volume = &Config.ambientVolume;
219 			break;
220 
221 		case 3:
222 			volume = &Config.sfxVolume;
223 			break;
224 
225 		case 4:
226 			volume = &Config.voiceVolume;
227 			break;
228 
229 		case 5:
230 			volume = &Config.movieVolume;
231 			break;
232 		}
233 
234 		// Adjust and normalize volume
235 		if (delta >= 0) {
236 			if (*volume < 0) {
237 				if (*volume == -9999)
238 					*volume = -5000;
239 
240 				*volume += 250;
241 
242 				if (*volume > 0)
243 					*volume = 0;
244 			}
245 		} else {
246 			if (*volume > -5000) {
247 				*volume -= 250;
248 
249 				if (*volume <= -5000)
250 					*volume = -9999;
251 			}
252 		}
253 
254 		++volumeIndex;
255 	} while (volumeIndex < 6);
256 }
257 
adjustTestVolume()258 void Menu::adjustTestVolume() {
259 	getSound()->setMusicVolume(Config.musicVolume);
260 	if ((Config.movieVolume / 250 + 20) <= 0)
261 		getSound()->playMusic(_musicResourceId);
262 
263 	if (getSound()->isPlaying(kAmbientSound))
264 		getSound()->setVolume(kAmbientSound, Config.ambientVolume);
265 	else if (_testSoundsPlaying)
266 		getSound()->playSound(kAmbientSound, true, Config.ambientVolume);
267 
268 	if (getSound()->isPlaying(kSfxSound))
269 		getSound()->setVolume(kSfxSound, Config.sfxVolume);
270 	else if (_testSoundsPlaying)
271 		getSound()->playSound(kSfxSound, true, Config.sfxVolume);
272 
273 	if (getSound()->isPlaying(kVoiceSound))
274 		getSound()->setVolume(kVoiceSound, Config.voiceVolume);
275 	else if (_testSoundsPlaying)
276 		getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
277 }
278 
setupMusic()279 void Menu::setupMusic() {
280 	getSound()->stopAll();
281 
282 	int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
283 
284 	if (index == kMusicStopped) {
285 		_soundResourceId = kResourceNone;
286 		_musicResourceId = MAKE_RESOURCE(kResourcePackShared, 39);
287 
288 		getSound()->playMusic(_musicResourceId);
289 	} else {
290 		_soundResourceId = kResourceNone;
291 		_musicResourceId = MAKE_RESOURCE(kResourcePackMusic, index);
292 	}
293 }
294 
adjustPerformance()295 void Menu::adjustPerformance() {
296 	// Original reinitialize sound to 11kHz for performance == 0, ikHz otherwise
297 	getSound()->stopAll();
298 	getSound()->playMusic(kResourceNone, 0);
299 	setupMusic();
300 
301 	int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
302 	if (index != kMusicStopped)
303 		getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index));
304 }
305 
getChapterName()306 Common::String Menu::getChapterName() {
307 	return Common::String::format("%s%2d", getText()->get(MAKE_RESOURCE(kResourcePackText, 1334)), chapterIndexes[getWorld()->chapter]);
308 }
309 
310 //////////////////////////////////////////////////////////////////////////
311 // Event Handler
312 //////////////////////////////////////////////////////////////////////////
handleEvent(const AsylumEvent & evt)313 bool Menu::handleEvent(const AsylumEvent &evt) {
314 	switch ((int32)evt.type) {
315 	default:
316 		break;
317 
318 	case EVENT_ASYLUM_INIT:
319 		return init();
320 
321 	case EVENT_ASYLUM_UPDATE:
322 		return update();
323 
324 	case EVENT_ASYLUM_MUSIC:
325 		return music();
326 
327 	case Common::EVENT_KEYDOWN:
328 		return key(evt);
329 
330 	case Common::EVENT_LBUTTONDOWN:
331 	case Common::EVENT_RBUTTONDOWN:
332 		return click(evt);
333 
334 	}
335 
336 	return false;
337 }
338 
init()339 bool Menu::init() {
340 	// TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
341 
342 	if (_showMovie) {
343 		_showMovie = false;
344 		getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
345 	} else {
346 		// Init the game if not already done
347 		if (!_initGame) {
348 			_initGame = true;
349 
350 			// The original also
351 			//  - load the config (this is done when constructing the config singleton).
352 			//  - initialize game structures (this is done in classes constructors)
353 			getSaveLoad()->loadMoviesViewed();
354 
355 			_showMovie = true;
356 
357 			// Play start video
358 			getVideo()->play(0, this);
359 
360 			// If no savegame is present, start the game directly
361 			if (!getSaveLoad()->hasSavegames()) {
362 				_vm->restart();
363 				return true;
364 			}
365 
366 			// The original preloads graphics
367 			getCursor()->show();
368 		}
369 
370 		_caretBlink = 0;
371 		_activeScreen = kMenuNone;
372 		_currentIcon = kMenuNone;
373 		_dword_455C74 = 0;
374 
375 		setupMusic();
376 
377 		getCursor()->hide();
378 		getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
379 	}
380 
381 	if (_gameStarted)
382 		getScene()->getActor()->stopWalking();
383 
384 	getScreen()->clear();
385 	getText()->loadFont(kFontYellow);
386 	getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
387 	getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
388 	getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
389 	                                 MAKE_RESOURCE(kResourcePackShared, 19),
390 	                                 MAKE_RESOURCE(kResourcePackShared, 20),
391 	                                 MAKE_RESOURCE(kResourcePackShared, 21));
392 	getScreen()->selectTransTable(1);
393 
394 	// Update the screen
395 	g_system->updateScreen();
396 
397 	getCursor()->show();
398 	return true;
399 }
400 
update()401 bool Menu::update() {
402 	uint32 ticks = _vm->getTick();
403 
404 	if (!getSharedData()->getFlag(kFlagRedraw)) {
405 		// The original clears the area where the eyes are
406 		//getScreen()->fillRect(260, 229, 119, 16, 0);
407 
408 		// Draw background
409 		getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, Common::Point(0, 0));
410 
411 		uint32 frameIndex = 0;
412 
413 		// Get the eye frame index
414 		if (!getCursor()->isHidden()) {
415 			Common::Point cursor = getCursor()->position();
416 
417 			if (cursor.x < 230 || cursor.x > 399 || cursor.y < 199 || cursor.y > 259)
418 				frameIndex = eyeFrameIndex[Actor::getAngle(Common::Point(320, 240), cursor)];
419 			else if (cursor.x >= 743 && cursor.x <= 743 && cursor.y >= 587 && cursor.y <= 602)
420 				frameIndex = 9;
421 		}
422 
423 		if (_activeScreen == kMenuNone) {
424 			// Draw eye
425 			getScreen()->draw(kEye, frameIndex, Common::Point(0, 0));
426 
427 			// Find mouse position
428 			MenuScreen icon = findMousePosition();
429 			if (icon != kMenuNone) {
430 				// Draw icon
431 				getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], Common::Point(0, 0));
432 				_iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
433 
434 				// Draw text
435 				getText()->drawCentered(Common::Point(menuRects[icon][0] - 5, menuRects[icon][3] + 5),
436 										menuRects[icon][2] - menuRects[icon][0],
437 										MAKE_RESOURCE(kResourcePackText, 1309 + icon));
438 
439 				if (!_dword_455C74 || _currentIcon != icon) {
440 					_dword_455C74 = true;
441 					_currentIcon = icon;
442 
443 					if (_soundResourceId
444 					 && getSound()->isPlaying(_soundResourceId)
445 					 && _soundResourceId != MAKE_RESOURCE(kResourcePackShared, icon + 44))
446 						getSound()->stopAll(_soundResourceId);
447 
448 					if (_soundResourceId != MAKE_RESOURCE(kResourcePackShared, icon + 44) || !getSound()->isPlaying(_soundResourceId)) {
449 						_soundResourceId = MAKE_RESOURCE(kResourcePackShared, icon + 44);
450 						getSound()->playSound(_soundResourceId, false, Config.voiceVolume);
451 					}
452 				}
453 			} else {
454 				_dword_455C74 = 0;
455 			}
456 		} else {
457 			getScreen()->drawTransparent(kEye, frameIndex, Common::Point(0, 0), kDrawFlagNone, 3);
458 
459 			// Draw icon
460 			getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], Common::Point(0, 0));
461 			_iconFrames[_activeScreen] = (_iconFrames[_activeScreen] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4));
462 		}
463 
464 		// Update current screen
465 		switch (_activeScreen) {
466 		default:
467 			break;
468 
469 		case kMenuNewGame:
470 			updateNewGame();
471 			break;
472 
473 		case kMenuLoadGame:
474 			updateLoadGame();
475 			break;
476 
477 		case kMenuSaveGame:
478 			updateSaveGame();
479 			break;
480 
481 		case kMenuDeleteGame:
482 			updateDeleteGame();
483 			break;
484 
485 		case kMenuViewMovies:
486 			updateViewMovies();
487 			break;
488 
489 		case kMenuQuitGame:
490 			updateQuitGame();
491 			break;
492 
493 		case kMenuTextOptions:
494 			updateTextOptions();
495 			break;
496 
497 		case kMenuAudioOptions:
498 			updateAudioOptions();
499 			break;
500 
501 		case kMenuSettings:
502 			updateSettings();
503 			break;
504 
505 		case kMenuKeyboardConfig:
506 			updateKeyboardConfig();
507 			break;
508 
509 		case kMenuShowCredits:
510 			updateShowCredits();
511 			break;
512 
513 		case kMenuReturnToGame:
514 			updateReturnToGame();
515 			break;
516 		}
517 
518 		// Ask for redraw
519 		getSharedData()->setFlag(kFlagRedraw, true);
520 	}
521 
522 	if (ticks > getSharedData()->getNextScreenUpdate()) {
523 		if (getSharedData()->getFlag(kFlagRedraw)) {
524 			getScreen()->copyBackBufferToScreen();
525 
526 			getSharedData()->setFlag(kFlagRedraw, false);
527 			getSharedData()->setNextScreenUpdate(ticks + 55);
528 		}
529 	}
530 
531 	return true;
532 }
533 
music()534 bool Menu::music() {
535 	if (_activeScreen == kMenuShowCredits
536 	 && _vm->isGameFlagSet(kGameFlagFinishGame)
537 	 && !_dword_455D5C
538 	 && !_dword_455D4C) {
539 		_dword_455D5C = true;
540 
541 		getSound()->playMusic(kResourceNone, 0);
542 		getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
543 
544 		return true;
545 	}
546 
547 	return false;
548 }
549 
key(const AsylumEvent & evt)550 bool Menu::key(const AsylumEvent &evt) {
551 	switch (_activeScreen) {
552 	default:
553 		break;
554 
555 	case kMenuSaveGame:
556 		keySaveGame(evt);
557 		break;
558 
559 	case kMenuKeyboardConfig:
560 		keyKeyboardConfig(evt);
561 		break;
562 
563 	case kMenuShowCredits:
564 		keyShowCredits();
565 		break;
566 	}
567 
568 	return true;
569 }
570 
click(const AsylumEvent & evt)571 bool Menu::click(const AsylumEvent &evt) {
572 	if (evt.type == Common::EVENT_RBUTTONDOWN
573 	 && _activeScreen == kMenuShowCredits) {
574 		 clickShowCredits();
575 		 return true;
576 	}
577 
578 	//////////////////////////////////////////////////////////////////////////
579 	// Handle clicks on sub-screens
580 	if (_activeScreen != kMenuNone) {
581 		switch (_activeScreen) {
582 		default:
583 			break;
584 
585 		case kMenuNewGame:
586 			clickNewGame();
587 			break;
588 
589 		case kMenuLoadGame:
590 			clickLoadGame();
591 			break;
592 
593 		case kMenuSaveGame:
594 			clickSaveGame();
595 			break;
596 
597 		case kMenuDeleteGame:
598 			clickDeleteGame();
599 			break;
600 
601 		case kMenuViewMovies:
602 			clickViewMovies();
603 			break;
604 
605 		case kMenuQuitGame:
606 			clickQuitGame();
607 			break;
608 
609 		case kMenuTextOptions:
610 			clickTextOptions();
611 			break;
612 
613 		case kMenuAudioOptions:
614 			clickAudioOptions();
615 			break;
616 
617 		case kMenuSettings:
618 			clickSettings();
619 			break;
620 
621 		case kMenuKeyboardConfig:
622 			clickKeyboardConfig();
623 			break;
624 
625 		case kMenuShowCredits:
626 			clickShowCredits();
627 			break;
628 
629 		case kMenuReturnToGame:
630 			clickReturnToGame();
631 			break;
632 		}
633 
634 		return true;
635 	}
636 
637 	//////////////////////////////////////////////////////////////////////////
638 	// Handle clicks on the main menu
639 	_activeScreen = findMousePosition();
640 	if (_activeScreen == kMenuNone)
641 		return true;
642 
643 	getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
644 	getText()->loadFont(kFontYellow);
645 
646 	switch (_activeScreen) {
647 	default:
648 		break;
649 
650 	case kMenuSaveGame:
651 		_isEditingSavegameName = false;
652 		// fallthrough
653 
654 	case kMenuLoadGame:
655 		_dword_455C80 = false;
656 		_dword_455C78 = false;
657 		_dword_456288 = 0;
658 		_startIndex = 0;
659 		getSaveLoad()->loadList();
660 		break;
661 
662 	case kMenuDeleteGame:
663 		_dword_455C80 = false;
664 		_startIndex = 0;
665 		getSaveLoad()->loadList();
666 		break;
667 
668 	case kMenuViewMovies:
669 		_showMovie = false;
670 		_dword_455C78 = false;
671 		_dword_456288 = 0;
672 		_startIndex = 0;
673 		_movieCount = getSaveLoad()->getMoviesViewed((int32 *)&_movieList);
674 		break;
675 
676 	case kMenuKeyboardConfig:
677 		_selectedShortcutIndex = -1;
678 		break;
679 
680 	case kMenuReturnToGame:
681 		if (!_gameStarted)
682 			break;
683 
684 		clickReturnToGame();
685 		break;
686 
687 	case kMenuShowCredits:
688 		_startIndex = 480;
689 		_creditsFrameIndex = 0;
690 		setup();
691 		break;
692 	}
693 
694 	return true;
695 }
696 
697 
698 //////////////////////////////////////////////////////////////////////////
699 // Update handlers
700 //////////////////////////////////////////////////////////////////////////
updateNewGame()701 void Menu::updateNewGame() {
702 	Common::Point cursor = getCursor()->position();
703 
704 	getText()->loadFont(kFontYellow);
705 
706 	// Begin new game
707 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1321));
708 
709 	// Yes
710 	switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) || cursor.y < 273 || cursor.y > (273 + 24));
711 	getText()->setPosition(Common::Point(247, 273));
712 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
713 
714 	// No
715 	switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323))) || cursor.y < 273 || cursor.y > (273 + 24));
716 	getText()->setPosition(Common::Point(369, 273));
717 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
718 }
719 
updateLoadGame()720 void Menu::updateLoadGame() {
721 	Common::Point cursor = getCursor()->position();
722 
723 	char text[100];
724 
725 	if (_dword_455C80) {
726 		getText()->loadFont(kFontYellow);
727 		getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1329));
728 
729 		snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
730 		getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
731 
732 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
733 		 || cursor.y < 273 || cursor.y > (273 + 24))
734 			getText()->loadFont(kFontYellow);
735 		else
736 			getText()->loadFont(kFontBlue);
737 
738 		getText()->setPosition(Common::Point(247, 273));
739 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1330));
740 
741 		if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1331)))
742 		 || cursor.y < 273 || cursor.y > (273 + 24))
743 			getText()->loadFont(kFontYellow);
744 		else
745 			getText()->loadFont(kFontBlue);
746 
747 		getText()->setPosition(Common::Point(369, 273));
748 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1331));
749 		return;
750 	}
751 
752 	getText()->loadFont(kFontYellow);
753 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1325));
754 
755 	if (_dword_455C78) {
756 		getText()->drawCentered(Common::Point(10,      190), 620, MAKE_RESOURCE(kResourcePackText, 1332));
757 		getText()->drawCentered(Common::Point(10, 190 + 29), 620, MAKE_RESOURCE(kResourcePackText, 1333));
758 		getText()->drawCentered(Common::Point(10, 190 + 53), 620, getSaveLoad()->getName()->c_str());
759 
760 		++_dword_456288;
761 
762 		if (_dword_456288 == 60) {
763 			_dword_456288 = 0;
764 			_dword_455C78 = false;
765 			getCursor()->show();
766 		} else if (_dword_456288 == 1) {
767 			getCursor()->hide();
768 		}
769 	} else {
770 		//////////////////////////////////////////////////////////////////////////
771 		// First column
772 		int32 index = 0;
773 		for (int16 y = 150; y < 324; y += 29) {
774 			if (index + _startIndex >= 25)
775 				break;
776 
777 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
778 
779 			if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
780 			 || cursor.y < y  || cursor.y > (y + 24))
781 				getText()->loadFont(kFontYellow);
782 			else
783 				getText()->loadFont(kFontBlue);
784 
785 			getText()->setPosition(Common::Point(30, y));
786 			getText()->draw((char *)&text);
787 
788 			++index;
789 		}
790 
791 		//////////////////////////////////////////////////////////////////////////
792 		// Second column
793 		for (int16 y = 150; y < 324; y += 29) {
794 			if (index + _startIndex >= 25)
795 				break;
796 
797 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
798 
799 			if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
800 				|| cursor.y < y   || cursor.y > (y + 24))
801 				getText()->loadFont(kFontYellow);
802 			else
803 				getText()->loadFont(kFontBlue);
804 
805 			getText()->setPosition(Common::Point(350, y));
806 			getText()->draw((char *)&text);
807 
808 			++index;
809 		}
810 	}
811 
812 	//////////////////////////////////////////////////////////////////////////
813 	// Previous page
814 	if (cursor.x < 30  || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1326)))
815 	 || cursor.y < 340 || cursor.y > (340 + 24))
816 		getText()->loadFont(kFontYellow);
817 	else
818 		getText()->loadFont(kFontBlue);
819 
820 	getText()->setPosition(Common::Point(30, 340));
821 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1326));
822 
823 	//////////////////////////////////////////////////////////////////////////
824 	// Main menu
825 	if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1328)))
826 	 || cursor.y < 340 || cursor.y > (340 + 24))
827 		getText()->loadFont(kFontYellow);
828 	else
829 		getText()->loadFont(kFontBlue);
830 
831 	getText()->setPosition(Common::Point(300, 340));
832 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1328));
833 
834 	//////////////////////////////////////////////////////////////////////////
835 	// Next page
836 	if (cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1327)))
837 	 || cursor.y < 340 || cursor.y > (340 + 24))
838 		getText()->loadFont(kFontYellow);
839 	else
840 		getText()->loadFont(kFontBlue);
841 
842 	getText()->setPosition(Common::Point(550, 340));
843 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1327));
844 }
845 
updateSaveGame()846 void Menu::updateSaveGame() {
847 	Common::Point cursor = getCursor()->position();
848 
849 	char text[100];
850 
851 	if (_dword_455C80) {
852 		getText()->loadFont(kFontYellow);
853 		getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1339));
854 
855 		snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
856 		getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
857 
858 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
859 		 || cursor.y < 273 || cursor.y > (273 + 24))
860 			getText()->loadFont(kFontYellow);
861 		else
862 			getText()->loadFont(kFontBlue);
863 
864 		getText()->setPosition(Common::Point(247, 273));
865 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1340));
866 
867 		if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
868 		 || cursor.y < 273 || cursor.y > (273 + 24))
869 			getText()->loadFont(kFontYellow);
870 		else
871 			getText()->loadFont(kFontBlue);
872 
873 		getText()->setPosition(Common::Point(369, 273));
874 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1341));
875 		return;
876 	}
877 
878 	getText()->loadFont(kFontYellow);
879 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1335));
880 
881 	if (_dword_455C78) {
882 		getText()->drawCentered(Common::Point(10,      220), 620, MAKE_RESOURCE(kResourcePackText, 1343));
883 		getText()->drawCentered(Common::Point(10, 220 + 29), 620, getSaveLoad()->getName()->c_str());
884 
885 		++_dword_456288;
886 
887 		if (_dword_456288 == 30) {
888 			_dword_456288 = 0;
889 			_dword_455C78 = false;
890 			getCursor()->show();
891 		}
892 	} else {
893 		//////////////////////////////////////////////////////////////////////////
894 		// First column
895 		int32 index = 0;
896 		for (int16 y = 150; y < 324; y += 29) {
897 			if (index + _startIndex >= 25)
898 				break;
899 
900 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
901 
902 			if (!_isEditingSavegameName) {
903 				if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
904 				 || cursor.y < y  || cursor.y > (y + 24))
905 					getText()->loadFont(kFontYellow);
906 				else
907 					getText()->loadFont(kFontBlue);
908 			} else {
909 				if (getSaveLoad()->getIndex() != (uint32)(index + _startIndex))
910 					getText()->loadFont(kFontYellow);
911 				else
912 					getText()->loadFont(kFontBlue);
913 			}
914 
915 			getText()->setPosition(Common::Point(30, y));
916 			getText()->draw((char *)&text);
917 
918 			// Draw underscore
919 			if (_isEditingSavegameName) {
920 				if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
921 					if (_caretBlink < 6)
922 						getText()->drawChar('_');
923 
924 					_caretBlink = (_caretBlink + 1) % 12;
925 				}
926 			}
927 
928 			++index;
929 		}
930 
931 		//////////////////////////////////////////////////////////////////////////
932 		// Second column
933 		for (int16 y = 150; y < 324; y += 29) {
934 			if (index + _startIndex >= 25)
935 				break;
936 
937 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
938 
939 			if (!_isEditingSavegameName) {
940 				if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
941 				 || cursor.y < y   || cursor.y > (y + 24))
942 					getText()->loadFont(kFontYellow);
943 				else
944 					getText()->loadFont(kFontBlue);
945 			} else {
946 				if (getSaveLoad()->getIndex() != (uint32)(index + _startIndex))
947 					getText()->loadFont(kFontYellow);
948 				else
949 					getText()->loadFont(kFontBlue);
950 			}
951 
952 			getText()->setPosition(Common::Point(350, y));
953 			getText()->draw((char *)&text);
954 
955 			// Draw underscore
956 			if (_isEditingSavegameName) {
957 				if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
958 					if (_caretBlink < 6)
959 						getText()->drawChar('_');
960 
961 					_caretBlink = (_caretBlink + 1) % 12;
962 				}
963 			}
964 
965 			++index;
966 		}
967 	}
968 
969 	//////////////////////////////////////////////////////////////////////////
970 	// Previous page
971 	if (getCursor()->isHidden()
972 	 || cursor.x < 30  || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1336)))
973 	 || cursor.y < 340 || cursor.y > (340 + 24))
974 		getText()->loadFont(kFontYellow);
975 	else
976 		getText()->loadFont(kFontBlue);
977 
978 	getText()->setPosition(Common::Point(30, 340));
979 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1336));
980 
981 	//////////////////////////////////////////////////////////////////////////
982 	// Main menu
983 	if (getCursor()->isHidden()
984 	 || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1338)))
985 	 || cursor.y < 340 || cursor.y > (340 + 24))
986 		getText()->loadFont(kFontYellow);
987 	else
988 		getText()->loadFont(kFontBlue);
989 
990 	getText()->setPosition(Common::Point(300, 340));
991 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1338));
992 
993 	//////////////////////////////////////////////////////////////////////////
994 	// Next page
995 	if (getCursor()->isHidden()
996 	 || cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1337)))
997 	 || cursor.y < 340 || cursor.y > (340 + 24))
998 		getText()->loadFont(kFontYellow);
999 	else
1000 		getText()->loadFont(kFontBlue);
1001 
1002 	getText()->setPosition(Common::Point(550, 340));
1003 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1337));
1004 }
1005 
updateDeleteGame()1006 void Menu::updateDeleteGame() {
1007 	Common::Point cursor = getCursor()->position();
1008 
1009 	char text[100];
1010 
1011 	if (_dword_455C80) {
1012 		getText()->loadFont(kFontYellow);
1013 		getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1349));
1014 
1015 		snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
1016 		getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
1017 
1018 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
1019 		 || cursor.y < 273 || cursor.y > (273 + 24))
1020 			getText()->loadFont(kFontYellow);
1021 		else
1022 			getText()->loadFont(kFontBlue);
1023 
1024 		getText()->setPosition(Common::Point(247, 273));
1025 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1350));
1026 
1027 		if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
1028 		 || cursor.y < 273 || cursor.y > (273 + 24))
1029 			getText()->loadFont(kFontYellow);
1030 		else
1031 			getText()->loadFont(kFontBlue);
1032 
1033 		getText()->setPosition(Common::Point(369, 273));
1034 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1351));
1035 		return;
1036 	}
1037 
1038 	getText()->loadFont(kFontYellow);
1039 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1345));
1040 
1041 	//////////////////////////////////////////////////////////////////////////
1042 	// First column
1043 	int32 index = 0;
1044 	for (int16 y = 150; y < 324; y += 29) {
1045 		if (index + _startIndex >= 25)
1046 			break;
1047 
1048 		snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
1049 
1050 		if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
1051 		 || cursor.y < y  || cursor.y > (y + 24))
1052 			getText()->loadFont(kFontYellow);
1053 		else
1054 			getText()->loadFont(kFontBlue);
1055 
1056 		getText()->setPosition(Common::Point(30, y));
1057 		getText()->draw((char *)&text);
1058 
1059 		++index;
1060 	}
1061 
1062 	//////////////////////////////////////////////////////////////////////////
1063 	// Second column
1064 	for (int16 y = 150; y < 324; y += 29) {
1065 		if (index + _startIndex >= 25)
1066 			break;
1067 
1068 		snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
1069 
1070 		if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
1071 		 || cursor.y < y   || cursor.y > (y + 24))
1072 			getText()->loadFont(kFontYellow);
1073 		else
1074 			getText()->loadFont(kFontBlue);
1075 
1076 		getText()->setPosition(Common::Point(350, y));
1077 		getText()->draw((char *)&text);
1078 
1079 		++index;
1080 	}
1081 
1082 	//////////////////////////////////////////////////////////////////////////
1083 	// Previous page
1084 	if (cursor.x < 30  || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
1085 	 || cursor.y < 340 || cursor.y > (340 + 24))
1086 		getText()->loadFont(kFontYellow);
1087 	else
1088 		getText()->loadFont(kFontBlue);
1089 
1090 	getText()->setPosition(Common::Point(30, 340));
1091 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1346));
1092 
1093 	//////////////////////////////////////////////////////////////////////////
1094 	// Main menu
1095 	if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1348)))
1096 	 || cursor.y < 340 || cursor.y > (340 + 24))
1097 		getText()->loadFont(kFontYellow);
1098 	else
1099 		getText()->loadFont(kFontBlue);
1100 
1101 	getText()->setPosition(Common::Point(300, 340));
1102 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1348));
1103 
1104 	//////////////////////////////////////////////////////////////////////////
1105 	// Next page
1106 	if (cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
1107 	 || cursor.y < 340 || cursor.y > (340 + 24))
1108 		getText()->loadFont(kFontYellow);
1109 	else
1110 		getText()->loadFont(kFontBlue);
1111 
1112 	getText()->setPosition(Common::Point(550, 340));
1113 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1347));
1114 }
1115 
updateViewMovies()1116 void Menu::updateViewMovies() {
1117 	Common::Point cursor = getCursor()->position();
1118 
1119 	char text[100];
1120 	char text2[100];
1121 
1122 	if (!_dword_455C78) {
1123 		getText()->loadFont(kFontYellow);
1124 		snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
1125 		getText()->drawCentered(Common::Point(10, 100), 620, (char *)&text2);
1126 
1127 		//////////////////////////////////////////////////////////////////////////
1128 		// First column
1129 		int32 index = _startIndex;
1130 		for (int16 y = 150; y < 324; y += 29) {
1131 			if (index >= ARRAYSIZE(_movieList))
1132 				break;
1133 
1134 			if (_movieList[index] != -1) {
1135 				snprintf((char *)&text, sizeof(text), "%d. %s", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
1136 				snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
1137 				strcat((char *)&text, (char *)&text2);
1138 
1139 				if (getCursor()->isHidden()
1140 				 || cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
1141 				 || cursor.y < y || cursor.y > (y + 24))
1142 					getText()->loadFont(kFontYellow);
1143 				else
1144 					getText()->loadFont(kFontBlue);
1145 
1146 				getText()->setPosition(Common::Point(30, y));
1147 				getText()->draw((char *)&text);
1148 			}
1149 
1150 			++index;
1151 		}
1152 
1153 		//////////////////////////////////////////////////////////////////////////
1154 		// Second column
1155 		for (int16 y = 150; y < 324; y += 29) {
1156 			if (index >= ARRAYSIZE(_movieList))
1157 				break;
1158 
1159 			if (_movieList[index] != -1) {
1160 				snprintf((char *)&text, sizeof(text), "%d. %s", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
1161 				snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
1162 				strcat((char *)&text, (char *)&text2);
1163 
1164 				if (getCursor()->isHidden()
1165 					|| cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
1166 					|| cursor.y < y || cursor.y > (y + 24))
1167 					getText()->loadFont(kFontYellow);
1168 				else
1169 					getText()->loadFont(kFontBlue);
1170 
1171 				getText()->setPosition(Common::Point(350, y));
1172 				getText()->draw((char *)&text);
1173 			}
1174 
1175 			index++;
1176 		}
1177 
1178 		//////////////////////////////////////////////////////////////////////////
1179 		// Previous page
1180 		if (getCursor()->isHidden()
1181 			|| cursor.x < 30 || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1353)))
1182 			|| cursor.y < 340 || cursor.y > (340 + 24))
1183 			getText()->loadFont(kFontYellow);
1184 		else
1185 			getText()->loadFont(kFontBlue);
1186 
1187 		getText()->setPosition(Common::Point(30, 340));
1188 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353));
1189 
1190 		//////////////////////////////////////////////////////////////////////////
1191 		// Main Menu
1192 		if (getCursor()->isHidden()
1193 		 || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1355)))
1194 		 || cursor.y < 340 || cursor.y > (340 + 24))
1195 			getText()->loadFont(kFontYellow);
1196 		else
1197 			getText()->loadFont(kFontBlue);
1198 
1199 		getText()->setPosition(Common::Point(300, 340));
1200 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355));
1201 
1202 		//////////////////////////////////////////////////////////////////////////
1203 		// Next Page
1204 		if (getCursor()->isHidden()
1205 		 || cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1354)))
1206 		 || cursor.y < 340 || cursor.y > (340 + 24))
1207 			getText()->loadFont(kFontYellow);
1208 		else
1209 			getText()->loadFont(kFontBlue);
1210 
1211 		getText()->setPosition(Common::Point(550, 340));
1212 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354));
1213 
1214 		//////////////////////////////////////////////////////////////////////////
1215 		// Play video if needed
1216 		if (_showMovie) {
1217 			getSound()->playMusic(0, 0);
1218 
1219 			getVideo()->play(_movieIndex, this);
1220 
1221 			getSound()->playMusic(_musicResourceId);
1222 		}
1223 
1224 		return;
1225 	}
1226 
1227 	getText()->loadFont(kFontYellow);
1228 	snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
1229 	getText()->drawCentered(Common::Point(10, 100), 620, text2);
1230 
1231 	strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieIndex)));
1232 	snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieIndex]);
1233 	strcat((char *)&text, (char *)&text2);
1234 	getText()->drawCentered(Common::Point(10, 134), 620, text);
1235 
1236 	getText()->drawCentered(Common::Point(10, 168), 620, getText()->get(MAKE_RESOURCE(kResourcePackText, 1358)));
1237 
1238 	++_dword_456288;
1239 	if (_dword_456288 == 90) {
1240 		_dword_456288 = 0;
1241 		_dword_455C78 = false;
1242 
1243 		getCursor()->show();
1244 	}
1245 }
1246 
updateQuitGame()1247 void Menu::updateQuitGame() {
1248 	Common::Point cursor = getCursor()->position();
1249 
1250 	getText()->loadFont(kFontYellow);
1251 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1408));
1252 
1253 	// Yes
1254 	switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) || cursor.y < 273 || cursor.y > (273 + 24));
1255 	getText()->setPosition(Common::Point(247, 273));
1256 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
1257 
1258 	// No
1259 	switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410))) || cursor.y < 273 || cursor.y > (273 + 24));
1260 	getText()->setPosition(Common::Point(369, 273));
1261 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
1262 }
1263 
updateTextOptions()1264 void Menu::updateTextOptions() {
1265 	Common::Point cursor = getCursor()->position();
1266 
1267 	getText()->loadFont(kFontYellow);
1268 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1411));
1269 
1270 	getText()->draw(Common::Point(320, 150), MAKE_RESOURCE(kResourcePackText, 1412));
1271 
1272 	switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174);
1273 	getText()->setPosition(Common::Point(350, 150));
1274 	getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415));
1275 
1276 	getText()->loadFont(kFontYellow);
1277 	getText()->draw(Common::Point(320, 179), MAKE_RESOURCE(kResourcePackText, 1413));
1278 
1279 	switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415))) || cursor.y < 179 || cursor.y > 203);
1280 	getText()->setPosition(Common::Point(350, 179));
1281 	getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415));
1282 
1283 	switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) || cursor.y < 340 || cursor.y > (340 + 24));
1284 	getText()->setPosition(Common::Point(300, 340));
1285 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1416));
1286 }
1287 
updateAudioOptions()1288 void Menu::updateAudioOptions() {
1289 	Common::Point cursor = getCursor()->position();
1290 
1291 	// Size of - and +
1292 	int16 sizeMinus	= getText()->getWidth("-");
1293 	int16 sizePlus  = getText()->getWidth("+");
1294 
1295 	getText()->loadFont(kFontYellow);
1296 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1420));
1297 
1298 	int16 volumeIndex = 0;
1299 	int32 volumeValue = cursor.x;
1300 	do {
1301 		getText()->loadFont(kFontYellow);
1302 		getText()->draw(Common::Point(320, (int16)(29 * volumeIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
1303 
1304 		switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
1305 		getText()->setPosition(Common::Point(350, (int16)(29 * volumeIndex + 150)));
1306 		getText()->draw("-");
1307 
1308 		switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
1309 		getText()->setPosition(Common::Point(sizeMinus + 360, (int16)(29 * volumeIndex + 150)));
1310 		getText()->draw("+");
1311 
1312 		switch(volumeIndex) {
1313 		default:
1314 			break;
1315 
1316 		case 0:
1317 			volumeValue = 0;
1318 			break;
1319 
1320 		case 1:
1321 			volumeValue = Config.musicVolume / 250 + 20;
1322 			break;
1323 
1324 		case 2:
1325 			volumeValue = Config.ambientVolume / 250 + 20;
1326 			break;
1327 
1328 		case 3:
1329 			volumeValue = Config.sfxVolume / 250 + 20;
1330 			break;
1331 
1332 		case 4:
1333 			volumeValue = Config.voiceVolume / 250 + 20;
1334 			break;
1335 
1336 		case 5:
1337 			volumeValue = Config.movieVolume / 250 + 20;
1338 			break;
1339 		}
1340 
1341 		getText()->loadFont(kFontYellow);
1342 		getText()->setPosition(Common::Point(sizePlus + sizeMinus + 365, (int16)(29 * volumeIndex + 150)));
1343 		if (volumeValue > 0) {
1344 			for (int32 i = 0; i < volumeValue; i++)
1345 				getText()->drawChar(']');
1346 
1347 			if (volumeValue == 20)
1348 				getText()->drawChar('*');
1349 		} else if (volumeIndex) {
1350 			getText()->draw(MAKE_RESOURCE(kResourcePackText, 1429));
1351 		}
1352 
1353 		++volumeIndex;
1354 	} while (volumeIndex < 6);
1355 
1356 	//////////////////////////////////////////////////////////////////////////
1357 	//
1358 	getText()->loadFont(kFontYellow);
1359 	getText()->draw(Common::Point(320, (int16)(29 *volumeIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1427));
1360 
1361 	switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429))) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
1362 	getText()->setPosition(Common::Point(350, (int16)(29 * volumeIndex + 150)));
1363 	getText()->draw(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429));
1364 
1365 	switchFont(cursor.x < 220 || cursor.x > (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) || cursor.y < 360 || cursor.y > (360 + 24));
1366 	getText()->setPosition(Common::Point(220, 360));
1367 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1430));
1368 
1369 	switchFont((cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) && !_testSoundsPlaying);
1370 	getText()->setPosition(Common::Point(360, 360));
1371 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1431));
1372 }
1373 
updateSettings()1374 void Menu::updateSettings() {
1375 	Common::Point cursor = getCursor()->position();
1376 
1377 	// Size of - and +
1378 	int16 sizeMinus	= getText()->getWidth("-");
1379 	int16 sizePlus  = getText()->getWidth("+");
1380 
1381 	getText()->loadFont(kFontYellow);
1382 
1383 	// Settings
1384 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1432));
1385 
1386 	//////////////////////////////////////////////////////////////////////////
1387 	// Gamma correction
1388 	getText()->draw(Common::Point(320, 150), MAKE_RESOURCE(kResourcePackText, 1433));
1389 
1390 	switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 150 || cursor.y > 174);
1391 	getText()->setPosition(Common::Point(350, 150));
1392 	getText()->draw("-");
1393 
1394 	switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 150 || cursor.y > 174);
1395 	getText()->setPosition(Common::Point(sizeMinus + 360, 150));
1396 	getText()->draw("+");
1397 
1398 	getText()->setPosition(Common::Point(sizeMinus + sizePlus + 365, 150));
1399 	getText()->loadFont(kFontYellow);
1400 	if (Config.gammaLevel) {
1401 		for (int32 i = 0; i < Config.gammaLevel; i++)
1402 			getText()->drawChar(']');
1403 
1404 		if (Config.gammaLevel == 8)
1405 			getText()->drawChar('*');
1406 	} else {
1407 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
1408 	}
1409 
1410 	//////////////////////////////////////////////////////////////////////////
1411 	// Performance
1412 	getText()->loadFont(kFontYellow);
1413 	getText()->draw(Common::Point(320, 179), MAKE_RESOURCE(kResourcePackText, 1434));
1414 
1415 	switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 179 || cursor.y > 203);
1416 	getText()->setPosition(Common::Point(350, 179));
1417 	getText()->draw("-");
1418 
1419 	switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 179 || cursor.y > 203);
1420 	getText()->setPosition(Common::Point(sizeMinus + 360, 179));
1421 	getText()->draw("+");
1422 
1423 	getText()->setPosition(Common::Point(sizeMinus + sizePlus + 365, 179));
1424 	getText()->loadFont(kFontYellow);
1425 	if (Config.performance == 5) {
1426 		getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
1427 	} else {
1428 		for (int32 i = 5; i > Config.performance; --i) // This has ] augmenting when pressing - which is a bit convoluted (perf == speed == more ])
1429 			getText()->drawChar(']');
1430 
1431 		if (!Config.performance)
1432 			getText()->draw('*');
1433 	}
1434 
1435 	//////////////////////////////////////////////////////////////////////////
1436 	// Back to main menu
1437 	switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437))) || cursor.y < 340 || cursor.y > (340 + 24));
1438 	getText()->setPosition(Common::Point(300, 340));
1439 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
1440 }
1441 
updateKeyboardConfig()1442 void Menu::updateKeyboardConfig() {
1443 	Common::Point cursor = getCursor()->position();
1444 
1445 	getText()->loadFont(kFontYellow);
1446 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1438));
1447 
1448 	int16 keyIndex = 0;
1449 	Common::Keymap *keymap = g_system->getEventManager()->getKeymapper()->getKeymap("asylum");
1450 
1451 	do {
1452 		Common::Array<Common::HardwareInput> mappings = keymap->getActionMapping(keymap->getActions()[keyIndex]);
1453 		Common::String keyCode = mappings.size() ? mappings[0].description.encode() : "<Not mapped>";
1454 
1455 		getText()->loadFont(kFontYellow);
1456 		getText()->draw(Common::Point(320, (int16)(29 * keyIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
1457 
1458 		getText()->setPosition(Common::Point(350, (int16)(29 * keyIndex + 150)));
1459 
1460 		if (keyIndex == _selectedShortcutIndex) {
1461 			getText()->loadFont(kFontBlue);
1462 
1463 			if (_caretBlink < 6)
1464 				getText()->drawChar('_');
1465 
1466 			_caretBlink = (_caretBlink + 1) % 12;
1467 		} else {
1468 			switchFont(getCursor()->isHidden() || cursor.x < 350 || cursor.x > (350 + getText()->getWidth(keyCode.c_str())) || cursor.y < (29 * keyIndex + 150) || cursor.y > (29 * (keyIndex + 6)));
1469 			getText()->draw(keyCode.c_str());
1470 		}
1471 
1472 		++keyIndex;
1473 	} while (keyIndex < 6);
1474 
1475 	switchFont(getCursor()->isHidden() || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24));
1476 	getText()->setPosition(Common::Point(300, 340));
1477 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1446));
1478 }
1479 
updateReturnToGame()1480 void Menu::updateReturnToGame() {
1481 	Common::Point cursor = getCursor()->position();
1482 
1483 	getText()->loadFont(kFontYellow);
1484 
1485 	// No game loaded
1486 	getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1810));
1487 
1488 	// Main Menu
1489 	switchFont(cursor.x < 285 || cursor.x > (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811))) || cursor.y < 273 || cursor.y > (273 + 24));
1490 	getText()->setPosition(Common::Point(285, 273));
1491 	getText()->draw(MAKE_RESOURCE(kResourcePackText, 1811));
1492 
1493 }
1494 
updateShowCredits()1495 void Menu::updateShowCredits() {
1496 	if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
1497 		getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33));
1498 	} else {
1499 		getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23));
1500 		getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), (uint32)_creditsFrameIndex++ / 2, Common::Point(0, 0), kDrawFlagNone, false);
1501 
1502 		_creditsFrameIndex %= 2 * (int32)GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
1503 	}
1504 
1505 	int16 step = 0;
1506 	uint32 index = 0;
1507 	do {
1508 		if ((_startIndex + step) >= -24) {
1509 			if ((_startIndex + step) > 480)
1510 				break;
1511 
1512 			int32 minBound = _startIndex + step + 24;
1513 			int32 maxBound = _startIndex + step;
1514 
1515 			if (minBound >= 0 && minBound < 32)
1516 				getText()->setTransTableNum((uint32)(3 - minBound / 8));
1517 
1518 			if (maxBound < 480 && maxBound > 448)
1519 				getText()->setTransTableNum((uint32)(3 - (479 - maxBound) / 8));
1520 
1521 			getText()->setPosition(Common::Point(320, (int16)(step + _startIndex)));
1522 			getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
1523 			getText()->setTransTableNum(0);
1524 		}
1525 
1526 		step += 24;
1527 		++index;
1528 	} while (step < 8688);
1529 
1530 	if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
1531 		if (!_dword_455D4C && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackShared, 56))) {
1532 			_dword_455D4C = true;
1533 			getSound()->playMusic(kResourceNone, 0);
1534 			getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 40));
1535 		}
1536 	}
1537 
1538 	_startIndex -= 2;
1539 	if (_startIndex < -8712)   // 8688 + 24
1540 		closeCredits();
1541 }
1542 
1543 //////////////////////////////////////////////////////////////////////////
1544 // Click handlers
1545 //////////////////////////////////////////////////////////////////////////
clickNewGame()1546 void Menu::clickNewGame() {
1547 	Common::Point cursor = getCursor()->position();
1548 
1549 	if (cursor.x < 247
1550 	 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)))
1551 	 || cursor.y < 273
1552 	 || cursor.y > (273 + 24)) {
1553 		if (cursor.x >= 369
1554 		 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
1555 		 && cursor.y >= 273
1556 		 && cursor.y <= (273 + 24))
1557 			leave();
1558 	} else {
1559 		_vm->restart();
1560 	}
1561 }
1562 
clickLoadGame()1563 void Menu::clickLoadGame() {
1564 	Common::Point cursor = getCursor()->position();
1565 
1566 	if (_dword_455C80) {
1567 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
1568 		 || cursor.y < 273 || cursor.y > (273 + 24)) {
1569 			if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1331)))
1570 			 && cursor.y >= 273 && cursor.y <= (273 + 24))
1571 				_dword_455C80 = false;
1572 		} else {
1573 			_vm->startGame(getSaveLoad()->getScenePack(), AsylumEngine::kStartGameLoad);
1574 		}
1575 		return;
1576 	}
1577 
1578 	//////////////////////////////////////////////////////////////////////////
1579 	// Previous page
1580 	if (cursor.x >= 30  && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1326)))
1581 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1582 		if (_startIndex) {
1583 			_startIndex -= 12;
1584 			if (_startIndex < 0)
1585 				_startIndex = 0;
1586 		}
1587 
1588 		return;
1589 	}
1590 
1591 	//////////////////////////////////////////////////////////////////////////
1592 	// Main Menu
1593 	if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1328)))
1594 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1595 		leave();
1596 		return;
1597 	}
1598 
1599 	//////////////////////////////////////////////////////////////////////////
1600 	// Next page
1601 	if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1327)))
1602 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1603 		if (_startIndex + 12 < 25) {
1604 			_startIndex += 12;
1605 			if (_startIndex >= 25)
1606 				_startIndex = 24;
1607 		}
1608 
1609 		return;
1610 	}
1611 
1612 	char text[100];
1613 
1614 	//////////////////////////////////////////////////////////////////////////
1615 	// Columns
1616 	int32 index = 0;
1617 	for (int32 y = 150; y < 324; y += 29) {
1618 		if (cursor.x >= 350) {
1619 			if (index + _startIndex + 6 > 24)
1620 				break;
1621 
1622 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
1623 
1624 			if (cursor.x <= (350 + getText()->getWidth((char *)&text))
1625 			 && cursor.y >= y
1626 			 && cursor.y <= (y + 24)) {
1627 				uint32 saveIndex = (uint32)(index + _startIndex + 6);
1628 				if (saveIndex < 25) {
1629 					if (getSaveLoad()->hasSavegame(saveIndex)) {
1630 						_dword_455C80 = true;
1631 						getSaveLoad()->setIndex(saveIndex);
1632 					}
1633 				}
1634 				break;
1635 			}
1636 		} else if (cursor.x >= 30) {
1637 			if (index + _startIndex > 24)
1638 				break;
1639 
1640 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
1641 
1642 			if (cursor.x <= (30 + getText()->getWidth((char *)&text))
1643 			 && cursor.y >= y
1644 			 && cursor.y <= (y + 24)) {
1645 				uint32 saveIndex = (uint32)(index + _startIndex);
1646 				if (saveIndex < 25) {
1647 					if (getSaveLoad()->hasSavegame(saveIndex)) {
1648 						_dword_455C80 = true;
1649 						getSaveLoad()->setIndex(saveIndex);
1650 					}
1651 				}
1652 				break;
1653 			}
1654 		}
1655 
1656 		++index;
1657 	}
1658 }
1659 
clickSaveGame()1660 void Menu::clickSaveGame() {
1661 	Common::Point cursor = getCursor()->position();
1662 
1663 	if (_dword_455C80) {
1664 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
1665 		 || cursor.y < 273 || cursor.y > (273 + 24)) {
1666 			if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
1667 			 && cursor.y >= 273 && cursor.y <= (273 + 24))
1668 				_dword_455C80 = false;
1669 		} else {
1670 			_dword_455C80 = false;
1671 			_isEditingSavegameName = true;
1672 
1673 			_previousName = *getSaveLoad()->getName();
1674 			_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
1675 			getCursor()->hide();
1676 		}
1677 
1678 		return;
1679 	}
1680 
1681 	//////////////////////////////////////////////////////////////////////////
1682 	// Previous page
1683 	if (cursor.x >= 30  && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1336)))
1684 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1685 		if (_startIndex) {
1686 			_startIndex -= 12;
1687 			if (_startIndex < 0)
1688 				_startIndex = 0;
1689 		}
1690 
1691 		return;
1692 	}
1693 
1694 	//////////////////////////////////////////////////////////////////////////
1695 	// Main menu
1696 	if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1338)))
1697 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1698 		leave();
1699 		return;
1700 	}
1701 
1702 	//////////////////////////////////////////////////////////////////////////
1703 	// Next page
1704 	if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1337)))
1705 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1706 		if (_startIndex + 12 < 25) {
1707 			_startIndex += 12;
1708 			if (_startIndex >= 25)
1709 				_startIndex = 24;
1710 		}
1711 		return;
1712 	}
1713 
1714 	char text[200];
1715 
1716 	//////////////////////////////////////////////////////////////////////////
1717 	// Columns
1718 	int32 index = 0;
1719 	for (int16 y = 150; y < 324; y += 29) {
1720 		if (cursor.x >= 350) {
1721 			if (index + _startIndex + 6 > 24)
1722 				break;
1723 
1724 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
1725 
1726 			if (cursor.x <= (350 + getText()->getWidth((char *)&text))
1727 			 && cursor.y >= y
1728 			 && cursor.y <= (y + 24)
1729 			 && getScene()
1730 			 && getWorld()->chapter != kChapterNone) {
1731 				if (index + _startIndex < 25) {
1732 					uint32 saveIndex = (uint32)(index + _startIndex + 6);
1733 					getSaveLoad()->setIndex(saveIndex);
1734 					if (getSaveLoad()->hasSavegame(saveIndex)) {
1735 						_dword_455C80 = true;
1736 					} else {
1737 						_isEditingSavegameName = true;
1738 						_previousName = *getSaveLoad()->getName();
1739 						*getSaveLoad()->getName() = getChapterName();
1740 						_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
1741 						getCursor()->hide();
1742 					}
1743 				}
1744 				break;
1745 			}
1746 		} else if (cursor.x >= 30) {
1747 			if (index + _startIndex > 24)
1748 				break;
1749 
1750 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
1751 
1752 			if (cursor.x <= (30 + getText()->getWidth((char *)&text))
1753 			 && cursor.y >= y
1754 			 && cursor.y <= (y + 24)
1755 			 && getScene()
1756 			 && getWorld()->chapter != kChapterNone) {
1757 				uint32 saveIndex = (uint32)(index + _startIndex);
1758 				if (saveIndex < 25) {
1759 					getSaveLoad()->setIndex(saveIndex);
1760 					if (getSaveLoad()->hasSavegame(saveIndex)) {
1761 						_dword_455C80 = true;
1762 					} else {
1763 						_isEditingSavegameName = true;
1764 						_previousName = *getSaveLoad()->getName();
1765 						*getSaveLoad()->getName() = getChapterName();
1766 						_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
1767 						getCursor()->hide();
1768 					}
1769 				}
1770 				break;
1771 			}
1772 		}
1773 
1774 		++index;
1775 	}
1776 }
1777 
clickDeleteGame()1778 void Menu::clickDeleteGame() {
1779 	Common::Point cursor = getCursor()->position();
1780 
1781 	if (_dword_455C80) {
1782 		if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
1783 		 || cursor.y < 273 || cursor.y > (273 + 24)) {
1784 			if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
1785 			 && cursor.y >= 273 && cursor.y <= (273 + 24))
1786 				_dword_455C80 = false;
1787 		} else {
1788 			getSaveLoad()->remove();
1789 		}
1790 
1791 		return;
1792 	}
1793 
1794 	//////////////////////////////////////////////////////////////////////////
1795 	// Previous page
1796 	if (cursor.x >= 30  && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
1797 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1798 		if (_startIndex) {
1799 			_startIndex -= 12;
1800 			if (_startIndex < 0)
1801 				_startIndex = 0;
1802 		}
1803 
1804 		return;
1805 	}
1806 
1807 	//////////////////////////////////////////////////////////////////////////
1808 	// Main menu
1809 	if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1348)))
1810 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1811 		leave();
1812 		return;
1813 	}
1814 
1815 	//////////////////////////////////////////////////////////////////////////
1816 	// Next page
1817 	if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
1818 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1819 		if (_startIndex + 12 < 25) {
1820 			_startIndex += 12;
1821 			if (_startIndex >= 25)
1822 				_startIndex = 24;
1823 		}
1824 
1825 		return;
1826 	}
1827 
1828 	char text[200];
1829 
1830 	//////////////////////////////////////////////////////////////////////////
1831 	// Columns
1832 	int32 index = 0;
1833 	for (int16 y = 150; y < 324; y += 29) {
1834 		if (cursor.x >= 350) {
1835 			if (index + _startIndex + 6 > 24)
1836 				break;
1837 
1838 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
1839 
1840 			if (cursor.x <= (350 + getText()->getWidth((char *)&text))
1841 			 && cursor.y >= y
1842 			 && cursor.y <= (y + 24)) {
1843 				uint32 saveIndex = (uint32)(index + _startIndex);
1844 				if (saveIndex < 25) {
1845 					if (getSaveLoad()->hasSavegame(saveIndex + 6)) {
1846 						_dword_455C80 = true;
1847 						getSaveLoad()->setIndex(saveIndex + 6);
1848 					}
1849 				}
1850 				break;
1851 			}
1852 		} else if (cursor.x >= 30) {
1853 			if (index + _startIndex > 24)
1854 				break;
1855 
1856 			snprintf((char *)&text, sizeof(text), "%d. %s", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
1857 
1858 			if (cursor.x <= (30 + getText()->getWidth((char *)&text))
1859 			 && cursor.y >= y
1860 			 && cursor.y <= (y + 24)) {
1861 				uint32 saveIndex = (uint32)(index + _startIndex);
1862 				if (saveIndex < 25) {
1863 					if (getSaveLoad()->hasSavegame(saveIndex)) {
1864 						_dword_455C80 = true;
1865 						getSaveLoad()->setIndex(saveIndex);
1866 					}
1867 				}
1868 				break;
1869 			}
1870 		}
1871 
1872 		++index;
1873 	}
1874 }
1875 
clickViewMovies()1876 void Menu::clickViewMovies() {
1877 	Common::Point cursor = getCursor()->position();
1878 
1879 	if (_dword_455C78)
1880 		return;
1881 
1882 	//////////////////////////////////////////////////////////////////////////
1883 	// Previous page
1884 	if (cursor.x >= 30  && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1353)))
1885 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1886 		if (_startIndex) {
1887 			_startIndex -= 12;
1888 			if (_startIndex < 0)
1889 				_startIndex = 0;
1890 		}
1891 
1892 		return;
1893 	}
1894 
1895 	//////////////////////////////////////////////////////////////////////////
1896 	// Main Menu
1897 	if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1355)))
1898 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1899 		leave();
1900 		return;
1901 	}
1902 
1903 	//////////////////////////////////////////////////////////////////////////
1904 	// Next page
1905 	if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1354)))
1906 	 && cursor.y >= 340 && cursor.y <= (340 + 24)) {
1907 		if (_startIndex + 12 < (int32)_movieCount) {
1908 			_startIndex += 12;
1909 			if (_startIndex >= (int32)_movieCount)
1910 				_startIndex = _movieCount - 1;
1911 		}
1912 
1913 		return;
1914 	}
1915 
1916 	char text[100];
1917 	char text2[100];
1918 
1919 	//////////////////////////////////////////////////////////////////////////
1920 	// Columns
1921 	int32 index = 0;
1922 	for (int32 y = 150; y < 324; y += 29) {
1923 		if (cursor.x >= 350) {
1924 			if (_movieList[index + _startIndex + 6] == -1)
1925 				break;
1926 
1927 			snprintf((char *)&text, sizeof(text), "%d. %s", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
1928 			snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
1929 			strcat((char *)&text, (char *)&text2);
1930 
1931 			if (cursor.x <= (350 + getText()->getWidth((char *)&text))
1932 			 && cursor.y >= y
1933 			 && cursor.y <= (y + 24)) {
1934 				uint32 movieIndex = (uint32)(index + _startIndex  + 6);
1935 				if (movieIndex <= _movieCount) {
1936 					// The original checks for the proper cd, but we can skip that since we have all data on disk
1937 					_movieIndex = (uint32)_movieList[movieIndex];
1938 
1939 					// FIXME
1940 					//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
1941 					//	_dword_455C78 = true;
1942 					//	getCursor()->hide();
1943 					//} else {
1944 						_showMovie = true;
1945 					//}
1946 				}
1947 			}
1948 		} else if (cursor.x >= 30) {
1949 			if (_movieList[index + _startIndex] == -1)
1950 				break;
1951 
1952 			snprintf((char *)&text, sizeof(text), "%d. %s", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
1953 			snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
1954 			strcat((char *)&text, (char *)&text2);
1955 
1956 			if (cursor.x <= (30 + getText()->getWidth((char *)&text))
1957 			 && cursor.y >= y
1958 			 && cursor.y <= (y + 24)) {
1959 
1960 				uint32 listIndex = (uint32)(index + _startIndex);
1961 				if (listIndex < _movieCount) {
1962 					// The original checks for the proper cd, but we can skip that since we have all data on disk
1963 					_movieIndex = (uint32)_movieList[listIndex];
1964 
1965 					//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
1966 					//	_dword_455C78 = true;
1967 					//	getCursor()->hide();
1968 					//} else {
1969 						_showMovie = true;
1970 					//}
1971 				}
1972 			}
1973 		}
1974 
1975 		++index;
1976 	}
1977 }
1978 
clickQuitGame()1979 void Menu::clickQuitGame() {
1980 	Common::Point cursor = getCursor()->position();
1981 
1982 	if (cursor.x < 247
1983 	 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409)))
1984 	 || cursor.y < 273
1985 	 || cursor.y > (273 + 24)) {
1986 		if (cursor.x >= 369
1987 		 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
1988 		 && cursor.y >= 273
1989 		 && cursor.y <= (273 + 24)) {
1990 			leave();
1991 		}
1992 	} else {
1993 		getCursor()->hide();
1994 		getScreen()->clear();
1995 		Engine::quitGame();
1996 	}
1997 }
1998 
clickTextOptions()1999 void Menu::clickTextOptions() {
2000 	Common::Point cursor = getCursor()->position();
2001 
2002 	if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174) {
2003 		if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415))) || cursor.y < 179 || cursor.y > 203) {
2004 			if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) && cursor.y >= 340 && cursor.y <= (340 + 24)) {
2005 				Config.write();
2006 				leave();
2007 			}
2008 		} else {
2009 			Config.showEncounterSubtitles = !Config.showEncounterSubtitles;
2010 		}
2011 	} else {
2012 		Config.showMovieSubtitles = !Config.showMovieSubtitles;
2013 	}
2014 }
2015 
clickAudioOptions()2016 void Menu::clickAudioOptions() {
2017 	Common::Point cursor = getCursor()->position();
2018 
2019 	// Size of - and +
2020 	int32 sizeMinus	= getText()->getWidth("-");
2021 	int32 sizePlus  = getText()->getWidth("+");
2022 
2023 	if (cursor.x >= 220 && cursor.x <= (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) && cursor.y >= 360 && cursor.y <= (360 + 24)) {
2024 		stopTestSounds();
2025 		Config.write();
2026 		_vm->syncSoundSettings();
2027 		leave();
2028 		return;
2029 	}
2030 
2031 	if (cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) {
2032 		int32 volumeIndex = 0;
2033 		int32 defaultVolume = 0;
2034 		int32 *volume = &defaultVolume;
2035 		bool found = false;
2036 
2037 		for (;;) {
2038 			if (found)
2039 				return;
2040 
2041 			switch (volumeIndex) {
2042 			default:
2043 				break;
2044 
2045 			case 0:
2046 				if (cursor.x >= 350 && cursor.x <= (350 + sizeMinus) && cursor.y >= 150 && cursor.y <= 174) {
2047 					adjustMasterVolume(-1);
2048 					adjustTestVolume();
2049 					found = true;
2050 					break;
2051 				}
2052 
2053 				if (cursor.x >= (360 + sizeMinus) && cursor.x <= (360 + sizeMinus + sizePlus) && cursor.y >= 150 && cursor.y <= 174) {
2054 					adjustMasterVolume(1);
2055 					adjustTestVolume();
2056 					found = true;
2057 					break;
2058 				}
2059 				break;
2060 
2061 			case 1:
2062 				volume = &Config.musicVolume;
2063 				break;
2064 
2065 			case 2:
2066 				volume = &Config.ambientVolume;
2067 				break;
2068 
2069 			case 3:
2070 				volume = &Config.sfxVolume;
2071 				break;
2072 
2073 			case 4:
2074 				volume = &Config.voiceVolume;
2075 				break;
2076 
2077 			case 5:
2078 				volume = &Config.movieVolume;
2079 				break;
2080 			}
2081 
2082 			if (!found) {
2083 				if (cursor.x < 350 || cursor.x > (350 + sizeMinus) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6))) {
2084 					if (cursor.x >= (sizeMinus + 360)) {
2085 						if (cursor.x <= (sizeMinus + sizePlus + 360)) {
2086 
2087 							if (cursor.y >= (29 * volumeIndex + 150) && cursor.y <= (29 * (volumeIndex + 6))) {
2088 								// Normalize volume
2089 								if (*volume < 0) {
2090 									if (*volume == -9999)
2091 										*volume = -5000;
2092 
2093 									*volume += 250;
2094 
2095 									if (*volume > 0)
2096 										*volume = 0;
2097 
2098 									adjustTestVolume();
2099 								}
2100 								found = true;
2101 							}
2102 						}
2103 					}
2104 				} else {
2105 					if (*volume > -5000) {
2106 						*volume -= 250;
2107 
2108 						if (*volume <= -5000)
2109 							*volume = -9999;
2110 
2111 						adjustTestVolume();
2112 					}
2113 					found = true;
2114 				}
2115 			}
2116 
2117 			++volumeIndex;
2118 
2119 			if (volumeIndex >= 6) {
2120 				if (!found) {
2121 					if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.reverseStereo ? 1428 : 1429)))
2122 					 && cursor.y >= (29 * volumeIndex + 150) && cursor.y <= (29 * (volumeIndex + 6))) {
2123 						Config.reverseStereo = !Config.reverseStereo;
2124 						_vm->updateReverseStereo();
2125 					}
2126 				}
2127 
2128 				return;
2129 			}
2130 		}
2131 	}
2132 
2133 	if (_testSoundsPlaying)
2134 		stopTestSounds();
2135 	else
2136 		playTestSounds();
2137 }
2138 
clickSettings()2139 void Menu::clickSettings() {
2140 	Common::Point cursor = getCursor()->position();
2141 
2142 	// Size of - and +
2143 	int32 sizeMinus	= getText()->getWidth("-");
2144 	int32 sizePlus  = getText()->getWidth("+");
2145 
2146 	//////////////////////////////////////////////////////////////////////////
2147 	// Back to main menu
2148 	if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437))) && cursor.y >= 340 && cursor.y <= (340 + 24)) {
2149 		Config.write();
2150 		leave();
2151 		return;
2152 	}
2153 
2154 	//////////////////////////////////////////////////////////////////////////
2155 	// Performance minus
2156 	if (cursor.x >= 350 && cursor.x <= (sizeMinus + 350) && cursor.y >= 179 && cursor.y <= 203) {
2157 		if (!Config.performance)
2158 			return;
2159 
2160 		Config.performance -= 1;
2161 		adjustPerformance();
2162 
2163 		return;
2164 	}
2165 
2166 	//////////////////////////////////////////////////////////////////////////
2167 	// Performance plus
2168 	if (cursor.x >= sizeMinus + 360 && cursor.x <= (sizeMinus + sizePlus + 360) && cursor.y >= 179 && cursor.y <= 203) {
2169 		if (Config.performance >= 5)
2170 			return;
2171 
2172 		Config.performance += 1;
2173 		adjustPerformance();
2174 
2175 		return;
2176 	}
2177 
2178 	//////////////////////////////////////////////////////////////////////////
2179 	// Gamma level minus
2180 	if (cursor.x >= 350 && cursor.x <= (sizeMinus + 350) && cursor.y >= 150 && cursor.y <= 174) {
2181 		if (!Config.gammaLevel)
2182 			return;
2183 
2184 		Config.gammaLevel -= 1;
2185 		getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
2186 
2187 		return;
2188 	}
2189 
2190 	//////////////////////////////////////////////////////////////////////////
2191 	// Gamma level plus
2192 	if (cursor.x >= (sizeMinus + 360) && cursor.x <= (sizeMinus + sizePlus + 360) && cursor.y >= 150 && cursor.y <= 174) {
2193 		if (Config.gammaLevel >= 8)
2194 			return;
2195 
2196 
2197 		Config.gammaLevel += 1;
2198 		getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
2199 
2200 		return;
2201 	}
2202 }
2203 
clickKeyboardConfig()2204 void Menu::clickKeyboardConfig() {
2205 	Common::Point cursor = getCursor()->position();
2206 
2207 	if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24)) {
2208 		int32 keyIndex = 0;
2209 		Common::Keymap *keymap = g_system->getEventManager()->getKeymapper()->getKeymap("asylum");
2210 
2211 		do {
2212 			Common::Array<Common::HardwareInput> mappings = keymap->getActionMapping(keymap->getActions()[keyIndex]);
2213 			Common::String keyCode = mappings.size() ? mappings[0].description.encode() : "<Not mapped>";
2214 
2215 			if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(keyCode.c_str())) && cursor.y >= (29 * keyIndex + 150) && cursor.y <= (29 * (keyIndex + 6))) {
2216 				_selectedShortcutIndex = keyIndex;
2217 				getCursor()->hide();
2218 			}
2219 
2220 			++keyIndex;
2221 		} while (keyIndex < 6);
2222 	} else {
2223 		Config.write();
2224 		leave();
2225 	}
2226 }
2227 
clickReturnToGame()2228 void Menu::clickReturnToGame() {
2229 	if (_gameStarted) {
2230 		if (_musicResourceId != MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex))
2231 			getSound()->playMusic(kResourceNone, 0);
2232 
2233 		getScreen()->clear();
2234 
2235 		_vm->switchEventHandler(_vm->scene());
2236 	} else {
2237 		Common::Point cursor = getCursor()->position();
2238 
2239 		if (cursor.x >= 285
2240 		 && cursor.x <= (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811)))
2241 		 && cursor.y >= 273
2242 		 && cursor.y <= (273 + 24))
2243 			leave();
2244 	}
2245 }
2246 
clickShowCredits()2247 void Menu::clickShowCredits() {
2248 	closeCredits();
2249 }
2250 
2251 //////////////////////////////////////////////////////////////////////////
2252 // Key handlers
2253 //////////////////////////////////////////////////////////////////////////
keySaveGame(const AsylumEvent & evt)2254 void Menu::keySaveGame(const AsylumEvent &evt) {
2255 	if (!_isEditingSavegameName)
2256 		return;
2257 
2258 	switch (evt.kbd.keycode) {
2259 	default:
2260 		if (evt.kbd.ascii > 255 || !Common::isPrint(evt.kbd.ascii))
2261 			break;
2262 
2263 		if (getSaveLoad()->getName()->size() < 44) {
2264 			int32 width = getText()->getWidth(getSaveLoad()->getName()->c_str());
2265 
2266 			bool test = false;
2267 			if ((getSaveLoad()->getIndex() % 12) >= 6)
2268 				test = (width + _prefixWidth + 350 < 630);
2269 			else
2270 				test = (width + _prefixWidth + 30 < 340);
2271 
2272 			if (test)
2273 				*getSaveLoad()->getName() += (char)evt.kbd.ascii;
2274 		}
2275 		break;
2276 
2277 	case Common::KEYCODE_RETURN:
2278 	case Common::KEYCODE_KP_ENTER:
2279 		_isEditingSavegameName = false;
2280 		getSaveLoad()->save();
2281 		break;
2282 
2283 	case Common::KEYCODE_ESCAPE:
2284 		_dword_455C80 = false;
2285 		_isEditingSavegameName = false;
2286 		*getSaveLoad()->getName() = _previousName;
2287 		getCursor()->show();
2288 		break;
2289 
2290 	case Common::KEYCODE_BACKSPACE:
2291 	case Common::KEYCODE_DELETE:
2292 		if (getSaveLoad()->getName()->size())
2293 			getSaveLoad()->getName()->deleteLastChar();
2294 		break;
2295 
2296 	case Common::KEYCODE_KP_PERIOD:
2297 		*getSaveLoad()->getName() = "";
2298 		break;
2299 	}
2300 }
2301 
keyKeyboardConfig(const AsylumEvent & evt)2302 void Menu::keyKeyboardConfig(const AsylumEvent &evt) {
2303 	if (_selectedShortcutIndex == -1)
2304 		return;
2305 
2306 	if (evt.kbd.keycode == Common::KEYCODE_ESCAPE || evt.kbd.keycode == Common::KEYCODE_RETURN || evt.kbd.keycode == Common::KEYCODE_KP_ENTER) {
2307 		_selectedShortcutIndex = -1;
2308 		getCursor()->show();
2309 		return;
2310 	}
2311 
2312 	// Check for alphanumeric character
2313 	if (evt.kbd.ascii > 255 || !Common::isAlnum(evt.kbd.ascii))
2314 		return;
2315 
2316 	Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
2317 	Common::Keymap    *keymap    = keymapper->getKeymap("asylum");
2318 	Common::Action    *action    = keymap->getActions()[_selectedShortcutIndex];
2319 
2320 	keymap->unregisterMapping(action);
2321 	keymap->registerMapping(action, keymapper->findHardwareInput(evt));
2322 	keymap->saveMappings();
2323 
2324 	_selectedShortcutIndex = -1;
2325 	getCursor()->show();
2326 }
2327 
keyShowCredits()2328 void Menu::keyShowCredits() {
2329 	closeCredits();
2330 }
2331 
2332 } // end of namespace Asylum
2333 
2334