aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-04-12 11:06:25 -0500
committerPaul Gilbert2015-04-12 11:06:25 -0500
commit454b6a2bbe38a4540769ad5cf51290b7a19524e4 (patch)
treef6901e29bcbc31080677f94909079fedf227ab1c /engines
parent461d5c64f27c2cf86890a9ba8d7df8a63f6278e7 (diff)
downloadscummvm-rg350-454b6a2bbe38a4540769ad5cf51290b7a19524e4.tar.gz
scummvm-rg350-454b6a2bbe38a4540769ad5cf51290b7a19524e4.tar.bz2
scummvm-rg350-454b6a2bbe38a4540769ad5cf51290b7a19524e4.zip
SHERLOCK: Implemented pick up code
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/inventory.h3
-rw-r--r--engines/sherlock/objects.cpp91
-rw-r--r--engines/sherlock/objects.h2
-rw-r--r--engines/sherlock/user_interface.cpp27
-rw-r--r--engines/sherlock/user_interface.h1
5 files changed, 121 insertions, 3 deletions
diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h
index 436d2bc18d..4e426beaf4 100644
--- a/engines/sherlock/inventory.h
+++ b/engines/sherlock/inventory.h
@@ -62,8 +62,6 @@ class Inventory : public Common::Array<InventoryItem> {
private:
SherlockEngine *_vm;
- int putItemInInventory(Object &obj);
-
void copyToInventory(Object &obj);
public:
ImageFile *_invShapes[MAX_VISIBLE_INVENTORY];
@@ -98,6 +96,7 @@ public:
void doInvJF();
int putNameInInventory(const Common::String &name);
+ int putItemInInventory(Object &obj);
int deleteItemFromInventory(const Common::String &name);
};
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index dc57322bd4..cab35f9634 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -948,6 +948,97 @@ void Object::adjustObject() {
}
/**
+ * Handles trying to pick up an object. If allowed, plays an y necessary animation for picking
+ * up the item, and then adds it to the player's inventory
+ */
+int Object::pickUpObject(const char *const messages[]) {
+ Inventory &inv = *_vm->_inventory;
+ People &people = *_vm->_people;
+ Scene &scene = *_vm->_scene;
+ Screen &screen = *_vm->_screen;
+ Talk &talk = *_vm->_talk;
+ UserInterface &ui = *_vm->_ui;
+ int pickup = _pickup & 0x7f;
+ bool printed = false;
+ bool takeFlag = true;
+ int numObjects = 0;
+ int message;
+
+ if (pickup == 99) {
+ for (int idx = 0; idx < 4 && !talk._talkToAbort; ++idx) {
+ if (checkNameForCodes(_use[0]._names[idx], nullptr)) {
+ if (!talk._talkToAbort)
+ printed = true;
+ }
+ }
+
+ return 0;
+ }
+
+ if (!pickup || (pickup > 50 && pickup <= 80)) {
+ int message = _pickup;
+ if (message > 50)
+ message -= 50;
+
+ ++ui._infoFlag;
+ ui.clearInfo();
+ screen.print(Common::Point(0, INFO_LINE + 1), INFO_LINE, messages[message]);
+ ui._menuCounter = 30;
+ } else {
+ // Pick it up
+ if ((_pickup & 0x80) == 0) {
+ // Play an animation
+ if (pickup > 80) {
+ takeFlag = false; // Don't pick it up
+ scene.startCAnim(pickup - 81, 1);
+ if (_pickupFlag)
+ _vm->setFlags(_pickupFlag);
+ } else {
+ scene.startCAnim(pickup - 1, 1);
+ if (!talk._talkToAbort) {
+ // Erase the shape
+ _type = _type == NO_SHAPE ? INVALID : REMOVE;
+ }
+ }
+
+ if (talk._talkToAbort)
+ return 0;
+ } else {
+ // Play generic pickup sequence
+ // Original moved cursor position here
+ people.goAllTheWay();
+ ui._menuCounter = 25;
+ ui._temp1 = 1;
+ }
+
+ for (int idx = 0; idx < 4 && !talk._talkToAbort; ++idx) {
+ if (checkNameForCodes(_use[0]._names[idx], nullptr)) {
+ if (!talk._talkToAbort)
+ printed = true;
+ }
+ }
+ if (talk._talkToAbort)
+ return 0;
+
+ // Add the item to the player's inventory
+ if (takeFlag)
+ numObjects = inv.putItemInInventory(*this);
+
+ if (!printed) {
+ ui._infoFlag++;
+ ui.clearInfo();
+
+ Common::String itemName = _description;
+ itemName.setChar(tolower(itemName[0]), 0);
+ screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Picked up %s", itemName.c_str());
+ ui._menuCounter = 25;
+ }
+ }
+
+ return numObjects;
+}
+
+/**
* Returns the current bounds for the sprite
*/
const Common::Rect Object::getNewBounds() const {
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 2c642b5a58..534ed66643 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -214,6 +214,8 @@ public:
void adjustObject();
+ int pickUpObject(const char *const messages[]);
+
int frameWidth() const { return _imageFrame ? _imageFrame->_frame.w : 0; }
int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; }
const Common::Rect getNewBounds() const;
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index ebbe00ffbc..9104c761a0 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -92,6 +92,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
_lookHelp = 0;
_key = _oldKey = 0;
_temp = _oldTemp = 0;
+ _temp1 = 0;
_invLookFlag = 0;
_windowOpen = false;
_oldLook = false;
@@ -711,6 +712,9 @@ void UserInterface::lookInv() {
}
}
+/**
+ * Handles input when the file list window is being displayed
+ */
void UserInterface::doEnvControl() {
// TODO
}
@@ -1193,8 +1197,29 @@ void UserInterface::doMiscControl(int allowed) {
}
}
+/**
+ * Handles input for picking up items
+ */
void UserInterface::doPickControl() {
- // TODO
+ Events &events = *_vm->_events;
+ Scene &scene = *_vm->_scene;
+
+ if (events._released) {
+ if ((_temp = _bgFound) != -1) {
+ events.clearEvents();
+
+ // Don't allow characters to be picked up
+ if (_bgFound < 1000) {
+ scene._bgShapes[_bgFound].pickUpObject(MPICK);
+
+ if (_menuMode != TALK_MODE) {
+ _key = _oldKey = -1;
+ _menuMode = STD_MODE;
+ restoreButton(PICKUP_MODE - 1);
+ }
+ }
+ }
+ }
}
void UserInterface::doTalkControl() {
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 9b104465cf..c4a07abc76 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -125,6 +125,7 @@ public:
bool _windowOpen;
bool _endKeyActive;
int _invLookFlag;
+ int _temp1;
public:
UserInterface(SherlockEngine *vm);
~UserInterface();