diff options
author | Paul Gilbert | 2016-05-02 20:18:47 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:09 -0400 |
commit | ab769eee0c99f262052b7a15295a74053943a372 (patch) | |
tree | 4bb0ba38b37bce3dc63a4babd50a5941085e92f6 /engines/titanic/pet_control | |
parent | 9a6ad7d1e012a5cb1a4ca955b0f738f12c0a7874 (diff) | |
download | scummvm-rg350-ab769eee0c99f262052b7a15295a74053943a372.tar.gz scummvm-rg350-ab769eee0c99f262052b7a15295a74053943a372.tar.bz2 scummvm-rg350-ab769eee0c99f262052b7a15295a74053943a372.zip |
TITANIC: Implement Operate Lights glyph
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_remote.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote_glyphs.cpp | 55 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote_glyphs.h | 37 |
4 files changed, 102 insertions, 8 deletions
diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp index fd2d5e1dc3..1ed0251f24 100644 --- a/engines/titanic/pet_control/pet_remote.cpp +++ b/engines/titanic/pet_control/pet_remote.cpp @@ -35,7 +35,7 @@ static const byte REMOTE_DATA[] = { 0x01, 0x02, GLYPH_SUMMON_PELLERATOR, 0x10, 0x02, 0x03, - GLYPH_TELEVISION_CONTROL, 0x04, 0x10, + GLYPH_TELEVISION_CONTROL, GLYPH_OPERATE_LIGHTS, 0x10, 0x03, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, 0x04, 0x02, @@ -200,7 +200,7 @@ CPetGfxElement *CPetRemote::getElement(uint id) { } void CPetRemote::proc38(int val) { - int highlightIndex = getHighlightIndex(val); + int highlightIndex = getHighlightIndex((RemoteGlyph)val); if (highlightIndex != -1) _items.highlight(highlightIndex); } @@ -253,7 +253,7 @@ CRoomItem *CPetRemote::getRoom() const { return nullptr; } -int CPetRemote::getHighlightIndex(int val) { +int CPetRemote::getHighlightIndex(RemoteGlyph val) { CRoomItem *room = getRoom(); if (!room) return -1; @@ -267,7 +267,7 @@ int CPetRemote::getHighlightIndex(int val) { // Loop through the data for the room for (uint idx = 0; idx < remoteData.size(); ++idx) { - if (remoteData[idx + 1] == val) + if ((RemoteGlyph)remoteData[idx + 1] == val) return idx; } @@ -287,8 +287,8 @@ void CPetRemote::getRemoteData(int roomIndex, Common::Array<uint> &indexes) { const byte *p = &REMOTE_DATA[0]; for (int idx = 0; idx < TOTAL_ROOMS; ++idx) { if (*p == roomIndex) { - for (int idx = 0; idx < *p; ++idx) - indexes.push_back(p[idx + 1]); + for (int ctr = 0; ctr < *p; ++ctr) + indexes.push_back(p[ctr + 1]); return; } @@ -325,6 +325,10 @@ bool CPetRemote::loadGlyph(int glyphIndex) { glyph = new CEntertainmentDeviceGlyph(); break; + case GLYPH_OPERATE_LIGHTS: + glyph = new COperateLightsGlyph(); + break; + default: break; } diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h index 6982c93aef..8703abd099 100644 --- a/engines/titanic/pet_control/pet_remote.h +++ b/engines/titanic/pet_control/pet_remote.h @@ -60,7 +60,7 @@ private: /** * Return a highlight index */ - int getHighlightIndex(int val); + int getHighlightIndex(RemoteGlyph val); /** * Return the index of a room name in the master room names list diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp index e0334fef31..c1d86d6703 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.cpp +++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp @@ -236,4 +236,59 @@ void CEntertainmentDeviceGlyph::getTooltip(CPetText *text) { text->setText("Operate visual entertainment device"); } +/*------------------------------------------------------------------------*/ + + +bool COperateLightsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetLights", petControl); + + if (owner) { + _left = getElement(3); + _right = getElement(4); + _up = getElement(5); + _down = getElement(6); + _activate = getElement(7); + } + + return true; +} + +void COperateLightsGlyph::draw2(CScreenManager *screenManager) { + _left->draw(screenManager); + _right->draw(screenManager); + _up->draw(screenManager); + _down->draw(screenManager); + _activate->draw(screenManager); +} + +bool COperateLightsGlyph::MouseButtonDownMsg(const Point &pt) { + if (_left->MouseButtonDownMsg(pt) + || _right->MouseButtonDownMsg(pt) + || _up->MouseButtonDownMsg(pt) + || _down->MouseButtonDownMsg(pt) + || _activate->MouseButtonDownMsg(pt)) + return true; + return true; +} + +bool COperateLightsGlyph::MouseButtonUpMsg(const Point &pt) { + if (_left && _left->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_LEFT, "Light"); + else if (_right && _right->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_RIGHT, "Light"); + else if (_up && _up->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_UP, "Light"); + else if (_down && _down->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_DOWN, "Light"); + else + getOwner()->generateMessage(RMSG_ACTIVATE, "Light"); + + return true; +} + +void COperateLightsGlyph::getTooltip(CPetText *text) { + text->setText("Operate the lights"); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote_glyphs.h b/engines/titanic/pet_control/pet_remote_glyphs.h index e8f0c8d8c7..39f9164979 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.h +++ b/engines/titanic/pet_control/pet_remote_glyphs.h @@ -30,7 +30,8 @@ namespace Titanic { enum RemoteGlyph { GLYPH_SUMMON_ELEVATOR = 0, GLYPH_SUMMON_PELLERATOR = 1, - GLYPH_TELEVISION_CONTROL = 2, GLYPH_ENTERTAINMENT_DEVICE = 3 + GLYPH_TELEVISION_CONTROL = 2, GLYPH_ENTERTAINMENT_DEVICE = 3, + GLYPH_OPERATE_LIGHTS = 4 }; enum RemoteMessage { @@ -216,6 +217,40 @@ public: virtual void getTooltip(CPetText *text); }; + +class COperateLightsGlyph : public CPetRemoteGlyph { +public: + CPetGfxElement *_left, *_right, *_up, *_down, *_activate; +public: + COperateLightsGlyph() : CPetRemoteGlyph(), _left(nullptr), _right(nullptr), + _up(nullptr), _down(nullptr), _activate(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + } // End of namespace Titanic #endif /* TITANIC_PET_REMOTE_GLYPHS_H */ |