diff options
| author | Paul Gilbert | 2016-04-29 19:29:28 -0400 | 
|---|---|---|
| committer | Paul Gilbert | 2016-07-10 16:37:24 -0400 | 
| commit | 6ec129d188a2b5b86dba6540b38a959bbf8b2491 (patch) | |
| tree | 312a0ffb0e0c91afeec2465c62789bfb9a1c09a9 | |
| parent | 5d087a8fcd709550ec14fc6b01acf045f8d6614b (diff) | |
| download | scummvm-rg350-6ec129d188a2b5b86dba6540b38a959bbf8b2491.tar.gz scummvm-rg350-6ec129d188a2b5b86dba6540b38a959bbf8b2491.tar.bz2 scummvm-rg350-6ec129d188a2b5b86dba6540b38a959bbf8b2491.zip | |
TITANIC: Added PET Conversations enter, PET Timers, and Text Cursor show
| -rw-r--r-- | engines/titanic/pet_control/pet_control.cpp | 20 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_control.h | 19 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_conversations.cpp | 8 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_conversations.h | 5 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_section.cpp | 7 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_section.h | 2 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_text.cpp | 14 | ||||
| -rw-r--r-- | engines/titanic/pet_control/pet_text.h | 6 | 
8 files changed, 75 insertions, 6 deletions
| diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 997d35b681..d67ce543fe 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -46,8 +46,6 @@ CPetControl::CPetControl() : CGameObject(),  		_currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0),  		_activeNPC(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr),  		_drawBounds(20, 350, 620, 480) { -	setup(); -	_timers[0] = _timers[1] = nullptr;  	_sections[PET_INVENTORY] = &_inventory;  	_sections[PET_CONVERSATION] = &_conversations;  	_sections[PET_REMOTE] = &_remote; @@ -487,4 +485,22 @@ void CPetControl::summonNPC(const CString &name, int val) {  	}  } +void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, void *target) { +	stopPetTimer(timerIndex); +	_timers[timerIndex]._id = (timerIndex, firstDuration, duration); +	_timers[timerIndex]._target = target; +	setTimer44(_timers[timerIndex]._id, 0); +} + +void CPetControl::stopPetTimer(uint timerIndex) { +	if (_timers[timerIndex]._target) { +		stopTimer(_timers[timerIndex]._id); +		_timers[timerIndex]._target = nullptr; +	} +} + +void CPetControl::setTimer44(int id, int val) { +	getGameManager()->setTimer44(id, val); +} +  } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index 7e720b7b10..5fbd8a0107 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -43,6 +43,11 @@ enum SummonResult { SUMMON_CANT = 0, SUMMON_PRESENT = 1, SUMMON_CAN = 2 };  class CPetControl : public CGameObject {  	DECLARE_MESSAGE_MAP +	struct PetEventInfo { +		int _id; +		void *_target; +		PetEventInfo() : _id(0), _target(nullptr) {} +	};  private:  	int _fieldC0;  	int _locked; @@ -61,7 +66,7 @@ private:  	CString _string2;  	CRoomItem *_hiddenRoom;  	Rect _drawBounds; -	void *_timers[2]; +	PetEventInfo _timers[2];  private:  	/**  	 * Returns true if the control is in a valid state @@ -94,6 +99,8 @@ private:  	 * Checks whether a designated NPC in present in the current view  	 */  	bool isNPCInView(const CString &name) const; + +	void setTimer44(int id, int val);  protected:  	bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);  	bool MouseDragStartMsg(CMouseDragStartMsg *msg); @@ -267,6 +274,16 @@ public:  	 * Summon an NPC to the player  	 */  	void summonNPC(const CString &name, int val); + +	/** +	 * Start a timer +	 */ +	void startPetTimer(uint timerIndex, uint firstDuration, uint duration, void *target); + +	/** +	 * Stop a timer +	 */ +	void stopPetTimer(uint timerIndex);  };  } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp index d21380c28f..960b325bc0 100644 --- a/engines/titanic/pet_control/pet_conversations.cpp +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -124,7 +124,11 @@ void CPetConversations::save(SimpleFile *file, int indent) const {  }  void CPetConversations::enter(PetArea oldArea) { +	if (_petControl && _petControl->_activeNPC) +		// Start a timer for the NPC +		addNPCTimer(); +	_textInput.showCursor(-2);  }  void CPetConversations::leave() { @@ -229,6 +233,10 @@ void CPetConversations::summonNPC(const CString &name) {  	}  } +void CPetConversations::addNPCTimer() { +	_petControl->startPetTimer(1, 1000, 1000, this); +} +  bool CPetConversations::handleKey(const Common::KeyState &keyState) {  	switch (keyState.keycode) {  	case Common::KEYCODE_UP: diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h index 9247b44a42..ca85e14583 100644 --- a/engines/titanic/pet_control/pet_conversations.h +++ b/engines/titanic/pet_control/pet_conversations.h @@ -97,6 +97,11 @@ private:  	void summonNPC(const CString &name);  	/** +	 * Adds an NPC timer +	 */ +	void addNPCTimer(); + +	/**  	 * Handle a keypress  	 */  	bool handleKey(const Common::KeyState &keyState); diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp index afdbc9fdd8..213c93e78d 100644 --- a/engines/titanic/pet_control/pet_section.cpp +++ b/engines/titanic/pet_control/pet_section.cpp @@ -46,8 +46,11 @@ void CPetSection::proc25() {  	error("TODO");  } -void CPetSection::proc27() { -	error("TODO"); +void CPetSection::proc27(int duration) { +	if (duration > 0) +		_petControl->startPetTimer(0, duration, 0, this); +	else +		proc28();  }  void CPetSection::proc28() { diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h index 720e5323cf..d582f38f0d 100644 --- a/engines/titanic/pet_control/pet_section.h +++ b/engines/titanic/pet_control/pet_section.h @@ -146,7 +146,7 @@ public:  	 */  	virtual CPetText *getText() { return nullptr; } -	virtual void proc27(); +	virtual void proc27(int duration);  	virtual void proc28();  	virtual void proc29();  	virtual void proc30(); diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 87a6868d92..7e5f329632 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -388,4 +388,18 @@ bool CPetText::handleKey(char c) {  	return false;  } +void CPetText::showCursor(int mode) { +	CScreenManager *screenManager = CScreenManager::setCurrent(); +	_textCursor = screenManager->_textCursor; +	if (_textCursor) { +		_textCursor->setPos(Point(0, 0)); +		_textCursor->setSize(Point(2, 10)); +		_textCursor->setColor(0, 0, 0); +		_textCursor->setBlinkRate(300); +		_textCursor->setMode(mode); +		_textCursor->setBounds(_bounds); +		_textCursor->show(); +	} +} +  } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index dd1547bff4..2b68b743c2 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -230,6 +230,12 @@ public:  	 * @returns		True if the Enter key was pressed  	 */  	bool handleKey(char c); + +	/** +	 * Attaches the current system cursor to the text control, +	 * and give it suitable defaults +	 */ +	void showCursor(int mode);  };  } // End of namespace Titanic | 
