aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-12 22:43:14 -0400
committerPaul Gilbert2016-08-12 22:43:14 -0400
commit4f8c31ecf7c8ac71e1be65771ce508fb11c62749 (patch)
treeaab2bac6a82e02e690d96800eb154621f5cd95d5 /engines/titanic
parent9e0a6cda67a63e74419a891a90ea835d17a8f3c9 (diff)
downloadscummvm-rg350-4f8c31ecf7c8ac71e1be65771ce508fb11c62749.tar.gz
scummvm-rg350-4f8c31ecf7c8ac71e1be65771ce508fb11c62749.tar.bz2
scummvm-rg350-4f8c31ecf7c8ac71e1be65771ce508fb11c62749.zip
TITANIC: Implemented CAnnounce and CActButton classes
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/game/announce.cpp101
-rw-r--r--engines/titanic/game/announce.h12
-rw-r--r--engines/titanic/game/arboretum_gate.cpp3
-rw-r--r--engines/titanic/gfx/act_button.cpp10
-rw-r--r--engines/titanic/gfx/act_button.h2
-rw-r--r--engines/titanic/gfx/st_button.cpp14
-rw-r--r--engines/titanic/gfx/st_button.h6
7 files changed, 123 insertions, 25 deletions
diff --git a/engines/titanic/game/announce.cpp b/engines/titanic/game/announce.cpp
index df6689d262..04e7a84271 100644
--- a/engines/titanic/game/announce.cpp
+++ b/engines/titanic/game/announce.cpp
@@ -21,30 +21,113 @@
*/
#include "titanic/game/announce.h"
+#include "titanic/titanic.h"
namespace Titanic {
-CAnnounce::CAnnounce() : _fieldBC(0), _fieldC0(0), _fieldC4(1), _fieldC8(0) {
+BEGIN_MESSAGE_MAP(CAnnounce, CGameObject)
+ ON_MESSAGE(TimerMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+ ON_MESSAGE(ActMsg)
+END_MESSAGE_MAP()
+
+CAnnounce::CAnnounce() : _nameIndex(0), _soundHandle(0), _leaveFlag(1), _enabled(false) {
}
void CAnnounce::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldBC, indent);
- file->writeNumberLine(_fieldC0, indent);
- file->writeNumberLine(_fieldC4, indent);
- file->writeNumberLine(_fieldC8, indent);
+ file->writeNumberLine(_nameIndex, indent);
+ file->writeNumberLine(_soundHandle, indent);
+ file->writeNumberLine(_leaveFlag, indent);
+ file->writeNumberLine(_enabled, indent);
CGameObject::save(file, indent);
}
void CAnnounce::load(SimpleFile *file) {
file->readNumber();
- _fieldBC = file->readNumber();
- _fieldC0 = file->readNumber();
- _fieldC4 = file->readNumber();
- _fieldC8 = file->readNumber();
+ _nameIndex = file->readNumber();
+ _soundHandle = file->readNumber();
+ _leaveFlag = file->readNumber();
+ _enabled = file->readNumber();
CGameObject::load(file);
}
+bool CAnnounce::TimerMsg(CTimerMsg *msg) {
+ if (!_enabled)
+ return false;
+
+ if (msg->_timerCtr == 1) {
+ CString numStr = "0";
+ CString waveNames1[20] = {
+ "z#181.wav", "z#211.wav", "z#203.wav", "z#202.wav", "z#201.wav",
+ "z#200.wav", "z#199.wav", "z#198.wav", "z#197.wav", "z#196.wav",
+ "z#210.wav", "z#209.wav", "z#208.wav", "z#207.wav", "z#206.wav",
+ "z#205.wav", "z#204.wav", "z#145.wav", "", ""
+ };
+ CString waveNames2[37] = {
+ "z#154.wav", "z#153.wav", "z#152.wav", "z#151.wav", "z#150.wav",
+ "z#149.wav", "z#148.wav", "z#169.wav", "z#171.wav", "z#178.wav",
+ "z#176.wav", "z#177.wav", "z#165.wav", "z#170.wav", "z#180.wav",
+ "z#156.wav", "z#172.wav", "z#173.wav", "z#160.wav", "z#158.wav",
+ "z#161.wav", "z#179.wav", "z#163.wav", "z#164.wav", "z#162.wav",
+ "z#159.wav", "z#175.wav", "z#166.wav", "z#174.wav", "z#157.wav",
+ "", "", "", "", "", "", ""
+ };
+
+ int randVal = _nameIndex ? g_vm->getRandomNumber(2) : 0;
+ switch (randVal) {
+ case 0:
+ case 1:
+ _soundHandle = playSound("z#189.wav");
+ if (_nameIndex < 20) {
+ queueSound(waveNames1[_nameIndex], _soundHandle);
+ ++_nameIndex;
+ } else {
+ queueSound(waveNames1[1 + g_vm->getRandomNumber(17)], _soundHandle);
+ }
+ break;
+
+ case 2:
+ _soundHandle = playSound("z#189.wav");
+ queueSound(waveNames2[1 + g_vm->getRandomNumber(35)], _soundHandle);
+ break;
+
+ default:
+ break;
+ }
+
+ addTimer(1, 300000 + g_vm->getRandomNumber(30000), 0);
+ if (g_vm->getRandomNumber(3) == 0)
+ addTimer(2, 4000, 0);
+
+ } else if (msg->_timerCtr == 2) {
+ CParrotSpeakMsg speakMsg;
+ speakMsg._value1 = "Announcements";
+ speakMsg.execute("PerchedParrot");
+ }
+
+ return true;
+}
+
+bool CAnnounce::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ if (_leaveFlag) {
+ addTimer(1, 1000, 0);
+ _leaveFlag = 0;
+ _enabled = true;
+ }
+
+ return true;
+}
+
+bool CAnnounce::ActMsg(CActMsg *msg) {
+ if (msg->_action == "Enable")
+ _enabled = true;
+ else if (msg->_action == "Disable")
+ _enabled = false;
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/announce.h b/engines/titanic/game/announce.h
index f960241c36..9bf060daae 100644
--- a/engines/titanic/game/announce.h
+++ b/engines/titanic/game/announce.h
@@ -28,11 +28,15 @@
namespace Titanic {
class CAnnounce : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool TimerMsg(CTimerMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+ bool ActMsg(CActMsg *msg);
private:
- int _fieldBC;
- int _fieldC0;
- int _fieldC4;
- int _fieldC8;
+ int _nameIndex;
+ int _soundHandle;
+ bool _leaveFlag;
+ bool _enabled;
public:
CLASSDEF;
CAnnounce();
diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp
index f51d2aa436..1f92f56acb 100644
--- a/engines/titanic/game/arboretum_gate.cpp
+++ b/engines/titanic/game/arboretum_gate.cpp
@@ -325,8 +325,7 @@ bool CArboretumGate::EnterViewMsg(CEnterViewMsg *msg) {
loadFrame(_initialFrame);
}
- warning("CArboretumGate::handleEvent");
- return false;
+ return true;
}
} // End of namespace Titanic
diff --git a/engines/titanic/gfx/act_button.cpp b/engines/titanic/gfx/act_button.cpp
index c84f358ca9..75c999b10f 100644
--- a/engines/titanic/gfx/act_button.cpp
+++ b/engines/titanic/gfx/act_button.cpp
@@ -24,6 +24,10 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CActButton, CSTButton)
+ ON_MESSAGE(MouseButtonUpMsg)
+END_MESSAGE_MAP()
+
CActButton::CActButton() : CSTButton() {
}
@@ -37,4 +41,10 @@ void CActButton::load(SimpleFile *file) {
CSTButton::load(file);
}
+bool CActButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
+ CActMsg actMsg(_actionName);
+ actMsg.execute(_actionTarget);
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/gfx/act_button.h b/engines/titanic/gfx/act_button.h
index 26e5595411..910ace1d13 100644
--- a/engines/titanic/gfx/act_button.h
+++ b/engines/titanic/gfx/act_button.h
@@ -28,6 +28,8 @@
namespace Titanic {
class CActButton : public CSTButton {
+ DECLARE_MESSAGE_MAP;
+ bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
public:
CLASSDEF;
CActButton();
diff --git a/engines/titanic/gfx/st_button.cpp b/engines/titanic/gfx/st_button.cpp
index 4b93d46595..6fc31f4c64 100644
--- a/engines/titanic/gfx/st_button.cpp
+++ b/engines/titanic/gfx/st_button.cpp
@@ -32,10 +32,10 @@ END_MESSAGE_MAP()
CSTButton::CSTButton() : CBackground() {
_statusInc = 0;
- _statusTarget = "NULL";
+ _actionTarget = "NULL";
_fieldF0 = 0;
_currentStatus = 0;
- _string4 = "NULL";
+ _actionName = "NULL";
_soundName = "NULL";
_buttonFrame = 0;
}
@@ -43,10 +43,10 @@ CSTButton::CSTButton() : CBackground() {
void CSTButton::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_statusInc, indent);
- file->writeQuotedLine(_statusTarget, indent);
+ file->writeQuotedLine(_actionTarget, indent);
file->writeNumberLine(_fieldF0, indent);
file->writeNumberLine(_currentStatus, indent);
- file->writeQuotedLine(_string4, indent);
+ file->writeQuotedLine(_actionName, indent);
file->writeQuotedLine(_soundName, indent);
file->writeNumberLine(_buttonFrame, indent);
@@ -56,10 +56,10 @@ void CSTButton::save(SimpleFile *file, int indent) {
void CSTButton::load(SimpleFile *file) {
file->readNumber();
_statusInc = file->readNumber();
- _statusTarget = file->readString();
+ _actionTarget = file->readString();
_fieldF0 = file->readNumber();
_currentStatus = file->readNumber();
- _string4 = file->readString();
+ _actionName = file->readString();
_soundName = file->readString();
_buttonFrame = file->readNumber() != 0;
@@ -79,7 +79,7 @@ bool CSTButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
CStatusChangeMsg statusMsg(oldStatus, newStatus, false);
_currentStatus = newStatus;
- statusMsg.execute(_statusTarget);
+ statusMsg.execute(_actionTarget);
if (!statusMsg._success) {
_currentStatus -= _statusInc;
diff --git a/engines/titanic/gfx/st_button.h b/engines/titanic/gfx/st_button.h
index 789437691b..444c883f59 100644
--- a/engines/titanic/gfx/st_button.h
+++ b/engines/titanic/gfx/st_button.h
@@ -34,12 +34,12 @@ class CSTButton : public CBackground {
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
-private:
+protected:
int _statusInc;
- CString _statusTarget;
+ CString _actionTarget;
int _fieldF0;
int _currentStatus;
- CString _string4;
+ CString _actionName;
CString _soundName;
int _buttonFrame;
public: