aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-17 23:56:20 -0400
committerPaul Gilbert2016-08-17 23:56:20 -0400
commit912b3b15d2f11f12303d8dd7beb20c5f8716ea51 (patch)
treebaa57737ff53716da0712083e571bc9ac1a9453b /engines
parent69083ae71f2fe111a64206f234011013fcfd2ba4 (diff)
downloadscummvm-rg350-912b3b15d2f11f12303d8dd7beb20c5f8716ea51.tar.gz
scummvm-rg350-912b3b15d2f11f12303d8dd7beb20c5f8716ea51.tar.bz2
scummvm-rg350-912b3b15d2f11f12303d8dd7beb20c5f8716ea51.zip
TITANIC: Implemented CChevPanel class
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/game/chev_code.cpp36
-rw-r--r--engines/titanic/game/chev_code.h4
-rw-r--r--engines/titanic/game/chev_panel.cpp88
-rw-r--r--engines/titanic/game/chev_panel.h16
-rw-r--r--engines/titanic/messages/messages.h4
-rw-r--r--engines/titanic/messages/mouse_messages.h26
6 files changed, 141 insertions, 33 deletions
diff --git a/engines/titanic/game/chev_code.cpp b/engines/titanic/game/chev_code.cpp
index 1feef0cad0..07225f0cf8 100644
--- a/engines/titanic/game/chev_code.cpp
+++ b/engines/titanic/game/chev_code.cpp
@@ -39,28 +39,28 @@ END_MESSAGE_MAP()
void CChevCode::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_floorBits, indent);
+ file->writeNumberLine(_chevCode, indent);
CGameObject::save(file, indent);
}
void CChevCode::load(SimpleFile *file) {
file->readNumber();
- _floorBits = file->readNumber();
+ _chevCode = file->readNumber();
CGameObject::load(file);
}
bool CChevCode::SetChevLiftBits(CSetChevLiftBits *msg) {
- _floorBits &= ~0xC0000;
+ _chevCode &= ~0xC0000;
if (msg->_liftNum > 0 && msg->_liftNum < 5)
- _floorBits = ((msg->_liftNum - 1) << 18) | _floorBits;
+ _chevCode = ((msg->_liftNum - 1) << 18) | _chevCode;
return true;
}
bool CChevCode::SetChevClassBits(CSetChevClassBits *msg) {
- _floorBits &= ~0x30000;
+ _chevCode &= ~0x30000;
if (msg->_classNum > 0 && msg->_classNum < 4)
- _floorBits = (msg->_classNum << 16) | msg->_classNum;
+ _chevCode = (msg->_classNum << 16) | msg->_classNum;
return true;
}
@@ -68,7 +68,7 @@ bool CChevCode::SetChevClassBits(CSetChevClassBits *msg) {
bool CChevCode::SetChevFloorBits(CSetChevFloorBits *msg) {
int section = (msg->_floorNum + 4) / 10;
int index = (msg->_floorNum + 4) % 10;
- _floorBits &= ~0xFF00;
+ _chevCode &= ~0xFF00;
int val;
switch (section) {
@@ -88,31 +88,31 @@ bool CChevCode::SetChevFloorBits(CSetChevFloorBits *msg) {
break;
}
- _floorBits |= ((index + val) << 8);
+ _chevCode |= ((index + val) << 8);
return true;
}
bool CChevCode::SetChevRoomBits(CSetChevRoomBits *msg) {
- _floorBits &= ~0xff;
+ _chevCode &= ~0xff;
if (msg->_roomNum > 0 && msg->_roomNum < 128)
- _floorBits |= msg->_roomNum * 2;
+ _chevCode |= msg->_roomNum * 2;
return true;
}
bool CChevCode::GetChevLiftNum(CGetChevLiftNum *msg) {
- msg->_liftNum = (_floorBits >> 18) & 3 + 1;
+ msg->_liftNum = (_chevCode >> 18) & 3 + 1;
return true;
}
bool CChevCode::GetChevClassNum(CGetChevClassNum *msg) {
- msg->_classNum = (_floorBits >> 16) & 3;
+ msg->_classNum = (_chevCode >> 16) & 3;
return true;
}
bool CChevCode::GetChevFloorNum(CGetChevFloorNum *msg) {
- int val1 = (_floorBits >> 8) & 0xF;
- int val2 = (_floorBits >> 12) & 0xF - 9;
+ int val1 = (_chevCode >> 8) & 0xF;
+ int val2 = (_chevCode >> 12) & 0xF - 9;
switch (val2) {
case 0:
@@ -137,7 +137,7 @@ bool CChevCode::GetChevFloorNum(CGetChevFloorNum *msg) {
}
bool CChevCode::GetChevRoomNum(CGetChevRoomNum *msg) {
- msg->_roomNum = (_floorBits >> 1) & 0x7F;
+ msg->_roomNum = (_chevCode >> 1) & 0x7F;
return true;
}
@@ -150,8 +150,8 @@ bool CChevCode::CheckChevCode(CCheckChevCode *msg) {
int classNum = 0;
uint bits;
- if (_floorBits & 1) {
- switch (_floorBits) {
+ if (_chevCode & 1) {
+ switch (_chevCode) {
case 0x1D0D9:
roomName = "ParrLobby";
classNum = 4;
@@ -210,7 +210,7 @@ bool CChevCode::CheckChevCode(CCheckChevCode *msg) {
break;
}
- bits = classNum == 5 ? 0x3D94B : _floorBits;
+ bits = classNum == 5 ? 0x3D94B : _chevCode;
} else {
getFloorMsg.execute(this);
getRoomMsg.execute(this);
diff --git a/engines/titanic/game/chev_code.h b/engines/titanic/game/chev_code.h
index 88b26cd6ec..4a71b13f9e 100644
--- a/engines/titanic/game/chev_code.h
+++ b/engines/titanic/game/chev_code.h
@@ -40,10 +40,10 @@ class CChevCode : public CGameObject {
bool CheckChevCode(CCheckChevCode *msg);
bool GetChevCodeFromRoomNameMsg(CGetChevCodeFromRoomNameMsg *msg);
public:
- int _floorBits;
+ int _chevCode;
public:
CLASSDEF;
- CChevCode() : CGameObject(), _floorBits(0) {}
+ CChevCode() : CGameObject(), _chevCode(0) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/game/chev_panel.cpp b/engines/titanic/game/chev_panel.cpp
index 245968e356..c644776bc9 100644
--- a/engines/titanic/game/chev_panel.cpp
+++ b/engines/titanic/game/chev_panel.cpp
@@ -21,25 +21,101 @@
*/
#include "titanic/game/chev_panel.h"
+#include "titanic/game/chev_code.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CChevPanel, CGameObject)
+ ON_MESSAGE(MouseDragStartMsg)
+ ON_MESSAGE(MouseDragMoveMsg)
+ ON_MESSAGE(MouseButtonUpMsg)
+ ON_MESSAGE(SetChevPanelBitMsg)
+ ON_MESSAGE(MouseDragEndMsg)
+ ON_MESSAGE(ClearChevPanelBits)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(SetChevPanelButtonsMsg)
+END_MESSAGE_MAP()
+
void CChevPanel::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldBC, indent);
- file->writeNumberLine(_fieldC0, indent);
- file->writeNumberLine(_fieldC4, indent);
+ file->writeNumberLine(_startPos.x, indent);
+ file->writeNumberLine(_startPos.y, indent);
+ file->writeNumberLine(_chevCode, indent);
CGameObject::save(file, indent);
}
void CChevPanel::load(SimpleFile *file) {
file->readNumber();
- _fieldBC = file->readNumber();
- _fieldC0 = file->readNumber();
- _fieldC4 = file->readNumber();
+ _startPos.x = file->readNumber();
+ _startPos.y = file->readNumber();
+ _chevCode = file->readNumber();
CGameObject::load(file);
}
+bool CChevPanel::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ if (checkStartDragging(msg)) {
+ _startPos = Point(msg->_mousePos.x - _bounds.left,
+ msg->_mousePos.y - _bounds.top);
+ CChildDragStartMsg dragMsg(_startPos);
+ dragMsg.execute(this, nullptr, MSGFLAG_SCAN);
+ }
+
+ return true;
+}
+
+bool CChevPanel::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
+ CChildDragMoveMsg dragMsg(_startPos);
+ dragMsg.execute(this, nullptr, MSGFLAG_SCAN);
+
+ setPosition(msg->_mousePos - _startPos);
+ return true;
+}
+
+bool CChevPanel::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
+ CChevCode chevCode;
+ chevCode._chevCode = _chevCode;
+ CCheckChevCode checkCode;
+ checkCode.execute(this);
+ CClearChevPanelBits panelBits;
+ panelBits.execute(this, nullptr, MSGFLAG_SCAN);
+ CSetChevPanelButtonsMsg setMsg;
+ setMsg._chevCode = checkCode._chevCode;
+ setMsg.execute(this);
+
+ return true;
+}
+
+bool CChevPanel::SetChevPanelBitMsg(CSetChevPanelBitMsg *msg) {
+ _chevCode = _chevCode & ~(1 << msg->_value1) | (msg->_value2 << msg->_value1);
+ return true;
+}
+
+bool CChevPanel::MouseDragEndMsg(CMouseDragEndMsg *msg) {
+ setPosition(msg->_mousePos - _startPos);
+ return true;
+}
+
+bool CChevPanel::ClearChevPanelBits(CClearChevPanelBits *msg) {
+ CSetChevPanelButtonsMsg setMsg;
+ setMsg._chevCode = 0;
+ setMsg.execute(this);
+
+ return true;
+}
+
+bool CChevPanel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ return true;
+}
+
+bool CChevPanel::SetChevPanelButtonsMsg(CSetChevPanelButtonsMsg *msg) {
+ _chevCode = msg->_chevCode;
+ CSetChevButtonImageMsg setMsg;
+ setMsg._value2 = 1;
+ setMsg.execute(this, nullptr, MSGFLAG_SCAN);
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/chev_panel.h b/engines/titanic/game/chev_panel.h
index 99b5501ac2..bcfb920221 100644
--- a/engines/titanic/game/chev_panel.h
+++ b/engines/titanic/game/chev_panel.h
@@ -28,13 +28,21 @@
namespace Titanic {
class CChevPanel : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool MouseDragStartMsg(CMouseDragStartMsg *msg);
+ bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
+ bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
+ bool SetChevPanelBitMsg(CSetChevPanelBitMsg *msg);
+ bool MouseDragEndMsg(CMouseDragEndMsg *msg);
+ bool ClearChevPanelBits(CClearChevPanelBits *msg);
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool SetChevPanelButtonsMsg(CSetChevPanelButtonsMsg *msg);
public:
- int _fieldBC;
- int _fieldC0;
- int _fieldC4;
+ Point _startPos;
+ int _chevCode;
public:
CLASSDEF;
- CChevPanel() : _fieldBC(0), _fieldC0(0), _fieldC4(0) {}
+ CChevPanel() : _chevCode(0) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index c146052f10..e6d494ebc8 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -213,8 +213,6 @@ MESSAGE1(CChangeSeasonMsg, CString, season, "Summer");
MESSAGE0(CCheckAllPossibleCodes);
MESSAGE2(CCheckChevCode, int, classNum, 0, uint, chevCode, 0);
MESSAGE1(CChildDragEndMsg, int, value, 0);
-MESSAGE2(CChildDragMoveMsg, int, value1, 0, int, value2, 0);
-MESSAGE2(CChildDragStartMsg, int, value1, 0, int, value2, 0);
MESSAGE0(CClearChevPanelBits);
MESSAGE0(CCorrectMusicPlayedMsg);
MESSAGE0(CCreateMusicPlayerMsg);
@@ -312,7 +310,7 @@ MESSAGE1(CSetChevClassBits, int, classNum, 0);
MESSAGE1(CSetChevFloorBits, int, floorNum, 0);
MESSAGE1(CSetChevLiftBits, int, liftNum, 0);
MESSAGE2(CSetChevPanelBitMsg, int, value1, 0, int, value2, 0);
-MESSAGE1(CSetChevPanelButtonsMsg, int, value, 0);
+MESSAGE1(CSetChevPanelButtonsMsg, int, chevCode, 0);
MESSAGE1(CSetChevRoomBits, int, roomNum, 0);
MESSAGE1(CSetFrameMsg, int, frameNumber, 0);
MESSAGE0(CSetMusicControlsMsg);
diff --git a/engines/titanic/messages/mouse_messages.h b/engines/titanic/messages/mouse_messages.h
index d17bd51c78..e7c419bbdc 100644
--- a/engines/titanic/messages/mouse_messages.h
+++ b/engines/titanic/messages/mouse_messages.h
@@ -179,6 +179,32 @@ public:
}
};
+class CChildDragMoveMsg : public CMessage {
+public:
+ Point _mousePos;
+public:
+ CLASSDEF;
+ CChildDragMoveMsg() : CMessage() {}
+ CChildDragMoveMsg(const Point &pt) : CMessage(), _mousePos(pt) {}
+
+ static bool isSupportedBy(const CTreeItem *item) {
+ return supports(item, _type);
+ }
+};
+
+class CChildDragStartMsg : public CMessage {
+public:
+ Point _mousePos;
+public:
+ CLASSDEF;
+ CChildDragStartMsg() : CMessage() {}
+ CChildDragStartMsg(const Point &pt) : CMessage(), _mousePos(pt) {}
+
+ static bool isSupportedBy(const CTreeItem *item) {
+ return supports(item, _type);
+ }
+};
+
} // End of namespace Titanic
#endif /* TITANIC_MOUSE_MESSAGES_H */