diff options
author | Paul Gilbert | 2016-05-01 23:48:22 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:06 -0400 |
commit | efaa86bee4f0183365309056d43b3aa3801f3ddf (patch) | |
tree | ff1b1c4330ac996c487637e4c193495db9ae5e6c /engines/titanic | |
parent | c3dadcfe3b9d62eb19970b200e941f138f8abf1b (diff) | |
download | scummvm-rg350-efaa86bee4f0183365309056d43b3aa3801f3ddf.tar.gz scummvm-rg350-efaa86bee4f0183365309056d43b3aa3801f3ddf.tar.bz2 scummvm-rg350-efaa86bee4f0183365309056d43b3aa3801f3ddf.zip |
TITANIC: Implement Television Control glyph
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/pet_control/pet_element.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_element.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote.cpp | 82 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote_glyphs.cpp | 71 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote_glyphs.h | 58 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.cpp | 2 |
6 files changed, 183 insertions, 42 deletions
diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp index da37b35246..0827b331df 100644 --- a/engines/titanic/pet_control/pet_element.cpp +++ b/engines/titanic/pet_control/pet_element.cpp @@ -96,4 +96,11 @@ void CPetElement::setMode(PetElementMode newMode) { changeMode(newMode); } +void CPetElement::setSelected(bool flag) { + if (flag) + changeMode(MODE_SELECTED); + else + changeMode(MODE_UNSELECTED); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h index 578f306dff..e1edcac217 100644 --- a/engines/titanic/pet_control/pet_element.h +++ b/engines/titanic/pet_control/pet_element.h @@ -126,6 +126,11 @@ public: void setMode(PetElementMode mode); /** + * Set whether the element is selected + */ + void setSelected(bool flag); + + /** * Set the bounds for the element */ void setBounds(const Rect &r) { _bounds = r; } diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp index fb9178b13b..9149ed851e 100644 --- a/engines/titanic/pet_control/pet_remote.cpp +++ b/engines/titanic/pet_control/pet_remote.cpp @@ -32,40 +32,52 @@ namespace Titanic { static const byte REMOTE_DATA[] = { 0x00, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, - 0x01, 0x02, 0x01, 0x10, - 0x02, 0x03, 0x02, 0x04, 0x10, + 0x01, 0x02, + GLYPH_SUMMON_PELLERATOR, 0x10, + 0x02, 0x03, + GLYPH_TELEVISION_CONTROL, 0x04, 0x10, 0x03, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, - 0x04, 0x02, 0x02, 0x10, - 0x05, 0x02, 0x01, 0x10, - 0x06, 0x02, 0x01, 0x10, - 0x07, 0x03, 0x02, 0x01, 0x10, - 0x08, 0x01, 0x10, - 0x09, 0x01, 0x10, - 0x0A, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, - 0x0B, 0x01, 0x11, - 0x0C, 0x01, 0x10, - 0x0D, 0x01, 0x10, - 0x0E, 0x00, - 0x0F, 0x01, 0x02, - 0x10, 0x03, 0x12, 0x14, 0x13, - 0x11, 0x01, 0x10, - 0x12, 0x00, - 0x13, 0x02, 0x01, 0x10, - 0x14, 0x00, - 0x15, 0x02, 0x10, 0x02, - 0x16, 0x00, - 0x17, 0x02, 0x01, 0x10, - 0x18, 0x01, 0x10, - 0x19, 0x00, - 0x1A, 0x00, - 0x1B, 0x00, - 0x1C, 0x00, - 0x1D, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, - 0x1E, 0x0C, 0x05, 0x06, 0x07, 0x08, 0x03, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x1F, 0x01, 0x10, - 0x20, 0x02, GLYPH_SUMMON_ELEVATOR, 0x01, - 0x21, 0x00 + 0x04, 0x02, + GLYPH_TELEVISION_CONTROL, 0x10, + 0x05, 0x02, + GLYPH_SUMMON_PELLERATOR, 0x10, + 0x06, 0x02, + GLYPH_SUMMON_PELLERATOR, 0x10, + 0x07, 0x03, + GLYPH_TELEVISION_CONTROL, GLYPH_SUMMON_PELLERATOR, 0x10, + 0x08, 0x01, 0x10, + 0x09, 0x01, 0x10, + 0x0A, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, + 0x0B, 0x01, 0x11, + 0x0C, 0x01, 0x10, + 0x0D, 0x01, 0x10, + 0x0E, 0x00, + 0x0F, 0x01, + GLYPH_TELEVISION_CONTROL, + 0x10, 0x03, 0x12, 0x14, 0x13, + 0x11, 0x01, 0x10, + 0x12, 0x00, + 0x13, 0x02, + GLYPH_SUMMON_PELLERATOR, 0x10, + 0x14, 0x00, + 0x15, 0x02, + 0x10, GLYPH_TELEVISION_CONTROL, + 0x16, 0x00, + 0x17, 0x02, + GLYPH_SUMMON_PELLERATOR, 0x10, + 0x18, 0x01, 0x10, + 0x19, 0x00, + 0x1A, 0x00, + 0x1B, 0x00, + 0x1C, 0x00, + 0x1D, 0x02, GLYPH_SUMMON_ELEVATOR, 0x10, + 0x1E, 0x0C, + 0x05, 0x06, 0x07, 0x08, 0x03, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1F, 0x01, 0x10, + 0x20, 0x02, + GLYPH_SUMMON_ELEVATOR, GLYPH_SUMMON_PELLERATOR, + 0x21, 0x00 }; CPetRemote::CPetRemote() : CPetSection() { @@ -301,6 +313,12 @@ bool CPetRemote::loadGlyph(int glyphIndex) { glyph = new CSummonElevatorGlyph(); break; + case GLYPH_SUMMON_PELLERATOR: + glyph = new CSummonPelleratorGlyph(); + break; + + case GLYPH_TELEVISION_CONTROL: + default: break; } diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp index 76ab3839b7..9db3b66c3d 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.cpp +++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp @@ -51,23 +51,24 @@ CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const { /*------------------------------------------------------------------------*/ -bool CSummonElevatorGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { - setDefaults("3PetLift", petControl); +bool CBasicRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults(_gfxName, petControl); if (owner) _gfxElement = getElement(18); return true; } -void CSummonElevatorGlyph::draw2(CScreenManager *screenManager) { +void CBasicRemoteGlyph::draw2(CScreenManager *screenManager) { if (_gfxElement) _gfxElement->draw(screenManager); } -bool CSummonElevatorGlyph::MouseButtonDownMsg(const Point &pt) { +bool CBasicRemoteGlyph::MouseButtonDownMsg(const Point &pt) { return _gfxElement && _gfxElement->MouseButtonDownMsg(pt); } -bool CSummonElevatorGlyph::MouseButtonUpMsg(const Point &pt) { +bool CBasicRemoteGlyph::MouseButtonUpMsg(const Point &pt) { if (_gfxElement && _gfxElement->MouseButtonUpMsg(pt)) { getOwner()->generateMessage(RMSG_ACTIVATE, "Lift"); return true; @@ -76,8 +77,64 @@ bool CSummonElevatorGlyph::MouseButtonUpMsg(const Point &pt) { return false; } -void CSummonElevatorGlyph::getTooltip(CPetText *text) { - text->setText("Summon Elevator"); +void CBasicRemoteGlyph::getTooltip(CPetText *text) { + text->setText(_tooltip); +} + +/*------------------------------------------------------------------------*/ + +bool CTelevisionControlGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetTV", petControl); + if (owner) { + _up = getElement(1); + _down = getElement(2); + _onOff = getElement(4); + } + + return true; +} + +void CTelevisionControlGlyph::draw2(CScreenManager *screenManager) { + _onOff->setSelected(_flag); + _onOff->draw(screenManager); + _up->draw(screenManager); + _down->draw(screenManager); +} + +bool CTelevisionControlGlyph::MouseButtonDownMsg(const Point &pt) { + if (_onOff && _onOff->MouseButtonDownMsg(pt)) + return true; + if (_up && _up->MouseButtonDownMsg(pt)) + return true; + if (_down && _down->MouseButtonDownMsg(pt)) + return true; + + return false; +} + +bool CTelevisionControlGlyph::MouseButtonUpMsg(const Point &pt) { + if (_onOff && _onOff->MouseButtonUpMsg(pt)) { + _flag = !_flag; + getOwner()->generateMessage(RMSG_ACTIVATE, "Television"); + return true; + } + + if (_up && _up->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_UP, "Television"); + return true; + } + + if (_down && _down->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_DOWN, "Television"); + return true; + } + + return false; +} + +void CTelevisionControlGlyph::getTooltip(CPetText *text) { + text->setText("Television control"); } } // 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 56a2e2cf51..1a4ee28f12 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.h +++ b/engines/titanic/pet_control/pet_remote_glyphs.h @@ -29,7 +29,8 @@ namespace Titanic { enum RemoteGlyph { - GLYPH_SUMMON_ELEVATOR = 0 + GLYPH_SUMMON_ELEVATOR = 0, GLYPH_SUMMON_PELLERATOR = 1, + GLYPH_TELEVISION_CONTROL = 2 }; enum RemoteMessage { @@ -73,9 +74,13 @@ protected: CPetGfxElement *getElement(uint id) const; }; -class CSummonElevatorGlyph : public CPetRemoteGlyph { +class CBasicRemoteGlyph : public CPetRemoteGlyph { +private: + CString _gfxName, _tooltip, _msgString; public: - CSummonElevatorGlyph() : CPetRemoteGlyph() {} + CBasicRemoteGlyph(const CString &gfxName, const CString &tooltip, + const CString &msgString) : CPetRemoteGlyph(), + _gfxName(gfxName), _tooltip(tooltip), _msgString(msgString) {} /** * Setup the glyph @@ -103,6 +108,53 @@ public: virtual void getTooltip(CPetText *text); }; +class CSummonElevatorGlyph : public CBasicRemoteGlyph { +public: + CSummonElevatorGlyph() : CBasicRemoteGlyph( + "3PetLift", "Summon Elevator", "Lift") {} +}; + +class CSummonPelleratorGlyph : public CBasicRemoteGlyph { +public: + CSummonPelleratorGlyph() : CBasicRemoteGlyph( + "3PetPellerator", "Summon Pellerator", "Pellerator") {} +}; + +class CTelevisionControlGlyph : public CPetRemoteGlyph { +private: + bool _flag; + CPetGfxElement *_up, *_down, *_onOff; +public: + CTelevisionControlGlyph() : CPetRemoteGlyph(), _flag(false), + _up(nullptr), _down(nullptr), _onOff(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 */ diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index e474e35eac..acf9acfe24 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -216,6 +216,8 @@ CPetRoomsGlyph *CPetRooms::addGlyph(int val, bool highlight) { _glyphs.push_back(glyph); if (highlight) _glyphs.highlight(glyph); + + return glyph; } } |