diff options
author | Paul Gilbert | 2016-08-14 15:52:03 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-14 15:52:03 -0400 |
commit | 8ea436686dc0bd1726831f1648778903896b26c7 (patch) | |
tree | 79bcf7b1165faa25e3b374d78ba7363200da73c6 /engines/titanic | |
parent | b670c02835f52673064cce9b025a353ca8fe82ce (diff) | |
download | scummvm-rg350-8ea436686dc0bd1726831f1648778903896b26c7.tar.gz scummvm-rg350-8ea436686dc0bd1726831f1648778903896b26c7.tar.bz2 scummvm-rg350-8ea436686dc0bd1726831f1648778903896b26c7.zip |
TITANIC: Implemented CBarMenu and CBarMenuButton classes
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/game/bar_menu.cpp | 70 | ||||
-rw-r--r-- | engines/titanic/game/bar_menu.h | 13 | ||||
-rw-r--r-- | engines/titanic/game/bar_menu_button.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/game/bar_menu_button.h | 3 |
4 files changed, 98 insertions, 10 deletions
diff --git a/engines/titanic/game/bar_menu.cpp b/engines/titanic/game/bar_menu.cpp index b24c429c9b..3812a8dab6 100644 --- a/engines/titanic/game/bar_menu.cpp +++ b/engines/titanic/game/bar_menu.cpp @@ -24,25 +24,81 @@ namespace Titanic { -CBarMenu::CBarMenu() : CGameObject(), _fieldBC(0), _fieldC0(0), _fieldC4(6) { +BEGIN_MESSAGE_MAP(CBarMenu, CGameObject) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(PETDownMsg) + ON_MESSAGE(PETUpMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +CBarMenu::CBarMenu() : CGameObject(), _barFrameNumber(0), _visibleFlag(false), _numFrames(6) { } void CBarMenu::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeNumberLine(_fieldC0, indent); - file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_barFrameNumber, indent); + file->writeNumberLine(_visibleFlag, indent); + file->writeNumberLine(_numFrames, indent); CGameObject::save(file, indent); } void CBarMenu::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); - _fieldC4 = file->readNumber(); + _barFrameNumber = file->readNumber(); + _visibleFlag = file->readNumber(); + _numFrames = file->readNumber(); CGameObject::load(file); } +bool CBarMenu::PETActivateMsg(CPETActivateMsg *msg) { + if (msg->_name == "Television") { + _visibleFlag = !_visibleFlag; + setVisible(_visibleFlag); + loadFrame(_barFrameNumber); + } + + return true; +} + +bool CBarMenu::PETDownMsg(CPETDownMsg *msg) { + if (_visibleFlag) { + if (--_barFrameNumber < 0) + _barFrameNumber = _numFrames - 1; + + loadFrame(_barFrameNumber); + } + + return true; +} + +bool CBarMenu::PETUpMsg(CPETUpMsg *msg) { + if (_visibleFlag) { + _barFrameNumber = (_barFrameNumber + 1) % _numFrames; + loadFrame(_barFrameNumber); + } + + return true; +} + +bool CBarMenu::EnterViewMsg(CEnterViewMsg *msg) { + petSetArea(PET_REMOTE); + petHighlightGlyph(2); + petSetRemoteTarget(); + setVisible(_visibleFlag); + loadFrame(_barFrameNumber); + + return true; +} + +bool CBarMenu::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + _visibleFlag = false; + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/bar_menu.h b/engines/titanic/game/bar_menu.h index 84c0219084..f16f7b035d 100644 --- a/engines/titanic/game/bar_menu.h +++ b/engines/titanic/game/bar_menu.h @@ -24,14 +24,21 @@ #define TITANIC_BAR_MENU_H #include "titanic/core/game_object.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CBarMenu : public CGameObject { + DECLARE_MESSAGE_MAP; + bool PETActivateMsg(CPETActivateMsg *msg); + bool PETDownMsg(CPETDownMsg *msg); + bool PETUpMsg(CPETUpMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: - int _fieldBC; - int _fieldC0; - int _fieldC4; + int _barFrameNumber; + bool _visibleFlag; + int _numFrames; public: CLASSDEF; CBarMenu(); diff --git a/engines/titanic/game/bar_menu_button.cpp b/engines/titanic/game/bar_menu_button.cpp index f57d72c64a..874584db30 100644 --- a/engines/titanic/game/bar_menu_button.cpp +++ b/engines/titanic/game/bar_menu_button.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/bar_menu_button.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CBarMenuButton, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + void CBarMenuButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +42,20 @@ void CBarMenuButton::load(SimpleFile *file) { CGameObject::load(file); } +bool CBarMenuButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CBarMenuButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (_value) { + CPETUpMsg upMsg("", -1); + upMsg.execute("BarTelevision"); + } else { + CPETDownMsg downMsg("", -1); + downMsg.execute("BarTelevision"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/bar_menu_button.h b/engines/titanic/game/bar_menu_button.h index c666df413b..300435c209 100644 --- a/engines/titanic/game/bar_menu_button.h +++ b/engines/titanic/game/bar_menu_button.h @@ -28,6 +28,9 @@ namespace Titanic { class CBarMenuButton : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); public: int _value; public: |