aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-11-05 22:32:12 -0500
committerPaul Gilbert2014-12-12 22:23:04 -0500
commit6ceda069c7042bc081845d3a52f99e21a58c43d8 (patch)
treed2e4da755a2900a2b0a420a1505bb02ae2f4466c /engines
parentb8c95e653dab6a82926effe772b03eb6770e6083 (diff)
downloadscummvm-rg350-6ceda069c7042bc081845d3a52f99e21a58c43d8.tar.gz
scummvm-rg350-6ceda069c7042bc081845d3a52f99e21a58c43d8.tar.bz2
scummvm-rg350-6ceda069c7042bc081845d3a52f99e21a58c43d8.zip
ACCESS: Beginnings of inventory dragging for combining items
Diffstat (limited to 'engines')
-rw-r--r--engines/access/amazon/amazon_resources.cpp88
-rw-r--r--engines/access/amazon/amazon_resources.h2
-rw-r--r--engines/access/events.cpp13
-rw-r--r--engines/access/events.h2
-rw-r--r--engines/access/inventory.cpp100
-rw-r--r--engines/access/inventory.h18
-rw-r--r--engines/access/scripts.cpp20
-rw-r--r--engines/access/scripts.h2
8 files changed, 218 insertions, 27 deletions
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 0807a979cc..c2eab7b5c2 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1352,6 +1352,94 @@ const int CHAPTER_JUMP[14] = {
0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0
};
+const int COMBO_TABLE[85][4] = {
+ { -1, -1, -1, -1 },
+ { 12, 3, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 24, 25, -1, -1 },
+ { 10, 24, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 8, 24, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 1, 3, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 7, 25, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 80, 81, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 41, 42, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 39, 40, -1, -1 },
+ { 38, 40, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 32, 42, 77, 78 },
+ { -1, -1, -1, -1 },
+ { 60, 61, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 73, 72, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 64, 67, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 59, 60, -1, -1 },
+ { 58, 60, -1, -1 },
+ { 43, 61, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 56, 67, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 50, 72, -1, -1 },
+ { 75, 77, -1, -1 },
+ { 74, 77, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 41, 78, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { 29, 81, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 },
+ { -1, -1, -1, -1 }
+};
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index d8d37b5a5f..2be9b4dd4b 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -64,6 +64,8 @@ extern const int CHAPTER_TABLE[14][5];
extern const int CHAPTER_JUMP[14];
+extern const int COMBO_TABLE[85][4];
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 0a754305b2..0b7a34841e 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -250,5 +250,18 @@ Common::Point EventsManager::calcRawMouse() {
return pt;
}
+int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
+ int i = 0;
+ for (i = 0;; i++) {
+ if (rects[i].left == -1)
+ return -1;
+
+ if ((_mousePos.x > rects[i].left) && (_mousePos.x < rects[i].right)
+ && (_mousePos.y > rects[i].top) && (_mousePos.y < rects[i].bottom))
+ return i;
+ }
+}
+
+
} // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 313a039831..b29b54159e 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -121,6 +121,8 @@ public:
Common::Point &getMousePos() { return _mousePos; }
Common::Point calcRawMouse();
+
+ int checkMouseBox1(Common::Array<Common::Rect> &rects);
};
} // End of namespace Access
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index bb735d45a9..f31379a2fa 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -28,6 +28,26 @@
namespace Access {
+void InventoryEntry::load(const Common::String &name, const int *data) {
+ _value = 0;
+ _name = name;
+ _otherItem1 = *data++;
+ _newItem1 = *data++;
+ _otherItem2 = *data++;
+ _newItem2 = *data;
+}
+
+int InventoryEntry::checkItem(int itemId) {
+ if (_otherItem1 == itemId)
+ return _newItem1;
+ else if (_otherItem2 == itemId)
+ return _newItem2;
+ else
+ return -1;
+}
+
+/*------------------------------------------------------------------------*/
+
InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
_startInvItem = 0;
_startInvBox = 0;
@@ -39,9 +59,12 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
_iconDisplayFlag = true;
const char *const *names;
+ const int *combineP;
+
switch (vm->getGameID()) {
case GType_Amazon:
names = Amazon::INVENTORY_NAMES;
+ combineP = &Amazon::COMBO_TABLE[0][0];
_inv.resize(85);
break;
case GType_MartianMemorandum:
@@ -52,8 +75,9 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
error("Unknown game");
}
- for (uint i = 0; i < _inv.size(); ++i)
- _names.push_back(names[i]);
+ for (uint i = 0; i < _inv.size(); ++i, combineP += 4) {
+ _inv[i].load(names[i], combineP);
+ }
for (uint i = 0; i < 26; ++i) {
const int *r = INVCOORDS[i];
@@ -62,7 +86,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
}
int &InventoryManager::operator[](int idx) {
- return _inv[idx];
+ return _inv[idx]._value;
}
int InventoryManager::useItem() {
@@ -255,9 +279,9 @@ void InventoryManager::getList() {
_tempLOff.clear();
for (uint i = 0; i < _inv.size(); ++i) {
- if (_inv[i] == 1) {
+ if (_inv[i]._value == 1) {
_items.push_back(i);
- _tempLOff.push_back(_names[i]);
+ _tempLOff.push_back(_inv[i]._name);
}
}
}
@@ -351,7 +375,69 @@ void InventoryManager::outlineIcon(int itemIndex) {
}
void InventoryManager::combineItems() {
- warning("TODO: combineItems");
+ Screen &screen = *_vm->_screen;
+ EventsManager &events = *_vm->_events;
+ screen._leftSkip = screen._rightSkip = 0;
+ screen._topSkip = screen._bottomSkip = 0;
+ screen._screenYOff = 0;
+
+ Common::Point tempMouse = events._mousePos;
+ Common::Point lastMouse = events._mousePos;
+
+ Common::Rect &inv = _invCoords[_boxNum];
+ Common::Rect r(inv.left, inv.top, inv.left + 46, inv.top + 35);
+ Common::Point tempBox(inv.left, inv.top);
+ Common::Point lastBox(inv.left, inv.top);
+
+ _vm->_buffer2.copyBlock(&_vm->_buffer1, r);
+ SpriteResource *sprites = _vm->_objectsTable[99];
+ int invItem = _items[_boxNum];
+ events.pollEvents();
+
+ // Item drag handling loop
+ while (!_vm->shouldQuit() && events._leftButton) {
+ // Poll for events
+ events.pollEvents();
+ g_system->delayMillis(10);
+
+ // Check positioning
+ if (lastMouse == events._mousePos)
+ continue;
+
+ lastMouse = events._mousePos;
+ Common::Rect lastRect(lastBox.x, lastBox.y, lastBox.x + 46, lastBox.y + 35);
+ screen.copyBlock(&_vm->_buffer2, lastRect);
+
+ int xp = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0);
+ int yp = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0);
+ screen.plotImage(sprites, invItem, Common::Point(xp, yp));
+ }
+
+ int destBox = events.checkMouseBox1(_invCoords);
+ if (destBox >= 0 && destBox != _boxNum && destBox < _items.size()
+ && _items[destBox] != -1) {
+ int itemA = invItem;
+ int itemB = _items[destBox];
+
+ // Check whether the items can be combined
+ int combinedItem = _inv[itemA].checkItem(itemB);
+ if (combinedItem != -1) {
+ _inv[combinedItem]._value = 1;
+ _inv[itemA]._value = 2;
+ _inv[itemB]._value = 2;
+ _items[_boxNum] = -1;
+ _items[destBox] = combinedItem;
+ _tempLOff[destBox] = _inv[combinedItem]._name;
+
+ // TODO: zoomIcon calls?
+
+ _boxNum = destBox;
+ return;
+ }
+ }
+
+ _iconDisplayFlag = true;
+ putInvIcon(_boxNum, invItem);
}
void InventoryManager::synchronize(Common::Serializer &s) {
@@ -362,7 +448,7 @@ void InventoryManager::synchronize(Common::Serializer &s) {
_inv.resize(count);
for (int i = 0; i < count; ++i)
- s.syncAsUint16LE((*this)[i]);
+ s.syncAsUint16LE(_inv[i]._value);
}
} // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 0ff9020250..eff142c9c9 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -32,6 +32,21 @@
namespace Access {
+class InventoryEntry {
+public:
+ Common::String _name;
+ int _value;
+
+ int _otherItem1;
+ int _newItem1;
+ int _otherItem2;
+ int _newItem2;
+
+ void load(const Common::String &name, const int *data);
+
+ int checkItem(int itemId);
+};
+
class InventoryManager : public Manager {
struct SavedFields {
int _vWindowHeight;
@@ -58,7 +73,6 @@ private:
ASurface _savedScreen;
SavedFields _fields;
bool _iconDisplayFlag;
- Common::StringArray _names;
Common::Array<int> _tempLPtr;
Common::StringArray _tempLOff;
int _boxNum;
@@ -89,7 +103,7 @@ private:
void combineItems();
public:
- Common::Array<int> _inv;
+ Common::Array<InventoryEntry> _inv;
int _startInvItem;
int _startInvBox;
bool _invChangeFlag;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index c46d7b972f..6c4c37491f 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -554,18 +554,6 @@ void Scripts::cmdTexSpeak() {
findNull();
}
-int Scripts::checkMouseBox1(Common::Rect *rectArr) {
- int i = 0;
- for (i = 0; ; i++){
- if (rectArr[i].left == -1)
- return -1;
-
- if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right)
- && (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom))
- return i;
- }
-}
-
void Scripts::cmdTexChoice() {
static Common::Point cMouse[7] = {
Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232),
@@ -595,9 +583,9 @@ void Scripts::cmdTexChoice() {
_vm->_bubbleBox->calcBubble(tmpStr);
_vm->_bubbleBox->printBubble(tmpStr);
- Common::Rect responseCoords[2];
- responseCoords[0] = _vm->_bubbleBox->_bounds;
- responseCoords[1] = Common::Rect(0, 0, 0, 0);
+ Common::Array<Common::Rect> responseCoords;
+ responseCoords.push_back(_vm->_bubbleBox->_bounds);
+ responseCoords.push_back(Common::Rect(0, 0, 0, 0));
_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
findNull();
@@ -655,7 +643,7 @@ void Scripts::cmdTexChoice() {
}
} else {
_vm->_events->debounceLeft();
- choice = checkMouseBox1(responseCoords);
+ choice = _vm->_events->checkMouseBox1(responseCoords);
}
}
} while ((choice == -1) || ((choice == 2) && choice3Fl));
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index f4128f4e31..ab80c1cd9f 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -44,8 +44,6 @@ protected:
virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
virtual void executeCommand(int commandIndex);
- int checkMouseBox1(Common::Rect *rectArr);
-
/**
* Print a given message to the screen in a bubble box
*/