From 4933b59e8e039ae346f650c044e5fe0ba6310ead Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Aug 2016 14:39:59 -0400 Subject: TITANIC: Implemented remaining game classes --- engines/titanic/gfx/chev_switch.cpp | 10 +++++----- engines/titanic/gfx/toggle_button.h | 2 +- engines/titanic/gfx/toggle_switch.cpp | 32 +++++++++++++++++++++++++++++--- engines/titanic/gfx/toggle_switch.h | 6 +++++- 4 files changed, 40 insertions(+), 10 deletions(-) (limited to 'engines/titanic/gfx') diff --git a/engines/titanic/gfx/chev_switch.cpp b/engines/titanic/gfx/chev_switch.cpp index 177f0ada76..eb6c318604 100644 --- a/engines/titanic/gfx/chev_switch.cpp +++ b/engines/titanic/gfx/chev_switch.cpp @@ -52,8 +52,8 @@ bool CChevSwitch::SetChevButtonImageMsg(CSetChevButtonImageMsg *msg) { error("TODO: Don't know parent type"); } - _fieldBC = msg->_value1; - if (_fieldBC) { + _pressed = msg->_value1; + if (_pressed) { loadImage((_value & 1) ? "on_odd.tga" : "on_even.tga"); } else { loadImage((_value & 1) ? "off_odd.tga" : "off_even.tga"); @@ -63,13 +63,13 @@ bool CChevSwitch::SetChevButtonImageMsg(CSetChevButtonImageMsg *msg) { } bool CChevSwitch::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - _fieldBC ^= 1; + _pressed ^= 1; if (getParent()) { - CSetChevPanelBitMsg bitMsg(_value, _fieldBC); + CSetChevPanelBitMsg bitMsg(_value, _pressed); bitMsg.execute(getParent()); } - CSetChevButtonImageMsg chevMsg(_fieldBC, 0); + CSetChevButtonImageMsg chevMsg(_pressed, 0); chevMsg.execute(this); return true; diff --git a/engines/titanic/gfx/toggle_button.h b/engines/titanic/gfx/toggle_button.h index 5328072982..4fb7cdfaba 100644 --- a/engines/titanic/gfx/toggle_button.h +++ b/engines/titanic/gfx/toggle_button.h @@ -29,7 +29,7 @@ namespace Titanic { class CToggleButton : public CBackground { DECLARE_MESSAGE_MAP; -private: +protected: int _fieldE0; public: CLASSDEF; diff --git a/engines/titanic/gfx/toggle_switch.cpp b/engines/titanic/gfx/toggle_switch.cpp index 20cbb863ee..456ac79ff6 100644 --- a/engines/titanic/gfx/toggle_switch.cpp +++ b/engines/titanic/gfx/toggle_switch.cpp @@ -24,12 +24,18 @@ namespace Titanic { -CToggleSwitch::CToggleSwitch() : CGameObject(), _fieldBC(0) { +BEGIN_MESSAGE_MAP(CToggleSwitch, CToggleSwitch) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(ChildDragStartMsg) + ON_MESSAGE(ChildDragMoveMsg) +END_MESSAGE_MAP() + +CToggleSwitch::CToggleSwitch() : CGameObject(), _pressed(false) { } void CToggleSwitch::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_pressed, indent); file->writePoint(_pos1, indent); CGameObject::save(file, indent); @@ -37,10 +43,30 @@ void CToggleSwitch::save(SimpleFile *file, int indent) { void CToggleSwitch::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); + _pressed = file->readNumber(); _pos1 = file->readPoint(); CGameObject::load(file); } +bool CToggleSwitch::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + _pressed = !_pressed; + if (_pressed) + fn10(0, 0, 0); + else + fn10(0xff, 0xff, 0xff); + return true; +} + +bool CToggleSwitch::ChildDragStartMsg(CChildDragStartMsg *msg) { + _pos1.x = msg->_mousePos.x - _bounds.left; + _pos1.y = msg->_mousePos.y - _bounds.top; + return true; +} + +bool CToggleSwitch::ChildDragMoveMsg(CChildDragMoveMsg *msg) { + setPosition(Point(msg->_mousePos.x - _pos1.x, msg->_mousePos.y - _pos1.y)); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/toggle_switch.h b/engines/titanic/gfx/toggle_switch.h index 8e7d057d8c..69b8c50eec 100644 --- a/engines/titanic/gfx/toggle_switch.h +++ b/engines/titanic/gfx/toggle_switch.h @@ -28,8 +28,12 @@ namespace Titanic { class CToggleSwitch : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool ChildDragStartMsg(CChildDragStartMsg *msg); + bool ChildDragMoveMsg(CChildDragMoveMsg *msg); protected: - int _fieldBC; + bool _pressed; Point _pos1; public: CLASSDEF; -- cgit v1.2.3