2012-09-17 18:03:25 +10:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2012-10-29 23:38:31 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
2012-09-17 18:03:25 +10:00
|
|
|
* modify it under the terms of the GNU General Public License
|
2012-10-29 23:38:31 +01:00
|
|
|
* as published by the Free Software Foundation; either version 2
|
2012-09-17 18:03:25 +10:00
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2012-10-29 23:38:31 +01:00
|
|
|
* along with this program; if not, write to the Free Software
|
2012-10-27 19:08:53 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2012-09-17 18:03:25 +10:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2012-09-17 18:53:29 +10:00
|
|
|
#include "common/events.h"
|
2012-10-06 00:45:07 +10:00
|
|
|
#include "common/file.h"
|
2012-09-22 20:45:08 +10:00
|
|
|
#include "common/util.h"
|
2012-09-17 18:03:25 +10:00
|
|
|
#include "hopkins/menu.h"
|
2012-09-23 10:59:52 +10:00
|
|
|
#include "hopkins/dialogs.h"
|
2012-09-17 18:03:25 +10:00
|
|
|
#include "hopkins/files.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
|
|
|
#include "hopkins/globals.h"
|
|
|
|
#include "hopkins/events.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/sound.h"
|
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
|
|
|
void MenuManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2012-09-22 20:45:08 +10:00
|
|
|
enum MenuSelection { MENU_NONE = 0, PLAY_GAME = 1, LOAD_GAME = 2, OPTIONS = 3, INTRODUCTION = 4, QUIT = 5 };
|
|
|
|
|
2012-12-25 02:25:13 +01:00
|
|
|
int MenuManager::menu() {
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *spriteData = NULL;
|
2012-09-22 20:45:08 +10:00
|
|
|
MenuSelection menuIndex;
|
|
|
|
Common::Point mousePos;
|
2012-10-29 22:41:06 +11:00
|
|
|
signed int result;
|
|
|
|
int frame5Index;
|
|
|
|
int frame4Index;
|
|
|
|
int frame3Index;
|
|
|
|
int frame2Index;
|
|
|
|
int frame1Index;
|
|
|
|
|
2012-12-02 22:33:35 +11:00
|
|
|
if (g_system->getEventManager()->shouldQuit())
|
|
|
|
return -1;
|
|
|
|
|
2012-10-29 22:41:06 +11:00
|
|
|
result = 0;
|
2012-09-17 18:53:29 +10:00
|
|
|
while (!g_system->getEventManager()->shouldQuit()) {
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_globals._forestFl = false;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager._breakoutFl = false;
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_globals._disableInventFl = true;
|
2012-12-24 13:32:39 +01:00
|
|
|
_vm->_globals._exitId = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 31; ++idx)
|
2012-12-16 14:22:24 +01:00
|
|
|
_vm->_globals._inventory[idx] = 0;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-24 13:32:39 +01:00
|
|
|
memset(_vm->_globals._saveData, 0, 2000);
|
2012-12-16 14:22:24 +01:00
|
|
|
_vm->_objectsManager.addObject(14);
|
2012-10-29 22:41:06 +11:00
|
|
|
frame5Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame1Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
|
2012-12-26 07:55:56 +01:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
|
|
|
|
_vm->_graphicsManager.loadImage("MENU");
|
|
|
|
else if (_vm->_globals._language == LANG_EN)
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_graphicsManager.loadImage("MENUAN");
|
2012-12-24 11:36:53 +01:00
|
|
|
else if (_vm->_globals._language == LANG_FR)
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_graphicsManager.loadImage("MENUFR");
|
2012-12-24 11:36:53 +01:00
|
|
|
else if (_vm->_globals._language == LANG_SP)
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_graphicsManager.loadImage("MENUES");
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-03 22:32:22 +01:00
|
|
|
_vm->_graphicsManager.fadeInLong();
|
2012-12-26 07:55:56 +01:00
|
|
|
|
|
|
|
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
|
2013-01-07 23:56:39 +01:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENU.SPR");
|
2012-12-26 07:55:56 +01:00
|
|
|
else if (_vm->_globals._language == LANG_EN)
|
2013-01-07 23:56:39 +01:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUAN.SPR");
|
2012-12-24 11:36:53 +01:00
|
|
|
else if (_vm->_globals._language == LANG_FR)
|
2013-01-07 23:56:39 +01:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUFR.SPR");
|
2012-12-24 11:36:53 +01:00
|
|
|
else if (_vm->_globals._language == LANG_SP)
|
2013-01-07 23:56:39 +01:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUES.SPR");
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager.mouseOn();
|
|
|
|
_vm->_eventsManager.changeMouseCursor(0);
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = 0;
|
|
|
|
_vm->_eventsManager._mouseSpriteId = 0;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-17 18:03:25 +10:00
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
_vm->_soundManager.WSOUND(28);
|
|
|
|
|
2012-09-22 20:45:08 +10:00
|
|
|
// Loop to make menu selection
|
|
|
|
bool selectionMade = false;
|
2012-09-17 18:03:25 +10:00
|
|
|
do {
|
2012-09-17 18:53:29 +10:00
|
|
|
if (g_system->getEventManager()->shouldQuit())
|
|
|
|
return -1;
|
|
|
|
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = MENU_NONE;
|
2012-12-11 01:53:50 +01:00
|
|
|
mousePos = Common::Point(_vm->_eventsManager.getMouseX(), _vm->_eventsManager.getMouseY());
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-23 10:59:52 +10:00
|
|
|
if ((uint16)(mousePos.x - 232) <= 176) {
|
|
|
|
if ((uint16)(mousePos.y - 261) <= 23)
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = PLAY_GAME;
|
2012-09-23 10:59:52 +10:00
|
|
|
if ((uint16)(mousePos.y - 293) <= 23)
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = LOAD_GAME;
|
2012-09-23 10:59:52 +10:00
|
|
|
if ((uint16)(mousePos.y - 325) <= 22)
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = OPTIONS;
|
2012-09-23 10:59:52 +10:00
|
|
|
if ((uint16)(mousePos.y - 356) <= 23)
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = INTRODUCTION;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-23 10:59:52 +10:00
|
|
|
if ((uint16)(mousePos.y - 388) <= 23)
|
2012-09-22 20:45:08 +10:00
|
|
|
menuIndex = QUIT;
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-22 19:54:30 +10:00
|
|
|
switch (menuIndex) {
|
2012-09-22 20:45:08 +10:00
|
|
|
case MENU_NONE:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-09-22 20:45:08 +10:00
|
|
|
case PLAY_GAME:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 1;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-09-22 20:45:08 +10:00
|
|
|
case LOAD_GAME:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 1;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-09-22 20:45:08 +10:00
|
|
|
case OPTIONS:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 1;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-09-22 20:45:08 +10:00
|
|
|
case INTRODUCTION:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 1;
|
|
|
|
frame5Index = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-09-22 20:45:08 +10:00
|
|
|
case QUIT:
|
2012-10-29 22:41:06 +11:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 1;
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 259, frame1Index);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 291, frame2Index + 2);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 322, frame3Index + 4);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 354, frame4Index + 6);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 386, frame5Index + 8);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-11 01:53:50 +01:00
|
|
|
if (_vm->_eventsManager.getMouseButton() == 1 && menuIndex != MENU_NONE)
|
2012-12-18 00:37:52 +01:00
|
|
|
selectionMade = true;
|
2012-09-22 20:45:08 +10:00
|
|
|
} while (!selectionMade);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-22 20:45:08 +10:00
|
|
|
if (menuIndex == PLAY_GAME) {
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 259, 10);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 18:03:25 +10:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-10-29 22:41:06 +11:00
|
|
|
result = 1;
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
2012-09-22 20:45:08 +10:00
|
|
|
if (menuIndex != LOAD_GAME)
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
|
|
|
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 291, 11);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 18:03:25 +10:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-24 13:32:39 +01:00
|
|
|
_vm->_globals._exitId = -1;
|
2012-12-10 07:54:03 +01:00
|
|
|
_vm->_dialogsManager.showLoadGame();
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-24 13:32:39 +01:00
|
|
|
if (_vm->_globals._exitId != -1) {
|
|
|
|
result = _vm->_globals._exitId;
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
|
|
|
}
|
2012-12-24 13:32:39 +01:00
|
|
|
_vm->_globals._exitId = 0;
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-23 10:59:52 +10:00
|
|
|
if (menuIndex != OPTIONS)
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-23 10:59:52 +10:00
|
|
|
// Options menu item selected
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 322, 12);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 18:03:25 +10:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-09-23 10:59:52 +10:00
|
|
|
|
|
|
|
// Show the options dialog
|
2012-10-24 20:37:42 +11:00
|
|
|
_vm->_dialogsManager.showOptionsDialog();
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
2012-09-22 20:45:08 +10:00
|
|
|
if (menuIndex == INTRODUCTION) {
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 354, 13);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 18:03:25 +10:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-12-23 19:08:23 +01:00
|
|
|
_vm->playIntro();
|
2012-09-17 18:03:25 +10:00
|
|
|
continue;
|
|
|
|
}
|
2012-09-17 18:53:29 +10:00
|
|
|
|
2012-09-22 20:45:08 +10:00
|
|
|
if ( menuIndex == QUIT) {
|
2012-12-25 02:25:13 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 386, 14);
|
2012-09-23 10:59:52 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 18:53:29 +10:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-10-29 22:41:06 +11:00
|
|
|
result = -1;
|
2012-09-17 18:53:29 +10:00
|
|
|
}
|
2012-09-17 18:03:25 +10:00
|
|
|
break;
|
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
_vm->_globals.freeMemory(spriteData);
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_globals._disableInventFl = false;
|
2013-01-03 22:32:22 +01:00
|
|
|
_vm->_graphicsManager.fadeOutLong();
|
2012-10-29 22:41:06 +11:00
|
|
|
return result;
|
2012-09-17 18:03:25 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Hopkins
|