aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-07-28 11:50:36 +0000
committerNicola Mettifogo2008-07-28 11:50:36 +0000
commita1557bd776c9335b36313860d437bc8b1ef2a936 (patch)
tree7bcb7e7104780cb1e27d468af69ed8d382c101b6
parentfb388deb99be4c1457dd052382c32a05dfc4b528 (diff)
downloadscummvm-rg350-a1557bd776c9335b36313860d437bc8b1ef2a936.tar.gz
scummvm-rg350-a1557bd776c9335b36313860d437bc8b1ef2a936.tar.bz2
scummvm-rg350-a1557bd776c9335b36313860d437bc8b1ef2a936.zip
Pick up/drop/open/close actions are now available in game.
svn-id: r33371
-rw-r--r--engines/parallaction/input.cpp12
-rw-r--r--engines/parallaction/parallaction.cpp2
-rw-r--r--engines/parallaction/parallaction.h10
-rw-r--r--engines/parallaction/parallaction_br.cpp65
-rw-r--r--engines/parallaction/parallaction_ns.cpp20
5 files changed, 67 insertions, 42 deletions
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 380f766fe0..0e6e135cc3 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -301,13 +301,13 @@ void Input::enterInventoryMode() {
void Input::exitInventoryMode() {
// right up hides inventory
- int item = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+ int pos = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
_vm->highlightInventoryItem(-1); // disable
if ((_engineFlags & kEngineDragging)) {
_engineFlags &= ~kEngineDragging;
- ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(item));
+ ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(pos));
if (z) {
_vm->dropItem(z->u.merge->_obj1);
@@ -319,10 +319,14 @@ void Input::exitInventoryMode() {
}
_vm->closeInventory();
- if (item == -1) {
+ if (pos == -1) {
_vm->setArrowCursor();
} else {
- _vm->setInventoryCursor(item);
+ const InventoryItem *item = _vm->getInventoryItem(pos);
+ if (item->_index != 0) {
+ _activeItem._id = item->_id;
+ _vm->setInventoryCursor(item->_index);
+ }
}
_vm->resumeJobs();
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 436cad4ca4..54cb175e46 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -100,6 +100,8 @@ Parallaction::~Parallaction() {
cleanupGui();
+ delete _comboArrow;
+
delete _localFlagNames;
delete _gfx;
delete _soundMan;
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 8d4bb93c97..d8e4da5baf 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -325,6 +325,7 @@ public:
Common::RandomSource _rnd;
Debugger *_debugger;
+ Frames *_comboArrow;
protected: // data
@@ -365,7 +366,7 @@ public:
virtual void callFunction(uint index, void* parm) { }
virtual void setArrowCursor() = 0;
- virtual void setInventoryCursor(int pos) = 0;
+ virtual void setInventoryCursor(ItemName name) = 0;
virtual void parseLocation(const char* name) = 0;
@@ -481,7 +482,6 @@ public:
typedef void (Parallaction_ns::*Callable)(void*);
virtual void callFunction(uint index, void* parm);
- void setMousePointer(uint32 value);
bool loadGame();
bool saveGame();
@@ -512,7 +512,7 @@ private:
void changeCharacter(const char *name);
void runPendingZones();
- void setInventoryCursor(int pos);
+ void setInventoryCursor(ItemName name);
void doLoadGame(uint16 slot);
@@ -525,7 +525,6 @@ private:
static byte _resMouseArrow[256];
byte *_mouseArrow;
- Frames *_mouseComposedArrow;
static const Callable _dosCallables[25];
static const Callable _amigaCallables[25];
@@ -644,7 +643,7 @@ private:
void initFonts();
void freeFonts();
- void setInventoryCursor(int pos);
+ void setInventoryCursor(ItemName name);
void changeLocation(char *location);
void runPendingZones();
@@ -652,7 +651,6 @@ private:
void initPart();
void freePart();
- void setMousePointer(int16 index);
void initCursors();
Frames *_dinoCursor;
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 6482329c5e..efdf0d06b4 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -32,6 +32,27 @@
namespace Parallaction {
+struct MouseComboProperties {
+ int _xOffset;
+ int _yOffset;
+ int _width;
+ int _height;
+};
+/*
+// TODO: improve NS's handling of normal cursor before merging cursor code.
+MouseComboProperties _mouseComboProps_NS = {
+ 7, // combo x offset (the icon from the inventory will be rendered from here)
+ 7, // combo y offset (ditto)
+ 32, // combo (arrow + icon) width
+ 32 // combo (arrow + icon) height
+};
+*/
+MouseComboProperties _mouseComboProps_BR = {
+ 8, // combo x offset (the icon from the inventory will be rendered from here)
+ 8, // combo y offset (ditto)
+ 68, // combo (arrow + icon) width
+ 68 // combo (arrow + icon) height
+};
const char *Parallaction_br::_partNames[] = {
"PART0",
@@ -103,6 +124,7 @@ Parallaction_br::~Parallaction_br() {
delete _dougCursor;
delete _donnaCursor;
+ delete _mouseArrow;
}
void Parallaction_br::callFunction(uint index, void* parm) {
@@ -154,6 +176,12 @@ void Parallaction_br::initCursors() {
_dougCursor = _disk->loadPointer("pointer2");
_donnaCursor = _disk->loadPointer("pointer3");
+ Graphics::Surface *surf = new Graphics::Surface;
+ surf->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, 1);
+ _comboArrow = new SurfaceToFrames(surf);
+
+ // TODO: choose the pointer depending on the active character
+ // For now, we pick Donna's
_mouseArrow = _donnaCursor;
} else {
// TODO: Where are the Amiga cursors?
@@ -161,19 +189,6 @@ void Parallaction_br::initCursors() {
}
-void Parallaction_br::setMousePointer(int16 index) {
- // FIXME: Where are the Amiga cursors?
- if (getPlatform() == Common::kPlatformAmiga)
- return;
-
- Common::Rect r;
- _mouseArrow->getRect(0, r);
-
- _system->setMouseCursor(_mouseArrow->getData(0), r.width(), r.height(), 0, 0, 0);
- _system->showMouse(true);
-
-}
-
void Parallaction_br::initPart() {
memset(_counters, 0, ARRAYSIZE(_counters));
@@ -340,15 +355,29 @@ void Parallaction_br::changeCharacter(const char *name) {
void Parallaction_br::setArrowCursor() {
- // TODO: choose the pointer depending on the active character
- // For now, defaults to 0, that corresponds to the default in the original
- setMousePointer(0);
-}
+ // FIXME: Where are the Amiga cursors?
+ if (getPlatform() == Common::kPlatformAmiga)
+ return;
-void Parallaction_br::setInventoryCursor(int pos) {
+ Common::Rect r;
+ _mouseArrow->getRect(0, r);
+
+ _system->setMouseCursor(_mouseArrow->getData(0), r.width(), r.height(), 0, 0, 0);
+ _system->showMouse(true);
+
+ _input->_activeItem._id = 0;
+}
+void Parallaction_br::setInventoryCursor(ItemName name) {
+ assert(name > 0);
+ byte *src = _mouseArrow->getData(0);
+ byte *dst = _comboArrow->getData(0);
+ memcpy(dst, src, _comboArrow->getSize(0));
+ // FIXME: destination offseting is not clear
+ _inventoryRenderer->drawItem(name, dst + _mouseComboProps_BR._yOffset * _mouseComboProps_BR._width + _mouseComboProps_BR._xOffset, _mouseComboProps_BR._width);
+ _system->setMouseCursor(dst, _mouseComboProps_BR._width, _mouseComboProps_BR._height, 0, 0, 0);
}
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 5b5c9f6871..851fe38138 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -34,6 +34,7 @@
namespace Parallaction {
+
#define MOUSEARROW_WIDTH 16
#define MOUSEARROW_HEIGHT 16
@@ -165,7 +166,6 @@ Parallaction_ns::~Parallaction_ns() {
delete _locationParser;
delete _programParser;
- delete _mouseComposedArrow;
_location._animations.remove(_char._ani);
@@ -182,7 +182,7 @@ void Parallaction_ns::freeFonts() {
}
void Parallaction_ns::initCursors() {
- _mouseComposedArrow = _disk->loadPointer("pointer");
+ _comboArrow = _disk->loadPointer("pointer");
_mouseArrow = _resMouseArrow;
}
@@ -197,21 +197,13 @@ void Parallaction_ns::setArrowCursor() {
_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
}
-void Parallaction_ns::setInventoryCursor(int pos) {
-
- if (pos == -1)
- return;
-
- const InventoryItem *item = getInventoryItem(pos);
- if (item->_index == 0)
- return;
-
- _input->_activeItem._id = item->_id;
+void Parallaction_ns::setInventoryCursor(ItemName name) {
+ assert(name > 0);
- byte *v8 = _mouseComposedArrow->getData(0);
+ byte *v8 = _comboArrow->getData(0);
// FIXME: destination offseting is not clear
- _inventoryRenderer->drawItem(item->_index, v8 + 7 * MOUSECOMBO_WIDTH + 7, MOUSECOMBO_WIDTH);
+ _inventoryRenderer->drawItem(name, v8 + 7 * MOUSECOMBO_WIDTH + 7, MOUSECOMBO_WIDTH);
_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0);
}