aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-26 07:23:15 -0400
committerPaul Gilbert2016-07-15 19:25:06 -0400
commit0146a3c6b6bdb16eef6f46e116b0d9fe9883858f (patch)
tree01ad3515f6a5ce5a26f2e4aea6b7c11776d7a5b9 /engines/titanic/pet_control
parent04afc633794035cfcc0cb7030113d7750a7dbae3 (diff)
downloadscummvm-rg350-0146a3c6b6bdb16eef6f46e116b0d9fe9883858f.tar.gz
scummvm-rg350-0146a3c6b6bdb16eef6f46e116b0d9fe9883858f.tar.bz2
scummvm-rg350-0146a3c6b6bdb16eef6f46e116b0d9fe9883858f.zip
TITANIC: Added remaining CPetControl methods
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r--engines/titanic/pet_control/pet_control.cpp39
-rw-r--r--engines/titanic/pet_control/pet_control.h80
-rw-r--r--engines/titanic/pet_control/pet_conversations.cpp6
-rw-r--r--engines/titanic/pet_control/pet_conversations.h20
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.cpp2
-rw-r--r--engines/titanic/pet_control/pet_section.cpp2
-rw-r--r--engines/titanic/pet_control/pet_section.h10
7 files changed, 102 insertions, 57 deletions
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index f5c5647688..7e5cd20441 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -43,9 +43,9 @@ BEGIN_MESSAGE_MAP(CPetControl, CGameObject)
END_MESSAGE_MAP()
CPetControl::CPetControl() : CGameObject(),
- _currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0),
- _activeNPC(nullptr), _remoteTarget(nullptr), _hiddenRoom(nullptr),
- _drawBounds(20, 350, 620, 480) {
+ _currentArea(PET_CONVERSATION), _inputLockCount(0), _areaLockCount(0),
+ _areaChangeType(-1), _activeNPC(nullptr), _remoteTarget(nullptr),
+ _hiddenRoom(nullptr), _drawBounds(20, 350, 620, 480) {
_sections[PET_INVENTORY] = &_inventory;
_sections[PET_CONVERSATION] = &_conversations;
_sections[PET_REMOTE] = &_remote;
@@ -81,7 +81,7 @@ void CPetControl::load(SimpleFile *file) {
}
void CPetControl::setup() {
- warning("TODO: CPetControl::setup");
+ _conversations.setup(this);
_rooms.setup(this);
_remote.setup(this);
_inventory.setup(this);
@@ -130,9 +130,9 @@ void CPetControl::draw(CScreenManager *screenManager) {
bounds.constrain(gameManager->_bounds);
if (!bounds.isEmpty()) {
- if (_fieldC8 >= 0) {
- _inventory.changed(_fieldC8);
- _fieldC8 = -1;
+ if (_areaChangeType >= 0) {
+ _inventory.changed(_areaChangeType);
+ _areaChangeType = -1;
}
_frame.drawFrame(screenManager);
@@ -188,13 +188,8 @@ void CPetControl::resetActiveNPC() {
_activeNPCName = "";
}
-bool CPetControl::fn1(int val) {
- warning("TODO: CPetControl::fn1");
- return false;
-}
-
PetArea CPetControl::setArea(PetArea newArea) {
- if (newArea == _currentArea || !isUnlocked())
+ if (newArea == _currentArea || !isAreaActive())
return _currentArea;
// Signal the currently active area that it's being left
@@ -249,11 +244,11 @@ bool CPetControl::containsPt(const Common::Point &pt) const {
}
bool CPetControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
- if (!containsPt(msg->_mousePos) || getC0())
+ if (!containsPt(msg->_mousePos) || isInputLocked())
return false;
bool result = false;
- if (isUnlocked())
+ if (isAreaActive())
result = _frame.MouseButtonDownMsg(msg);
if (!result) {
@@ -265,7 +260,7 @@ bool CPetControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
}
bool CPetControl::MouseDragStartMsg(CMouseDragStartMsg *msg) {
- if (!containsPt(msg->_mousePos) || getC0())
+ if (!containsPt(msg->_mousePos) || isInputLocked())
return false;
return _sections[_currentArea]->MouseDragStartMsg(msg);
@@ -280,11 +275,11 @@ bool CPetControl::MouseDragEndMsg(CMouseDragEndMsg *msg) {
}
bool CPetControl::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
- if (!containsPt(msg->_mousePos) || getC0())
+ if (!containsPt(msg->_mousePos) || isInputLocked())
return false;
bool result = false;
- if (isUnlocked())
+ if (isAreaActive())
result = _frame.MouseButtonUpMsg(msg);
if (!result)
@@ -295,21 +290,21 @@ bool CPetControl::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
}
bool CPetControl::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
- if (!containsPt(msg->_mousePos) || getC0())
+ if (!containsPt(msg->_mousePos) || isInputLocked())
return false;
return _sections[_currentArea]->MouseDoubleClickMsg(msg);
}
bool CPetControl::KeyCharMsg(CKeyCharMsg *msg) {
- if (getC0())
+ if (isInputLocked())
return false;
return _sections[_currentArea]->KeyCharMsg(msg);
}
bool CPetControl::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) {
- if (getC0())
+ if (isInputLocked())
return false;
bool result = _sections[_currentArea]->VirtualKeyCharMsg(msg);
@@ -498,7 +493,7 @@ void CPetControl::summonNPC(const CString &name, int val) {
}
}
-void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, void *target) {
+void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target) {
stopPetTimer(timerIndex);
_timers[timerIndex]._id = addTimer(timerIndex, firstDuration, duration);
_timers[timerIndex]._target = target;
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 5e47f3299b..c3afb7862b 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -46,13 +46,13 @@ class CPetControl : public CGameObject {
DECLARE_MESSAGE_MAP
struct PetEventInfo {
int _id;
- void *_target;
+ CPetSection *_target;
PetEventInfo() : _id(0), _target(nullptr) {}
};
private:
- int _fieldC0;
- int _locked;
- int _fieldC8;
+ int _inputLockCount;
+ int _areaLockCount;
+ int _areaChangeType;
CPetSection *_sections[7];
CPetConversations _conversations;
CPetInventory _inventory;
@@ -163,13 +163,6 @@ public:
void resetRemoteTarget();
/**
- * Resets the Active NPC
- */
- void resetActiveNPC();
-
- bool fn1(int val);
-
- /**
* Set the remote target
*/
void setRemoteTarget(CGameObject *item);
@@ -194,10 +187,6 @@ public:
*/
void highlightGlyph(int id);
- /**
- * Returns true if the PET is currently unlocked
- */
- bool isUnlocked() const { return _locked == 0; }
/**
* Returns a game object used by the PET by name from within the
@@ -274,7 +263,11 @@ public:
*/
void moveToHiddenRoom(CTreeItem *item);
- void setC8(int val) { _fieldC8 = val; }
+ /**
+ * Sets a change for the PET Area's glyphs. Only applicable when
+ * the Inventory is the active tab
+ */
+ void setAreaChangeType(int changeType) { _areaChangeType = changeType; }
/**
* Play a sound
@@ -297,9 +290,9 @@ public:
void summonNPC(const CString &name, int val);
/**
- * Start a timer
+ * Start a timer for a Pet Area
*/
- void startPetTimer(uint timerIndex, uint firstDuration, uint duration, void *target);
+ void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target);
/**
* Stop a timer
@@ -312,15 +305,60 @@ public:
*/
CString getFullViewName();
- bool getC0() const { return _fieldC0 > 0; }
- void incC0() { ++_fieldC0; }
- void decC0() { --_fieldC0; }
+ /**
+ * Returns true if all input is currently locked (disabled)
+ */
+ bool isInputLocked() const { return _inputLockCount > 0; }
+
+ /**
+ * Increments the input locked count
+ */
+ void incInputLocks() { ++_inputLockCount; }
+
+ /**
+ * Decremenst the input locked count
+ */
+ void decInputLocks() { --_inputLockCount; }
+
+ /**
+ * Returns true if the PET is currently unlocked
+ */
+ bool isAreaActive() const { return _areaLockCount == 0; }
+
+ /**
+ * Increment the number of PET area (tab) locks
+ */
+ void incAreaLocks() { ++_areaLockCount; }
+
+ /**
+ * Decrement the number of PET area (tab) locks
+ */
+ void decAreaLocks() {
+ _areaLockCount = MAX(_areaLockCount - 1, 0);
+ }
bool isSuccUBusActive() const;
/*--- CPetConversations methods ---*/
/**
+ * Sets the active NPC
+ */
+ void setActiveNPC(const CString &name) {
+ _conversations.setActiveNPC(name);
+ }
+
+ /**
+ * Resets the Active NPC
+ */
+ void resetActiveNPC();
+
+ /**
+ * Resets the conversation dials back to 0 position
+ */
+ void resetDials0() { _conversations.resetDials0(); }
+
+ /**
* Resets the dial display in the conversation tab to reflect new values
*/
void convResetDials(int flag = 1);
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp
index 276b99e610..3d239bb36b 100644
--- a/engines/titanic/pet_control/pet_conversations.cpp
+++ b/engines/titanic/pet_control/pet_conversations.cpp
@@ -254,9 +254,9 @@ void CPetConversations::leave() {
stopNPCTimer();
}
-void CPetConversations::proc25(int val) {
+void CPetConversations::timerExpired(int val) {
if (val == 1) {
- proc25(val);
+ CPetSection::timerExpired(val);
} else {
CString name = _field418 ? _npcName : getActiveNPCName();
@@ -315,7 +315,7 @@ void CPetConversations::setNPC(const CString &name) {
startNPCTimer();
}
-void CPetConversations::proc35() {
+void CPetConversations::resetNPC() {
stopNPCTimer();
resetDials("0");
}
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index 4deab3eb5f..876f3d78a9 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -125,11 +125,6 @@ private:
void textLineEntered(const CString &textLine);
/**
- * Set the active NPC
- */
- void setActiveNPC(const CString &name);
-
- /**
* Updates one of the dials with data from a given NPC
*/
void updateDial(uint dialNum, const CString &npcName);
@@ -211,7 +206,10 @@ public:
*/
virtual void leave();
- virtual void proc25(int val);
+ /**
+ * Called when a previously set up PET timer expires
+ */
+ virtual void timerExpired(int val);
/**
* Display a title for an NPC
@@ -223,7 +221,10 @@ public:
*/
virtual void setNPC(const CString &name);
- virtual void proc35();
+ /**
+ * Resets the active NPC
+ */
+ virtual void resetNPC();
/**
* Show the text cursor
@@ -236,6 +237,11 @@ public:
virtual void hideCursor();
/**
+ * Set the active NPC
+ */
+ void setActiveNPC(const CString &name);
+
+ /**
* Resets the dials with the data for the currently active NPC
*/
void resetDials();
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index 8eeccbbd1d..deea8eebca 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -133,7 +133,7 @@ bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg
_item = nullptr;
_background = nullptr;
_field34 = 0;
- petControl->setC8(1);
+ petControl->setAreaChangeType(1);
return true;
} else {
petControl->addToInventory(carryParcel);
diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp
index a29a8f8115..50d6c7615c 100644
--- a/engines/titanic/pet_control/pet_section.cpp
+++ b/engines/titanic/pet_control/pet_section.cpp
@@ -48,7 +48,7 @@ void CPetSection::displayMessage(const CString &msg) {
}
}
-void CPetSection::proc25(int val) {
+void CPetSection::timerExpired(int val) {
if (!val) {
removeText();
_petControl->makeDirty();
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 5ae86b785c..58938c56c0 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -161,7 +161,10 @@ public:
*/
virtual void enterRoom(CRoomItem *room) {}
- virtual void proc25(int val);
+ /**
+ * Called when a previously set up PET timer expires
+ */
+ virtual void timerExpired(int val);
/**
* Get a reference to the tooltip text associated with the section
@@ -205,7 +208,10 @@ public:
*/
virtual void setNPC(const CString &name) {}
- virtual void proc35() {}
+ /**
+ * Resets the active NPC
+ */
+ virtual void resetNPC() {}
/**
* Show the text cursor