diff options
author | Paul Gilbert | 2016-05-01 19:09:21 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:04 -0400 |
commit | 8a6a5ad5c10b682bef145b414ebed386aa7df842 (patch) | |
tree | de8f6002d413744f6fb25a89aeac64c528da2476 /engines/titanic/pet_control | |
parent | 93f88cc668f15a4c2b411c99b3f07e2f03bee50a (diff) | |
download | scummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.tar.gz scummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.tar.bz2 scummvm-rg350-8a6a5ad5c10b682bef145b414ebed386aa7df842.zip |
TITANIC: In progress implementation of PET Remote
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_remote.cpp | 194 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote.h | 95 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.h | 7 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_section.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_section.h | 7 |
6 files changed, 292 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; } |