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 "common/scummsys.h"
|
2012-09-17 08:53:29 +00:00
|
|
|
#include "common/events.h"
|
2012-10-05 14:45:07 +00:00
|
|
|
#include "common/file.h"
|
2012-09-22 10:45:08 +00:00
|
|
|
#include "common/util.h"
|
2012-09-17 08:03:25 +00:00
|
|
|
#include "hopkins/menu.h"
|
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"
|
|
|
|
|
|
|
|
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;
|
|
|
|
int frame5Index;
|
|
|
|
int frame4Index;
|
|
|
|
int frame3Index;
|
|
|
|
int frame2Index;
|
|
|
|
int frame1Index;
|
|
|
|
|
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()) {
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_globals._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);
|
2012-10-29 11:41:06 +00:00
|
|
|
frame5Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame1Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
|
|
|
|
|
2012-12-24 10:36:53 +00:00
|
|
|
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
|
|
|
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_graphicsManager.FADE_INW();
|
2012-12-24 10:36:53 +00:00
|
|
|
if (_vm->_globals._language == LANG_EN)
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUAN.SPR");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_FR)
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUFR.SPR");
|
2012-12-24 10:36:53 +00:00
|
|
|
else if (_vm->_globals._language == LANG_SP)
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUES.SPR");
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-16 13:22:24 +00:00
|
|
|
spriteData = _vm->_objectsManager.loadSprite(_vm->_globals.NFICHIER);
|
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
|
|
|
|
2012-09-17 08:03:25 +00:00
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
_vm->_soundManager.WSOUND(28);
|
|
|
|
|
2012-09-22 10:45:08 +00:00
|
|
|
// Loop to make menu selection
|
|
|
|
bool selectionMade = false;
|
2012-09-17 08:03:25 +00:00
|
|
|
do {
|
2012-09-17 08:53:29 +00:00
|
|
|
if (g_system->getEventManager()->shouldQuit())
|
|
|
|
return -1;
|
|
|
|
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = MENU_NONE;
|
2012-12-11 00:53:50 +00:00
|
|
|
mousePos = Common::Point(_vm->_eventsManager.getMouseX(), _vm->_eventsManager.getMouseY());
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
if ((uint16)(mousePos.x - 232) <= 176) {
|
|
|
|
if ((uint16)(mousePos.y - 261) <= 23)
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = PLAY_GAME;
|
2012-09-23 00:59:52 +00:00
|
|
|
if ((uint16)(mousePos.y - 293) <= 23)
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = LOAD_GAME;
|
2012-09-23 00:59:52 +00:00
|
|
|
if ((uint16)(mousePos.y - 325) <= 22)
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = OPTIONS;
|
2012-09-23 00:59:52 +00:00
|
|
|
if ((uint16)(mousePos.y - 356) <= 23)
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = INTRODUCTION;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
if ((uint16)(mousePos.y - 388) <= 23)
|
2012-09-22 10:45:08 +00:00
|
|
|
menuIndex = QUIT;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-22 09:54:30 +00:00
|
|
|
switch (menuIndex) {
|
2012-09-22 10:45:08 +00:00
|
|
|
case MENU_NONE:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-09-22 10:45:08 +00:00
|
|
|
case PLAY_GAME:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 1;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-09-22 10:45:08 +00:00
|
|
|
case LOAD_GAME:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 1;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-09-22 10:45:08 +00:00
|
|
|
case OPTIONS:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 1;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-09-22 10:45:08 +00:00
|
|
|
case INTRODUCTION:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 1;
|
|
|
|
frame5Index = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-09-22 10:45:08 +00:00
|
|
|
case QUIT:
|
2012-10-29 11:41:06 +00:00
|
|
|
frame1Index = 0;
|
|
|
|
frame2Index = 0;
|
|
|
|
frame3Index = 0;
|
|
|
|
frame4Index = 0;
|
|
|
|
frame5Index = 1;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-25 01:25:13 +00: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 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_vm->_eventsManager.getMouseButton() == 1 && menuIndex != MENU_NONE)
|
2012-12-17 23:37:52 +00:00
|
|
|
selectionMade = true;
|
2012-09-22 10:45:08 +00:00
|
|
|
} while (!selectionMade);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-22 10:45:08 +00:00
|
|
|
if (menuIndex == PLAY_GAME) {
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 259, 10);
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-10-29 11:41:06 +00:00
|
|
|
result = 1;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-09-22 10:45:08 +00:00
|
|
|
if (menuIndex != LOAD_GAME)
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 291, 11);
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-24 12:32:39 +00:00
|
|
|
_vm->_globals._exitId = -1;
|
2012-12-10 06:54:03 +00:00
|
|
|
_vm->_dialogsManager.showLoadGame();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-24 12:32:39 +00:00
|
|
|
if (_vm->_globals._exitId != -1) {
|
|
|
|
result = _vm->_globals._exitId;
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-24 12:32:39 +00:00
|
|
|
_vm->_globals._exitId = 0;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
if (menuIndex != OPTIONS)
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
// Options menu item selected
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 322, 12);
|
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-23 00:59:52 +00:00
|
|
|
|
|
|
|
// Show the options dialog
|
2012-10-24 09:37:42 +00:00
|
|
|
_vm->_dialogsManager.showOptionsDialog();
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
2012-09-22 10:45:08 +00:00
|
|
|
if (menuIndex == INTRODUCTION) {
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 354, 13);
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-12-23 18:08:23 +00:00
|
|
|
_vm->playIntro();
|
2012-09-17 08:03:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-09-17 08:53:29 +00:00
|
|
|
|
2012-09-22 10:45:08 +00:00
|
|
|
if ( menuIndex == QUIT) {
|
2012-12-25 01:25:13 +00:00
|
|
|
_vm->_graphicsManager.fastDisplay(spriteData, 230, 386, 14);
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-17 08:53:29 +00:00
|
|
|
_vm->_eventsManager.delay(200);
|
2012-10-29 11:41:06 +00:00
|
|
|
result = -1;
|
2012-09-17 08:53:29 +00:00
|
|
|
}
|
2012-09-17 08:03:25 +00:00
|
|
|
break;
|
|
|
|
}
|
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;
|
2012-09-17 08:03:25 +00:00
|
|
|
_vm->_graphicsManager.FADE_OUTW();
|
2012-10-29 11:41:06 +00:00
|
|
|
return result;
|
2012-09-17 08:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Hopkins
|