aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-01 22:33:54 -0400
committerPaul Gilbert2016-07-10 16:38:05 -0400
commitc3dadcfe3b9d62eb19970b200e941f138f8abf1b (patch)
tree86cb10425d020ff41e0d469381cdebdebbf6c0f3 /engines
parent8a6a5ad5c10b682bef145b414ebed386aa7df842 (diff)
downloadscummvm-rg350-c3dadcfe3b9d62eb19970b200e941f138f8abf1b.tar.gz
scummvm-rg350-c3dadcfe3b9d62eb19970b200e941f138f8abf1b.tar.bz2
scummvm-rg350-c3dadcfe3b9d62eb19970b200e941f138f8abf1b.zip
TITANIC: Beginnings of PET Remote glyph classes
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/module.mk5
-rw-r--r--engines/titanic/pet_control/pet_control.cpp8
-rw-r--r--engines/titanic/pet_control/pet_control.h2
-rw-r--r--engines/titanic/pet_control/pet_glyphs.h5
-rw-r--r--engines/titanic/pet_control/pet_nav_helmet.cpp8
-rw-r--r--engines/titanic/pet_control/pet_remote.cpp133
-rw-r--r--engines/titanic/pet_control/pet_remote.h33
-rw-r--r--engines/titanic/pet_control/pet_remote_glyphs.cpp83
-rw-r--r--engines/titanic/pet_control/pet_remote_glyphs.h108
9 files changed, 367 insertions, 18 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index a9d758b57f..ae0c563f24 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -364,10 +364,11 @@ MODULE_OBJS := \
pet_control/pet_inventory_glyphs.o \
pet_control/pet_message.o \
pet_control/pet_nav_helmet.o \
+ pet_control/pet_real_life.o \
+ pet_control/pet_remote.o \
+ pet_control/pet_remote_glyphs.o \
pet_control/pet_rooms.o \
pet_control/pet_rooms_glyphs.o \
- pet_control/pet_remote.o \
- pet_control/pet_real_life.o \
pet_control/pet_section.o \
pet_control/pet_drag_chev.o \
pet_control/pet_graphic2.o \
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 2bd8864998..c115cb5979 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -44,7 +44,7 @@ END_MESSAGE_MAP()
CPetControl::CPetControl() : CGameObject(),
_currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0),
- _activeNPC(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr),
+ _activeNPC(nullptr), _remoteTarget(nullptr), _hiddenRoom(nullptr),
_drawBounds(20, 350, 620, 480) {
_sections[PET_INVENTORY] = &_inventory;
_sections[PET_CONVERSATION] = &_conversations;
@@ -152,7 +152,7 @@ void CPetControl::postLoad() {
if (!_activeNPCName.empty() && root)
_activeNPC = root->findByName(_activeNPCName);
if (!_string2.empty() && root)
- _treeItem2 = root->findByName(_string2);
+ _remoteTarget = root->findByName(_string2);
setArea(_currentArea);
loaded();
@@ -179,7 +179,7 @@ void CPetControl::enterRoom(CRoomItem *room) {
}
void CPetControl::clear() {
- _treeItem2 = nullptr;
+ _remoteTarget = nullptr;
_string2.clear();
}
@@ -216,7 +216,7 @@ void CPetControl::fn2(int val) {
}
void CPetControl::fn3(CTreeItem *item) {
- _treeItem2 = item;
+ _remoteTarget = item;
if (item)
_string2 = item->getName();
else
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 2c706397ea..7763dd91dc 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -113,7 +113,7 @@ protected:
public:
PetArea _currentArea;
CTreeItem *_activeNPC;
- CTreeItem *_treeItem2;
+ CTreeItem *_remoteTarget;
public:
CLASSDEF
CPetControl();
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index 2aa80db41b..5dc5013a9b 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -408,6 +408,11 @@ public:
* Returns the index of the specified glyph in the lsit
*/
int indexOf(const CPetGlyph *glyph) const;
+
+ /**
+ * Resets the scrolling of the glyphs list back to the start
+ */
+ void scrollToStart() { _firstVisibleIndex = 0; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_nav_helmet.cpp b/engines/titanic/pet_control/pet_nav_helmet.cpp
index 7697df40f6..b995786b97 100644
--- a/engines/titanic/pet_control/pet_nav_helmet.cpp
+++ b/engines/titanic/pet_control/pet_nav_helmet.cpp
@@ -77,17 +77,17 @@ void CPetNavHelmet::draw(CScreenManager *screenManager) {
}
bool CPetNavHelmet::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
- if (!_petControl->_treeItem2)
+ if (!_petControl->_remoteTarget)
return false;
if (_val1.MouseButtonDownMsg(msg->_mousePos)) {
CPETHelmetOnOffMsg helmetMsg;
- helmetMsg.execute(_petControl->_treeItem2);
+ helmetMsg.execute(_petControl->_remoteTarget);
} else if (_val2.MouseButtonDownMsg(msg->_mousePos)) {
if (_field210) {
_photoOn = !_photoOn;
CPETPhotoOnOffMsg photoMsg;
- photoMsg.execute(_petControl->_treeItem2);
+ photoMsg.execute(_petControl->_remoteTarget);
} else {
_petControl->displayMessage("Please supply Galactic reference material.");
}
@@ -99,7 +99,7 @@ bool CPetNavHelmet::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
}
bool CPetNavHelmet::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
- if (!_petControl->_treeItem2 || !_setDestination.MouseButtonUpMsg(msg->_mousePos))
+ if (!_petControl->_remoteTarget || !_setDestination.MouseButtonUpMsg(msg->_mousePos))
return false;
if (_petControl) {
diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp
index 1aef2bc511..fb9178b13b 100644
--- a/engines/titanic/pet_control/pet_remote.cpp
+++ b/engines/titanic/pet_control/pet_remote.cpp
@@ -21,12 +21,53 @@
*/
#include "titanic/pet_control/pet_remote.h"
+#include "titanic/pet_control/pet_remote_glyphs.h"
#include "titanic/pet_control/pet_control.h"
+#include "titanic/messages/pet_messages.h"
#include "titanic/game_manager.h"
#include "titanic/titanic.h"
namespace Titanic {
+static const byte REMOTE_DATA[] = {
+ 0x00, 0x02,
+ GLYPH_SUMMON_ELEVATOR, 0x10,
+ 0x01, 0x02, 0x01, 0x10,
+ 0x02, 0x03, 0x02, 0x04, 0x10,
+ 0x03, 0x02,
+ GLYPH_SUMMON_ELEVATOR, 0x10,
+ 0x04, 0x02, 0x02, 0x10,
+ 0x05, 0x02, 0x01, 0x10,
+ 0x06, 0x02, 0x01, 0x10,
+ 0x07, 0x03, 0x02, 0x01, 0x10,
+ 0x08, 0x01, 0x10,
+ 0x09, 0x01, 0x10,
+ 0x0A, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10,
+ 0x0B, 0x01, 0x11,
+ 0x0C, 0x01, 0x10,
+ 0x0D, 0x01, 0x10,
+ 0x0E, 0x00,
+ 0x0F, 0x01, 0x02,
+ 0x10, 0x03, 0x12, 0x14, 0x13,
+ 0x11, 0x01, 0x10,
+ 0x12, 0x00,
+ 0x13, 0x02, 0x01, 0x10,
+ 0x14, 0x00,
+ 0x15, 0x02, 0x10, 0x02,
+ 0x16, 0x00,
+ 0x17, 0x02, 0x01, 0x10,
+ 0x18, 0x01, 0x10,
+ 0x19, 0x00,
+ 0x1A, 0x00,
+ 0x1B, 0x00,
+ 0x1C, 0x00,
+ 0x1D, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10,
+ 0x1E, 0x0C, 0x05, 0x06, 0x07, 0x08, 0x03, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x1F, 0x01, 0x10,
+ 0x20, 0x02, GLYPH_SUMMON_ELEVATOR, 0x01,
+ 0x21, 0x00
+};
+
CPetRemote::CPetRemote() : CPetSection() {
}
@@ -117,7 +158,7 @@ CPetText *CPetRemote::getText() {
return &_text;
}
-CPetElement *CPetRemote::getElement(uint id) {
+CPetGfxElement *CPetRemote::getElement(uint id) {
switch (id) {
case 0:
return &_onOff;
@@ -209,7 +250,14 @@ int CPetRemote::getHighlightIndex(int val) {
if (roomIndex == -1)
return -1;
- // TODO: more
+ Common::Array<uint> remoteData;
+ getRemoteData(roomIndex, remoteData);
+
+ // Loop through the data for the room
+ for (uint idx = 0; idx < remoteData.size(); ++idx) {
+ if (remoteData[idx + 1] == val)
+ return idx;
+ }
return -1;
}
@@ -223,4 +271,85 @@ int CPetRemote::roomIndexOf(const CString &name) {
return -1;
}
+void CPetRemote::getRemoteData(int roomIndex, Common::Array<uint> &indexes) {
+ const byte *p = &REMOTE_DATA[0];
+ for (int idx = 0; idx < TOTAL_ROOMS; ++idx) {
+ if (*p == roomIndex) {
+ for (int idx = 0; idx < *p; ++idx)
+ indexes.push_back(p[idx + 1]);
+ return;
+ }
+
+ p += *(p + 1) + 2;
+ }
+}
+
+bool CPetRemote::loadGlyphs(const Common::Array<uint> &indexes) {
+ for (uint idx = 0; idx < indexes.size(); ++idx) {
+ if (!loadGlyph(indexes[idx]))
+ return false;
+ }
+
+ return true;
+}
+
+bool CPetRemote::loadGlyph(int glyphIndex) {
+ CPetRemoteGlyph *glyph = nullptr;
+
+ switch (glyphIndex) {
+ case GLYPH_SUMMON_ELEVATOR:
+ glyph = new CSummonElevatorGlyph();
+ break;
+
+ default:
+ break;
+ }
+
+ if (glyph) {
+ if (glyph->setup(_petControl, &_items)) {
+ _items.push_back(glyph);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void CPetRemote::generateMessage(RemoteMessage msgNum, const CString &name, int num) {
+ switch (msgNum) {
+ case RMSG_LEFT: {
+ CPETLeftMsg msg(name, num);
+ msg.execute(_petControl->_remoteTarget);
+ break;
+ }
+
+ case RMSG_RIGHT: {
+ CPETRightMsg msg(name, num);
+ msg.execute(_petControl->_remoteTarget);
+ break;
+ }
+
+ case RMSG_UP: {
+ CPETUpMsg msg(name, num);
+ msg.execute(_petControl->_remoteTarget);
+ break;
+ }
+
+ case RMSG_DOWN: {
+ CPETDownMsg msg(name, num);
+ msg.execute(_petControl->_remoteTarget);
+ break;
+ }
+
+ case RMSG_ACTIVATE: {
+ CPETActivateMsg msg(name, num);
+ msg.execute(_petControl->_remoteTarget);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h
index 5db7e7f912..6982c93aef 100644
--- a/engines/titanic/pet_control/pet_remote.h
+++ b/engines/titanic/pet_control/pet_remote.h
@@ -23,16 +23,14 @@
#ifndef TITANIC_PET_REMOTE_H
#define TITANIC_PET_REMOTE_H
+#include "common/array.h"
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_glyphs.h"
+#include "titanic/pet_control/pet_remote_glyphs.h"
#include "titanic/pet_control/pet_text.h"
-#include "titanic/pet_control/pet_gfx_element.h"
namespace Titanic {
-class CPetRemoteGlyphs : public CPetGlyphs {
-};
-
class CPetRemote : public CPetSection {
private:
CPetRemoteGlyphs _items;
@@ -68,6 +66,26 @@ private:
* Return the index of a room name in the master room names list
*/
int roomIndexOf(const CString &name);
+
+ /**
+ * Return a list of remote action glyph indexes for a given room
+ */
+ void getRemoteData(int roomIndex, Common::Array<uint> &indexes);
+
+ /**
+ * Clear the list of rooms glyphs
+ */
+ void clearGlyphs() { _items.clear(); }
+
+ /**
+ * Load the room glyphs
+ */
+ bool loadGlyphs(const Common::Array<uint> &indexes);
+
+ /**
+ * Load a single room glyph
+ */
+ bool loadGlyph(int glyphIndex);
public:
CPetRemote();
@@ -123,9 +141,14 @@ public:
/**
* Get an element from the section by a designated Id
*/
- virtual CPetElement *getElement(uint id);
+ virtual CPetGfxElement *getElement(uint id);
virtual void proc38(int val);
+
+ /**
+ * Generates a PET message
+ */
+ void generateMessage(RemoteMessage msgNum, const CString &name, int num);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp
new file mode 100644
index 0000000000..76ab3839b7
--- /dev/null
+++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp
@@ -0,0 +1,83 @@
+/* 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 "titanic/pet_control/pet_remote_glyphs.h"
+#include "titanic/pet_control/pet_remote.h"
+
+namespace Titanic {
+
+CPetRemote *CPetRemoteGlyphs::getOwner() const {
+ return static_cast<CPetRemote *>(_owner);
+}
+
+void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) {
+ getOwner()->generateMessage(msgNum, name, num);
+}
+
+/*------------------------------------------------------------------------*/
+
+void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) {
+ _gfxElement->setBounds(Rect(0, 0, 52, 52));
+ _gfxElement->setup(MODE_UNSELECTED, name, petControl);
+}
+
+CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const {
+ return static_cast<CPetRemoteGlyphs *>(_owner);
+}
+
+CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const {
+ CPetRemote *remote = static_cast<CPetRemote *>(_owner->getOwner());
+ return remote->getElement(id);
+}
+
+/*------------------------------------------------------------------------*/
+
+bool CSummonElevatorGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
+ setDefaults("3PetLift", petControl);
+ if (owner)
+ _gfxElement = getElement(18);
+ return true;
+}
+
+void CSummonElevatorGlyph::draw2(CScreenManager *screenManager) {
+ if (_gfxElement)
+ _gfxElement->draw(screenManager);
+}
+
+bool CSummonElevatorGlyph::MouseButtonDownMsg(const Point &pt) {
+ return _gfxElement && _gfxElement->MouseButtonDownMsg(pt);
+}
+
+bool CSummonElevatorGlyph::MouseButtonUpMsg(const Point &pt) {
+ if (_gfxElement && _gfxElement->MouseButtonUpMsg(pt)) {
+ getOwner()->generateMessage(RMSG_ACTIVATE, "Lift");
+ return true;
+ }
+
+ return false;
+}
+
+void CSummonElevatorGlyph::getTooltip(CPetText *text) {
+ text->setText("Summon Elevator");
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_remote_glyphs.h b/engines/titanic/pet_control/pet_remote_glyphs.h
new file mode 100644
index 0000000000..56a2e2cf51
--- /dev/null
+++ b/engines/titanic/pet_control/pet_remote_glyphs.h
@@ -0,0 +1,108 @@
+/* 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 TITANIC_PET_REMOTE_GLYPHS_H
+#define TITANIC_PET_REMOTE_GLYPHS_H
+
+#include "titanic/pet_control/pet_glyphs.h"
+#include "titanic/pet_control/pet_gfx_element.h"
+
+namespace Titanic {
+
+enum RemoteGlyph {
+ GLYPH_SUMMON_ELEVATOR = 0
+};
+
+enum RemoteMessage {
+ RMSG_LEFT = 0, RMSG_RIGHT = 1, RMSG_UP = 2, RMSG_DOWN = 3, RMSG_ACTIVATE = 4
+};
+
+class CPetRemote;
+
+class CPetRemoteGlyphs : public CPetGlyphs {
+public:
+ /**
+ * Returns the owning CPetRemote
+ */
+ CPetRemote *getOwner() const;
+
+ /**
+ * Generates a PET message
+ */
+ void generateMessage(RemoteMessage msgNum, const CString &name, int num = -1);
+};
+
+class CPetRemoteGlyph : public CPetGlyph {
+protected:
+ CPetGfxElement *_gfxElement;
+protected:
+ CPetRemoteGlyph() : CPetGlyph(), _gfxElement(nullptr) {}
+
+ /**
+ * Set defaults for the glyph
+ */
+ void setDefaults(const CString &name, CPetControl *petControl);
+
+ /**
+ * Get the owner
+ */
+ CPetRemoteGlyphs *getOwner() const;
+
+ /**
+ * Get an element by id from the parent Remote section
+ */
+ CPetGfxElement *getElement(uint id) const;
+};
+
+class CSummonElevatorGlyph : public CPetRemoteGlyph {
+public:
+ CSummonElevatorGlyph() : CPetRemoteGlyph() {}
+
+ /**
+ * Setup the glyph
+ */
+ virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
+
+ /**
+ * Handles any secondary drawing of the glyph
+ */
+ virtual void draw2(CScreenManager *screenManager);
+
+ /**
+ * Called for mouse button down messages
+ */
+ virtual bool MouseButtonDownMsg(const Point &pt);
+
+ /**
+ * Handles mouse button up messages
+ */
+ virtual bool MouseButtonUpMsg(const Point &pt);
+
+ /**
+ * Returns the tooltip text for when the glyph is selected
+ */
+ virtual void getTooltip(CPetText *text);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_PET_REMOTE_GLYPHS_H */