diff options
-rw-r--r-- | engines/titanic/events.h | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms_glyphs.cpp | 51 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms_glyphs.h | 10 |
4 files changed, 62 insertions, 5 deletions
diff --git a/engines/titanic/events.h b/engines/titanic/events.h index 4cbba178ad..4638056e8c 100644 --- a/engines/titanic/events.h +++ b/engines/titanic/events.h @@ -48,7 +48,7 @@ private: uint32 _priorMiddleDownTime; uint32 _priorRightDownTime; Common::Point _mousePos; - int _specialButtons; + uint _specialButtons; /** * Check whether it's time to display the next screen frame @@ -108,6 +108,8 @@ public: * Sleep for a specified period of time */ void sleep(uint time); + + uint getSpecialButtons() const { return _specialButtons; } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index 5dc5013a9b..f0b9ef128b 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -178,7 +178,7 @@ public: /** * */ - virtual void proc28(const Point &pt) {} + virtual void proc28(const Point &topLeft, const Point &pt) {} virtual int proc29(const Point &pt) { return 0; } diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp index 9ecaefbf68..de06e02bc4 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -21,9 +21,11 @@ */ #include "titanic/pet_control/pet_rooms_glyphs.h" +#include "titanic/pet_control/pet_control.h" #include "titanic/pet_control/pet_section.h" #include "titanic/support/screen_manager.h" #include "titanic/room_flags.h" +#include "titanic/titanic.h" namespace Titanic { @@ -63,11 +65,36 @@ void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt) { warning("TODO: CPetRoomsGlyph::drawAt"); } -void CPetRoomsGlyph::proc28(const Point &pt) { +void CPetRoomsGlyph::proc28(const Point &topLeft, const Point &pt) { + if (isModeValid()) { + bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT; + if (isShiftPressed) { + int selection = getSelection(topLeft, pt); + if (selection >= 0) + _roomFlags |= 1 << selection; + } + + updateTooltip(); + } } int CPetRoomsGlyph::proc29(const Point &pt) { + bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT; + CPetControl *petControl = getPetControl(); + + if (!isShiftPressed && petControl) { + CGameObject *chevron = petControl->getHiddenObject("3PetChevron"); + + if (chevron) { + chevron->_id = _roomFlags; + chevron->_isMail = _field38; +// petControl->removeFromInventory(chevon); +// chevron->loadSurface(); + // TODO + } + } + return 0; } @@ -92,6 +119,28 @@ void CPetRoomsGlyph::changeLocation(int newClassNum) { _roomFlags = roomFlags.get(); } +int CPetRoomsGlyph::getSelection(const Point &topLeft, const Point &pt) { + Rect rects[4] = { + Rect(topLeft.x, topLeft.y, topLeft.x + 13, topLeft.y + 10), + Rect(topLeft.x + 13, topLeft.y, topLeft.x + 26, topLeft.y + 10), + Rect(topLeft.x + 26, topLeft.y, topLeft.x + 39, topLeft.y + 10), + Rect(topLeft.x + 39, topLeft.y, topLeft.x + 52, topLeft.y + 10) + }; + + for (int idx = 0, btnIndex = 19; idx < 5; ++idx, btnIndex -= 4) { + // Iterate through each of the four rects, seeing if there's a match. + // If not, move it down to the next row for the next loop iteration + for (int i = 0; i < 4; ++i) { + if (rects[i].contains(pt)) + return btnIndex - i; + + rects[i].translate(0, 10); + } + } + + return -1; +} + /*------------------------------------------------------------------------*/ void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const { diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h index bed167f934..cb937ec5c0 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.h +++ b/engines/titanic/pet_control/pet_rooms_glyphs.h @@ -31,7 +31,7 @@ namespace Titanic { enum RoomGlyphMode { RGM_0 = 0, RGM_1 = 1, RGM_2 = 2 }; class CPetRoomsGlyph : public CPetGlyph { -protected: +private: uint _roomFlags; int _field38; RoomGlyphMode _mode; @@ -43,6 +43,12 @@ protected: CGameObject *_field54; CGameObject *_field58; CGameObject *_field5C; +private: + /** + * Find the selected button under the given point, based on the buttons + * starting at a designated top/left position + */ + int getSelection(const Point &topLeft, const Point &pt); public: CPetRoomsGlyph(); CPetRoomsGlyph(uint flags); @@ -65,7 +71,7 @@ public: /** * */ - virtual void proc28(const Point &pt); + virtual void proc28(const Point &topLeft, const Point &pt); virtual int proc29(const Point &pt); |