2021-03-16 09:49:39 +01: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-09 13:55:50 +01:00
|
|
|
#include "scheduler.h"
|
2021-05-04 22:19:15 +01:00
|
|
|
#include "trecision/3d.h"
|
|
|
|
#include "trecision/actor.h"
|
2021-04-28 21:33:53 +01:00
|
|
|
#include "trecision/defines.h"
|
2021-04-13 21:48:04 +03:00
|
|
|
#include "trecision/graphics.h"
|
|
|
|
#include "trecision/logic.h"
|
2021-05-08 14:21:09 +03:00
|
|
|
#include "trecision/text.h"
|
2021-03-16 09:49:39 +01:00
|
|
|
#include "trecision/trecision.h"
|
2021-03-19 23:12:03 +01:00
|
|
|
#include "trecision/video.h"
|
2021-05-04 22:19:15 +01:00
|
|
|
|
2021-03-16 09:49:39 +01:00
|
|
|
namespace Trecision {
|
2021-03-16 12:11:29 +01:00
|
|
|
|
2021-04-08 22:44:18 +01:00
|
|
|
void TrecisionEngine::refreshInventory(uint8 startIcon, uint8 startLine) {
|
|
|
|
if (startLine > ICONDY)
|
2021-05-17 00:40:24 +03:00
|
|
|
return;
|
2021-03-16 09:49:39 +01:00
|
|
|
|
2021-05-07 01:48:05 +03:00
|
|
|
_graphicsMgr->clearScreenBufferInventory();
|
2021-03-16 09:49:39 +01:00
|
|
|
|
2021-05-17 12:21:58 +03:00
|
|
|
for (byte iconSlot = 0; iconSlot < ICONSHOWN; iconSlot++) {
|
|
|
|
if (iconSlot + startIcon >= _inventory.size())
|
2021-04-29 21:21:33 +03:00
|
|
|
break;
|
2021-05-17 12:21:58 +03:00
|
|
|
const byte iconIndex = _inventory[iconSlot + startIcon];
|
2021-05-17 02:34:39 +03:00
|
|
|
if (iconIndex == _lightIcon)
|
|
|
|
continue;
|
2021-04-29 21:21:33 +03:00
|
|
|
|
2021-05-17 12:21:58 +03:00
|
|
|
if (iconIndex < EMPTYSLOT)
|
|
|
|
_graphicsMgr->drawInventoryIcon(iconIndex - 1, iconSlot, startLine);
|
|
|
|
else
|
|
|
|
_graphicsMgr->drawSaveSlotThumbnail(iconIndex - EMPTYSLOT - 1, iconSlot, startLine);
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-05-17 00:40:24 +03:00
|
|
|
if (startIcon != 0)
|
|
|
|
_graphicsMgr->drawLeftInventoryArrow(startLine);
|
2021-03-16 09:49:39 +01:00
|
|
|
|
2021-05-18 22:07:57 +01:00
|
|
|
if (startIcon + ICONSHOWN < (int)_inventory.size())
|
2021-05-17 00:40:24 +03:00
|
|
|
_graphicsMgr->drawRightInventoryArrow(startLine);
|
2021-03-16 09:49:39 +01:00
|
|
|
|
2021-04-14 01:20:17 +03:00
|
|
|
_graphicsMgr->copyToScreen(0, FIRSTLINE, MAXX, ICONDY);
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-04-08 22:44:18 +01:00
|
|
|
void TrecisionEngine::setInventoryStart(uint8 startIcon, uint8 startLine) {
|
|
|
|
_inventoryRefreshStartIcon = startIcon;
|
|
|
|
_inventoryRefreshStartLine = startLine;
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-03-16 12:11:29 +01:00
|
|
|
void TrecisionEngine::moveInventoryLeft() {
|
2021-04-29 21:21:33 +03:00
|
|
|
if (_iconBase < _inventory.size() - ICONSHOWN)
|
2021-03-16 09:49:39 +01:00
|
|
|
_iconBase++;
|
2021-03-18 13:31:55 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-03-16 12:11:29 +01:00
|
|
|
void TrecisionEngine::moveInventoryRight() {
|
2021-03-16 09:49:39 +01:00
|
|
|
if (_iconBase > 0)
|
|
|
|
_iconBase--;
|
2021-03-18 13:31:55 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::doInventory() {
|
|
|
|
switch (_curMessage->_event) {
|
|
|
|
case ME_OPEN:
|
2021-04-10 23:47:14 +01:00
|
|
|
if (!_flagInventoryLocked && (_inventoryStatus == INV_OFF) && !_flagDialogActive) {
|
2021-03-18 13:31:55 +01:00
|
|
|
_inventoryCounter = INVENTORY_HIDE;
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
_inventoryStatus = INV_PAINT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_CLOSE:
|
2021-04-10 23:47:14 +01:00
|
|
|
if (!_flagInventoryLocked && (_inventoryStatus == INV_INACTION) && !_flagDialogActive) {
|
2021-03-18 13:31:55 +01:00
|
|
|
_inventoryCounter = INVENTORY_SHOW;
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
_inventoryStatus = INV_DEPAINT;
|
|
|
|
_lightIcon = 0xFF;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_ONELEFT:
|
|
|
|
if (_inventoryStatus == INV_INACTION)
|
|
|
|
moveInventoryLeft();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_ONERIGHT:
|
|
|
|
if (_inventoryStatus == INV_INACTION)
|
|
|
|
moveInventoryRight();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_OPERATEICON:
|
2021-05-06 22:03:56 +01:00
|
|
|
_curInventory = whatIcon(_mousePos);
|
2021-03-18 13:31:55 +01:00
|
|
|
if (_curInventory == 0)
|
|
|
|
break;
|
|
|
|
|
2021-04-10 23:47:14 +01:00
|
|
|
if (_flagUseWithStarted) {
|
2021-03-18 13:31:55 +01:00
|
|
|
_flagInventoryLocked = false;
|
2021-04-10 23:47:14 +01:00
|
|
|
_flagUseWithStarted = false;
|
2021-03-18 13:31:55 +01:00
|
|
|
_useWith[WITH] = _curInventory;
|
|
|
|
_useWithInv[WITH] = true;
|
|
|
|
|
|
|
|
if (_useWith[USED] != _curInventory) {
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_ACTION, ME_USEWITH, MP_DEFAULT, 0, 0, 0, 0);
|
2021-03-18 13:31:55 +01:00
|
|
|
_lightIcon = 0xFF;
|
2021-03-24 16:05:42 +01:00
|
|
|
} else {
|
2021-04-18 22:29:44 +03:00
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
2021-03-20 23:18:33 +01:00
|
|
|
showInventoryName(_curInventory, true);
|
2021-03-18 13:31:55 +01:00
|
|
|
_lightIcon = _curInventory;
|
|
|
|
}
|
2021-04-20 20:17:23 +03:00
|
|
|
} else if (_inventoryObj[_curInventory]._flag & kObjFlagUseWith) {
|
2021-04-24 16:12:16 +03:00
|
|
|
if ((_curInventory == kItemFlare) && (_curRoom == kRoom29)) {
|
2021-05-14 20:08:33 +01:00
|
|
|
_textMgr->characterSay(1565);
|
2021-03-18 13:31:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
_animMgr->startSmkAnim(_inventoryObj[_curInventory]._anim);
|
|
|
|
_lightIcon = _curInventory;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
_flagInventoryLocked = true;
|
2021-04-10 23:47:14 +01:00
|
|
|
_flagUseWithStarted = true;
|
2021-03-18 13:31:55 +01:00
|
|
|
_useWith[USED] = _curInventory;
|
|
|
|
_useWithInv[USED] = true;
|
2021-03-20 23:18:33 +01:00
|
|
|
showInventoryName(_curInventory, true);
|
2021-03-24 16:05:42 +01:00
|
|
|
} else
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_ACTION, ME_INVOPERATE, MP_DEFAULT, 0, 0, 0, _curInventory);
|
2021-03-18 13:31:55 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_EXAMINEICON:
|
2021-05-06 22:03:56 +01:00
|
|
|
_curInventory = whatIcon(_mousePos);
|
2021-05-01 11:51:28 +01:00
|
|
|
_actor->actorStop();
|
2021-05-03 20:33:23 +01:00
|
|
|
_pathFind->nextStep();
|
2021-04-10 23:47:14 +01:00
|
|
|
if (_flagUseWithStarted) {
|
2021-03-18 13:31:55 +01:00
|
|
|
_flagInventoryLocked = false;
|
2021-04-10 23:47:14 +01:00
|
|
|
_flagUseWithStarted = false;
|
2021-03-18 13:31:55 +01:00
|
|
|
_useWith[WITH] = _curInventory;
|
|
|
|
_useWithInv[WITH] = true;
|
|
|
|
if (_useWith[USED] != _curInventory) {
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_ACTION, ME_USEWITH, MP_DEFAULT, 0, 0, 0, 0);
|
2021-03-18 13:31:55 +01:00
|
|
|
_lightIcon = 0xFF;
|
2021-03-24 16:05:42 +01:00
|
|
|
} else {
|
2021-04-18 22:29:44 +03:00
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
2021-03-20 23:18:33 +01:00
|
|
|
showInventoryName(_curInventory, true);
|
2021-03-18 13:31:55 +01:00
|
|
|
_lightIcon = _curInventory;
|
|
|
|
}
|
2021-03-24 16:05:42 +01:00
|
|
|
} else
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_ACTION, ME_INVEXAMINE, MP_DEFAULT, 0, 0, 0, _curInventory);
|
2021-03-18 13:31:55 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ME_SHOWICONNAME:
|
2021-05-06 22:03:56 +01:00
|
|
|
if (isIconArea(_mousePos)) {
|
2021-03-18 13:31:55 +01:00
|
|
|
if (_inventoryStatus != INV_ON)
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_INVENTORY, ME_OPEN, MP_DEFAULT, 0, 0, 0, 0);
|
2021-05-06 22:03:56 +01:00
|
|
|
_curInventory = whatIcon(_mousePos);
|
2021-03-20 23:18:33 +01:00
|
|
|
showInventoryName(_curInventory, true);
|
2021-03-18 13:31:55 +01:00
|
|
|
|
2021-04-10 23:47:14 +01:00
|
|
|
if (!_flagUseWithStarted && !_flagSomeoneSpeaks) {
|
2021-03-18 13:31:55 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
2021-03-24 16:05:42 +01:00
|
|
|
} else {
|
2021-05-06 22:03:56 +01:00
|
|
|
if (!isInventoryArea(_mousePos))
|
2021-03-18 13:31:55 +01:00
|
|
|
break;
|
2021-03-20 23:18:33 +01:00
|
|
|
showInventoryName(NO_OBJECTS, true);
|
2021-04-10 23:47:14 +01:00
|
|
|
if (!_flagUseWithStarted) {
|
2021-03-18 13:31:55 +01:00
|
|
|
_lightIcon = 0xFF;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2021-04-30 23:40:17 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2021-03-18 13:31:55 +01:00
|
|
|
}
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
uint8 TrecisionEngine::whatIcon(Common::Point pos) {
|
|
|
|
if (pos.x < ICONMARGSX || pos.x > MAXX - ICONMARGDX)
|
2021-03-20 23:18:33 +01:00
|
|
|
return 0;
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
int index = _iconBase + ((pos.x - ICONMARGSX) / (ICONDX));
|
2021-05-18 22:07:57 +01:00
|
|
|
|
|
|
|
return index < (int)_inventory.size() ? _inventory[index] : 0;
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
2021-04-29 21:21:33 +03:00
|
|
|
int8 TrecisionEngine::iconPos(uint8 icon) {
|
|
|
|
for (uint8 i = 0; i < _inventory.size(); i++) {
|
2021-03-20 23:18:33 +01:00
|
|
|
if (_inventory[i] == icon)
|
2021-04-29 21:21:33 +03:00
|
|
|
return i;
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
2021-04-29 21:21:33 +03:00
|
|
|
return -1;
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::showInventoryName(uint16 obj, bool showhide) {
|
2021-05-05 00:54:15 +03:00
|
|
|
if (_logicMgr->isCloseupOrControlRoom() || _flagSomeoneSpeaks)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
if (_lastObj) {
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearLastText();
|
2021-04-08 22:25:19 +01:00
|
|
|
_lastObj = 0;
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 23:32:28 +01:00
|
|
|
if (_flagUseWithStarted) {
|
2021-03-20 23:18:33 +01:00
|
|
|
if (!showhide) {
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearLastText();
|
2021-04-08 22:25:19 +01:00
|
|
|
_lastInv = 0;
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-04-08 22:25:19 +01:00
|
|
|
if ((obj | 0x8000) == _lastInv)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
char locsent[256];
|
2021-04-01 10:27:14 +03:00
|
|
|
strcpy(locsent, _sysText[kMessageUse]);
|
2021-03-20 23:18:33 +01:00
|
|
|
if (_useWithInv[USED]) {
|
|
|
|
strcat(locsent, _objName[_inventoryObj[_useWith[USED]]._name]);
|
2021-04-01 10:27:14 +03:00
|
|
|
strcat(locsent, _sysText[kMessageWith]);
|
2021-03-20 23:18:33 +01:00
|
|
|
if (obj && (_inventoryObj[_useWith[USED]]._name != _inventoryObj[obj]._name))
|
|
|
|
strcat(locsent, _objName[_inventoryObj[obj]._name]);
|
|
|
|
} else {
|
|
|
|
if (_obj[_useWith[USED]]._mode & OBJMODE_HIDDEN)
|
2021-05-18 19:50:35 +03:00
|
|
|
strcat(locsent, "?"); // dunno
|
2021-03-20 23:18:33 +01:00
|
|
|
else
|
|
|
|
strcat(locsent, _objName[_obj[_useWith[USED]]._name]);
|
2021-04-01 10:27:14 +03:00
|
|
|
strcat(locsent, _sysText[kMessageWith]);
|
2021-03-20 23:18:33 +01:00
|
|
|
if (obj && (_obj[_useWith[USED]]._name != _inventoryObj[obj]._name))
|
|
|
|
strcat(locsent, _objName[_inventoryObj[obj]._name]);
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:23:17 +01:00
|
|
|
uint16 lenText = textLength(locsent);
|
2021-04-14 01:20:17 +03:00
|
|
|
uint16 posX = CLIP(320 - (lenText / 2), 2, MAXX - 2 - lenText);
|
2021-03-24 22:49:16 +01:00
|
|
|
uint16 posY = MAXY - CARHEI;
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
_lastInv = (obj | 0x8000);
|
|
|
|
if (_lastInv)
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearLastText();
|
|
|
|
_textMgr->addText(posX, posY, locsent, COLOR_INVENTORY, MASKCOL);
|
2021-03-20 23:18:33 +01:00
|
|
|
} else {
|
2021-04-08 22:25:19 +01:00
|
|
|
if (obj == _lastInv)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!obj || !showhide) {
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearLastText();
|
2021-04-08 22:25:19 +01:00
|
|
|
_lastInv = 0;
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-03-24 22:49:16 +01:00
|
|
|
uint16 posX = ICONMARGSX + ((iconPos(_curInventory) - _iconBase) * (ICONDX)) + ICONDX / 2;
|
|
|
|
uint16 posY = MAXY - CARHEI;
|
2021-04-08 22:25:19 +01:00
|
|
|
_lastInv = obj;
|
2021-05-14 17:23:17 +01:00
|
|
|
uint16 lenText = textLength(_objName[_inventoryObj[obj]._name]);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-04-14 01:20:17 +03:00
|
|
|
posX = CLIP(posX - (lenText / 2), 2, MAXX - 2 - lenText);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-04-08 22:25:19 +01:00
|
|
|
if (_lastInv)
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearLastText();
|
2021-03-20 23:18:33 +01:00
|
|
|
|
|
|
|
if (_inventoryObj[obj]._name)
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->addText(posX, posY, _objName[_inventoryObj[obj]._name], COLOR_INVENTORY, MASKCOL);
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::removeIcon(uint8 icon) {
|
2021-04-29 21:21:33 +03:00
|
|
|
int8 pos = iconPos(icon);
|
|
|
|
if (pos == -1)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-29 21:21:33 +03:00
|
|
|
_inventory.remove_at(pos);
|
2021-05-20 09:27:36 +03:00
|
|
|
_iconBase = _inventory.size() <= ICONSHOWN ? 0 : _inventory.size() - ICONSHOWN;
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->redrawString();
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::addIcon(uint8 icon) {
|
2021-04-29 21:21:33 +03:00
|
|
|
if (iconPos(icon) != -1)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-29 21:21:33 +03:00
|
|
|
_inventory.push_back(icon);
|
2021-05-20 09:27:36 +03:00
|
|
|
_iconBase = _inventory.size() <= ICONSHOWN ? 0 : _inventory.size() - ICONSHOWN;
|
2021-03-20 23:18:33 +01:00
|
|
|
|
|
|
|
// To show the icon that enters the inventory
|
|
|
|
// doEvent(MC_INVENTORY,ME_OPEN,MP_DEFAULT,0,0,0,0);
|
|
|
|
// FlagForceRegenInventory = true;
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->redrawString();
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::replaceIcon(uint8 oldIcon, uint8 newIcon) {
|
2021-04-29 21:21:33 +03:00
|
|
|
int8 pos = iconPos(oldIcon);
|
|
|
|
if (pos >= 0)
|
|
|
|
_inventory[pos] = newIcon;
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::doInventoryUseWithInventory() {
|
|
|
|
if (!_useWith[USED] || !_useWith[WITH])
|
2021-03-24 22:49:16 +01:00
|
|
|
warning("doInventoryUseWithInventory - _useWith not set properly");
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-04-18 22:29:44 +03:00
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-03-24 16:05:42 +01:00
|
|
|
bool refreshInventory, printSentence;
|
2021-03-25 10:21:26 +01:00
|
|
|
_logicMgr->useInventoryWithInventory(&refreshInventory, &printSentence);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
|
|
|
if (printSentence)
|
2021-05-14 20:08:33 +01:00
|
|
|
_textMgr->characterSay(_inventoryObj[_useWith[USED]]._action);
|
2021-03-24 16:05:42 +01:00
|
|
|
if (refreshInventory)
|
2021-03-20 23:18:33 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::doInventoryUseWithScreen() {
|
|
|
|
if (!_useWith[USED] || !_useWith[WITH])
|
2021-03-24 22:49:16 +01:00
|
|
|
warning("doInventoryUseWithScreen - _useWith not set properly");
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-04-18 22:29:44 +03:00
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
2021-05-03 20:33:23 +01:00
|
|
|
if (_pathFind->_characterInMovement)
|
2021-03-20 23:18:33 +01:00
|
|
|
return;
|
2021-04-23 22:36:31 +03:00
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
bool refreshInventory, printSentence;
|
2021-03-25 10:21:26 +01:00
|
|
|
_logicMgr->useInventoryWithScreen(&refreshInventory, &printSentence);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
if (printSentence)
|
2021-05-14 20:08:33 +01:00
|
|
|
_textMgr->characterSay(_inventoryObj[_useWith[USED]]._action);
|
2021-03-20 23:18:33 +01:00
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
if (refreshInventory)
|
2021-03-20 23:18:33 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
|
2021-04-10 19:05:23 +01:00
|
|
|
void TrecisionEngine::rollInventory(uint8 status) {
|
|
|
|
if (status == INV_PAINT) {
|
|
|
|
_inventoryCounter -= _inventorySpeed[_inventorySpeedIndex++];
|
|
|
|
if (_inventoryCounter <= INVENTORY_SHOW || _inventorySpeedIndex > 5) {
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
_inventoryStatus = INV_INACTION;
|
|
|
|
_inventoryCounter = INVENTORY_SHOW;
|
2021-05-06 22:03:56 +01:00
|
|
|
if (!isInventoryArea(_mousePos))
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_INVENTORY, ME_CLOSE, MP_DEFAULT, 0, 0, 0, 0);
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->redrawString();
|
2021-04-10 19:05:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (status == INV_DEPAINT) {
|
|
|
|
_inventoryCounter += _inventorySpeed[_inventorySpeedIndex++];
|
|
|
|
|
|
|
|
if (_inventoryCounter > INVENTORY_HIDE || _inventorySpeedIndex > 5) {
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_HIDE);
|
|
|
|
_inventoryStatus = INV_OFF;
|
|
|
|
_inventoryCounter = INVENTORY_HIDE;
|
2021-05-06 22:03:56 +01:00
|
|
|
if (isInventoryArea(_mousePos) && !(_flagDialogActive || _flagDialogMenuActive))
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_INVENTORY, ME_OPEN, MP_DEFAULT, 0, 0, 0, 0);
|
2021-04-10 19:05:23 +01:00
|
|
|
else
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->redrawString();
|
2021-04-10 19:05:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setInventoryStart(_iconBase, _inventoryCounter);
|
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
void TrecisionEngine::doScrollInventory(Common::Point pos) {
|
2021-04-29 21:21:33 +03:00
|
|
|
if (_inventoryStatus == INV_PAINT || _inventoryStatus == INV_DEPAINT)
|
2021-04-10 19:05:23 +01:00
|
|
|
return;
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
if (pos.x <= ICONMARGSX && _iconBase)
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_INVENTORY, ME_ONERIGHT, MP_DEFAULT, 0, 0, 0, 0);
|
2021-05-18 22:07:57 +01:00
|
|
|
else if (isBetween(MAXX - ICONMARGDX, pos.x, MAXX) && (_iconBase + ICONSHOWN < (int)_inventory.size()))
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_INVENTORY, ME_ONELEFT, MP_DEFAULT, 0, 0, 0, 0);
|
2021-04-10 19:05:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-29 21:21:33 +03:00
|
|
|
void TrecisionEngine::syncInventory(Common::Serializer &ser) {
|
|
|
|
if (ser.isLoading()) {
|
|
|
|
_inventory.clear();
|
|
|
|
_cyberInventory.clear();
|
|
|
|
}
|
|
|
|
|
2021-04-30 23:40:17 +01:00
|
|
|
for (uint which = 0; which <= 1; which++) {
|
|
|
|
for (uint i = 0; i < MAXICON; i++) {
|
2021-04-29 21:21:33 +03:00
|
|
|
byte val = 0;
|
|
|
|
if (ser.isSaving()) {
|
|
|
|
if (which == 0)
|
|
|
|
val = i < _inventory.size() ? _inventory[i] : 0;
|
|
|
|
else
|
|
|
|
val = i < _cyberInventory.size() ? _cyberInventory[i] : 0;
|
|
|
|
ser.syncAsByte(val);
|
|
|
|
} else {
|
|
|
|
ser.syncAsByte(val);
|
|
|
|
if (val != kItemNull) {
|
|
|
|
if (which == 0)
|
|
|
|
_inventory.push_back(val);
|
|
|
|
else
|
|
|
|
_cyberInventory.push_back(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 09:49:39 +01:00
|
|
|
} // End of namespace Trecision
|