aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-01 19:09:21 -0400
committerPaul Gilbert2016-07-10 16:38:04 -0400
commit8a6a5ad5c10b682bef145b414ebed386aa7df842 (patch)
treede8f6002d413744f6fb25a89aeac64c528da2476
parent93f88cc668f15a4c2b411c99b3f07e2f03bee50a (diff)
downloadscummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.tar.gz
scummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.tar.bz2
scummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.zip
TITANIC: In progress implementation of PET Remote
-rw-r--r--engines/titanic/pet_control/pet_remote.cpp194
-rw-r--r--engines/titanic/pet_control/pet_remote.h95
-rw-r--r--engines/titanic/pet_control/pet_rooms.cpp7
-rw-r--r--engines/titanic/pet_control/pet_rooms.h7
-rw-r--r--engines/titanic/pet_control/pet_section.cpp4
-rw-r--r--engines/titanic/pet_control/pet_section.h7
-rw-r--r--engines/titanic/titanic.cpp16
-rw-r--r--engines/titanic/titanic.h7
8 files changed, 315 insertions, 22 deletions
diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp
index 4463c31bee..1aef2bc511 100644
--- a/engines/titanic/pet_control/pet_remote.cpp
+++ b/engines/titanic/pet_control/pet_remote.cpp
@@ -21,12 +21,206 @@
*/
#include "titanic/pet_control/pet_remote.h"
+#include "titanic/pet_control/pet_control.h"
+#include "titanic/game_manager.h"
+#include "titanic/titanic.h"
namespace Titanic {
+CPetRemote::CPetRemote() : CPetSection() {
+}
+
+bool CPetRemote::setup(CPetControl *petControl) {
+ if (petControl && setupControl(petControl))
+ return reset();
+ return false;
+}
+
+bool CPetRemote::reset() {
+ if (_petControl) {
+ _onOff.reset("PetSwitchOn", _petControl, MODE_SELECTED);
+ _onOff.reset("PetSwitchOff", _petControl, MODE_UNSELECTED);
+
+ _up.reset("PetUp", _petControl, MODE_UNSELECTED);
+ _down.reset("PetDown", _petControl, MODE_UNSELECTED);
+
+ _left.reset("PetLeftUp", _petControl, MODE_SELECTED);
+ _left.reset("PetLeft", _petControl, MODE_UNSELECTED);
+ _right.reset("PetRightUp", _petControl, MODE_SELECTED);
+ _right.reset("PetRight", _petControl, MODE_UNSELECTED);
+ _top.reset("PetTopUp", _petControl, MODE_SELECTED);
+ _top.reset("PetTop", _petControl, MODE_UNSELECTED);
+ _bottom.reset("PetBottomUp", _petControl, MODE_SELECTED);
+ _bottom.reset("PetBottom", _petControl, MODE_UNSELECTED);
+ _action.reset("PetActionUp", _petControl, MODE_SELECTED);
+ _action.reset("PetAction", _petControl, MODE_UNSELECTED);
+
+ _send.reset("PetActSend0", _petControl, MODE_UNSELECTED);
+ _send.reset("PetActSend1", _petControl, MODE_SELECTED);
+ _receive.reset("PetActReceive0", _petControl, MODE_UNSELECTED);
+ _receive.reset("PetActReceive1", _petControl, MODE_SELECTED);
+ _call.reset("PetActCall0", _petControl, MODE_UNSELECTED);
+ _call.reset("PetActCall1", _petControl, MODE_SELECTED);
+
+ _items.reset();
+ uint col = getColor(0);
+ _text.setColor(col);
+ _text.setLineColor(0, col);
+ }
+
+ return true;
+}
+
+void CPetRemote::draw(CScreenManager *screenManager) {
+ _petControl->drawSquares(screenManager, 6);
+ _items.draw(screenManager);
+ _text.draw(screenManager);
+}
+
+bool CPetRemote::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ return _items.MouseButtonDownMsg(msg->_mousePos);
+}
+
+bool CPetRemote::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
+ return _items.MouseButtonUpMsg(msg->_mousePos);
+}
+
+bool CPetRemote::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
+ return _items.MouseButtonDownMsg(msg->_mousePos);
+}
+
+bool CPetRemote::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) {
+ return _items.VirtualKeyCharMsg(msg->_keyState.keycode);
+}
+
bool CPetRemote::isValid(CPetControl *petControl) {
+ return setupControl(petControl);
+}
+
+void CPetRemote::postLoad() {
+ reset();
+ CRoomItem *room = getRoom();
+ if (room)
+ enterRoom(room);
+}
+
+void CPetRemote::enter(PetArea oldArea) {
+ if (_items.highlighted14())
+ _text.setText(CString());
+}
+
+void CPetRemote::enterRoom(CRoomItem *room) {
// TODO
+}
+
+CPetText *CPetRemote::getText() {
+ return &_text;
+}
+
+CPetElement *CPetRemote::getElement(uint id) {
+ switch (id) {
+ case 0:
+ return &_onOff;
+ case 1:
+ return &_up;
+ case 2:
+ return &_down;
+ case 3:
+ return &_left;
+ case 4:
+ return &_right;
+ case 5:
+ return &_top;
+ case 6:
+ return &_bottom;
+ case 7:
+ return &_action;
+ case 16:
+ return &_send;
+ case 17:
+ return &_receive;
+ case 18:
+ return &_call;
+ default:
+ return nullptr;
+ }
+}
+
+void CPetRemote::proc38(int val) {
+ int highlightIndex = getHighlightIndex(val);
+ if (highlightIndex != -1)
+ _items.highlight(highlightIndex);
+}
+
+bool CPetRemote::setupControl(CPetControl *petControl) {
+ _petControl = petControl;
+ if (!petControl)
+ return false;
+
+ _onOff.setBounds(Rect(0, 0, 15, 43));
+ _onOff.translate(519, 381);
+ _up.setBounds(Rect(0, 0, 21, 24));
+ _up.translate(551, 381);
+ _down.setBounds(Rect(0, 0, 21, 24));
+ _down.translate(551, 402);
+ _left.setBounds(Rect(0, 0, 22, 21));
+ _left.translate(518, 393);
+ _right.setBounds(Rect(0, 0, 21, 21));
+ _right.translate(560, 393);
+ _top.setBounds(Rect(0, 0, 21, 22));
+ _top.translate(539, 371);
+ _bottom.setBounds(Rect(0, 0, 21, 22));
+ _bottom.translate(539, 414);
+ _action.setBounds(Rect(0, 0, 21, 21));
+ _action.translate(539, 393);
+ _send.setBounds(Rect(0, 0, 62, 38));
+ _send.translate(503, 373);
+ _receive.setBounds(Rect(0, 0, 62, 38));
+ _receive.translate(503, 420);
+ _call.setBounds(Rect(0, 0, 62, 38));
+ _call.translate(503, 383);
+
+ Rect rect(0, 0, 580, 15);
+ rect.moveTo(32, 445);
+ _text.setBounds(rect);
+ _text.setHasBorder(false);
+
+ _items.setup(6, this);
+ _items.setFlags(19);
return true;
}
+CRoomItem *CPetRemote::getRoom() const {
+ if (_petControl) {
+ CGameManager *gameManager = _petControl->getGameManager();
+ if (gameManager)
+ return gameManager->getRoom();
+ }
+
+ return nullptr;
+}
+
+int CPetRemote::getHighlightIndex(int val) {
+ CRoomItem *room = getRoom();
+ if (!room)
+ return -1;
+
+ int roomIndex = roomIndexOf(room->getName());
+ if (roomIndex == -1)
+ return -1;
+
+ // TODO: more
+
+ return -1;
+}
+
+int CPetRemote::roomIndexOf(const CString &name) {
+ for (int idx = 0; idx < TOTAL_ROOMS; ++idx) {
+ if (g_vm->_roomNames[idx] == name)
+ return idx;
+ }
+
+ return -1;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h
index 70f6c3262c..5db7e7f912 100644
--- a/engines/titanic/pet_control/pet_remote.h
+++ b/engines/titanic/pet_control/pet_remote.h
@@ -36,23 +36,96 @@ class CPetRemoteGlyphs : public CPetGlyphs {
class CPetRemote : public CPetSection {
private:
CPetRemoteGlyphs _items;
- CPetGfxElement _val1;
- CPetGfxElement _val2;
- CPetGfxElement _val3;
- CPetGfxElement _val4;
- CPetGfxElement _val5;
- CPetGfxElement _val6;
- CPetGfxElement _val7;
- CPetGfxElement _val8;
- CPetGfxElement _val9;
- CPetGfxElement _val10;
- CPetGfxElement _val11;
+ CPetGfxElement _onOff;
+ CPetGfxElement _up;
+ CPetGfxElement _down;
+ CPetGfxElement _left;
+ CPetGfxElement _right;
+ CPetGfxElement _top;
+ CPetGfxElement _bottom;
+ CPetGfxElement _action;
+ CPetGfxElement _send;
+ CPetGfxElement _receive;
+ CPetGfxElement _call;
CPetText _text;
+private:
+ /**
+ * Setup the control
+ */
+ bool setupControl(CPetControl *petControl);
+
+ /**
+ * Get the current room
+ */
+ CRoomItem *getRoom() const;
+
+ /**
+ * Return a highlight index
+ */
+ int getHighlightIndex(int val);
+
+ /**
+ * Return the index of a room name in the master room names list
+ */
+ int roomIndexOf(const CString &name);
public:
+ CPetRemote();
+
+ /**
+ * Sets up the section
+ */
+ virtual bool setup(CPetControl *petControl);
+
+ /**
+ * Reset the section
+ */
+ virtual bool reset();
+
+ /**
+ * Draw the section
+ */
+ virtual void draw(CScreenManager *screenManager);
+
+ /**
+ * Following are handlers for the various messages that the PET can
+ * pass onto the currently active section/area
+ */
+ virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
+ virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
+ virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
+
/**
* Returns true if the object is in a valid state
*/
virtual bool isValid(CPetControl *petControl);
+
+ /**
+ * Called after a game has been loaded
+ */
+ virtual void postLoad();
+
+ /**
+ * Called when a section is switched to
+ */
+ virtual void enter(PetArea oldArea);
+
+ /**
+ * Called when a new room is entered
+ */
+ virtual void enterRoom(CRoomItem *room);
+
+ /**
+ * Get a reference to the tooltip text associated with the section
+ */
+ virtual CPetText *getText();
+
+ /**
+ * Get an element from the section by a designated Id
+ */
+ virtual CPetElement *getElement(uint id);
+
+ virtual void proc38(int val);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp
index 7c2b9fb569..e474e35eac 100644
--- a/engines/titanic/pet_control/pet_rooms.cpp
+++ b/engines/titanic/pet_control/pet_rooms.cpp
@@ -94,8 +94,8 @@ bool CPetRooms::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) {
return _glyphs.VirtualKeyCharMsg(msg->_keyState.keycode);
}
-bool CPetRooms::proc14(void *v1) {
- warning("TODO: proc14");
+bool CPetRooms::checkDragEnd(CGameObject *item) {
+ warning("TODO: CPetRooms::checkDragEnd");
return false;
}
@@ -171,8 +171,8 @@ bool CPetRooms::setupControl(CPetControl *petControl) {
_text.setHasBorder(false);
Rect rect2(0, 0, 81, 81);
- rect2.moveTo(374, 494);
_plinth.setBounds(rect2);
+ _plinth.translate(494, 374);
_chevLeftOnDim = petControl->getHiddenObject("3PetChevLeftOnDim");
_chevLeftOffDim = petControl->getHiddenObject("3PetChevLeftOffDim");
@@ -219,5 +219,4 @@ CPetRoomsGlyph *CPetRooms::addGlyph(int val, bool highlight) {
}
}
-
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h
index a0fd3e92cb..522a1e2399 100644
--- a/engines/titanic/pet_control/pet_rooms.h
+++ b/engines/titanic/pet_control/pet_rooms.h
@@ -101,8 +101,11 @@ public:
virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
- virtual bool proc14(void *v1);
-
+ /**
+ * Check whether a drag drop can occur
+ */
+ virtual bool checkDragEnd(CGameObject *item);
+
/**
* Display a message
*/
diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp
index 7f0a0005e5..116fd94ddb 100644
--- a/engines/titanic/pet_control/pet_section.cpp
+++ b/engines/titanic/pet_control/pet_section.cpp
@@ -66,10 +66,6 @@ void CPetSection::proc29() {
_petControl->stopPetTimer(0);
}
-void CPetSection::proc30() {
- error("TODO");
-}
-
uint CPetSection::getColor(uint index) {
return getColorTable()[index];
}
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 296479d025..52890fc79a 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -34,6 +34,7 @@ enum PetArea {
};
class CPetControl;
+class CPetElement;
class CPetText;
class CScreenManager;
class CRoomItem;
@@ -152,7 +153,11 @@ public:
virtual void proc27(int duration);
virtual void proc28();
virtual void proc29();
- virtual void proc30();
+
+ /**
+ * Get an element from the section by a designated Id
+ */
+ virtual CPetElement *getElement(uint id) { return nullptr; }
virtual CGameObject *getBackground(int index) const { return nullptr; }
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index 932189067f..f1d24a0a1e 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -78,6 +78,7 @@ void TitanicEngine::initialize() {
DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling");
setItemNames();
+ setRoomNames();
CSaveableObject::initClassList();
CEnterExitFirstClassState::init();
CGetLiftEye2::init();
@@ -173,5 +174,20 @@ void TitanicEngine::setItemNames() {
_itemIds[idx] = ITEM_IDS[idx];
}
+void TitanicEngine::setRoomNames() {
+ static const char *const ROOM_NAMES[TOTAL_ROOMS] = {
+ "1stClassLobby", "1stClassRestaurant", "1stClassState",
+ "2ndClassLobby", "secClassState", "Arboretum", "FrozenArboretum",
+ "Bar", "BilgeRoom", "BilgeRoomWith", "BottomOfWell", "Bridge",
+ "CreatorsChamber", "CreatorsChamberOn", "Dome", "Home", "Lift",
+ "EmbLobby", "MoonEmbLobby", "MusicRoomLobby", "MusicRoom",
+ "ParrotLobby", "Pellerator", "PromenadeDeck", "SculptureChamber",
+ "SecClassLittleLift", "ServiceElevator", "SGTLeisure", "SGTLittleLift",
+ "SgtLobby", "SGTState", "Titania", "TopOfWell", "PlayersRoom"
+ };
+
+ for (uint idx = 0; idx < TOTAL_ROOMS; ++idx)
+ _roomNames[idx] = ROOM_NAMES[idx];
+}
} // End of namespace Titanic
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index f639a9c672..a5cf0ff9b8 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -65,6 +65,7 @@ enum TitanicDebugChannels {
#define ERROR_DETAILED 3
#define TOTAL_ITEMS 46
+#define TOTAL_ROOMS 34
struct TitanicGameDescription;
class TitanicEngine;
@@ -94,6 +95,11 @@ private:
* Sets up the item names, short, and long descriptions
*/
void setItemNames();
+
+ /**
+ * Sets up the list of room names
+ */
+ void setRoomNames();
protected:
const TitanicGameDescription *_gameDescription;
int _loadSaveSlot;
@@ -115,6 +121,7 @@ public:
CString _itemDescriptions[TOTAL_ITEMS];
CString _itemObjects[TOTAL_ITEMS];
CString _itemIds[40];
+ CString _roomNames[TOTAL_ROOMS];
public:
TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc);
virtual ~TitanicEngine();