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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2021-03-16 09:49:39 +01:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-03-16 09:49:39 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-04 22:19:15 +01:00
|
|
|
#include "trecision/actor.h"
|
2022-01-24 00:24:05 +02:00
|
|
|
#include "trecision/animmanager.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-06-09 02:52:21 +03:00
|
|
|
#include "trecision/pathfinding3d.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-06-30 09:36:17 +01:00
|
|
|
for (uint8 iconSlot = 0; iconSlot < ICONSHOWN; iconSlot++) {
|
|
|
|
uint8 i = iconSlot + startIcon;
|
|
|
|
if (i >= _inventory.size())
|
2021-04-29 21:21:33 +03:00
|
|
|
break;
|
2021-06-30 09:36:17 +01:00
|
|
|
const byte iconIndex = _inventory[i];
|
2021-05-17 02:34:39 +03:00
|
|
|
if (iconIndex == _lightIcon)
|
|
|
|
continue;
|
2021-04-29 21:21:33 +03:00
|
|
|
|
2021-05-28 23:38:00 +03:00
|
|
|
if (iconIndex <= EMPTYSLOT)
|
2021-05-17 12:21:58 +03:00
|
|
|
_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-05-22 18:48:41 +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)
|
2021-05-22 18:48:41 +01:00
|
|
|
--_iconBase;
|
2021-03-18 13:31:55 +01:00
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
|
2021-05-21 11:49:50 +03:00
|
|
|
void TrecisionEngine::showIconName() {
|
|
|
|
if (isIconArea(_mousePos)) {
|
|
|
|
if (_inventoryStatus != INV_ON)
|
2021-05-24 18:01:45 +03:00
|
|
|
openInventory();
|
2021-05-21 11:49:50 +03:00
|
|
|
_curInventory = whatIcon(_mousePos);
|
|
|
|
showInventoryName(_curInventory, true);
|
|
|
|
|
|
|
|
if (!_flagUseWithStarted && !_flagSomeoneSpeaks) {
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
} else if (isInventoryArea(_mousePos)) {
|
|
|
|
showInventoryName(NO_OBJECTS, true);
|
|
|
|
if (!_flagUseWithStarted) {
|
|
|
|
_lightIcon = 0xFF;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 18:01:45 +03:00
|
|
|
void TrecisionEngine::openInventory() {
|
|
|
|
if (!_flagInventoryLocked && (_inventoryStatus == INV_OFF) && !_flagDialogActive) {
|
|
|
|
_inventoryCounter = INVENTORY_HIDE;
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
_inventoryStatus = INV_PAINT;
|
|
|
|
}
|
|
|
|
}
|
2021-03-18 13:31:55 +01:00
|
|
|
|
2021-05-24 18:01:45 +03:00
|
|
|
void TrecisionEngine::closeInventory() {
|
|
|
|
if (!_flagInventoryLocked && (_inventoryStatus == INV_INACTION) && !_flagDialogActive) {
|
|
|
|
_inventoryCounter = INVENTORY_SHOW;
|
|
|
|
_inventorySpeedIndex = 0;
|
|
|
|
_inventoryStatus = INV_DEPAINT;
|
|
|
|
_lightIcon = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 23:56:51 +03:00
|
|
|
void TrecisionEngine::closeInventoryImmediately() {
|
|
|
|
_inventoryStatus = INV_OFF;
|
|
|
|
_lightIcon = 0xFF;
|
|
|
|
_flagInventoryLocked = false;
|
|
|
|
_inventoryRefreshStartLine = INVENTORY_HIDE;
|
|
|
|
_inventoryCounter = INVENTORY_HIDE;
|
|
|
|
setInventoryStart(_inventoryRefreshStartIcon, INVENTORY_HIDE);
|
|
|
|
refreshInventory(_inventoryRefreshStartIcon, _inventoryRefreshStartLine);
|
|
|
|
}
|
|
|
|
|
2021-05-24 18:01:45 +03:00
|
|
|
void TrecisionEngine::examineItem() {
|
|
|
|
_curInventory = whatIcon(_mousePos);
|
|
|
|
_actor->actorStop();
|
|
|
|
_pathFind->nextStep();
|
|
|
|
if (_flagUseWithStarted) {
|
2021-05-30 10:57:42 +03:00
|
|
|
endUseWith();
|
2021-05-24 18:01:45 +03:00
|
|
|
} else
|
|
|
|
doInvExamine();
|
|
|
|
}
|
2021-03-18 13:31:55 +01:00
|
|
|
|
2021-05-24 18:01:45 +03:00
|
|
|
void TrecisionEngine::useItem() {
|
|
|
|
_curInventory = whatIcon(_mousePos);
|
|
|
|
if (_curInventory == 0)
|
|
|
|
return;
|
2021-03-18 13:31:55 +01:00
|
|
|
|
2021-05-24 18:01:45 +03:00
|
|
|
if (_flagUseWithStarted) {
|
2021-05-30 10:57:42 +03:00
|
|
|
endUseWith();
|
2021-05-29 00:27:18 +01:00
|
|
|
} else if (_inventoryObj[_curInventory].isUseWith()) {
|
2021-05-31 02:33:15 +03:00
|
|
|
if (_curInventory == kItemFlare && _curRoom == kRoom29) {
|
|
|
|
_textMgr->characterSay(kSentenceOnlyGotOne);
|
2021-05-24 18:01:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
_animMgr->startSmkAnim(_inventoryObj[_curInventory]._anim);
|
|
|
|
_lightIcon = _curInventory;
|
|
|
|
setInventoryStart(_iconBase, INVENTORY_SHOW);
|
|
|
|
_flagInventoryLocked = true;
|
|
|
|
_flagUseWithStarted = true;
|
|
|
|
_useWith[USED] = _curInventory;
|
|
|
|
_useWithInv[USED] = true;
|
|
|
|
showInventoryName(_curInventory, true);
|
|
|
|
} else
|
|
|
|
doInvOperate();
|
2021-03-16 09:49:39 +01:00
|
|
|
}
|
|
|
|
|
2021-05-30 10:57:42 +03:00
|
|
|
void TrecisionEngine::endUseWith() {
|
|
|
|
_flagInventoryLocked = false;
|
|
|
|
_flagUseWithStarted = false;
|
|
|
|
_useWith[WITH] = _curInventory;
|
|
|
|
_useWithInv[WITH] = true;
|
2021-09-30 03:17:50 +03:00
|
|
|
_lightIcon = 0xFF;
|
|
|
|
|
2021-05-30 10:57:42 +03:00
|
|
|
if (_useWith[USED] != _curInventory) {
|
|
|
|
doUseWith();
|
|
|
|
} else {
|
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
|
|
|
showInventoryName(_curInventory, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::clearUseWith() {
|
|
|
|
if (_flagUseWithStarted) {
|
|
|
|
if (_useWithInv[USED]) {
|
|
|
|
_lightIcon = 0xFF;
|
|
|
|
_animMgr->smkStop(kSmackerIcon);
|
|
|
|
setInventoryStart(_inventoryRefreshStartIcon, INVENTORY_HIDE);
|
|
|
|
_flagInventoryLocked = false;
|
|
|
|
}
|
|
|
|
_useWith[USED] = 0;
|
|
|
|
_useWith[WITH] = 0;
|
|
|
|
_useWithInv[USED] = false;
|
|
|
|
_useWithInv[WITH] = false;
|
|
|
|
_flagUseWithStarted = false;
|
|
|
|
_textMgr->clearLastText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2021-05-22 13:58:00 +03:00
|
|
|
Common::String desc = _sysText[kMessageUse];
|
2021-03-20 23:18:33 +01:00
|
|
|
if (_useWithInv[USED]) {
|
2021-05-22 13:58:00 +03:00
|
|
|
desc += _objName[_inventoryObj[_useWith[USED]]._name];
|
|
|
|
desc += _sysText[kMessageWith];
|
2021-03-20 23:18:33 +01:00
|
|
|
if (obj && (_inventoryObj[_useWith[USED]]._name != _inventoryObj[obj]._name))
|
2021-05-22 13:58:00 +03:00
|
|
|
desc += _objName[_inventoryObj[obj]._name];
|
2021-03-20 23:18:33 +01:00
|
|
|
} else {
|
2021-05-28 21:54:39 +01:00
|
|
|
if (_obj[_useWith[USED]].isModeHidden())
|
2021-05-22 13:58:00 +03:00
|
|
|
desc += "?"; // dunno
|
2021-03-20 23:18:33 +01:00
|
|
|
else
|
2021-05-22 13:58:00 +03:00
|
|
|
desc += _objName[_obj[_useWith[USED]]._name];
|
|
|
|
desc += _sysText[kMessageWith];
|
2021-03-20 23:18:33 +01:00
|
|
|
if (obj && (_obj[_useWith[USED]]._name != _inventoryObj[obj]._name))
|
2021-05-22 13:58:00 +03:00
|
|
|
desc += _objName[_inventoryObj[obj]._name];
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
|
2021-05-22 13:58:00 +03:00
|
|
|
const uint16 lenText = textLength(desc);
|
2021-05-30 14:16:31 +03:00
|
|
|
Common::Point pos(CLIP(320 - (lenText / 2), 2, MAXX - 2 - lenText), 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();
|
2021-06-09 00:38:47 +03:00
|
|
|
_textMgr->addText(pos, desc.c_str(), COLOR_INVENTORY);
|
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-05-22 13:58:00 +03:00
|
|
|
const uint16 lenText = textLength(_objName[_inventoryObj[obj]._name]);
|
|
|
|
uint16 posX = ICONMARGSX + ((iconPos(_curInventory) - _iconBase) * (ICONDX)) + ICONDX / 2;
|
2021-04-14 01:20:17 +03:00
|
|
|
posX = CLIP(posX - (lenText / 2), 2, MAXX - 2 - lenText);
|
2021-05-30 14:16:31 +03:00
|
|
|
Common::Point pos(posX, MAXY - CARHEI);
|
2021-05-22 13:58:00 +03:00
|
|
|
|
|
|
|
_lastInv = obj;
|
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-06-09 00:38:47 +03:00
|
|
|
_textMgr->addText(pos, _objName[_inventoryObj[obj]._name], COLOR_INVENTORY);
|
2021-03-20 23:18:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::removeIcon(uint8 icon) {
|
2021-05-22 13:58:00 +03:00
|
|
|
const int8 pos = iconPos(icon);
|
2021-04-29 21:21:33 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-04-10 19:05:23 +01:00
|
|
|
void TrecisionEngine::rollInventory(uint8 status) {
|
2021-06-12 00:04:44 +03:00
|
|
|
static const int16 inventorySpeed[8] = { 20, 10, 5, 3, 2, 0, 0, 0 };
|
|
|
|
|
2021-04-10 19:05:23 +01:00
|
|
|
if (status == INV_PAINT) {
|
2021-06-12 00:04:44 +03:00
|
|
|
_inventoryCounter -= inventorySpeed[_inventorySpeedIndex++];
|
2021-04-10 19:05:23 +01:00
|
|
|
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-24 18:01:45 +03:00
|
|
|
closeInventory();
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->redrawString();
|
2021-04-10 19:05:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (status == INV_DEPAINT) {
|
2021-06-12 00:04:44 +03:00
|
|
|
_inventoryCounter += inventorySpeed[_inventorySpeedIndex++];
|
2021-04-10 19:05:23 +01:00
|
|
|
|
|
|
|
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-24 18:01:45 +03:00
|
|
|
openInventory();
|
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-05-20 15:59:15 +03:00
|
|
|
if (_inventoryStatus != INV_INACTION)
|
2021-04-10 19:05:23 +01:00
|
|
|
return;
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
if (pos.x <= ICONMARGSX && _iconBase)
|
2021-05-20 15:59:15 +03:00
|
|
|
moveInventoryRight();
|
2021-05-18 22:07:57 +01:00
|
|
|
else if (isBetween(MAXX - ICONMARGDX, pos.x, MAXX) && (_iconBase + ICONSHOWN < (int)_inventory.size()))
|
2021-05-20 15:59:15 +03:00
|
|
|
moveInventoryLeft();
|
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
|