aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-28 20:10:02 -0400
committerPaul Gilbert2015-06-28 20:10:02 -0400
commita041aec839911793bc34a74f6e88fd37fe8adf3c (patch)
tree7b0cf988c7fb495ac66eaa57d0e9c657c9618922
parent144aa6483b23e422d458af3a12bed1af6e5e0b33 (diff)
downloadscummvm-rg350-a041aec839911793bc34a74f6e88fd37fe8adf3c.tar.gz
scummvm-rg350-a041aec839911793bc34a74f6e88fd37fe8adf3c.tar.bz2
scummvm-rg350-a041aec839911793bc34a74f6e88fd37fe8adf3c.zip
SHERLOCK: RT: Inventory window now partially showing
-rw-r--r--engines/sherlock/inventory.cpp40
-rw-r--r--engines/sherlock/inventory.h16
-rw-r--r--engines/sherlock/module.mk1
-rw-r--r--engines/sherlock/scalpel/scalpel_inventory.cpp30
-rw-r--r--engines/sherlock/scalpel/scalpel_inventory.h8
-rw-r--r--engines/sherlock/tattoo/tattoo_inventory.cpp63
-rw-r--r--engines/sherlock/tattoo/tattoo_inventory.h48
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp1
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp2
9 files changed, 161 insertions, 48 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp
index 5614775e02..c74034f8e1 100644
--- a/engines/sherlock/inventory.cpp
+++ b/engines/sherlock/inventory.cpp
@@ -24,6 +24,7 @@
#include "sherlock/sherlock.h"
#include "sherlock/scalpel/scalpel_inventory.h"
#include "sherlock/scalpel/scalpel_user_interface.h"
+#include "sherlock/tattoo/tattoo_inventory.h"
namespace Sherlock {
@@ -54,17 +55,14 @@ Inventory *Inventory::init(SherlockEngine *vm) {
if (vm->getGameID() == GType_SerratedScalpel)
return new Scalpel::ScalpelInventory(vm);
else
- return new Inventory(vm);
+ return new Tattoo::TattooInventory(vm);
}
Inventory::Inventory(SherlockEngine *vm) : Common::Array<InventoryItem>(), _vm(vm) {
- Common::fill(&_invShapes[0], &_invShapes[MAX_VISIBLE_INVENTORY], (ImageFile *)nullptr);
_invGraphicsLoaded = false;
_invIndex = 0;
_holdings = 0;
_invMode = INVMODE_EXIT;
- for (int i = 0; i < 6; ++i)
- _invShapes[i] = nullptr;
}
Inventory::~Inventory() {
@@ -79,44 +77,20 @@ void Inventory::freeInv() {
}
void Inventory::freeGraphics() {
- for (uint idx = 0; idx < MAX_VISIBLE_INVENTORY; ++idx)
+ int count = _invShapes.size();
+ for (int idx = 0; idx < count; ++idx)
delete _invShapes[idx];
+ _invShapes.clear();
+ _invShapes.resize(count);
- Common::fill(&_invShapes[0], &_invShapes[MAX_VISIBLE_INVENTORY], (ImageFile *)nullptr);
_invGraphicsLoaded = false;
}
-void Inventory::loadInv() {
- // Exit if the inventory names are already loaded
- if (_names.size() > 0)
- return;
-
- // Load the inventory names
- Common::SeekableReadStream *stream = _vm->_res->load("invent.txt");
-
- int streamSize = stream->size();
- while (stream->pos() < streamSize) {
- Common::String name;
- char c;
- while ((c = stream->readByte()) != 0)
- name += c;
-
- _names.push_back(name);
- }
-
- delete stream;
-
- loadGraphics();
-}
-
void Inventory::loadGraphics() {
if (_invGraphicsLoaded)
return;
- // Default all inventory slots to empty
- Common::fill(&_invShapes[0], &_invShapes[MAX_VISIBLE_INVENTORY], (ImageFile *)nullptr);
-
- for (int idx = _invIndex; (idx < _holdings) && (idx - _invIndex) < MAX_VISIBLE_INVENTORY; ++idx) {
+ for (int idx = _invIndex; (idx < _holdings) && (idx - _invIndex) < (int)_invShapes.size(); ++idx) {
// Get the name of the item to be displayed, figure out its accompanying
// .VGS file with its picture, and then load it
int invNum = findInv((*this)[idx]._name);
diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h
index 9d5e2c42a7..fac0b2f888 100644
--- a/engines/sherlock/inventory.h
+++ b/engines/sherlock/inventory.h
@@ -32,8 +32,6 @@
namespace Sherlock {
-#define MAX_VISIBLE_INVENTORY 6
-
enum InvMode {
INVMODE_EXIT = 0,
INVMODE_LOOK = 1,
@@ -88,7 +86,7 @@ protected:
*/
void copyToInventory(Object &obj);
public:
- ImageFile *_invShapes[MAX_VISIBLE_INVENTORY];
+ Common::Array<ImageFile *> _invShapes;
bool _invGraphicsLoaded;
InvMode _invMode;
int _invIndex;
@@ -109,12 +107,6 @@ public:
void freeInv();
/**
- * Load the list of names the inventory items correspond to, if not already loaded,
- * and then calls loadGraphics to load the associated graphics
- */
- void loadInv();
-
- /**
* Load the list of names of graphics for the inventory
*/
void loadGraphics();
@@ -145,6 +137,12 @@ public:
* Synchronize the data for a savegame
*/
void synchronize(Serializer &s);
+
+ /**
+ * Load the list of names the inventory items correspond to, if not already loaded,
+ * and then calls loadGraphics to load the associated graphics
+ */
+ virtual void loadInv() = 0;
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index e592baa5f5..9997301710 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
scalpel/settings.o \
tattoo/tattoo.o \
tattoo/tattoo_fixed_text.o \
+ tattoo/tattoo_inventory.o \
tattoo/tattoo_journal.o \
tattoo/tattoo_map.o \
tattoo/tattoo_people.o \
diff --git a/engines/sherlock/scalpel/scalpel_inventory.cpp b/engines/sherlock/scalpel/scalpel_inventory.cpp
index 95ca67336a..11f2b33eac 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.cpp
+++ b/engines/sherlock/scalpel/scalpel_inventory.cpp
@@ -30,7 +30,8 @@ namespace Sherlock {
namespace Scalpel {
-ScalpelInventory::ScalpelInventory(SherlockEngine *vm) : Inventory(vm), _invIndex(0) {
+ScalpelInventory::ScalpelInventory(SherlockEngine *vm) : Inventory(vm) {
+ _invShapes.resize(6);
}
ScalpelInventory::~ScalpelInventory() {
@@ -216,7 +217,7 @@ void ScalpelInventory::putInv(InvSlamMode slamIt) {
// If an inventory item has disappeared (due to using it or giving it),
// a blank space slot may have appeared. If so, adjust the inventory
- if (_invIndex > 0 && _invIndex > (_holdings - 6)) {
+ if (_invIndex > 0 && _invIndex > (_holdings - (int)_invShapes.size())) {
--_invIndex;
freeGraphics();
loadGraphics();
@@ -232,7 +233,7 @@ void ScalpelInventory::putInv(InvSlamMode slamIt) {
}
// Iterate through displaying up to 6 objects at a time
- for (int idx = _invIndex; idx < _holdings && (idx - _invIndex) < MAX_VISIBLE_INVENTORY; ++idx) {
+ for (int idx = _invIndex; idx < _holdings && (idx - _invIndex) < (int)_invShapes.size(); ++idx) {
int itemNum = idx - _invIndex;
Surface &bb = slamIt == SLAM_SECONDARY_BUFFER ? screen._backBuffer2 : screen._backBuffer1;
Common::Rect r(8 + itemNum * 52, 165, 51 + itemNum * 52, 194);
@@ -267,6 +268,29 @@ void ScalpelInventory::putInv(InvSlamMode slamIt) {
}
}
+void ScalpelInventory::loadInv() {
+ // Exit if the inventory names are already loaded
+ if (_names.size() > 0)
+ return;
+
+ // Load the inventory names
+ Common::SeekableReadStream *stream = _vm->_res->load("invent.txt");
+
+ int streamSize = stream->size();
+ while (stream->pos() < streamSize) {
+ Common::String name;
+ char c;
+ while ((c = stream->readByte()) != 0)
+ name += c;
+
+ _names.push_back(name);
+ }
+
+ delete stream;
+
+ loadGraphics();
+}
+
} // End of namespace Scalpel
} // End of namespace Sherlock
diff --git a/engines/sherlock/scalpel/scalpel_inventory.h b/engines/sherlock/scalpel/scalpel_inventory.h
index 1a26fabb50..afafb0b94a 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.h
+++ b/engines/sherlock/scalpel/scalpel_inventory.h
@@ -31,8 +31,6 @@ namespace Scalpel {
class ScalpelInventory : public Inventory {
public:
- int _invIndex;
-public:
ScalpelInventory(SherlockEngine *vm);
~ScalpelInventory();
@@ -61,6 +59,12 @@ public:
* Display the character's inventory. The slamIt parameter specifies:
*/
void putInv(InvSlamMode slamIt);
+
+ /**
+ * Load the list of names the inventory items correspond to, if not already loaded,
+ * and then calls loadGraphics to load the associated graphics
+ */
+ virtual void loadInv();
};
} // End of namespace Scalpel
diff --git a/engines/sherlock/tattoo/tattoo_inventory.cpp b/engines/sherlock/tattoo/tattoo_inventory.cpp
new file mode 100644
index 0000000000..6bd1822c10
--- /dev/null
+++ b/engines/sherlock/tattoo/tattoo_inventory.cpp
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ */
+
+#include "sherlock/tattoo/tattoo_inventory.h"
+#include "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+TattooInventory::TattooInventory(SherlockEngine *vm) : Inventory(vm) {
+ _invShapes.resize(8);
+}
+
+TattooInventory::~TattooInventory() {
+}
+
+void TattooInventory::loadInv() {
+ // Exit if the inventory names are already loaded
+ if (_names.size() > 0)
+ return;
+
+ // Load the inventory names
+ Common::SeekableReadStream *stream = _vm->_res->load("invent.txt");
+
+ int count = stream->readByte();
+ char c;
+
+ for (int idx = 0; idx < count; ++idx) {
+ Common::String name;
+ while ((c = stream->readByte()) != 0)
+ name += c;
+
+ _names.push_back(name);
+ }
+
+ delete stream;
+
+ loadGraphics();
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_inventory.h b/engines/sherlock/tattoo/tattoo_inventory.h
new file mode 100644
index 0000000000..a18324b785
--- /dev/null
+++ b/engines/sherlock/tattoo/tattoo_inventory.h
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ */
+
+#ifndef SHERLOCK_TATTOO_INVENTORY_H
+#define SHERLOCK_TATTOO_INVENTORY_H
+
+#include "sherlock/inventory.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+class TattooInventory : public Inventory {
+public:
+ TattooInventory(SherlockEngine *vm);
+ ~TattooInventory();
+
+ /**
+ * Load the list of names the inventory items correspond to, if not already loaded,
+ * and then calls loadGraphics to load the associated graphics
+ */
+ virtual void loadInv();
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 51dd4d1f7c..5f9aec89bf 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -568,6 +568,7 @@ void TattooUserInterface::doInventory(int mode) {
people[HOLMES].gotoStand();
_inventoryWidget.load(mode);
+ _inventoryWidget.summonWindow();
_menuMode = INV_MODE;
}
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index ea07793e10..2d5e0c3746 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -91,7 +91,7 @@ void WidgetInventory::drawInventory() {
Inventory &inv = *_vm->_inventory;
// TODO: Refactor _invIndex into this widget class
- for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) {
+ for (int idx = 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx, ++itemId) {
// Figure out the drawing position
Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)),
3 + (INVENTORY_YSIZE + 3) * idx / (NUM_INVENTORY_SHOWN / 2));