2014-10-06 14:50:05 +02: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.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on Labyrinth of Time code with assistance of
|
|
|
|
*
|
|
|
|
* Copyright (c) 1993 Terra Nova Development
|
|
|
|
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-12-25 19:13:52 +01:00
|
|
|
#include "lab/lab.h"
|
2015-12-08 21:10:54 +01:00
|
|
|
|
2015-12-08 21:35:31 +01:00
|
|
|
#include "lab/anim.h"
|
2015-12-08 21:19:41 +01:00
|
|
|
#include "lab/dispman.h"
|
|
|
|
#include "lab/eventman.h"
|
2015-12-08 21:00:50 +01:00
|
|
|
#include "lab/image.h"
|
2015-11-20 20:17:30 +01:00
|
|
|
#include "lab/intro.h"
|
2015-12-08 21:00:50 +01:00
|
|
|
#include "lab/labsets.h"
|
2015-12-08 20:36:05 +01:00
|
|
|
#include "lab/music.h"
|
2015-12-08 21:47:36 +01:00
|
|
|
#include "lab/processroom.h"
|
2015-12-08 21:10:54 +01:00
|
|
|
#include "lab/resource.h"
|
2015-12-12 03:28:06 +02:00
|
|
|
#include "lab/tilepuzzle.h"
|
2015-12-08 21:00:50 +01:00
|
|
|
#include "lab/utils.h"
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
namespace Lab {
|
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
// LAB: Labyrinth specific code for the special puzzles
|
2014-10-06 14:50:05 +02:00
|
|
|
#define SPECIALLOCK 100
|
|
|
|
#define SPECIALBRICK 101
|
|
|
|
#define SPECIALBRICKNOMOUSE 102
|
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
enum Items {
|
|
|
|
kItemHelmet = 1,
|
|
|
|
kItemBelt = 3,
|
|
|
|
kItemPithHelmet = 7,
|
|
|
|
kItemJournal = 9,
|
|
|
|
kItemNotes = 12,
|
|
|
|
kItemWestPaper = 18,
|
|
|
|
kItemWhiskey = 25,
|
|
|
|
kItemLamp = 27,
|
|
|
|
kItemMap = 28,
|
|
|
|
kItemQuarter = 30
|
|
|
|
};
|
|
|
|
|
|
|
|
#define kCondLampOn 151
|
|
|
|
#define kCondBeltGlowing 70
|
|
|
|
#define kCondUsedHelmet 184
|
|
|
|
|
|
|
|
enum Monitors {
|
|
|
|
kMonitorMuseum = 71,
|
|
|
|
kMonitorGramophone = 72,
|
|
|
|
kMonitorUnicycle = 73,
|
|
|
|
kMonitorStatue = 74,
|
|
|
|
kMonitorTalisman = 75,
|
|
|
|
kMonitorLute = 76,
|
|
|
|
kMonitorClock = 77,
|
|
|
|
kMonitorWindow = 78,
|
|
|
|
//kMonitorBelt = 79,
|
|
|
|
kMonitorLibrary = 80,
|
|
|
|
kMonitorTerminal = 81
|
|
|
|
//kMonitorLevers = 82
|
|
|
|
};
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
|
|
|
|
'\x30', '\x30', '\x10', '\x10',
|
|
|
|
'\x10', '\x14', '\x14', '\x14',
|
|
|
|
'\x20', '\x20', '\x20', '\x24',
|
|
|
|
'\x24', '\x24', '\x2c', '\x2c',
|
2015-12-08 22:00:19 +01:00
|
|
|
'\x2c', '\x08', '\x08', '\x08' };
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
uint16 LabEngine::getQuarters() {
|
|
|
|
return _inventory[kItemQuarter]._many;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LabEngine::setQuarters(uint16 quarters) {
|
|
|
|
_inventory[kItemQuarter]._many = quarters;
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Draws the message for the room.
|
|
|
|
*/
|
2015-12-03 01:06:04 +01:00
|
|
|
void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
|
2015-12-01 10:35:31 +01:00
|
|
|
if (_lastTooLong) {
|
|
|
|
_lastTooLong = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
if (_alternate) {
|
2015-12-06 21:53:57 +01:00
|
|
|
if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName) {
|
2015-12-12 19:11:30 +02:00
|
|
|
if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
|
2015-12-08 11:27:34 +01:00
|
|
|
// LAB: Labyrinth specific
|
2015-12-12 19:11:30 +02:00
|
|
|
drawStaticMessage(kTextkLampOn);
|
2015-12-06 21:53:57 +01:00
|
|
|
else if (_inventory[curInv]._many > 1) {
|
|
|
|
Common::String roomMessage = Common::String(_inventory[curInv]._name) + " (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawMessage(roomMessage.c_str());
|
2014-10-06 14:50:05 +02:00
|
|
|
} else
|
2015-12-06 21:53:57 +01:00
|
|
|
_graphics->drawMessage(_inventory[curInv]._name);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
} else
|
2015-12-03 01:06:04 +01:00
|
|
|
drawDirection(closePtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_lastTooLong = _graphics->_lastMessageLong;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-02 20:32:06 +01:00
|
|
|
void LabEngine::freeScreens() {
|
2015-12-04 16:52:13 +01:00
|
|
|
for (uint16 i = 0; i < 20; i++) {
|
2015-12-02 20:32:06 +01:00
|
|
|
delete _moveImages[i];
|
2015-12-04 16:52:13 +01:00
|
|
|
_moveImages[i] = nullptr;
|
|
|
|
}
|
2015-12-02 20:32:06 +01:00
|
|
|
|
2015-12-04 16:52:13 +01:00
|
|
|
for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
|
|
|
|
delete _invImages[imgIdx];
|
2015-12-12 03:28:06 +02:00
|
|
|
_invImages[imgIdx] = nullptr;
|
2015-12-02 20:32:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Permanently flips the imagery of a gadget.
|
|
|
|
*/
|
2015-12-03 01:06:04 +01:00
|
|
|
void LabEngine::perFlipGadget(uint16 gadgetId) {
|
2015-12-06 22:50:41 +02:00
|
|
|
for (GadgetList::iterator gadget = _moveGadgetList.begin(); gadget != _moveGadgetList.end(); ++gadget) {
|
|
|
|
Gadget *topGadget = *gadget;
|
2015-12-07 07:18:16 +01:00
|
|
|
if (topGadget->_gadgetID == gadgetId) {
|
2015-12-03 01:06:04 +01:00
|
|
|
Image *tmpImage = topGadget->_image;
|
|
|
|
topGadget->_image = topGadget->_altImage;
|
|
|
|
topGadget->_altImage = tmpImage;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
if (!_alternate) {
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseHide();
|
2015-12-03 01:06:04 +01:00
|
|
|
topGadget->_image->drawImage(topGadget->x, topGadget->y);
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseShow();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-06 22:50:41 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Eats all the available messages.
|
|
|
|
*/
|
2015-11-29 18:10:06 +01:00
|
|
|
void LabEngine::eatMessages() {
|
2015-12-03 01:06:04 +01:00
|
|
|
IntuiMessage *msg;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
do {
|
2015-12-13 15:37:39 +02:00
|
|
|
msg = _event->getMsg();
|
2015-12-03 01:06:04 +01:00
|
|
|
} while (msg);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Checks whether the close up is one of the special case closeups.
|
|
|
|
*/
|
2015-12-03 01:06:04 +01:00
|
|
|
bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!closePtr)
|
2014-10-06 14:50:05 +02:00
|
|
|
return false;
|
|
|
|
|
2014-12-27 14:18:40 +01:00
|
|
|
int monltmargin, monrtmargin, montopmargin, lutertmargin;
|
|
|
|
|
2015-11-29 23:34:35 +01:00
|
|
|
if (getPlatform() != Common::kPlatformWindows) {
|
2014-12-27 14:18:40 +01:00
|
|
|
monltmargin = 0;
|
|
|
|
monrtmargin = 319;
|
|
|
|
montopmargin = 0;
|
|
|
|
lutertmargin = 124;
|
|
|
|
} else {
|
|
|
|
monltmargin = 2;
|
|
|
|
monrtmargin = 317;
|
|
|
|
montopmargin = 2;
|
|
|
|
lutertmargin = 128;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:53:57 +01:00
|
|
|
switch (closePtr->_closeUpType) {
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorMuseum:
|
|
|
|
case kMonitorLibrary:
|
|
|
|
case kMonitorWindow:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, monrtmargin, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorGramophone:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 171, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorUnicycle:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, 100, montopmargin, monrtmargin, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorStatue:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, 117, montopmargin, monrtmargin, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorTalisman:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 184, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorLute:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, lutertmargin, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorClock:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 206, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kMonitorTerminal:
|
2015-12-06 21:53:57 +01:00
|
|
|
doMonitor(closePtr->_graphicName, closePtr->_message, true, monltmargin, montopmargin, monrtmargin, 165);
|
2015-07-21 22:13:28 +03:00
|
|
|
break;
|
|
|
|
default:
|
2014-10-06 14:50:05 +02:00
|
|
|
return false;
|
2015-07-21 22:13:28 +03:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Gets the current inventory name.
|
|
|
|
*/
|
2015-12-06 21:39:41 +01:00
|
|
|
const char *LabEngine::getInvName(uint16 curInv) {
|
|
|
|
if (_mainDisplay)
|
2015-12-06 21:53:57 +01:00
|
|
|
return _inventory[curInv]._bitmapName;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
|
2014-10-06 14:50:05 +02:00
|
|
|
return "P:Mines/120";
|
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
if ((curInv == kItemBelt) && _conditions->in(kCondBeltGlowing))
|
|
|
|
return "P:Future/kCondBeltGlowing";
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
if (curInv == kItemWestPaper) {
|
2015-12-06 21:53:57 +01:00
|
|
|
_curFileName = _inventory[curInv]._bitmapName;
|
2015-12-04 13:32:08 +01:00
|
|
|
_anim->_noPalChange = true;
|
|
|
|
_graphics->readPict(_curFileName, false);
|
|
|
|
_anim->_noPalChange = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
doWestPaper();
|
2015-12-12 19:11:30 +02:00
|
|
|
} else if (curInv == kItemNotes) {
|
2015-12-06 21:53:57 +01:00
|
|
|
_curFileName = _inventory[curInv]._bitmapName;
|
2015-12-04 13:32:08 +01:00
|
|
|
_anim->_noPalChange = true;
|
|
|
|
_graphics->readPict(_curFileName, false);
|
|
|
|
_anim->_noPalChange = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
doNotes();
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:53:57 +01:00
|
|
|
return _inventory[curInv]._bitmapName;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Turns the interface off.
|
|
|
|
*/
|
2015-11-29 18:10:06 +01:00
|
|
|
void LabEngine::interfaceOff() {
|
2015-12-03 01:06:04 +01:00
|
|
|
if (!_interfaceOff) {
|
2015-12-09 11:22:41 +01:00
|
|
|
_event->attachGadgetList(nullptr);
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseHide();
|
2015-12-03 01:06:04 +01:00
|
|
|
_interfaceOff = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Turns the interface on.
|
|
|
|
*/
|
2015-11-29 18:10:06 +01:00
|
|
|
void LabEngine::interfaceOn() {
|
2015-12-03 01:06:04 +01:00
|
|
|
if (_interfaceOff) {
|
|
|
|
_interfaceOff = false;
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseShow();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
if (_graphics->_longWinInFront)
|
2015-12-06 21:39:41 +01:00
|
|
|
_event->attachGadgetList(nullptr);
|
2015-12-03 01:06:04 +01:00
|
|
|
else if (_alternate)
|
2015-12-06 22:50:41 +02:00
|
|
|
_event->attachGadgetList(&_invGadgetList);
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-12-06 22:50:41 +02:00
|
|
|
_event->attachGadgetList(&_moveGadgetList);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* If the user hits the "Use" gadget; things that can get used on themselves.
|
|
|
|
*/
|
2015-12-06 21:39:41 +01:00
|
|
|
bool LabEngine::doUse(uint16 curInv) {
|
2015-12-12 16:33:01 +02:00
|
|
|
switch (curInv) {
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemMap:
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextUseMap);
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOff();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->stopDiff();
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
2015-11-30 01:42:12 +01:00
|
|
|
doMap(_roomNum);
|
2015-12-06 14:36:49 +01:00
|
|
|
_graphics->setPalette(initcolors, 8);
|
2015-12-09 11:22:41 +01:00
|
|
|
_graphics->drawMessage(nullptr);
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemJournal:
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextUseJournal);
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOff();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->stopDiff();
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
2014-12-25 19:13:52 +01:00
|
|
|
doJournal();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
_graphics->drawMessage(nullptr);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemLamp:
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOff();
|
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
if (_conditions->in(kCondLampOn)) {
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextTurnLampOff);
|
2015-12-12 19:11:30 +02:00
|
|
|
_conditions->exclElement(kCondLampOn);
|
2015-12-12 16:33:01 +02:00
|
|
|
}
|
|
|
|
else {
|
2015-12-12 19:11:30 +02:00
|
|
|
drawStaticMessage(kTextTurnkLampOn);
|
|
|
|
_conditions->inclElement(kCondLampOn);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = false;
|
|
|
|
_anim->_waitForEffect = true;
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->readPict("Music:Click", true);
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_waitForEffect = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = false;
|
2015-12-06 21:39:41 +01:00
|
|
|
_nextFileName = getInvName(curInv);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemBelt:
|
|
|
|
if (!_conditions->in(kCondBeltGlowing))
|
|
|
|
_conditions->inclElement(kCondBeltGlowing);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = false;
|
2015-12-06 21:39:41 +01:00
|
|
|
_nextFileName = getInvName(curInv);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemWhiskey:
|
|
|
|
_conditions->inclElement(kCondUsedHelmet);
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextUseWhiskey);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemPithHelmet:
|
|
|
|
_conditions->inclElement(kCondUsedHelmet);
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextUsePith);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
2015-12-12 19:11:30 +02:00
|
|
|
case kItemHelmet:
|
|
|
|
_conditions->inclElement(kCondUsedHelmet);
|
2015-10-08 06:39:59 +03:00
|
|
|
drawStaticMessage(kTextUseHelmet);
|
2015-12-12 16:33:01 +02:00
|
|
|
return true;
|
|
|
|
default:
|
2014-10-06 14:50:05 +02:00
|
|
|
return false;
|
2015-12-12 16:33:01 +02:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* Decrements the current inventory number.
|
|
|
|
*/
|
2015-12-06 21:39:41 +01:00
|
|
|
void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOff();
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (decreaseFl)
|
|
|
|
(*curInv)--;
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-12-06 21:39:41 +01:00
|
|
|
(*curInv)++;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
while (*curInv && (*curInv <= _numInv)) {
|
2015-12-06 21:53:57 +01:00
|
|
|
if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
|
2015-12-06 21:39:41 +01:00
|
|
|
_nextFileName = getInvName(*curInv);
|
2014-10-06 14:50:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (decreaseFl)
|
|
|
|
(*curInv)--;
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-12-06 21:39:41 +01:00
|
|
|
(*curInv)++;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if ((*curInv == 0) || (*curInv > _numInv)) {
|
|
|
|
if (decreaseFl)
|
|
|
|
*curInv = _numInv;
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-12-06 21:39:41 +01:00
|
|
|
*curInv = 1;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
while (*curInv && (*curInv <= _numInv)) {
|
2015-12-06 21:53:57 +01:00
|
|
|
if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
|
2015-12-06 21:39:41 +01:00
|
|
|
_nextFileName = getInvName(*curInv);
|
2014-10-06 14:50:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (decreaseFl)
|
|
|
|
(*curInv)--;
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-12-06 21:39:41 +01:00
|
|
|
(*curInv)++;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* The main game loop.
|
|
|
|
*/
|
2015-11-24 23:59:30 +01:00
|
|
|
void LabEngine::mainGameLoop() {
|
2015-11-30 13:09:36 +01:00
|
|
|
uint16 actionMode = 4;
|
2015-12-12 19:11:30 +02:00
|
|
|
uint16 curInv = kItemMap;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
bool forceDraw = false;
|
|
|
|
bool gotMessage = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 14:36:49 +01:00
|
|
|
_graphics->setPalette(initcolors, 8);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
2015-11-30 01:42:12 +01:00
|
|
|
_roomNum = 1;
|
2015-12-06 17:24:25 +01:00
|
|
|
_direction = NORTH;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 00:34:43 +01:00
|
|
|
_resource->readRoomData("LAB:Doors");
|
2015-12-03 19:49:55 +01:00
|
|
|
if (!(_inventory = _resource->readInventory("LAB:Inventor")))
|
|
|
|
return;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (!(_conditions = new LargeSet(_highestCondition + 1, this)))
|
2014-10-06 14:50:05 +02:00
|
|
|
return;
|
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (!(_roomsFound = new LargeSet(_manyRooms + 1, this)))
|
2014-10-06 14:50:05 +02:00
|
|
|
return;
|
|
|
|
|
2015-11-29 23:34:35 +01:00
|
|
|
_conditions->readInitialConditions("LAB:Conditio");
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->_longWinInFront = false;
|
|
|
|
_graphics->drawPanel();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
perFlipGadget(actionMode);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
// Set up initial picture.
|
2014-10-06 14:50:05 +02:00
|
|
|
while (1) {
|
2015-12-02 01:39:58 +01:00
|
|
|
_event->processInput(true);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (gotMessage) {
|
2015-12-06 17:24:25 +01:00
|
|
|
if (_quitLab || g_engine->shouldQuit()) {
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->stopDiff();
|
2014-10-06 14:50:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-11-30 01:17:05 +01:00
|
|
|
_music->resumeBackMusic();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sees what kind of close up we're in and does the appropriate stuff, if any.
|
2015-12-09 11:22:41 +01:00
|
|
|
if (doCloseUp(_closeDataPtr)) {
|
|
|
|
_closeDataPtr = nullptr;
|
2014-10-06 14:50:05 +02:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the current picture properly on the screen
|
2015-12-06 21:39:41 +01:00
|
|
|
if (_mainDisplay)
|
2015-12-09 11:22:41 +01:00
|
|
|
_nextFileName = getPictName(&_closeDataPtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (_noUpdateDiff) {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Potentially entered another room
|
|
|
|
_roomsFound->inclElement(_roomNum);
|
2015-12-03 01:06:04 +01:00
|
|
|
forceDraw |= (strcmp(_nextFileName, _curFileName) != 0);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
_noUpdateDiff = false;
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _nextFileName;
|
|
|
|
} else if (strcmp(_nextFileName, _curFileName) != 0) {
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOff();
|
2015-12-08 11:27:34 +01:00
|
|
|
// Potentially entered another room
|
|
|
|
_roomsFound->inclElement(_roomNum);
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _nextFileName;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (_closeDataPtr) {
|
2015-12-12 16:33:01 +02:00
|
|
|
switch (_closeDataPtr->_closeUpType) {
|
|
|
|
case SPECIALLOCK:
|
|
|
|
if (_mainDisplay)
|
|
|
|
_tilePuzzle->showCombination(_curFileName);
|
|
|
|
break;
|
|
|
|
case SPECIALBRICK:
|
|
|
|
case SPECIALBRICKNOMOUSE:
|
|
|
|
if (_mainDisplay)
|
|
|
|
_tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->readPict(_curFileName, false);
|
2015-12-12 16:33:01 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
} else
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->readPict(_curFileName, false);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-11-30 13:09:36 +01:00
|
|
|
forceDraw = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
if (!_followingCrumbs)
|
2014-10-06 14:50:05 +02:00
|
|
|
eatMessages();
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (forceDraw) {
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-11-30 13:09:36 +01:00
|
|
|
forceDraw = false;
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
// Make sure we check the music at least after every message
|
|
|
|
_music->updateMusic();
|
2014-10-06 14:50:05 +02:00
|
|
|
interfaceOn();
|
2015-12-13 15:37:39 +02:00
|
|
|
IntuiMessage *curMsg = _event->getMsg();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!curMsg) {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Does music load and next animation frame when you've run out of messages
|
2015-12-06 21:39:41 +01:00
|
|
|
gotMessage = false;
|
2015-11-30 01:17:05 +01:00
|
|
|
_music->checkRoomMusic();
|
|
|
|
_music->updateMusic();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->diffNextFrame();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
if (_followingCrumbs) {
|
2014-10-06 14:50:05 +02:00
|
|
|
int result = followCrumbs();
|
|
|
|
|
|
|
|
if (result != 0) {
|
2015-11-30 13:09:36 +01:00
|
|
|
uint16 code = 0;
|
2015-12-12 16:33:01 +02:00
|
|
|
switch (result) {
|
|
|
|
case VKEY_UPARROW:
|
2015-11-30 13:09:36 +01:00
|
|
|
code = 7;
|
2015-12-12 16:33:01 +02:00
|
|
|
break;
|
|
|
|
case VKEY_LTARROW:
|
2015-11-30 13:09:36 +01:00
|
|
|
code = 6;
|
2015-12-12 16:33:01 +02:00
|
|
|
break;
|
|
|
|
case VKEY_RTARROW:
|
2015-11-30 13:09:36 +01:00
|
|
|
code = 8;
|
2015-12-12 16:33:01 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
gotMessage = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!fromCrumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
|
2015-11-30 13:09:36 +01:00
|
|
|
break;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
} else {
|
2015-12-06 21:39:41 +01:00
|
|
|
gotMessage = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
Common::Point curPos;
|
2015-12-07 07:18:16 +01:00
|
|
|
curPos.x = curMsg->_mouseX;
|
|
|
|
curPos.y = curMsg->_mouseY;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
_followingCrumbs = false;
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_gadgetID, actionMode))
|
2015-11-30 13:09:36 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
delete _conditions;
|
|
|
|
delete _roomsFound;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (_rooms) {
|
2015-12-07 11:00:54 +02:00
|
|
|
delete[] _rooms;
|
2015-11-30 13:09:36 +01:00
|
|
|
_rooms = nullptr;
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-03 19:49:55 +01:00
|
|
|
if (_inventory) {
|
2015-12-06 17:24:25 +01:00
|
|
|
for (int i = 1; i <= _numInv; i++) {
|
2015-12-06 21:53:57 +01:00
|
|
|
if (_inventory[i]._name)
|
2015-12-07 11:00:54 +02:00
|
|
|
delete _inventory[i]._name;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-06 21:53:57 +01:00
|
|
|
if (_inventory[i]._bitmapName)
|
2015-12-07 11:00:54 +02:00
|
|
|
delete _inventory[i]._bitmapName;
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
|
2015-12-07 11:00:54 +02:00
|
|
|
delete[] _inventory;
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
|
2015-12-08 21:53:42 +01:00
|
|
|
uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
|
2015-11-30 13:09:36 +01:00
|
|
|
uint32 msgClass = tmpClass;
|
|
|
|
Common::Point curPos = tmpPos;
|
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
uint16 oldDirection = 0;
|
2015-12-12 19:11:30 +02:00
|
|
|
uint16 lastInv = kItemMap;
|
2015-12-09 11:22:41 +01:00
|
|
|
CloseDataPtr wrkClosePtr = nullptr;
|
2015-11-30 13:09:36 +01:00
|
|
|
bool doit;
|
|
|
|
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = false;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
|
2015-12-13 16:59:52 +02:00
|
|
|
byte codeLower = tolower(code);
|
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
if (code == 13) {
|
|
|
|
// The return key
|
2015-12-08 09:19:00 +01:00
|
|
|
msgClass = MOUSEBUTTONS;
|
2015-12-08 21:53:42 +01:00
|
|
|
qualifier = IEQUALIFIER_LEFTBUTTON;
|
2015-11-30 13:09:36 +01:00
|
|
|
curPos = _event->getMousePos();
|
2015-12-13 16:59:52 +02:00
|
|
|
} else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Start bread crumbs
|
2015-11-30 13:09:36 +01:00
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_numCrumbs = 0;
|
|
|
|
_droppingCrumbs = true;
|
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-13 16:59:52 +02:00
|
|
|
} else if (codeLower == 'f' || codeLower == 'r') {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Follow bread crumbs
|
2015-11-30 13:09:36 +01:00
|
|
|
if (_droppingCrumbs) {
|
|
|
|
if (_numCrumbs > 0) {
|
|
|
|
_followingCrumbs = true;
|
2015-12-13 16:59:52 +02:00
|
|
|
_followCrumbsFast = (codeLower == 'r');
|
2015-11-30 13:09:36 +01:00
|
|
|
_isCrumbTurning = false;
|
|
|
|
_isCrumbWaiting = false;
|
2015-12-13 04:12:29 +02:00
|
|
|
uint32 t = g_system->getMillis();
|
|
|
|
_crumbSecs = t / 1000;
|
|
|
|
_crumbMicros = t % 1000;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
if (_alternate) {
|
2015-11-30 13:09:36 +01:00
|
|
|
eatMessages();
|
2015-12-03 01:06:04 +01:00
|
|
|
_alternate = false;
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the correct gadget list
|
|
|
|
interfaceOn();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
2015-11-30 13:09:36 +01:00
|
|
|
} else {
|
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_droppingCrumbs = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
// Need to hide indicator!!!!
|
|
|
|
mayShowCrumbIndicatorOff();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-13 16:59:52 +02:00
|
|
|
} else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Quit?
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawMessage("Do you want to quit? (Y/N)");
|
2015-11-30 13:09:36 +01:00
|
|
|
eatMessages();
|
|
|
|
interfaceOff();
|
|
|
|
|
|
|
|
while (1) {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Make sure we check the music at least after every message
|
|
|
|
_music->updateMusic();
|
2015-12-13 15:37:39 +02:00
|
|
|
curMsg = _event->getMsg();
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!curMsg) {
|
2015-12-08 11:27:34 +01:00
|
|
|
// Does music load and next animation frame when you've run out of messages
|
2015-11-30 13:09:36 +01:00
|
|
|
_music->updateMusic();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->diffNextFrame();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else {
|
2015-12-07 07:18:16 +01:00
|
|
|
if (curMsg->_msgClass == RAWKEY) {
|
2015-12-13 16:59:52 +02:00
|
|
|
codeLower = tolower(curMsg->_code);
|
|
|
|
if (codeLower == 'y' || codeLower == 'q') {
|
|
|
|
_anim->stopDiff();
|
|
|
|
return false;
|
2015-12-07 07:18:16 +01:00
|
|
|
} else if (curMsg->_code < 128) {
|
2015-11-30 13:09:36 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-12-07 07:18:16 +01:00
|
|
|
} else if (curMsg->_msgClass == MOUSEBUTTONS) {
|
2014-10-06 14:50:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-13 16:59:52 +02:00
|
|
|
forceDraw = true;
|
|
|
|
interfaceOn();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (code == 9) {
|
|
|
|
// TAB key
|
2015-11-30 13:09:36 +01:00
|
|
|
msgClass = DELTAMOVE;
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (code == 27) {
|
|
|
|
// ESC key
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
eatMessages();
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
if (_graphics->_longWinInFront) {
|
2015-12-08 09:19:00 +01:00
|
|
|
if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) &&
|
2015-12-08 21:53:42 +01:00
|
|
|
((IEQUALIFIER_LEFTBUTTON & qualifier) ||
|
2015-12-13 14:12:18 +01:00
|
|
|
(IEQUALIFIER_RIGHTBUTTON & qualifier)))) {
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->_longWinInFront = false;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2015-12-03 01:06:04 +01:00
|
|
|
} else if ((msgClass == GADGETUP) && !_alternate) {
|
2015-11-30 13:09:36 +01:00
|
|
|
if (gadgetId <= 5) {
|
2015-12-09 11:22:41 +01:00
|
|
|
if ((actionMode == 4) && (gadgetId == 4) && _closeDataPtr) {
|
|
|
|
doMainView(&_closeDataPtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = nullptr;
|
|
|
|
_closeDataPtr = nullptr;
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else if (gadgetId == 5) {
|
|
|
|
eatMessages();
|
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
_alternate = true;
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the correct gadget list
|
|
|
|
interfaceOn();
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (lastInv && _conditions->in(lastInv)) {
|
|
|
|
curInv = lastInv;
|
2015-12-03 01:06:04 +01:00
|
|
|
_nextFileName = getInvName(curInv);
|
2015-11-30 13:09:36 +01:00
|
|
|
} else
|
|
|
|
decIncInv(&curInv, false);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else {
|
2015-12-06 17:24:25 +01:00
|
|
|
uint16 oldActionMode = actionMode;
|
2015-11-30 13:09:36 +01:00
|
|
|
actionMode = gadgetId;
|
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (oldActionMode < 5)
|
|
|
|
perFlipGadget(oldActionMode);
|
2015-11-30 13:09:36 +01:00
|
|
|
|
|
|
|
perFlipGadget(actionMode);
|
|
|
|
|
2015-12-04 02:52:29 +02:00
|
|
|
if (gadgetId <= 4)
|
|
|
|
drawStaticMessage(kTextTakeWhat + gadgetId);
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
} else if (gadgetId == 9) {
|
2015-12-12 19:11:30 +02:00
|
|
|
doUse(kItemMap);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (gadgetId >= 6) {
|
|
|
|
// Arrow Gadgets
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
|
|
|
wrkClosePtr = nullptr;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if ((gadgetId == 6) || (gadgetId == 8)) {
|
|
|
|
if (gadgetId == 6)
|
|
|
|
drawStaticMessage(kTextTurnLeft);
|
|
|
|
else
|
|
|
|
drawStaticMessage(kTextTurnRight);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
oldDirection = _direction;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-08 22:00:19 +01:00
|
|
|
uint16 newDir = processArrow(_direction, gadgetId - 6);
|
2015-12-09 11:22:41 +01:00
|
|
|
doTurn(_direction, newDir, &_closeDataPtr);
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-08 21:53:42 +01:00
|
|
|
_direction = newDir;
|
2015-11-30 13:09:36 +01:00
|
|
|
forceDraw = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else if (gadgetId == 7) {
|
2015-12-06 17:24:25 +01:00
|
|
|
uint16 oldRoomNum = _roomNum;
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (doGoForward(&_closeDataPtr)) {
|
2015-12-06 17:24:25 +01:00
|
|
|
if (oldRoomNum == _roomNum)
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-11-30 13:09:36 +01:00
|
|
|
} else {
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-07 10:08:01 +02:00
|
|
|
_direction = processArrow(_direction, gadgetId - 6);
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (oldRoomNum != _roomNum) {
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextGoForward);
|
2015-12-08 11:27:34 +01:00
|
|
|
// Potentially entered a new room
|
|
|
|
_roomsFound->inclElement(_roomNum);
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2015-11-30 13:09:36 +01:00
|
|
|
forceDraw = true;
|
|
|
|
} else {
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNoPath);
|
|
|
|
}
|
|
|
|
}
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (_followingCrumbs) {
|
|
|
|
if (_isCrumbTurning) {
|
2015-12-06 17:24:25 +01:00
|
|
|
if (_direction == oldDirection) {
|
2015-11-30 13:09:36 +01:00
|
|
|
_followingCrumbs = false;
|
|
|
|
}
|
|
|
|
} else {
|
2015-12-06 17:24:25 +01:00
|
|
|
if (_roomNum == oldRoomNum) { // didn't get there?
|
2015-11-30 13:09:36 +01:00
|
|
|
_followingCrumbs = false;
|
|
|
|
}
|
|
|
|
}
|
2015-12-06 17:24:25 +01:00
|
|
|
} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
|
2015-11-30 13:09:36 +01:00
|
|
|
// If in surreal maze, turn off DroppingCrumbs.
|
|
|
|
if (_roomNum >= 245 && _roomNum <= 280) {
|
|
|
|
_followingCrumbs = false;
|
|
|
|
_droppingCrumbs = false;
|
|
|
|
_numCrumbs = 0;
|
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
} else {
|
|
|
|
bool intersect = false;
|
|
|
|
for (int idx = 0; idx < _numCrumbs; idx++) {
|
|
|
|
if (_breadCrumbs[idx]._roomNum == _roomNum) {
|
|
|
|
_numCrumbs = idx + 1;
|
|
|
|
_breadCrumbs[_numCrumbs]._roomNum = 0;
|
|
|
|
intersect = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (!intersect) {
|
|
|
|
if (_numCrumbs == MAX_CRUMBS) {
|
|
|
|
_numCrumbs = MAX_CRUMBS - 1;
|
|
|
|
memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
|
2015-12-06 17:24:25 +01:00
|
|
|
_breadCrumbs[_numCrumbs++]._direction = _direction;
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-03 01:06:04 +01:00
|
|
|
} else if ((msgClass == GADGETUP) && _alternate) {
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (gadgetId == 0) {
|
|
|
|
eatMessages();
|
2015-12-03 01:06:04 +01:00
|
|
|
_alternate = false;
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the correct gadget list
|
|
|
|
interfaceOn();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
gadgetId--;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (gadgetId == 0) {
|
|
|
|
interfaceOff();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->stopDiff();
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = " ";
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
doit = !saveRestoreGame();
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = nullptr;
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-12 19:11:30 +02:00
|
|
|
curInv = kItemMap;
|
|
|
|
lastInv = kItemMap;
|
2014-12-27 14:18:40 +01:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
_nextFileName = getInvName(curInv);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
if (doit) {
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawMessage("Disk operation failed.");
|
2015-12-06 14:36:49 +01:00
|
|
|
_graphics->setPalette(initcolors, 8);
|
2015-11-30 13:09:36 +01:00
|
|
|
g_system->delayMillis(1000);
|
|
|
|
}
|
2015-12-06 14:36:49 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else if (gadgetId == 1) {
|
|
|
|
if (!doUse(curInv)) {
|
2015-12-06 17:24:25 +01:00
|
|
|
uint16 oldActionMode = actionMode;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Use button
|
|
|
|
actionMode = 5;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if (oldActionMode < 5)
|
|
|
|
perFlipGadget(oldActionMode);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextUseOnWhat);
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
} else if (gadgetId == 2) {
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = !_mainDisplay;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
if ((curInv == 0) || (curInv > _numInv)) {
|
2015-11-30 13:09:36 +01:00
|
|
|
curInv = 1;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
while ((curInv <= _numInv) && (!_conditions->in(curInv)))
|
2015-11-30 13:09:36 +01:00
|
|
|
curInv++;
|
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-08 09:19:00 +01:00
|
|
|
if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
|
2015-12-03 01:06:04 +01:00
|
|
|
_nextFileName = getInvName(curInv);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (gadgetId == 3) {
|
|
|
|
// Left gadget
|
2015-11-30 13:09:36 +01:00
|
|
|
decIncInv(&curInv, true);
|
2015-12-06 17:24:25 +01:00
|
|
|
lastInv = curInv;
|
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (gadgetId == 4) {
|
|
|
|
// Right gadget
|
2015-11-30 13:09:36 +01:00
|
|
|
decIncInv(&curInv, false);
|
2015-12-06 17:24:25 +01:00
|
|
|
lastInv = curInv;
|
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (gadgetId == 5) {
|
|
|
|
// bread crumbs
|
2015-11-30 13:09:36 +01:00
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_numCrumbs = 0;
|
|
|
|
_droppingCrumbs = true;
|
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (gadgetId == 6) {
|
|
|
|
// follow crumbs
|
2015-11-30 13:09:36 +01:00
|
|
|
if (_droppingCrumbs) {
|
|
|
|
if (_numCrumbs > 0) {
|
|
|
|
_followingCrumbs = true;
|
|
|
|
_followCrumbsFast = false;
|
|
|
|
_isCrumbTurning = false;
|
|
|
|
_isCrumbWaiting = false;
|
2015-12-13 04:12:29 +02:00
|
|
|
uint32 t = g_system->getMillis();
|
|
|
|
_crumbSecs = t / 1000;
|
|
|
|
_crumbMicros = t % 1000;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
eatMessages();
|
2015-12-03 01:06:04 +01:00
|
|
|
_alternate = false;
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the correct gadget list
|
|
|
|
interfaceOn();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else {
|
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_droppingCrumbs = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
// Need to hide indicator!!!!
|
|
|
|
mayShowCrumbIndicatorOff();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-08 21:53:42 +01:00
|
|
|
} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier) && _mainDisplay) {
|
2015-11-30 13:09:36 +01:00
|
|
|
interfaceOff();
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
doit = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (_closeDataPtr) {
|
2015-12-12 16:33:01 +02:00
|
|
|
switch (_closeDataPtr->_closeUpType) {
|
|
|
|
case SPECIALLOCK:
|
|
|
|
if (_mainDisplay)
|
|
|
|
_tilePuzzle->mouseCombination(curPos);
|
|
|
|
break;
|
|
|
|
case SPECIALBRICK:
|
|
|
|
if (_mainDisplay)
|
|
|
|
_tilePuzzle->mouseTile(curPos);
|
|
|
|
break;
|
|
|
|
default:
|
2015-11-30 13:09:36 +01:00
|
|
|
doit = true;
|
2015-12-12 16:33:01 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-11-30 13:09:36 +01:00
|
|
|
} else
|
|
|
|
doit = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (doit) {
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = nullptr;
|
2015-11-30 13:09:36 +01:00
|
|
|
eatMessages();
|
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
if (actionMode == 0) {
|
|
|
|
// Take something.
|
2015-12-09 11:22:41 +01:00
|
|
|
if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_closeDataPtr))
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _newFileName;
|
2015-12-09 11:22:41 +01:00
|
|
|
else if (takeItem(curPos.x, curPos.y, &_closeDataPtr))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextTakeItem);
|
2015-12-09 11:22:41 +01:00
|
|
|
else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _newFileName;
|
2015-12-09 11:22:41 +01:00
|
|
|
else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _newFileName;
|
2015-12-07 17:46:37 +01:00
|
|
|
else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if ((actionMode == 1) || (actionMode == 2) || (actionMode == 3)) {
|
|
|
|
// Manipulate an object, Open up a "door" or Close a "door"
|
2015-12-09 11:22:41 +01:00
|
|
|
if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _newFileName;
|
2015-12-09 11:22:41 +01:00
|
|
|
else if (!doActionRule(curPos, actionMode, 0, &_closeDataPtr)) {
|
2015-12-07 17:46:37 +01:00
|
|
|
if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if (actionMode == 4) {
|
|
|
|
// Look at closeups
|
2015-12-09 11:22:41 +01:00
|
|
|
CloseDataPtr tmpClosePtr = _closeDataPtr;
|
2015-12-09 19:53:23 +01:00
|
|
|
setCurrentClose(curPos, &tmpClosePtr, true);
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (_closeDataPtr == tmpClosePtr) {
|
2015-12-07 17:46:37 +01:00
|
|
|
if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2015-12-09 11:22:41 +01:00
|
|
|
} else if (tmpClosePtr->_graphicName) {
|
|
|
|
if (*(tmpClosePtr->_graphicName)) {
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-09 11:22:41 +01:00
|
|
|
_closeDataPtr = tmpClosePtr;
|
2015-12-07 17:46:37 +01:00
|
|
|
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2015-12-07 17:46:37 +01:00
|
|
|
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2015-12-08 11:27:34 +01:00
|
|
|
} else if ((actionMode == 5) && _conditions->in(curInv)) {
|
|
|
|
// Use an item on something else
|
2015-12-09 11:22:41 +01:00
|
|
|
if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
|
2015-12-03 01:06:04 +01:00
|
|
|
_curFileName = _newFileName;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
|
|
|
if (!_conditions->in(curInv))
|
|
|
|
decIncInv(&curInv, false);
|
2015-12-07 17:46:37 +01:00
|
|
|
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
|
2015-11-30 13:09:36 +01:00
|
|
|
drawStaticMessage(kTextNothing);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:09:36 +01:00
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2015-11-30 13:09:36 +01:00
|
|
|
} else if (msgClass == DELTAMOVE) {
|
2015-12-08 22:00:19 +01:00
|
|
|
ViewData *vptr = getViewData(_roomNum, _direction);
|
2015-12-09 11:22:41 +01:00
|
|
|
CloseDataPtr oldClosePtr = vptr->_closeUps;
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!wrkClosePtr) {
|
|
|
|
CloseDataPtr tmpClosePtr = _closeDataPtr;
|
2015-12-09 19:53:23 +01:00
|
|
|
setCurrentClose(curPos, &tmpClosePtr, true);
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!tmpClosePtr || (tmpClosePtr == _closeDataPtr)) {
|
|
|
|
if (!_closeDataPtr)
|
|
|
|
wrkClosePtr = oldClosePtr;
|
2015-11-30 13:09:36 +01:00
|
|
|
else
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = _closeDataPtr->_subCloseUps;
|
2015-11-30 13:09:36 +01:00
|
|
|
} else
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = tmpClosePtr->_nextCloseUp;
|
2015-11-30 13:09:36 +01:00
|
|
|
} else
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = wrkClosePtr->_nextCloseUp;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (!wrkClosePtr) {
|
|
|
|
if (!_closeDataPtr)
|
|
|
|
wrkClosePtr = oldClosePtr;
|
2015-11-30 13:09:36 +01:00
|
|
|
else
|
2015-12-09 11:22:41 +01:00
|
|
|
wrkClosePtr = _closeDataPtr->_subCloseUps;
|
2015-11-30 13:09:36 +01:00
|
|
|
}
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-09 11:22:41 +01:00
|
|
|
if (wrkClosePtr)
|
|
|
|
_event->setMousePos(Common::Point(_utils->scaleX((wrkClosePtr->_x1 + wrkClosePtr->_x2) / 2), _utils->scaleY((wrkClosePtr->_y1 + wrkClosePtr->_y2) / 2)));
|
2015-12-13 14:12:18 +01:00
|
|
|
} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) {
|
2015-11-30 13:09:36 +01:00
|
|
|
eatMessages();
|
2015-12-03 01:06:04 +01:00
|
|
|
_alternate = !_alternate;
|
2015-12-02 00:34:51 +01:00
|
|
|
_anim->_doBlack = true;
|
2015-12-06 17:24:25 +01:00
|
|
|
_graphics->_doNotDrawMessage = false;
|
2015-12-06 21:39:41 +01:00
|
|
|
_mainDisplay = true;
|
2015-12-08 11:27:34 +01:00
|
|
|
// Sets the correct gadget list
|
|
|
|
interfaceOn();
|
2015-11-30 13:09:36 +01:00
|
|
|
|
2015-12-03 01:06:04 +01:00
|
|
|
if (_alternate) {
|
2015-12-06 17:24:25 +01:00
|
|
|
if (lastInv && _conditions->in(lastInv))
|
|
|
|
curInv = lastInv;
|
2015-11-30 13:09:36 +01:00
|
|
|
else
|
|
|
|
decIncInv(&curInv, false);
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->drawPanel();
|
2015-12-09 11:22:41 +01:00
|
|
|
drawRoomMessage(curInv, _closeDataPtr);
|
2015-11-30 13:09:36 +01:00
|
|
|
|
|
|
|
mayShowCrumbIndicator();
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
2015-11-30 13:09:36 +01:00
|
|
|
return true;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2014-12-27 14:18:40 +01:00
|
|
|
void LabEngine::go() {
|
2015-11-30 00:12:01 +01:00
|
|
|
_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
|
2015-12-08 17:19:08 +02:00
|
|
|
_graphics->setUpScreens();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->initMouse();
|
2015-12-03 11:01:50 +01:00
|
|
|
_msgFont = _resource->getFont("P:AvanteG.12");
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseHide();
|
2015-02-25 00:37:07 +02:00
|
|
|
|
2015-12-04 22:10:07 +02:00
|
|
|
Intro *intro = new Intro(this);
|
|
|
|
intro->introSequence();
|
|
|
|
delete intro;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-04 21:18:41 +02:00
|
|
|
_event->mouseShow();
|
|
|
|
mainGameLoop();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-08 11:27:34 +01:00
|
|
|
if (_quitLab) {
|
|
|
|
// Won the game
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->blackAllScreen();
|
|
|
|
_graphics->readPict("P:End/L2In.1", true);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-27 23:18:15 +01:00
|
|
|
for (uint16 i = 0; i < 120; i++) {
|
2015-11-30 01:17:05 +01:00
|
|
|
_music->updateMusic();
|
2014-10-06 14:50:05 +02:00
|
|
|
waitTOF();
|
|
|
|
}
|
|
|
|
|
2015-12-04 13:32:08 +01:00
|
|
|
_graphics->readPict("P:End/L2In.9", true);
|
|
|
|
_graphics->readPict("P:End/Lost", true);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
warning("STUB: waitForPress");
|
|
|
|
while (!1) { // 1 means ignore SDL_ProcessInput calls
|
2015-11-30 01:17:05 +01:00
|
|
|
_music->updateMusic();
|
2015-12-01 20:10:42 +01:00
|
|
|
_anim->diffNextFrame();
|
2014-10-06 14:50:05 +02:00
|
|
|
waitTOF();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-07 07:48:54 +01:00
|
|
|
_graphics->closeFont(_msgFont);
|
2015-12-04 21:18:41 +02:00
|
|
|
_graphics->freePict();
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-02 20:32:06 +01:00
|
|
|
freeScreens();
|
|
|
|
|
2015-11-30 01:17:05 +01:00
|
|
|
_music->freeMusic();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 09:46:54 +01:00
|
|
|
/**
|
|
|
|
* New code to allow quick(er) return navigation in game.
|
|
|
|
*/
|
2015-11-30 07:13:09 +01:00
|
|
|
int LabEngine::followCrumbs() {
|
2014-10-06 14:50:05 +02:00
|
|
|
// NORTH, SOUTH, EAST, WEST
|
2015-12-13 05:00:10 +02:00
|
|
|
int movement[4][4] = {
|
2014-12-27 14:18:40 +01:00
|
|
|
{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
|
|
|
|
{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
|
|
|
|
{ VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW },
|
|
|
|
{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
|
2014-10-06 14:50:05 +02:00
|
|
|
};
|
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
if (_isCrumbWaiting) {
|
2015-12-13 04:53:12 +02:00
|
|
|
if (g_system->getMillis() <= _crumbSecs * 1000 + _crumbMicros)
|
2014-10-06 14:50:05 +02:00
|
|
|
return 0;
|
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
_isCrumbWaiting = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
if (!_isCrumbTurning)
|
|
|
|
_breadCrumbs[_numCrumbs--]._roomNum = 0;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
|
|
|
// Is the current crumb this room? If not, logic error.
|
2015-12-06 18:31:57 +01:00
|
|
|
if (_roomNum != _breadCrumbs[_numCrumbs]._roomNum) {
|
2015-11-30 07:13:09 +01:00
|
|
|
_numCrumbs = 0;
|
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_droppingCrumbs = false;
|
|
|
|
_followingCrumbs = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
int exitDir;
|
2015-11-27 23:18:15 +01:00
|
|
|
|
2014-10-06 14:50:05 +02:00
|
|
|
// which direction is last crumb
|
2015-11-30 07:13:09 +01:00
|
|
|
if (_breadCrumbs[_numCrumbs]._direction == EAST)
|
|
|
|
exitDir = WEST;
|
|
|
|
else if (_breadCrumbs[_numCrumbs]._direction == WEST)
|
|
|
|
exitDir = EAST;
|
|
|
|
else if (_breadCrumbs[_numCrumbs]._direction == NORTH)
|
|
|
|
exitDir = SOUTH;
|
2014-10-06 14:50:05 +02:00
|
|
|
else
|
2015-11-30 07:13:09 +01:00
|
|
|
exitDir = NORTH;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-06 17:24:25 +01:00
|
|
|
int moveDir = movement[_direction][exitDir];
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
if (_numCrumbs == 0) {
|
|
|
|
_isCrumbTurning = false;
|
|
|
|
_breadCrumbs[0]._roomNum = 0;
|
|
|
|
_droppingCrumbs = false;
|
|
|
|
_followingCrumbs = false;
|
2014-10-06 14:50:05 +02:00
|
|
|
} else {
|
2015-11-30 07:13:09 +01:00
|
|
|
int theDelay = (_followCrumbsFast ? ONESECOND / 4 : ONESECOND);
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
_isCrumbTurning = (moveDir != VKEY_UPARROW);
|
|
|
|
_isCrumbWaiting = true;
|
2014-10-06 14:50:05 +02:00
|
|
|
|
2015-12-13 04:53:12 +02:00
|
|
|
_crumbSecs = (theDelay + g_system->getMillis()) / 1000;
|
|
|
|
_crumbMicros = (theDelay + g_system->getMillis()) % 1000;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 07:13:09 +01:00
|
|
|
return moveDir;
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-01 21:42:44 +01:00
|
|
|
byte dropCrumbs[] = { 0x00 };
|
|
|
|
Image dropCrumbsImage(24, 24, dropCrumbs);
|
|
|
|
|
2015-11-24 23:59:30 +01:00
|
|
|
void LabEngine::mayShowCrumbIndicator() {
|
|
|
|
if (getPlatform() != Common::kPlatformWindows)
|
2014-12-27 14:18:40 +01:00
|
|
|
return;
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (_droppingCrumbs && _mainDisplay) {
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseHide();
|
2015-12-01 21:42:44 +01:00
|
|
|
dropCrumbsImage.drawMaskImage(612, 4);
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseShow();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-01 21:42:44 +01:00
|
|
|
byte dropCrumbsOff[] = { 0x00 };
|
|
|
|
Image dropCrumbsOffImage(24, 24, dropCrumbsOff);
|
|
|
|
|
2015-11-24 23:59:30 +01:00
|
|
|
void LabEngine::mayShowCrumbIndicatorOff() {
|
|
|
|
if (getPlatform() != Common::kPlatformWindows)
|
2014-12-27 14:18:40 +01:00
|
|
|
return;
|
|
|
|
|
2015-12-06 21:39:41 +01:00
|
|
|
if (_mainDisplay) {
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseHide();
|
2015-12-01 21:42:44 +01:00
|
|
|
dropCrumbsOffImage.drawMaskImage(612, 4);
|
2015-11-29 18:10:06 +01:00
|
|
|
_event->mouseShow();
|
2014-10-06 14:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Lab
|