2012-09-17 08:03:25 +00: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 22:38:31 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
2012-09-17 08:03:25 +00:00
|
|
|
* modify it under the terms of the GNU General Public License
|
2012-10-29 22:38:31 +00:00
|
|
|
* as published by the Free Software Foundation; either version 2
|
2012-09-17 08:03:25 +00: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 22:38:31 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2012-10-27 17:08:53 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2012-09-17 08:03:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hopkins/menu.h"
|
2013-02-15 21:20:24 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
#include "hopkins/dialogs.h"
|
2012-09-17 08:03:25 +00: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"
|
|
|
|
|
2013-02-15 21:20:24 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
|
2012-09-17 08:03:25 +00:00
|
|
|
namespace Hopkins {
|
|
|
|
|
|
|
|
void MenuManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2012-09-22 10:45:08 +00:00
|
|
|
enum MenuSelection { MENU_NONE = 0, PLAY_GAME = 1, LOAD_GAME = 2, OPTIONS = 3, INTRODUCTION = 4, QUIT = 5 };
|
|
|
|
|
2012-12-25 01:25:13 +00:00
|
|
|
int MenuManager::menu() {
|
2012-12-14 00:49:22 +00:00
|
|
|
byte *spriteData = NULL;
|
2012-09-22 10:45:08 +00:00
|
|
|
MenuSelection menuIndex;
|
|
|
|
Common::Point mousePos;
|
2012-10-29 11:41:06 +00:00
|
|
|
signed int result;
|
2013-01-08 11:12:49 +00:00
|
|
|
int frameIndex[] = { 0, 0, 0, 0, 0 };
|
2012-10-29 11:41:06 +00:00
|
|
|
|
2012-12-02 11:33:35 +00:00
|
|
|
if (g_system->getEventManager()->shouldQuit())
|
|
|
|
return -1;
|
|
|
|
|
2012-10-29 11:41:06 +00:00
|
|
|
result = 0;
|
2012-09-17 08:53:29 +00:00
|
|
|
while (!g_system->getEventManager()->shouldQuit()) {
|
2013-02-07 21:30:40 +00:00
|
|
|
_vm->_objectsManager._forestFl = false;
|
2012-12-11 00:53:50 +00:00
|
|
|
_vm->_eventsManager._breakoutFl = false;
|
2012-12-10 22:57:59 +00:00
|
|
|
_vm->_globals._disableInventFl = true;
|
2012-12-24 12:32:39 +00:00
|
|
|
_vm->_globals._exitId = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 31; ++idx)
|
2012-12-16 13:22:24 +00:00
|
|
|
_vm->_globals._inventory[idx] = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-24 12:32:39 +00:00
|
|
|
memset(_vm->_globals._saveData, 0, 2000);
|
2012-12-16 13:22:24 +00:00
|
|
|
_vm->_objectsManager.addObject(14);
|
2013-01-08 11:12:49 +00:00
|
|
|
memset(frameIndex, 0, sizeof(int) * ARRAYSIZE(frameIndex));
|
2012-09-17 08:03:25 +00:00
|
|
|
|
2012-12-26 06:55:56 +00:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
|
|
|
|
_vm->_graphicsManager.loadImage("MENU");
|
|
|
|
else if (_vm->_globals._language == LANG_EN)
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.loadImage("MENUAN");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_FR)
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.loadImage("MENUFR");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_SP)
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_graphicsManager.loadImage("MENUES");
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2013-01-03 21:32:22 +00:00
|
|
|
_vm->_graphicsManager.fadeInLong();
|
2012-12-26 06:55:56 +00:00
|
|
|
|
|
|
|
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
|
2013-01-07 22:56:39 +00:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENU.SPR");
|
2012-12-26 06:55:56 +00:00
|
|
|
else if (_vm->_globals._language == LANG_EN)
|
2013-01-07 22:56:39 +00:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUAN.SPR");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_FR)
|
2013-01-07 22:56:39 +00:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUFR.SPR");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_SP)
|
2013-01-07 22:56:39 +00:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite("MENUES.SPR");
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
_vm->_eventsManager.mouseOn();
|
|
|
|
_vm->_eventsManager.changeMouseCursor(0);
|
2012-12-11 07:31:07 +00:00
|
|
|
_vm->_eventsManager._mouseCursorId = 0;
|
|
|
|
_vm->_eventsManager._mouseSpriteId = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2013-02-19 13:34:43 +00:00
|
|
|
_vm->_soundManager.playSound(28);
|
2013-01-08 11:12:49 +00:00
|
|
|
|
|
|
|
// Loop to make menu selection
|
|
|
|
bool selectionMade = false;
|
|
|
|
do {
|
|
|
|
if (g_system->getEventManager()->shouldQuit())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
menuIndex = MENU_NONE;
|
|
|
|
mousePos = Common::Point(_vm->_eventsManager.getMouseX(), _vm->_eventsManager.getMouseY());
|
|
|
|
|
2013-01-08 22:45:15 +00:00
|
|
|
if (mousePos.x >= 232 && mousePos.x <= 408) {
|
|
|
|
if (mousePos.y >= 261 && mousePos.y <= 284)
|
2013-01-08 11:12:49 +00:00
|
|
|
menuIndex = PLAY_GAME;
|
2013-01-08 22:45:15 +00:00
|
|
|
else if (mousePos.y >= 293 && mousePos.y <= 316)
|
2013-01-08 11:12:49 +00:00
|
|
|
menuIndex = LOAD_GAME;
|
2013-01-08 22:45:15 +00:00
|
|
|
else if (mousePos.y >= 325 && mousePos.y <= 347)
|
2013-01-08 11:12:49 +00:00
|
|
|
menuIndex = OPTIONS;
|
2013-01-08 22:45:15 +00:00
|
|
|
else if (mousePos.y >= 356 && mousePos.y <= 379)
|
2013-01-08 11:12:49 +00:00
|
|
|
menuIndex = INTRODUCTION;
|
2013-01-08 22:45:15 +00:00
|
|
|
else if (mousePos.y >= 388 && mousePos.y <= 411)
|
2013-01-08 11:12:49 +00:00
|
|
|
menuIndex = QUIT;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2013-01-08 11:12:49 +00:00
|
|
|
memset(frameIndex, 0, sizeof(int) * ARRAYSIZE(frameIndex));
|
|
|
|
if (menuIndex > MENU_NONE)
|
|
|
|
frameIndex[menuIndex - 1] = 1;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2013-02-06 07:18:19 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 259, frameIndex[0]);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 291, frameIndex[1] + 2);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 322, frameIndex[2] + 4);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 354, frameIndex[3] + 6);
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 386, frameIndex[4] + 8);
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
|
|
|
|
2013-01-08 11:12:49 +00:00
|
|
|
if (_vm->_eventsManager.getMouseButton() == 1 && menuIndex != MENU_NONE)
|
|
|
|
selectionMade = true;
|
|
|
|
} while (!selectionMade);
|
|
|
|
|
|
|
|
if (menuIndex > MENU_NONE) {
|
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 259 + 32 * (menuIndex - 1), 10 + (menuIndex - 1));
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_eventsManager.delay(200);
|
|
|
|
}
|
2012-09-17 08:53:29 +00:00
|
|
|
|
2013-01-08 11:12:49 +00:00
|
|
|
if (menuIndex == PLAY_GAME) {
|
|
|
|
result = 1;
|
|
|
|
break;
|
|
|
|
} else if (menuIndex == LOAD_GAME) {
|
|
|
|
_vm->_globals._exitId = -1;
|
|
|
|
_vm->_dialogsManager.showLoadGame();
|
|
|
|
|
|
|
|
if (_vm->_globals._exitId != -1) {
|
|
|
|
result = _vm->_globals._exitId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_vm->_globals._exitId = 0;
|
|
|
|
} else if (menuIndex == OPTIONS) {
|
|
|
|
_vm->_dialogsManager.showOptionsDialog();
|
|
|
|
} else if (menuIndex == INTRODUCTION) {
|
|
|
|
_vm->playIntro();
|
|
|
|
} else if (menuIndex == QUIT) {
|
2012-10-29 11:41:06 +00:00
|
|
|
result = -1;
|
2013-01-08 11:12:49 +00:00
|
|
|
break;
|
2012-09-17 08:53:29 +00:00
|
|
|
}
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.freeMemory(spriteData);
|
2012-12-10 22:57:59 +00:00
|
|
|
_vm->_globals._disableInventFl = false;
|
2013-01-03 21:32:22 +00:00
|
|
|
_vm->_graphicsManager.fadeOutLong();
|
2012-10-29 11:41:06 +00:00
|
|
|
return result;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Hopkins
|