aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2011-09-04 12:33:32 -0400
committerMatthew Hoops2011-09-04 12:33:32 -0400
commitbfb0de109ab8cc27aae9ed9a46c55068ac20eecc (patch)
treea92ea296d049f1ed343c1ebc3df7ba785831b398 /engines
parentcb7b382acfd29957c9522b08b6460526fc73983c (diff)
downloadscummvm-rg350-bfb0de109ab8cc27aae9ed9a46c55068ac20eecc.tar.gz
scummvm-rg350-bfb0de109ab8cc27aae9ed9a46c55068ac20eecc.tar.bz2
scummvm-rg350-bfb0de109ab8cc27aae9ed9a46c55068ac20eecc.zip
PEGASUS: Implement more item code
Diffstat (limited to 'engines')
-rwxr-xr-xengines/pegasus/items/biochips/biochipitem.cpp92
-rwxr-xr-xengines/pegasus/items/biochips/biochipitem.h54
-rwxr-xr-xengines/pegasus/items/inventory/inventoryitem.cpp107
-rwxr-xr-xengines/pegasus/items/inventory/inventoryitem.h67
-rwxr-xr-xengines/pegasus/items/item.cpp157
-rwxr-xr-xengines/pegasus/items/item.h127
-rw-r--r--engines/pegasus/module.mk2
-rw-r--r--engines/pegasus/pegasus.h35
8 files changed, 597 insertions, 44 deletions
diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
new file mode 100755
index 0000000000..a291a53d91
--- /dev/null
+++ b/engines/pegasus/items/biochips/biochipitem.cpp
@@ -0,0 +1,92 @@
+/* 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.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * 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.
+ *
+ */
+
+
+#include "common/stream.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+BiochipItem::BiochipItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+ Item(id, neighborhood, room, direction) {
+
+ PegasusEngine *vm = (PegasusEngine *)vm;
+
+ Common::SeekableReadStream *biochipInfo = vm->_resFork->getResource(MKTAG('B', 'i', 'o', 'I'), kItemBaseResID + id);
+ if (biochipInfo) {
+ _biochipInfoPanelTime = biochipInfo->readUint32BE();
+ delete biochipInfo;
+ } else {
+ _biochipInfoPanelTime = 0;
+ }
+
+ Common::SeekableReadStream *rightInfo = vm->_resFork->getResource(MKTAG('R', 'g', 'h', 't'), kItemBaseResID + id);
+ if (!rightInfo)
+ error("Could not find right info for biochip %d", id);
+
+ _rightAreaInfo = readItemState(rightInfo);
+ delete rightInfo;
+
+ setItemState(kNormalItem);
+}
+
+BiochipItem::~BiochipItem() {
+ delete[] _rightAreaInfo.entries;
+}
+
+tItemType BiochipItem::getItemType() {
+ return kBiochipItemType;
+}
+
+TimeValue BiochipItem::getRightAreaTime() const {
+ if (!_rightAreaInfo.entries)
+ return 0xffffffff;
+
+ TimeValue time;
+ tItemState state;
+
+ findItemStateEntryByState(_rightAreaInfo, _itemState, time);
+ if (time == 0xffffffff)
+ getItemStateEntry(_rightAreaInfo, 0, state, time);
+
+ return time;
+}
+
+// Must affect images in right area.
+void BiochipItem::select() {
+ Item::select();
+
+ // TODO: AI
+}
+
+void BiochipItem::deselect() {
+ Item::deselect();
+
+ // TODO: AI
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/biochipitem.h b/engines/pegasus/items/biochips/biochipitem.h
new file mode 100755
index 0000000000..904c23b392
--- /dev/null
+++ b/engines/pegasus/items/biochips/biochipitem.h
@@ -0,0 +1,54 @@
+/* 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.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * 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.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_BIOCHIPITEM_H
+#define PEGASUS_ITEMS_BIOCHIPS_BIOCHIPITEM_H
+
+#include "pegasus/items/item.h"
+
+namespace Pegasus {
+
+class BiochipItem : public Item {
+public:
+ BiochipItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+ virtual ~BiochipItem();
+
+ virtual tItemType getItemType();
+
+ TimeValue getPanelTime() const { return _biochipInfoPanelTime; }
+ TimeValue getRightAreaTime() const;
+
+ // Must affect images in right area.
+ virtual void select();
+ virtual void deselect();
+
+protected:
+ TimeValue _biochipInfoPanelTime;
+ ItemStateInfo _rightAreaInfo;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
new file mode 100755
index 0000000000..868291109d
--- /dev/null
+++ b/engines/pegasus/items/inventory/inventoryitem.cpp
@@ -0,0 +1,107 @@
+/* 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.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * 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.
+ *
+ */
+
+#include "common/stream.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+InventoryItem::InventoryItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+ Item(id, neighborhood, room, direction) {
+
+ PegasusEngine *vm = (PegasusEngine *)vm;
+
+ Common::SeekableReadStream *leftInfo = vm->_resFork->getResource(MKTAG('L', 'e', 'f', 't'), kItemBaseResID + id);
+ if (leftInfo) {
+ _leftAreaInfo = readItemState(leftInfo);
+ delete leftInfo;
+ } else {
+ _leftAreaInfo.numEntries = 0;
+ _leftAreaInfo.entries = 0;
+ }
+
+ Common::SeekableReadStream *inventoryInfo = vm->_resFork->getResource(MKTAG('I', 'n', 'v', 'I'), kItemBaseResID + id);
+ if (inventoryInfo) {
+ _inventoryInfo.panelStart = inventoryInfo->readUint32BE();
+ _inventoryInfo.panelStop = inventoryInfo->readUint32BE();
+ delete inventoryInfo;
+ } else {
+ _inventoryInfo.panelStart = _inventoryInfo.panelStop = 0;
+ }
+
+ _itemAnimationTime = 0;
+}
+
+InventoryItem::~InventoryItem() {
+ delete[] _leftAreaInfo.entries;
+}
+
+tItemType InventoryItem::getItemType() {
+ return kInventoryItemType;
+}
+
+TimeValue InventoryItem::getLeftAreaTime() const {
+ if (!_leftAreaInfo.entries)
+ return 0xffffffff;
+
+ TimeValue time;
+ tItemState state;
+
+ findItemStateEntryByState(_leftAreaInfo, _itemState, time);
+ if (time == 0xffffffff)
+ getItemStateEntry(_leftAreaInfo, 0, state, time);
+
+ return time;
+}
+
+void InventoryItem::setAnimationTime(const TimeValue time) {
+ _itemAnimationTime = time;
+}
+
+TimeValue InventoryItem::getAnimationTime() const {
+ return _itemAnimationTime;
+}
+
+// Must affect images in left area.
+void InventoryItem::select() {
+ Item::select();
+
+ // TODO: AI
+}
+
+void InventoryItem::deselect() {
+ Item::deselect();
+
+ // TODO: AI
+}
+
+void InventoryItem::getPanelTimes(TimeValue &start, TimeValue &stop) const {
+ start = _inventoryInfo.panelStart;
+ stop = _inventoryInfo.panelStop;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventory/inventoryitem.h b/engines/pegasus/items/inventory/inventoryitem.h
new file mode 100755
index 0000000000..d3247d651c
--- /dev/null
+++ b/engines/pegasus/items/inventory/inventoryitem.h
@@ -0,0 +1,67 @@
+/* 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.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * 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.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
+#define PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
+
+#include "pegasus/items/item.h"
+
+namespace Pegasus {
+
+// JMPInventoryInfo contains the resource data used by InventoryItems.
+
+struct JMPInventoryInfo {
+ TimeValue panelStart;
+ TimeValue panelStop;
+};
+
+class InventoryItem : public Item {
+public:
+ InventoryItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+ virtual ~InventoryItem();
+
+ virtual tItemType getItemType();
+
+ void getPanelTimes(TimeValue&, TimeValue&) const;
+ TimeValue getLeftAreaTime() const;
+
+ void setAnimationTime(const TimeValue);
+ TimeValue getAnimationTime() const;
+
+ virtual void toggleItemState() {}
+
+ // Must affect images in left area.
+ virtual void select();
+ virtual void deselect();
+
+protected:
+ JMPInventoryInfo _inventoryInfo;
+ ItemStateInfo _leftAreaInfo;
+ TimeValue _itemAnimationTime;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index 934dce6f2d..2043317f5f 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -27,6 +27,7 @@
#include "common/stream.h"
#include "pegasus/constants.h"
+#include "pegasus/pegasus.h"
#include "pegasus/items/item.h"
#include "pegasus/items/itemlist.h"
@@ -40,10 +41,87 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
_itemOwnerID = kNoActorID;
_itemState = 0;
+ PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+ Common::SeekableReadStream *info = vm->_resFork->getResource(kItemInfoResType, kItemBaseResID + id);
+ if (info) {
+ _itemInfo.infoLeftTime = info->readUint32BE();
+ _itemInfo.infoRightStart = info->readUint32BE();
+ _itemInfo.infoRightStop = info->readUint32BE();
+ _itemInfo.dragSpriteNormalID = info->readUint32BE();
+ _itemInfo.dragSpriteUsedID = info->readUint32BE();
+
+ if (vm->isDemo()) {
+ // Adjust info right times to account for the stuff that was chopped out of the
+ // info right movies.
+ // Assumes time scale of 600.
+
+ // Gap times in seconds
+ static const TimeValue kGap1 = 24;
+ static const TimeValue kGap2 = 34;
+ static const TimeValue kGap3 = 4;
+ static const TimeValue kGap4 = 4;
+
+ static const TimeValue kGapForGroup1 = kGap1;
+ static const TimeValue kGapForGroup2 = kGapForGroup1 + kGap2;
+ static const TimeValue kGapForGroup3 = kGapForGroup2 + kGap3;
+ static const TimeValue kGapForGroup4 = kGapForGroup3 + kGap4;
+
+ switch (id) {
+ case kHistoricalLog:
+ case kJourneymanKey:
+ case kKeyCard:
+ _itemInfo.infoRightStart -= 600 * kGapForGroup1;
+ _itemInfo.infoRightStop -= 600 * kGapForGroup1;
+ break;
+ case kAIBiochip:
+ _itemInfo.infoRightStart -= 600 * kGapForGroup2;
+ _itemInfo.infoRightStop -= 600 * kGapForGroup2;
+ break;
+ case kMapBiochip:
+ _itemInfo.infoRightStart -= 600 * kGapForGroup3;
+ _itemInfo.infoRightStop -= 600 * kGapForGroup3;
+ break;
+ case kPegasusBiochip:
+ _itemInfo.infoRightStart -= 600 * kGapForGroup4;
+ _itemInfo.infoRightStop -= 600 * kGapForGroup4;
+ break;
+ }
+ }
+
+ delete info;
+ } else {
+ memset(&_itemInfo, 0, sizeof(_itemInfo));
+ }
+
+ Common::SeekableReadStream *middleAreaInfo = vm->_resFork->getResource(kMiddleAreaInfoResType, kItemBaseResID + id);
+ if (!middleAreaInfo)
+ error("Middle area info not found for item %d", id);
+
+ _sharedAreaInfo = readItemState(middleAreaInfo);
+
+ delete middleAreaInfo;
+
+ Common::SeekableReadStream *extraInfo = vm->_resFork->getResource(kItemExtraInfoResType, kItemBaseResID + id);
+ if (!extraInfo)
+ error("Extra info not found for item %d", id);
+
+ _itemExtras.numEntries = extraInfo->readUint16BE();
+ for (uint16 i = 0; i < _itemExtras.numEntries; i++) {
+ _itemExtras.entries[i].extraID = extraInfo->readUint32BE();
+ _itemExtras.entries[i].extraArea = extraInfo->readUint16BE();
+ _itemExtras.entries[i].extraStart = extraInfo->readUint32BE();
+ _itemExtras.entries[i].extraStop = extraInfo->readUint32BE();
+ }
+
+ delete extraInfo;
+
g_allItems.push_back(this);
}
Item::~Item() {
+ delete[] _sharedAreaInfo.entries;
+ delete[] _itemExtras.entries;
}
Common::Error Item::writeToStream(Common::WriteStream *stream) {
@@ -78,6 +156,14 @@ tActorID Item::getItemOwner() const {
void Item::setItemOwner(const tActorID owner) {
_itemOwnerID = owner;
+
+ if (owner == kNoActorID) {
+ if (isSelected())
+ deselect();
+ removedFromInventory();
+ } else {
+ addedToInventory();
+ }
}
tWeightType Item::getItemWeight() {
@@ -89,7 +175,10 @@ tItemState Item::getItemState() const {
}
void Item::setItemState(const tItemState state) {
- _itemState = state;
+ if (state != _itemState) {
+ _itemState = state;
+ // TODO: Selection
+ }
}
void Item::getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
@@ -102,10 +191,76 @@ void Item::setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, c
_itemNeighborhood = neighborhood;
_itemRoom = room;
_itemDirection = direction;
+
+ if (neighborhood == kNoNeighborhoodID)
+ pickedUp();
+ else
+ dropped();
}
tNeighborhoodID Item::getItemNeighborhood() const {
return _itemNeighborhood;
}
+TimeValue Item::getSharedAreaTime() const {
+ if (!_sharedAreaInfo.entries)
+ return 0xffffffff;
+
+ TimeValue time;
+ tItemState state;
+
+ findItemStateEntryByState(_sharedAreaInfo, _itemState, time);
+ if (time == 0xffffffff)
+ getItemStateEntry(_sharedAreaInfo, 0, state, time);
+
+ return time;
+}
+
+// Must affect images in shared area.
+void Item::select() {
+ _isSelected = true;
+
+ // TODO: AI
+}
+
+void Item::deselect() {
+ _isActive = false;
+ _isSelected = false;
+
+ // TODO: AI
+}
+
+void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state, TimeValue &time) {
+ if (index < info.numEntries) {
+ state = info.entries[index].itemState;
+ time = info.entries[index].itemTime;
+ } else {
+ state = kNoItemState;
+ time = 0xffffffff;
+ }
+}
+
+void Item::findItemStateEntryByState(ItemStateInfo info, tItemState state, TimeValue &time) {
+ for (uint16 i = 0; i < info.numEntries; i++) {
+ if (info.entries[i].itemState == state) {
+ time = info.entries[i].itemTime;
+ return;
+ }
+ }
+
+ time = 0xffffffff;
+}
+
+ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
+ ItemStateInfo info;
+
+ info.numEntries = stream->readUint16BE();
+ for (uint16 i = 0; i < info.numEntries; i++) {
+ info.entries[i].itemState = stream->readSint16BE();
+ info.entries[i].itemTime = stream->readUint32BE();
+ }
+
+ return info;
+}
+
} // End of namespace Pegasus
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index 37ad54e5e7..517ffc0c6e 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -26,6 +26,8 @@
#ifndef PEGASUS_ITEMS_ITEM_H
#define PEGASUS_ITEMS_ITEM_H
+#include "common/endian.h"
+
#include "pegasus/MMShell/Utilities/MMIDObject.h"
#include "pegasus/types.h"
@@ -33,20 +35,68 @@ namespace Common {
class Error;
class ReadStream;
class WriteStream;
+ class SeekableReadStream;
}
namespace Pegasus {
-/*
+// JMPItemInfo contains resource data used by all Items.
- Item is an object which can be picked up and carried around.
- Items have
- a location
- an ID.
- weight
- an owner (kNoActorID if no one is carrying the Item)
+struct JMPItemInfo {
+ TimeValue infoLeftTime;
+ TimeValue infoRightStart;
+ TimeValue infoRightStop;
+ uint32 dragSpriteNormalID;
+ uint32 dragSpriteUsedID;
+};
-*/
+// ItemStateEntry contains a single state/TimeValue pair. The TimeValue is
+// the time value to set the shared area movie that corresponds with the given
+// state of an inventory item.
+
+struct ItemStateEntry {
+ tItemState itemState;
+ TimeValue itemTime;
+};
+
+// ItemStateInfoHandle is an array of ItemStateEntry.
+
+struct ItemStateInfo {
+ uint16 numEntries; // For easy ResEdit access
+ ItemStateEntry *entries;
+};
+
+// ItemExtraEntry
+
+const short kLeftAreaExtra = 0;
+const short kMiddleAreaExtra = 1;
+const short kRightAreaExtra = 2;
+
+struct ItemExtraEntry {
+ uint32 extraID;
+ uint16 extraArea;
+ TimeValue extraStart;
+ TimeValue extraStop;
+};
+
+// tItemExtraInfoHandle is an array of tItemExtraEntry.
+
+struct ItemExtraInfo {
+ uint16 numEntries; // For easy ResEdit access
+ ItemExtraEntry *entries;
+};
+
+// Inventory info resource type and ID:
+// Individual inventory items are stored in these resource types.
+// Resource ID is item ID + kItemBaseResID.
+
+const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm'); // JMPItemInfoHandle
+const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't'); // ItemStateInfoHandle
+const uint32 kMiddleAreaInfoResType = MKTAG('M', 'i', 'd', 'l'); // ItemStateInfoHandle
+const uint32 kRightAreaInfoResType = MKTAG('R', 'g', 'h', 't'); // ItemStateInfoHandle
+const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r'); // ItemExtraInfoHandle
+
+const uint16 kItemBaseResID = 128;
// Item IDs.
@@ -219,6 +269,22 @@ const uint32 kRemoveGlass = 10;
const uint32 kRemoveDart = 11;
const uint32 kRemoveSinclairKey = 12;
+enum tItemType {
+ kInventoryItemType,
+ kBiochipItemType
+};
+
+/*
+
+ Item is an object which can be picked up and carried around.
+ Items have
+ a location
+ an ID.
+ weight
+ an owner (kNoActorID if no one is carrying the Item)
+
+*/
+
class Item : public MMIDObject {
public:
Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
@@ -241,6 +307,41 @@ public:
virtual void setItemState(const tItemState state);
virtual tItemState getItemState() const;
+ virtual tItemType getItemType() = 0;
+
+ TimeValue getInfoLeftTime() const;
+ void getInfoRightTimes(TimeValue&, TimeValue&) const;
+ TimeValue getSharedAreaTime() const;
+
+ //TODO
+ //MMSprite* GetDragSprite(const tDisplayElementID) const;
+
+ /*
+ select -- called when this item becomes current. Also called when the inventory
+ panel holding this item is raised and this is the current item.
+ deselect -- called when this item is no longer current.
+ activate -- called on the current item when the panel is closed.
+ */
+ // In an override of these three member functions, you must call the inherited
+ // member functions.
+ virtual void select();
+ virtual void deselect();
+ virtual bool isSelected() { return _isSelected; }
+
+ virtual void activate() { _isActive = true; }
+ virtual bool isActive() { return _isActive; }
+ virtual void pickedUp() {}
+ virtual void addedToInventory() {}
+ virtual void removedFromInventory() {}
+ virtual void dropped() {}
+
+ // Called when the shared area is taken by another item, but this item is still
+ // selected.
+ virtual void giveUpSharedArea() {}
+ virtual void takeSharedArea() {}
+
+ void findItemExtra(const uint32 extraID, ItemExtraEntry &entry);
+
protected:
tNeighborhoodID _itemNeighborhood;
tRoomID _itemRoom;
@@ -248,6 +349,16 @@ protected:
tActorID _itemOwnerID;
tWeightType _itemWeight;
tItemState _itemState;
+
+ JMPItemInfo _itemInfo;
+ ItemStateInfo _sharedAreaInfo;
+ ItemExtraInfo _itemExtras;
+ bool _isActive;
+ bool _isSelected;
+
+ static void getItemStateEntry(ItemStateInfo, uint32, tItemState&, TimeValue&);
+ static void findItemStateEntryByState(ItemStateInfo, tItemState, TimeValue&);
+ static ItemStateInfo readItemState(Common::SeekableReadStream *stream);
};
} // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 4f44050787..be50ecb48a 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -14,6 +14,8 @@ MODULE_OBJS = \
items/inventory.o \
items/item.o \
items/itemlist.o \
+ items/biochips/biochipitem.o \
+ items/inventory/inventoryitem.o \
MMShell/Base_Classes/MMFunctionPtr.o \
MMShell/Notification/MMNotification.o \
MMShell/Notification/MMNotificationManager.o \
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 25fbc348b7..5c85251d76 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -66,41 +66,6 @@ struct ItemLocationData {
byte u1;
};
-struct InventoryPanelEntry {
- uint32 startTime;
- uint32 endTime;
-};
-
-struct InventoryItemData {
- uint32 leftFrameTime;
- uint32 rightStartTime;
- uint32 rightEndTime;
- uint16 pict; // Cannot use item at this spot
- uint16 usablePict; // Can use item at this spot
-};
-
-struct InventoryExtra {
- uint32 id;
- uint16 movie;
- uint32 startTime;
- uint32 endTime;
-};
-
-struct LeftAreaData {
- uint16 frame;
- uint32 time;
-};
-
-struct MiddleAreaData {
- uint16 id;
- uint32 time;
-};
-
-struct RightAreaData {
- uint16 frame;
- uint32 time;
-};
-
struct OverviewHotspot {
Common::Rect rect;
uint32 time;