From 5b98885f8797d5c36336a22a9399611b11a3715f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 23 Jun 2016 21:22:59 -0400 Subject: TITANIC: Figured out PET Room Glyph modes --- engines/titanic/core/game_object.cpp | 5 ++- engines/titanic/core/game_object.h | 14 ++++---- engines/titanic/npcs/deskbot.cpp | 6 ++-- engines/titanic/pet_control/pet_control.cpp | 4 +-- engines/titanic/pet_control/pet_control.h | 35 +++++++++++++------- engines/titanic/pet_control/pet_inventory.cpp | 2 +- engines/titanic/pet_control/pet_inventory.h | 2 +- engines/titanic/pet_control/pet_inventory_glyphs.h | 4 +-- engines/titanic/pet_control/pet_rooms.cpp | 38 ++++++++++++---------- engines/titanic/pet_control/pet_rooms.h | 28 ++++++++++++---- engines/titanic/pet_control/pet_rooms_glyphs.cpp | 34 +++++++++++++++---- engines/titanic/pet_control/pet_rooms_glyphs.h | 32 ++++++++++++++---- 12 files changed, 135 insertions(+), 69 deletions(-) (limited to 'engines') diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index f0fd08ae94..735caad288 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -1062,11 +1062,10 @@ int CGameObject::petGetRooms1D0() const { return petControl ? petControl->getRooms1D0() : 0; } -void CGameObject::petAddRandomRoom(int passClassNum) { +void CGameObject::reassignRoom(int passClassNum) { CPetControl *petControl = getPetControl(); if (petControl) - petControl->addRandomRoom(passClassNum); + petControl->reassignRoom(passClassNum); } - } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 0a6070463f..059b705700 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -270,11 +270,6 @@ protected: */ void endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); - /** - * Load the surface - */ - void loadSurface(); - /** * Change the view */ @@ -528,6 +523,11 @@ public: */ void loadFrame(int frameNumber); + /** + * Load the surface + */ + void loadSurface(); + /** * Marks the area occupied by the object as dirty, requiring re-rendering */ @@ -570,9 +570,9 @@ public: int petGetRooms1D0() const; /** - * Adds a random room to the pET + * Gives the player a new assigned room in the specified passenger class */ - void petAddRandomRoom(int passClassNum); + void reassignRoom(int passClassNum); }; } // End of namespace Titanic diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp index 2af758b598..eb42a8e21d 100644 --- a/engines/titanic/npcs/deskbot.cpp +++ b/engines/titanic/npcs/deskbot.cpp @@ -178,16 +178,16 @@ bool CDeskbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { case 1: petDisplayMsg("You have been upgraded to 1st Class status. Enjoy hugely."); setPassengerClass(_classNum); - petAddRandomRoom(_classNum); + reassignRoom(_classNum); break; case 2: petDisplayMsg("You have been upgraded to 2nd Class status. Enjoy."); setPassengerClass(_classNum); - petAddRandomRoom(_classNum); + reassignRoom(_classNum); break; case 3: setPassengerClass(3); - petAddRandomRoom(_classNum); + reassignRoom(_classNum); break; default: break; diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 22b513ef75..5de87cd04b 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -376,7 +376,7 @@ CGameObject *CPetControl::getNextObject(CGameObject *prior) const { return static_cast(prior->getNextSibling()); } -void CPetControl::addToInventory(CCarry *item) { +void CPetControl::addToInventory(CGameObject *item) { item->detach(); if (item->getName() == "CarryParcel") { @@ -403,7 +403,7 @@ void CPetControl::addToInventory(CCarry *item) { msg.execute(item); } -void CPetControl::removeFromInventory(CCarry *item, CTreeItem *newParent, +void CPetControl::removeFromInventory(CGameObject *item, CTreeItem *newParent, bool refreshUI, bool sendMsg) { if (item && newParent) { item->detach(); diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index 3881bda78f..8093152089 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -251,12 +251,12 @@ public: /** * Adds an item to the PET inventory */ - void addToInventory(CCarry *item); + void addToInventory(CGameObject *item); /** * Remove an item from the inventory */ - void removeFromInventory(CCarry *item, CTreeItem *newParent, + void removeFromInventory(CGameObject *item, CTreeItem *newParent, bool refreshUI = true, bool sendMsg = true); /** @@ -324,10 +324,10 @@ public: /* CPetRooms methods */ /** - * Adds a random room to the room list + * Gives the player a new assigned room in the specified passenger class */ - void addRandomRoom(int passClassNum) { - _rooms.addRandomRoom(passClassNum); + void reassignRoom(int passClassNum) { + _rooms.reassignRoom(passClassNum); } /** @@ -410,8 +410,8 @@ public: _rooms.resetHighlight(); } - int getRoomsMode1Flags() const { - return _rooms.mode1Flags(); + int getAssignedRoomFlags() const { + return _rooms.getAssignedRoomFlags(); } uint getSpecialRoomFlags(const CString &name) { @@ -427,14 +427,25 @@ public: return CRoomFlags(roomFlags).not5(); } - int getRoomsRoomNum1() const { - return _rooms.getMode1RoomNum(); + /** + * Returns the room number for the player's currently assigned room + */ + int getAssignedRoomNum() const { + return _rooms.getAssignedRoomNum(); } - int getRoomsFloorNum1() const { - return _rooms.getMode1FloorNum(); + + /** + * Returns the floor number for the player's currently assigned room + */ + int getAssignedFloorNum() const { + return _rooms.getAssignedFloorNum(); } + + /** + * Returns the elevator number for the player's currently assigned room + */ int getRoomsElevatorNum1() const { - return _rooms.getMode1ElevatorNum(); + return _rooms.getAssignedElevatorNum(); } void setRooms1D4(int val) { diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index 1ea78062d5..37a73420bd 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -128,7 +128,7 @@ void CPetInventory::change(CCarry *item) { } } -void CPetInventory::itemRemoved(CCarry *item) { +void CPetInventory::itemRemoved(CGameObject *item) { if (item) { CInventoryGlyphAction action(item, ACTION_REMOVED); _items.change(&action); diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h index 70bcc12f85..58e6bd9a1d 100644 --- a/engines/titanic/pet_control/pet_inventory.h +++ b/engines/titanic/pet_control/pet_inventory.h @@ -127,7 +127,7 @@ public: /** * Called when an item has been removed from the PET */ - void itemRemoved(CCarry *item); + void itemRemoved(CGameObject *item); /** * Called when the items under the PET have changed diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h index 190bce77ac..91b1e5ee50 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.h +++ b/engines/titanic/pet_control/pet_inventory_glyphs.h @@ -61,9 +61,9 @@ public: class CInventoryGlyphAction : public CGlyphAction { public: - CCarry *_item; + CGameObject *_item; public: - CInventoryGlyphAction(CCarry *item, GlyphActionMode mode) : + CInventoryGlyphAction(CGameObject *item, GlyphActionMode mode) : CGlyphAction(mode), _item(item) {} }; diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index 9db5adc7de..6f34ee5869 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -280,16 +280,18 @@ void CPetRooms::areaChanged(PetArea area) { _petControl->makeDirty(); } -void CPetRooms::addRandomRoom(int passClassNum) { - CPetRoomsGlyph *glyph = _glyphs.findMode1(); +void CPetRooms::reassignRoom(int passClassNum) { + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); if (glyph) - glyph->setMode(RGM_2); + // Flag the old assigned room as no longer assigned + glyph->setMode(RGM_PREV_ASSIGNED_ROOM); CRoomFlags roomFlags; roomFlags.setRandomLocation(passClassNum, _field1D4); glyph = addRoom(roomFlags, true); if (glyph) { - glyph->setMode(RGM_1); + // Flag the new room as assigned to the player, and highlight it + glyph->setMode(RGM_ASSIGNED_ROOM); _glyphs.highlight(glyph); } } @@ -307,7 +309,7 @@ CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight) { // no longer valid, and thus can be removed for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { CPetRoomsGlyph *glyph = static_cast(*i); - if (!glyph->isModeValid()) { + if (!glyph->isAssigned()) { _glyphs.erase(i); break; } @@ -331,13 +333,8 @@ CPetRoomsGlyph *CPetRooms::addGlyph(uint roomFlags, bool highlight) { } } -uint CPetRooms::mode1Flags() const { - CPetRoomsGlyph *glyph = _glyphs.findMode1(); - return glyph ? glyph->getRoomFlags() : 0; -} - bool CPetRooms::changeLocationClass(int newClassNum) { - CPetRoomsGlyph *glyph = _glyphs.findMode1(); + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); if (!glyph) return 0; @@ -348,31 +345,36 @@ bool CPetRooms::changeLocationClass(int newClassNum) { bool CPetRooms::hasRoomFlags(uint roomFlags) const { for (CPetRoomsGlyphs::const_iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { const CPetRoomsGlyph *glyph = static_cast(*i); - if (glyph->isModeValid() && glyph->getRoomFlags() == roomFlags) + if (glyph->isAssigned() && glyph->getRoomFlags() == roomFlags) return true; } return false; } -int CPetRooms::getMode1RoomNum() const { - uint flags = mode1Flags(); +uint CPetRooms::getAssignedRoomFlags() const { + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); + return glyph ? glyph->getRoomFlags() : 0; +} + +int CPetRooms::getAssignedRoomNum() const { + uint flags = getAssignedRoomFlags(); if (!flags) return 0; return CRoomFlags(flags).getRoomNum(); } -int CPetRooms::getMode1FloorNum() const { - uint flags = mode1Flags(); +int CPetRooms::getAssignedFloorNum() const { + uint flags = getAssignedRoomFlags(); if (!flags) return 0; return CRoomFlags(flags).getFloorNum(); } -int CPetRooms::getMode1ElevatorNum() const { - uint flags = mode1Flags(); +int CPetRooms::getAssignedElevatorNum() const { + uint flags = getAssignedRoomFlags(); if (!flags) return 0; diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h index 1e7468ac1b..b39587a7f7 100644 --- a/engines/titanic/pet_control/pet_rooms.h +++ b/engines/titanic/pet_control/pet_rooms.h @@ -152,9 +152,9 @@ public: void resetHighlight(); /** - * Adds a random room to the glyph list + * Gives the player a new assigned room in the specified passenger class */ - void addRandomRoom(int passClassNum); + void reassignRoom(int passClassNum); /** * Change the current location passenger class @@ -166,17 +166,31 @@ public: */ bool hasRoomFlags(uint roomFlags) const; - int getMode1RoomNum() const; - int getMode1FloorNum() const; - int getMode1ElevatorNum() const; + /** + * Returns the room flags for the player's currently assigned room + */ + uint getAssignedRoomFlags() const; + + /** + * Returns the room number for the player's currently assigned room + */ + int getAssignedRoomNum() const; + + /** + * Returns the floor number for the player's currently assigned room + */ + int getAssignedFloorNum() const; + + /** + * Returns the elevator number for the player's currently assigned room + */ + int getAssignedElevatorNum() const; /** * Gets room flags to use for glyphs */ uint getRoomFlags() const; - uint mode1Flags() const; - void setFloorNum(int floorNum) { _floorNum = floorNum; } int getFloorNum() const { return _floorNum; } void setElevatorNum(int elevNum) { _elevatorNum = elevNum; } diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp index de06e02bc4..d6f13c3314 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -30,13 +30,13 @@ namespace Titanic { CPetRoomsGlyph::CPetRoomsGlyph() : CPetGlyph(), - _roomFlags(0), _field38(0), _mode(RGM_0), + _roomFlags(0), _field38(0), _mode(RGM_UNASSIGNED), _field40(nullptr), _field44(nullptr), _field48(nullptr), _field4C(nullptr), _field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) { } CPetRoomsGlyph::CPetRoomsGlyph(uint flags) : CPetGlyph(), - _roomFlags(flags), _field38(0), _mode(RGM_0), + _roomFlags(flags), _field38(0), _mode(RGM_UNASSIGNED), _field40(nullptr), _field44(nullptr), _field48(nullptr), _field4C(nullptr), _field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) { } @@ -66,7 +66,7 @@ void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt) { } void CPetRoomsGlyph::proc28(const Point &topLeft, const Point &pt) { - if (isModeValid()) { + if (isAssigned()) { bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT; if (isShiftPressed) { @@ -89,8 +89,10 @@ int CPetRoomsGlyph::proc29(const Point &pt) { if (chevron) { chevron->_id = _roomFlags; chevron->_isMail = _field38; -// petControl->removeFromInventory(chevon); -// chevron->loadSurface(); + petControl->removeFromInventory(chevron, false, false); + chevron->loadSurface(); + + warning("TODO: CPetRoomsGlyph::proc29"); // TODO } } @@ -98,6 +100,24 @@ int CPetRoomsGlyph::proc29(const Point &pt) { return 0; } +void CPetRoomsGlyph::getTooltip(CPetText *text) { + CRoomFlags roomFlags(_roomFlags); + CPetSection *owner = getPetSection(); + + CString msg; + if (isCurrentlyAssigned()) { + msg = "Your assigned room: "; + } else if (isPreviouslyAssigned()) { + msg = "A previously assigned room: "; + } else if (!_field38) { + msg = "Saved Chevron: "; + } else if (_field38 == 1 && getRoomFlags() == _roomFlags) { + msg = "Current location: "; + } + + // TODO: More stuff +} + void CPetRoomsGlyph::save2(SimpleFile *file, int indent) const { file->writeNumberLine(_roomFlags, indent); file->writeNumberLine(_mode, indent); @@ -150,10 +170,10 @@ void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const { (*i)->save2(file, indent); } -CPetRoomsGlyph *CPetRoomsGlyphs::findMode1() const { +CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const { for (const_iterator i = begin(); i != end(); ++i) { CPetRoomsGlyph *glyph = static_cast(*i); - if (glyph->isMode1()) + if (glyph->isCurrentlyAssigned()) return glyph; } diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h index cb937ec5c0..574403b0c6 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.h +++ b/engines/titanic/pet_control/pet_rooms_glyphs.h @@ -28,7 +28,9 @@ namespace Titanic { -enum RoomGlyphMode { RGM_0 = 0, RGM_1 = 1, RGM_2 = 2 }; +enum RoomGlyphMode { + RGM_UNASSIGNED = 0, RGM_ASSIGNED_ROOM = 1, RGM_PREV_ASSIGNED_ROOM = 2 +}; class CPetRoomsGlyph : public CPetGlyph { private: @@ -75,6 +77,11 @@ public: virtual int proc29(const Point &pt); + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + virtual void save2(SimpleFile *file, int indent) const; virtual int proc33(); @@ -103,9 +110,20 @@ public: void changeLocation(int newClassNum); - bool isModeValid() const { return _mode != RGM_0; } - bool isMode1() const { return _mode == RGM_1; } - bool isMode2() const { return _mode == RGM_2; } + /** + * Returns true if the room is either currently or previously assigned + */ + bool isAssigned() const { return _mode != RGM_UNASSIGNED; } + + /** + * Returns true if the room is the one currently assigned to the player + */ + bool isCurrentlyAssigned() const { return _mode == RGM_ASSIGNED_ROOM; } + + /** + * Returns true if the room was previously assigned to the player + */ + bool isPreviouslyAssigned() const { return _mode == RGM_PREV_ASSIGNED_ROOM; } }; class CPetRoomsGlyphs : public CPetGlyphs { @@ -116,8 +134,10 @@ public: */ void save2(SimpleFile *file, int indent) const; - CPetRoomsGlyph *findMode1() const; - + /** + * Returns the glyph for hte player's assigned room + */ + CPetRoomsGlyph *findAssignedRoom() const; /** * Finds a glyph in the list by it's room flags -- cgit v1.2.3