[Scummvm-cvs-logs] scummvm master -> dc91d30b76ded7ed7a648a0b0b43d8fe99c00cf6

dreammaster dreammaster at scummvm.org
Fri Aug 19 04:46:08 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
dc91d30b76 TITANIC: Implementing game classes


Commit: dc91d30b76ded7ed7a648a0b0b43d8fe99c00cf6
    https://github.com/scummvm/scummvm/commit/dc91d30b76ded7ed7a648a0b0b43d8fe99c00cf6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-18T22:45:58-04:00

Commit Message:
TITANIC: Implementing game classes

Changed paths:
    engines/titanic/carry/chicken.h
    engines/titanic/carry/crushed_tv.cpp
    engines/titanic/core/click_responder.cpp
    engines/titanic/core/click_responder.h
    engines/titanic/game/chicken_cooler.cpp
    engines/titanic/game/chicken_cooler.h
    engines/titanic/game/chicken_dispensor.cpp
    engines/titanic/game/chicken_dispensor.h
    engines/titanic/game/close_broken_pel.cpp
    engines/titanic/game/close_broken_pel.h
    engines/titanic/game/cookie.cpp
    engines/titanic/game/cookie.h
    engines/titanic/game/credits.cpp
    engines/titanic/game/credits.h
    engines/titanic/game/credits_button.cpp
    engines/titanic/game/credits_button.h
    engines/titanic/game/null_port_hole.cpp
    engines/titanic/game/sgt/sgt_upper_doors_sound.cpp
    engines/titanic/gfx/chev_switch.cpp
    engines/titanic/gfx/chev_switch.h
    engines/titanic/gfx/toggle_switch.h



diff --git a/engines/titanic/carry/chicken.h b/engines/titanic/carry/chicken.h
index 65fe30f..e64ae45 100644
--- a/engines/titanic/carry/chicken.h
+++ b/engines/titanic/carry/chicken.h
@@ -41,7 +41,7 @@ class CChicken : public CCarry {
 	bool MouseDragEndMsg(CMouseDragEndMsg *msg);
 	bool PETObjectStateMsg(CPETObjectStateMsg *msg);
 	bool PETLostObjectMsg(CPETLostObjectMsg *msg);
-private:
+public:
 	static int _v1;
 public:
 	int _field12C;
diff --git a/engines/titanic/carry/crushed_tv.cpp b/engines/titanic/carry/crushed_tv.cpp
index a265b61..486537d 100644
--- a/engines/titanic/carry/crushed_tv.cpp
+++ b/engines/titanic/carry/crushed_tv.cpp
@@ -76,5 +76,4 @@ bool CCrushedTV::MouseDragStartMsg(CMouseDragStartMsg *msg) {
 	return CCarry::MouseDragStartMsg(msg);
 }
 
-
 } // End of namespace Titanic
diff --git a/engines/titanic/core/click_responder.cpp b/engines/titanic/core/click_responder.cpp
index f969455..9a0e0de 100644
--- a/engines/titanic/core/click_responder.cpp
+++ b/engines/titanic/core/click_responder.cpp
@@ -24,20 +24,33 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CClickResponder, CGameObject)
+	ON_MESSAGE(MouseButtonDownMsg)
+END_MESSAGE_MAP()
+
 void CClickResponder::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeQuotedLine(_string1, indent);
-	file->writeQuotedLine(_string2, indent);
+	file->writeQuotedLine(_message, indent);
+	file->writeQuotedLine(_soundName, indent);
 
 	CGameObject::save(file, indent);
 }
 
 void CClickResponder::load(SimpleFile *file) {
 	file->readNumber();
-	_string1 = file->readString();
-	_string2 = file->readString();
+	_message = file->readString();
+	_soundName = file->readString();
 
 	CGameObject::load(file);
 }
 
