diff options
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_frame.cpp | 32 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_frame.h | 7 |
2 files changed, 27 insertions, 12 deletions
diff --git a/engines/titanic/pet_control/pet_frame.cpp b/engines/titanic/pet_control/pet_frame.cpp index def6bca8e1..3e464a0647 100644 --- a/engines/titanic/pet_control/pet_frame.cpp +++ b/engines/titanic/pet_control/pet_frame.cpp @@ -25,13 +25,12 @@ namespace Titanic { -static const int INDEXES[6] = { 1, 0, 2, 3, 4, 5 }; +static const PetArea PET_AREAS[6] = { + PET_CONVERSATION, PET_INVENTORY, PET_REMOTE, + PET_ROOMS, PET_SAVE, PET_5 +}; -int CPetFrame::_indexes[6]; - -CPetFrame::CPetFrame() { - for (int idx = 0; idx < 6; ++idx) - _indexes[INDEXES[idx]] = idx; +CPetFrame::CPetFrame() : CPetSection() { } bool CPetFrame::setup(CPetControl *petControl) { @@ -64,11 +63,24 @@ bool CPetFrame::setup() { return true; } +bool CPetFrame::handleMessage(CMouseButtonDownMsg &msg) { + for (int idx = 0; idx < 5; ++idx) { + if (_modeButtons[idx].handleMessage(msg)) { + _petControl->setArea(PET_AREAS[idx]); + resetArea(); + _modeButtons[idx].setMode(MODE_SELECTED); + return true; + } + } + + return false; +} + bool CPetFrame::isValid(CPetControl *petControl) { bool result = setPetControl(petControl); if (result) { - _modeButtons[_indexes[0]].setMode(MODE_UNSELECTED); - _modeButtons[_indexes[4]].setMode(MODE_SELECTED); + _modeButtons[PET_AREAS[0]].setMode(MODE_UNSELECTED); + _modeButtons[PET_AREAS[4]].setMode(MODE_SELECTED); } return result; @@ -98,7 +110,7 @@ bool CPetFrame::setPetControl(CPetControl *petControl) { _modeButtons[idx].setBounds(r); _modeButtons[idx].translate(0, YLIST[idx]); } - _modeButtons[_indexes[0]].setMode(MODE_SELECTED); + _modeButtons[PET_AREAS[0]].setMode(MODE_SELECTED); const int XLIST[] = { 73, 54, 85, 109, 38, 71 }; for (int idx = 0; idx < 6; ++idx) { @@ -113,7 +125,7 @@ bool CPetFrame::setPetControl(CPetControl *petControl) { void CPetFrame::setArea(PetArea newArea) { resetArea(); if (newArea < PET_6) - _modeButtons[_indexes[newArea]].setMode(MODE_SELECTED); + _modeButtons[PET_AREAS[newArea]].setMode(MODE_SELECTED); } void CPetFrame::resetArea() { diff --git a/engines/titanic/pet_control/pet_frame.h b/engines/titanic/pet_control/pet_frame.h index 683f629db6..5b90fd2aa3 100644 --- a/engines/titanic/pet_control/pet_frame.h +++ b/engines/titanic/pet_control/pet_frame.h @@ -34,8 +34,6 @@ namespace Titanic { */ class CPetFrame : public CPetSection { private: - static int _indexes[6]; - CPetGfxElement _modeButtons[6]; CPetGfxElement _titles[6]; CPetGfxElement _modeBackground; @@ -60,6 +58,11 @@ public: * Sets up the section */ virtual bool setup(); + + /** + * Handles mouse down messages + */ + virtual bool handleMessage(CMouseButtonDownMsg &msg); /** * Returns true if the object is in a valid state |