+bool CClickResponder::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+	if (!_soundName.empty())
+		playSound(_soundName);
+	if (!_message.empty())
+		petDisplayMessage(_message);
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/core/click_responder.h b/engines/titanic/core/click_responder.h
index 78381b9..40f22d7 100644
--- a/engines/titanic/core/click_responder.h
+++ b/engines/titanic/core/click_responder.h
@@ -28,8 +28,10 @@
 namespace Titanic {
 
 class CClickResponder : public CGameObject {
+	DECLARE_MESSAGE_MAP;
+	bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
 protected:
-	CString _string1, _string2;
+	CString _message, _soundName;
 public:
 	CLASSDEF;
 
diff --git a/engines/titanic/game/chicken_cooler.cpp b/engines/titanic/game/chicken_cooler.cpp
index 29232e1..d10405d 100644
--- a/engines/titanic/game/chicken_cooler.cpp
+++ b/engines/titanic/game/chicken_cooler.cpp
@@ -21,9 +21,15 @@
  */
 
 #include "titanic/game/chicken_cooler.h"
+#include "titanic/carry/chicken.h"
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CChickenCooler, CGameObject)
+	ON_MESSAGE(EnterRoomMsg)
+	ON_MESSAGE(EnterViewMsg)
+END_MESSAGE_MAP()
+
 void CChickenCooler::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
 	file->writeNumberLine(_fieldBC, indent);
@@ -41,7 +47,32 @@ void CChickenCooler::load(SimpleFile *file) {
 }
 
 bool CChickenCooler::EnterRoomMsg(CEnterRoomMsg *msg) {
-	warning("CChickenCoolor::handlEvent");
+	if (_fieldC0) {
+		CGameObject *obj = getMailManFirstObject();
+		if (obj) {
+			// WORKAROUND: Redundant loop for chicken in originalhere
+		} else {
+			getNextMail(nullptr);
+			if (CChicken::_v1 > _fieldBC)
+				CChicken::_v1 = _fieldBC;
+		}
+	}
+
+	return true;
+}
+
+bool CChickenCooler::EnterViewMsg(CEnterViewMsg *msg) {
+	if (!_fieldC0) {
+		for (CGameObject *obj = getMailManFirstObject(); obj;
+				obj = getNextMail(obj)) {
+			if (obj->isEquals("Chicken"))
+				return true;
+		}
+
+		if (CChicken::_v1 > _fieldBC)
+			CChicken::_v1 = _fieldBC;
+	}
+
 	return true;
 }
 
diff --git a/engines/titanic/game/chicken_cooler.h b/engines/titanic/game/chicken_cooler.h
index 724727b..54dba90 100644
--- a/engines/titanic/game/chicken_cooler.h
+++ b/engines/titanic/game/chicken_cooler.h
@@ -29,7 +29,9 @@
 namespace Titanic {
 
 class CChickenCooler : public CGameObject {
+	DECLARE_MESSAGE_MAP;
 	bool EnterRoomMsg(CEnterRoomMsg *msg);
+	bool EnterViewMsg(CEnterViewMsg *msg);
 private:
 	int _fieldBC;
 	int _fieldC0;
diff --git a/engines/titanic/game/chicken_dispensor.cpp b/engines/titanic/game/chicken_dispensor.cpp
index a9bf576..7fb8fef 100644
--- a/engines/titanic/game/chicken_dispensor.cpp
+++ b/engines/titanic/game/chicken_dispensor.cpp
@@ -21,9 +21,21 @@
  */
 
 #include "titanic/game/chicken_dispensor.h"
+#include "titanic/core/project_item.h"
+#include "titanic/pet_control/pet_control.h"
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CChickenDispensor, CBackground)
+	ON_MESSAGE(StatusChangeMsg)
+	ON_MESSAGE(MovieEndMsg)
+	ON_MESSAGE(ActMsg)
+	ON_MESSAGE(LeaveViewMsg)
+	ON_MESSAGE(EnterViewMsg)
+	ON_MESSAGE(MouseDragStartMsg)
+	ON_MESSAGE(TurnOff)
+END_MESSAGE_MAP()
+
 CChickenDispensor::CChickenDispensor() : CBackground(),
 	_fieldE0(0), _fieldE4(0), _fieldE8(0) {
 }
@@ -45,4 +57,133 @@ void CChickenDispensor::load(SimpleFile *file) {
 	CBackground::load(file);
 }
 
+bool CChickenDispensor::StatusChangeMsg(CStatusChangeMsg *msg) {
+	msg->execute("SGTRestLeverAnimation");
+	int v1 = _fieldE8 ? 0 : _fieldE4;
+	CPetControl *pet = getPetControl();
+	CGameObject *obj;
+
+	for (obj = pet->getFirstObject(); obj; obj = pet->getNextObject(obj)) {
+		if (obj->isEquals("Chicken")) {
+			petDisplayMessage(1, "Chickens are allocated on a one-per-customer basis.");
+			return true;
+		}
+	}
+
+	for (obj = getMailManFirstObject(); obj; obj = getNextMail(obj)) {
+		if (obj->isEquals("Chicken")) {
+			petDisplayMessage(1, "Chickens are allocated on a one-per-customer basis.");
+			return true;
+		}
+	}
+
+	if (v1 == 1 || v1 == 2)
+		_fieldE8 = 1;
+
+	switch (v1) {
+	case 0:
+		petDisplayMessage(1, "Only one piece of chicken per passenger. Thank you.");
+		break;
+	case 1:
+		setVisible(true);
+		if (_fieldE0) {
+			playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+			playSound("z#400.wav");
+			_fieldE4 = 0;
+		} else {
+			playMovie(12, 16, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+			_fieldE8 = 1;
+			_fieldE4 = 0;
+		}
+		break;
+
+	case 2:
+		setVisible(true);
+		if (_fieldE0) {
+			playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+			playSound("z#400.wav");
+		} else {
+			playMovie(12, 16, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+			_fieldE8 = 1;
+		}
+		break;
+	
+	default:
+		break;
+	}
+
+	return true;
+}
+
+bool CChickenDispensor::MovieEndMsg(CMovieEndMsg *msg) {
+	if (getMovieFrame() == 16) {
+		playSound("b#50.wav", 50);
+		CActMsg actMsg("Dispense Chicken");
+		actMsg.execute("Chicken");
+	} else if (_fieldE8) {
+		_cursorId = CURSOR_ARROW;
+		loadFrame(0);
+		setVisible(false);
+		if (_fieldE4 == 2)
+			_fieldE8 = 0;
+	} else {
+		loadFrame(0);
+		setVisible(false);
+		changeView("SgtLobby.Node 1.N");
+	}
+
+	return true;
+}
+
+bool CChickenDispensor::ActMsg(CActMsg *msg) {
+	if (msg->_action == "EnableObject")
+		_fieldE0 = 0;
+	else if (msg->_action == "DisableObject")
+		_fieldE0 = 1;
+	else if (msg->_action == "IncreaseQuantity")
+		_fieldE4 = 2;
+	else if (msg->_action == "DecreaseQuantity")
+		_fieldE4 = 1;
+
+	return true;
+}
+
+bool CChickenDispensor::LeaveViewMsg(CLeaveViewMsg *msg) {
+	return true;
+}
+
+bool CChickenDispensor::EnterViewMsg(CEnterViewMsg *msg) {
+	playSound("b#51.wav");
+	_fieldE8 = 0;
+	_cursorId = CURSOR_ARROW;
+	return true;
+}
+
+bool CChickenDispensor::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+	if (getMovieFrame() == 16) {
+		setVisible(false);
+		loadFrame(0);
+		_cursorId = CURSOR_ARROW;
+		_fieldE8 = 1;
+
+		CVisibleMsg visibleMsg;
+		visibleMsg.execute("Chicken");
+		CPassOnDragStartMsg passMsg(msg->_mousePos, 1);
+		passMsg.execute("Chicken");
+
+		msg->_dragItem = getRoot()->findByName("Chicken");
+	}
+
+	return true;
+}
+
+bool CChickenDispensor::TurnOff(CTurnOff *msg) {
+	if (getMovieFrame() == 16)
+		setVisible(false);
+	playMovie(16, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+	_fieldE8 = 0;
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/chicken_dispensor.h b/engines/titanic/game/chicken_dispensor.h
index d86b850..5e3ba47 100644
--- a/engines/titanic/game/chicken_dispensor.h
+++ b/engines/titanic/game/chicken_dispensor.h
@@ -28,6 +28,14 @@
 namespace Titanic {
 
 class CChickenDispensor : public CBackground {
+	DECLARE_MESSAGE_MAP;
+	bool StatusChangeMsg(CStatusChangeMsg *msg);
+	bool MovieEndMsg(CMovieEndMsg *msg);
+	bool ActMsg(CActMsg *msg);
+	bool LeaveViewMsg(CLeaveViewMsg *msg);
+	bool EnterViewMsg(CEnterViewMsg *msg);
+	bool MouseDragStartMsg(CMouseDragStartMsg *msg);
+	bool TurnOff(CTurnOff *msg);
 public:
 	int _fieldE0;
 	int _fieldE4;
diff --git a/engines/titanic/game/close_broken_pel.cpp b/engines/titanic/game/close_broken_pel.cpp
index d27441a..c234590 100644
--- a/engines/titanic/game/close_broken_pel.cpp
+++ b/engines/titanic/game/close_broken_pel.cpp
@@ -24,16 +24,26 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CCloseBrokenPel, CBackground)
+	ON_MESSAGE(MouseButtonDownMsg)
+END_MESSAGE_MAP()
+
 void CCloseBrokenPel::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeQuotedLine(_string3, indent);
+	file->writeQuotedLine(_target, indent);
 	CBackground::save(file, indent);
 }
 
 void CCloseBrokenPel::load(SimpleFile *file) {
 	file->readNumber();
-	_string3 = file->readString();
+	_target = file->readString();
 	CBackground::load(file);
 }
 
+bool CCloseBrokenPel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+	CActMsg actMsg("Close");
+	actMsg.execute(_target);
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/close_broken_pel.h b/engines/titanic/game/close_broken_pel.h
index aacda6c..4bd6625 100644
--- a/engines/titanic/game/close_broken_pel.h
+++ b/engines/titanic/game/close_broken_pel.h
@@ -28,8 +28,10 @@
 namespace Titanic {
 
 class CCloseBrokenPel : public CBackground {
+	DECLARE_MESSAGE_MAP;
+	bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
 public:
-	CString _string3;
+	CString _target;
 public:
 	CLASSDEF;
 
diff --git a/engines/titanic/game/cookie.cpp b/engines/titanic/game/cookie.cpp
index 915bb93..96edca4 100644
--- a/engines/titanic/game/cookie.cpp
+++ b/engines/titanic/game/cookie.cpp
@@ -24,6 +24,11 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CCookie, CGameObject)
+	ON_MESSAGE(LeaveNodeMsg)
+	ON_MESSAGE(FreshenCookieMsg)
+END_MESSAGE_MAP()
+
 void CCookie::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
 	file->writeNumberLine(_value1, indent);
@@ -40,4 +45,16 @@ void CCookie::load(SimpleFile *file) {
 	CGameObject::load(file);
 }
 
+bool CCookie::LeaveNodeMsg(CLeaveNodeMsg *msg) {
+	if (_value2)
+		_value1 = 1;
+	return true;
+}
+
+bool CCookie::FreshenCookieMsg(CFreshenCookieMsg *msg) {
+	_value1 = msg->_value2;
+	_value2 = msg->_value1;
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/cookie.h b/engines/titanic/game/cookie.h
index 7ae04f1..2018dee 100644
--- a/engines/titanic/game/cookie.h
+++ b/engines/titanic/game/cookie.h
@@ -28,6 +28,9 @@
 namespace Titanic {
 
 class CCookie : public CGameObject {
+	DECLARE_MESSAGE_MAP;
+	bool LeaveNodeMsg(CLeaveNodeMsg *msg);
+	bool FreshenCookieMsg(CFreshenCookieMsg *msg);
 public:
 	int _value1;
 	int _value2;
diff --git a/engines/titanic/game/credits.cpp b/engines/titanic/game/credits.cpp
index 7078d41..d9149f6 100644
--- a/engines/titanic/game/credits.cpp
+++ b/engines/titanic/game/credits.cpp
@@ -24,6 +24,11 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CCredits, CGameObject)
+	ON_MESSAGE(SignalObject)
+	ON_MESSAGE(TimerMsg)
+END_MESSAGE_MAP()
+
 CCredits::CCredits() : CGameObject(), _fieldBC(-1), _fieldC0(1) {
 }
 
@@ -43,4 +48,34 @@ void CCredits::load(SimpleFile *file) {
 	CGameObject::load(file);
 }
 
+bool CCredits::SignalObject(CSignalObject *msg) {
+	petHide();
+	disableMouse();
+	addTimer(50);
+	return true;
+}
+
+bool CCredits::TimerMsg(CTimerMsg *msg) {
+	stopGlobalSound(true, -1);
+	setVisible(true);
+	loadSound("a#16.wav");
+	loadSound("a#24.wav");
+	
+	playCutscene(0, 18);
+	playGlobalSound("a#16.wav", -1, false, false, 0);
+	playCutscene(19, 642);
+	playSound("a#24.wav");
+	playCutscene(643, 750);
+
+	COpeningCreditsMsg creditsMsg;
+	creditsMsg.execute("Service Elevator Entity");
+	changeView("EmbLobby.Node 6.S");
+
+	setVisible(false);
+	petShow();
+	enableMouse();
+	stopGlobalSound(true, -1);
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/credits.h b/engines/titanic/game/credits.h
index fa9794b..23fd255 100644
--- a/engines/titanic/game/credits.h
+++ b/engines/titanic/game/credits.h
@@ -28,6 +28,9 @@
 namespace Titanic {
 
 class CCredits : public CGameObject {
+	DECLARE_MESSAGE_MAP;
+	bool SignalObject(CSignalObject *msg);
+	bool TimerMsg(CTimerMsg *msg);
 public:
 	int _fieldBC, _fieldC0;
 public:
diff --git a/engines/titanic/game/credits_button.cpp b/engines/titanic/game/credits_button.cpp
index 90bb1b5..ee8f7bb 100644
--- a/engines/titanic/game/credits_button.cpp
+++ b/engines/titanic/game/credits_button.cpp
@@ -24,6 +24,11 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CCreditsButton, CBackground)
+	ON_MESSAGE(MouseButtonUpMsg)
+	ON_MESSAGE(MouseButtonDownMsg)
+END_MESSAGE_MAP()
+
 CCreditsButton::CCreditsButton() : CBackground(), _fieldE0(1) {
 }
 
@@ -39,4 +44,19 @@ void CCreditsButton::load(SimpleFile *file) {
 	CBackground::load(file);
 }
 
+bool CCreditsButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
+	return true;
+}
+
+bool CCreditsButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+	if (_fieldE0) {
+		playSound("a#20.wav");
+		CSignalObject signalMsg;
+		signalMsg._numValue = 1;
+		signalMsg.execute("CreditsPlayer");
+	}
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/credits_button.h b/engines/titanic/game/credits_button.h
index 5e0bf96..4a53083 100644
--- a/engines/titanic/game/credits_button.h
+++ b/engines/titanic/game/credits_button.h
@@ -28,6 +28,9 @@
 namespace Titanic {
 
 class CCreditsButton : public CBackground {
+	DECLARE_MESSAGE_MAP;
+	bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
+	bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
 public:
 	int _fieldE0;
 public:
diff --git a/engines/titanic/game/null_port_hole.cpp b/engines/titanic/game/null_port_hole.cpp
index e651b1b..b1514c7 100644
--- a/engines/titanic/game/null_port_hole.cpp
+++ b/engines/titanic/game/null_port_hole.cpp
@@ -27,22 +27,22 @@ namespace Titanic {
 EMPTY_MESSAGE_MAP(CNullPortHole, CClickResponder);
 
 CNullPortHole::CNullPortHole() : CClickResponder() {
-	_string1 = "For a better view, why not visit the Promenade Deck?";
-	_string2 = "b#48.wav";
+	_message = "For a better view, why not visit the Promenade Deck?";
+	_soundName = "b#48.wav";
 }
 
 void CNullPortHole::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeQuotedLine(_string2, indent);
-	file->writeQuotedLine(_string1, indent);
+	file->writeQuotedLine(_soundName, indent);
+	file->writeQuotedLine(_message, indent);
 
 	CClickResponder::save(file, indent);
 }
 
 void CNullPortHole::load(SimpleFile *file) {
 	file->readNumber();
-	_string2 = file->readString();
-	_string1 = file->readString();
+	_soundName = file->readString();
+	_message = file->readString();
 
 	CClickResponder::load(file);
 }
diff --git a/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp b/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp
index ed37b0a..72cd7f9 100644
--- a/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp
+++ b/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp
@@ -25,19 +25,19 @@
 namespace Titanic {
 
 CSGTUpperDoorsSound::CSGTUpperDoorsSound() {
-	_string2 = "b#53.wav";
+	_soundName = "b#53.wav";
 }
 
 void CSGTUpperDoorsSound::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeQuotedLine(_string2, indent);
+	file->writeQuotedLine(_soundName, indent);
 
 	CClickResponder::save(file, indent);
 }
 
 void CSGTUpperDoorsSound::load(SimpleFile *file) {
 	file->readNumber();
-	_string2 = file->readString();
+	_soundName = file->readString();
 
 	CClickResponder::load(file);
 }
diff --git a/engines/titanic/gfx/chev_switch.cpp b/engines/titanic/gfx/chev_switch.cpp
index a6ce930..177f0ad 100644
--- a/engines/titanic/gfx/chev_switch.cpp
+++ b/engines/titanic/gfx/chev_switch.cpp
@@ -24,7 +24,13 @@
 
 namespace Titanic {
 
-CChevSwitch::CChevSwitch() : CToggleSwitch() {
+BEGIN_MESSAGE_MAP(CChevSwitch, CToggleSwitch)
+	ON_MESSAGE(MouseButtonUpMsg)
+	ON_MESSAGE(SetChevButtonImageMsg)
+	ON_MESSAGE(MouseButtonDownMsg)
+END_MESSAGE_MAP()
+
+CChevSwitch::CChevSwitch() : CToggleSwitch(), _value(0) {
 }
 
 void CChevSwitch::save(SimpleFile *file, int indent) {
@@ -37,4 +43,36 @@ void CChevSwitch::load(SimpleFile *file) {
 	CToggleSwitch::load(file);
 }
 
+bool CChevSwitch::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
+	return true;
+}
+
+bool CChevSwitch::SetChevButtonImageMsg(CSetChevButtonImageMsg *msg) {
+	if (msg->_value2 && getParent()) {
+		error("TODO: Don't know parent type");
+	}
+
+	_fieldBC = msg->_value1;
+	if (_fieldBC) {
+		loadImage((_value & 1) ? "on_odd.tga" : "on_even.tga");
+	} else {
+		loadImage((_value & 1) ? "off_odd.tga" : "off_even.tga");
+	}
+
+	return true;
+}
+
+bool CChevSwitch::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+	_fieldBC ^= 1;
+	if (getParent()) {
+		CSetChevPanelBitMsg bitMsg(_value, _fieldBC);
+		bitMsg.execute(getParent());
+	}
+
+	CSetChevButtonImageMsg chevMsg(_fieldBC, 0);
+	chevMsg.execute(this);
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/gfx/chev_switch.h b/engines/titanic/gfx/chev_switch.h
index 0305a6c..01da53c 100644
--- a/engines/titanic/gfx/chev_switch.h
+++ b/engines/titanic/gfx/chev_switch.h
@@ -28,6 +28,12 @@
 namespace Titanic {
 
 class CChevSwitch : public CToggleSwitch {
+	DECLARE_MESSAGE_MAP;
+	bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
+	bool SetChevButtonImageMsg(CSetChevButtonImageMsg *msg);
+	bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+public:
+	int _value;
 public:
 	CLASSDEF;
 	CChevSwitch();
diff --git a/engines/titanic/gfx/toggle_switch.h b/engines/titanic/gfx/toggle_switch.h
index ae96c75..8e7d057 100644
--- a/engines/titanic/gfx/toggle_switch.h
+++ b/engines/titanic/gfx/toggle_switch.h
@@ -28,7 +28,7 @@
 namespace Titanic {
 
 class CToggleSwitch : public CGameObject {
-private:
+protected:
 	int _fieldBC;
 	Point _pos1;
 public:






More information about the Scummvm-git-logs mailing list