diff options
| -rw-r--r-- | engines/pink/audio_info_mgr.cpp | 88 | ||||
| -rw-r--r-- | engines/pink/audio_info_mgr.h | 61 | ||||
| -rw-r--r-- | engines/pink/objects/actors/actor.cpp | 5 | ||||
| -rw-r--r-- | engines/pink/objects/actors/actor.h | 2 | ||||
| -rw-r--r-- | engines/pink/objects/actors/audio_info_pda_button.cpp | 50 | ||||
| -rw-r--r-- | engines/pink/objects/actors/audio_info_pda_button.h | 20 | ||||
| -rw-r--r-- | engines/pink/objects/actors/lead_actor.cpp | 47 | ||||
| -rw-r--r-- | engines/pink/objects/actors/lead_actor.h | 9 | ||||
| -rw-r--r-- | engines/pink/objects/actors/supporting_actor.cpp | 4 | ||||
| -rw-r--r-- | engines/pink/objects/actors/supporting_actor.h | 1 | ||||
| -rw-r--r-- | engines/pink/pink.cpp | 12 | ||||
| -rw-r--r-- | engines/pink/pink.h | 2 | 
12 files changed, 271 insertions, 30 deletions
| diff --git a/engines/pink/audio_info_mgr.cpp b/engines/pink/audio_info_mgr.cpp new file mode 100644 index 0000000000..6f559fe005 --- /dev/null +++ b/engines/pink/audio_info_mgr.cpp @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "pink/audio_info_mgr.h" +#include "pink/archive.h" +#include "pink/objects/actors/lead_actor.h" + +namespace Pink { + +AudioInfoMgr::AudioInfoMgr(LeadActor *lead) +	: _lead(lead) {} + +void AudioInfoMgr::loadState(Archive &archive) { +	_aboutWhom = archive.readString(); +} + +void AudioInfoMgr::saveState(Archive &archive) { +	archive.writeString(_aboutWhom); +} + +void AudioInfoMgr::start(Actor *actor) { +	if (!actor->getPDALink().empty()) { +		_aboutWhom = actor->getName(); +		playAudio(); +		showPDAButton(); +	} else +		stop(); +} + +void AudioInfoMgr::stop() { +	if (!_aboutWhom.empty()) { +		stopAudio(); +		hidePDAButton(); +		_aboutWhom.clear(); +	} +} + +void AudioInfoMgr::onLeftClick() { +	Actor *actor = _lead->findActor(_aboutWhom); +	assert(actor); +	_lead->loadPDA(actor->getPDALink()); +	stopAudio(); +} + +void AudioInfoMgr::playAudio() { +	Actor *audioInfo = _lead->findActor("AudioInfo"); +	assert(audioInfo); +	audioInfo->setAction(_aboutWhom); +} + +void AudioInfoMgr::stopAudio() { +	Actor *audioInfo = _lead->findActor("AudioInfo"); +	assert(audioInfo); +	audioInfo->setAction("Idle"); +} + +void AudioInfoMgr::showPDAButton() { +	Actor *pdaButton = _lead->findActor("PDAButton"); +	assert(pdaButton); +	pdaButton->setAction("Show"); +} + +void AudioInfoMgr::hidePDAButton() { +	Actor *pdaButton = _lead->findActor("PDAButton"); +	assert(pdaButton); +	pdaButton->setAction("Hide"); +} + +} // End of namespace Pink diff --git a/engines/pink/audio_info_mgr.h b/engines/pink/audio_info_mgr.h new file mode 100644 index 0000000000..655f1756d6 --- /dev/null +++ b/engines/pink/audio_info_mgr.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef PINK_AUDIO_INFO_MGR_H +#define PINK_AUDIO_INFO_MGR_H + +#include "common/str.h" + +namespace Pink { + +class Actor; +class LeadActor; +class Archive; + +class AudioInfoMgr { +public: +	AudioInfoMgr(LeadActor *lead); + +	void loadState(Archive &archive); +	void saveState(Archive &archive); + +	void start(Actor *actor); +	void stop(); + +	void onLeftClick(); + +private: +	void playAudio(); +	void stopAudio(); + +	void showPDAButton(); +	void hidePDAButton(); + +private: +	Common::String _aboutWhom; +	LeadActor *_lead; +}; + +} // End of namespace Pink + + +#endif diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index 8954d6c594..42c9e2d992 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -138,4 +138,9 @@ InventoryMgr *Actor::getInventoryMgr() const {  	return _page->getModule()->getInventoryMgr();  } +const Common::String &Actor::getPDALink() const { +	static const Common::String empty; +	return empty; +} +  } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index 9d00f6a364..7927c1bfb5 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -78,6 +78,8 @@ public:  	InventoryMgr *getInventoryMgr() const; +	virtual const Common::String &getPDALink() const; +  	virtual const Common::String &getLocation() const;  	void setAction(const Common::String &name) { setAction(findAction(name)); } diff --git a/engines/pink/objects/actors/audio_info_pda_button.cpp b/engines/pink/objects/actors/audio_info_pda_button.cpp new file mode 100644 index 0000000000..a5505de0f6 --- /dev/null +++ b/engines/pink/objects/actors/audio_info_pda_button.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "pink/objects/actors/audio_info_pda_button.h" +#include "pink/objects/actors/lead_actor.h" +#include "pink/objects/pages/page.h" + +namespace Pink { + +void AudioInfoPDAButton::toConsole()  { +	debug("AudioInfoPDAButton: _name = %s", _name.c_str()); +	for (uint i = 0; i < _actions.size(); ++i) { +		_actions[i]->toConsole(); +	} +} + +void AudioInfoPDAButton::onMouseOver(Common::Point point, CursorMgr *mgr)  { +	mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); +} + +void AudioInfoPDAButton::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) { +	onMouseOver(point, cursorMgr); +} + +bool AudioInfoPDAButton::onLeftClickMessage() { +	AudioInfoMgr *audioInfoMgr = _page->getLeadActor()->getAudioInfoMgr(); +	audioInfoMgr->onLeftClick(); +	return true; +} + +} // End of namespace Pink diff --git a/engines/pink/objects/actors/audio_info_pda_button.h b/engines/pink/objects/actors/audio_info_pda_button.h index f54edd66ee..4631bafd39 100644 --- a/engines/pink/objects/actors/audio_info_pda_button.h +++ b/engines/pink/objects/actors/audio_info_pda_button.h @@ -34,20 +34,12 @@ namespace Pink {  class AudioInfoPDAButton : public Actor {  public: -	void toConsole() override { -		debug("AudioInfoPDAButton: _name = %s", _name.c_str()); -		for (uint i = 0; i < _actions.size(); ++i) { -			_actions[i]->toConsole(); -		} -	} - -	void onMouseOver(Common::Point point, CursorMgr *mgr) override { -		mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); -	} - -	void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override { -		onMouseOver(point, cursorMgr); -	} +	void toConsole(); + +	void onMouseOver(Common::Point point, CursorMgr *mgr); +	void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override; + +	bool onLeftClickMessage() override;  };  } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 33b5bd5970..1db74d2599 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -36,7 +36,7 @@ namespace Pink {  LeadActor::LeadActor()  		: _state(kReady), _nextState(kReady), _isHaveItem(false),  		  _recipient(nullptr), _cursorMgr(nullptr), _walkMgr(nullptr), -		  _sequencer(nullptr) {} +		  _sequencer(nullptr), _audioInfoMgr(this) {}  void LeadActor::deserialize(Archive &archive) {  	_state = kReady; @@ -156,7 +156,7 @@ void LeadActor::update() {  void LeadActor::loadPDA(const Common::String &pageName) {  	if (_state != kPDA) {  		if (_state == kMoving) -			setReadyAfterWalk(); +			setNextStateReady();  		if (_state != kInventory)  			_page->pause(true); @@ -177,7 +177,7 @@ void LeadActor::onKeyboardButtonClick(Common::KeyCode code) {  	case kMoving:  		switch (code) {  		case Common::KEYCODE_ESCAPE: -			setReadyAfterWalk(); +			setNextStateReady();  			// Fall Through intended  		case Common::KEYCODE_SPACE:  			_walkMgr->skip(); @@ -215,17 +215,21 @@ void LeadActor::onLeftButtonClick(const Common::Point point) {  		Actor *clickedActor = getActorByPoint(point);  		if (this == clickedActor) { +			_audioInfoMgr.stop();  			onClick(); -			return;  		} +		else if (isInteractingWith(clickedActor)) { +			_recipient = clickedActor; +			if (!startWalk()) { +				_audioInfoMgr.stop(); +				if (_isHaveItem) +					sendUseClickMessage(clickedActor); +				else +					sendLeftClickMessage(clickedActor); +			} +		} else +			clickedActor->onLeftClickMessage(); -		_recipient = clickedActor; -		if (isInteractingWith(clickedActor) && !startWalk()) { -			if (_isHaveItem) -				sendUseClickMessage(clickedActor); -			else -				sendLeftClickMessage(clickedActor); -		}  		break;  	}  	case kPDA: @@ -239,6 +243,19 @@ void LeadActor::onLeftButtonClick(const Common::Point point) {  	}  } +void LeadActor::onRightButtonClick(const Common::Point point) { +	if (_state == kReady || _state == kMoving) { +		Actor *clickedActor = getActorByPoint(point); +		if (isInteractingWith(clickedActor)) { +			_audioInfoMgr.start(clickedActor); +		} + +		if (_state == kMoving) +			setNextStateReady(); +	} +} + +  void LeadActor::onMouseMove(Common::Point point) {  	if (_state != kPDA)  		updateCursor(point); @@ -259,7 +276,7 @@ void LeadActor::onClick() {  					 kUnk_Loading : kReady;  	} else {  		if (_state == kMoving) -			setReadyAfterWalk(); +			setNextStateReady();  		startInventory(0);  	}  } @@ -396,11 +413,15 @@ bool LeadActor::startWalk() {  	return false;  } -void LeadActor::setReadyAfterWalk() { +void LeadActor::setNextStateReady() {  	_recipient = nullptr;  	_nextState = kReady;  } +Actor *LeadActor::findActor(const Common::String &name) { +	return _page->findActor(name); +} +  void ParlSqPink::toConsole() {  	debug("ParlSqPink: _name = %s", _name.c_str());  	for (uint i = 0; i < _actions.size(); ++i) { diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index 43ad2ee05a..3e585a62b3 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -27,6 +27,7 @@  #include "common/keyboard.h"  #include "pink/objects/actors/actor.h" +#include "pink/audio_info_mgr.h"  namespace Pink { @@ -88,8 +89,12 @@ public:  	State getState() const { return _state; } +	AudioInfoMgr *getAudioInfoMgr() { return &_audioInfoMgr; } +  	Actor *getActorByPoint(const Common::Point point); +	Actor *findActor(const Common::String &name); +  protected:  	void forceUpdateCursor(); @@ -103,7 +108,7 @@ protected:  	void startInventory(bool paused);  	bool startWalk(); -	void setReadyAfterWalk(); +	void setNextStateReady();  	Actor *_recipient; @@ -111,6 +116,8 @@ protected:  	WalkMgr *_walkMgr;  	Sequencer *_sequencer; +	AudioInfoMgr _audioInfoMgr; +  	State _state;  	State _nextState;  	State _stateCopy; diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp index ea2a49e9a5..826226712b 100644 --- a/engines/pink/objects/actors/supporting_actor.cpp +++ b/engines/pink/objects/actors/supporting_actor.cpp @@ -88,4 +88,8 @@ const Common::String &SupportingActor::getLocation() const {  	return _location;  } +const Common::String &SupportingActor::getPDALink() const { +	return _pdaLink; +} +  } // End of namespace Pink diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h index 1d200d2945..7f53a3e9c0 100644 --- a/engines/pink/objects/actors/supporting_actor.h +++ b/engines/pink/objects/actors/supporting_actor.h @@ -47,6 +47,7 @@ public:  	bool onLeftClickMessage() override;  	bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) override; +	const Common::String &getPDALink() const override;  	const Common::String &getLocation() const override;  private: diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index d8e2738d68..dfa072bfdc 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -74,7 +74,7 @@ Common::Error PinkEngine::init() {  	const Common::String orbName = _desc.filesDescriptions[0].fileName;  	const Common::String broName = _desc.filesDescriptions[1].fileName; -	if (strcmp(_desc.gameId, kPeril) == 0) +	if (isPeril())  		_bro = new BroFile();  	else  		debug("This game doesn't need to use bro"); @@ -118,6 +118,10 @@ Common::Error Pink::PinkEngine::run() {  			case Common::EVENT_LBUTTONDOWN:  				_actor->onLeftButtonClick(event.mouse);  				break; +			case Common::EVENT_RBUTTONDOWN: +				if (isPeril()) +					_actor->onRightButtonClick(event.mouse); +				break;  			case Common::EVENT_KEYDOWN:  					_actor->onKeyboardButtonClick(event.kbd.keycode);  				break; @@ -196,7 +200,7 @@ bool PinkEngine::checkValueOfVariable(Common::String &variable, Common::String &  bool PinkEngine::loadCursors() {  	Common::PEResources exeResources; -	bool isPokus = !strcmp(_desc.gameId, kPokus); +	bool isPokus = !isPeril();  	Common::String fileName = isPokus ? _desc.filesDescriptions[1].fileName : _desc.filesDescriptions[2].fileName;  	if (!exeResources.loadFromEXE(fileName))  		return false; @@ -312,6 +316,10 @@ void PinkEngine::pauseEngineIntern(bool pause) {  	_system->showMouse(!pause);  } +bool PinkEngine::isPeril() { +	return !strcmp(_desc.gameId, "peril"); +} +  Common::String generateSaveName(int slot, const char *gameId) {  	return Common::String::format("%s.s%02d", gameId, slot);  } diff --git a/engines/pink/pink.h b/engines/pink/pink.h index 299de3faeb..cd05152127 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -96,6 +96,8 @@ public:  	virtual Common::Error saveGameState(int slot, const Common::String &desc);  	virtual bool canSaveGameStateCurrently(); +	bool isPeril(); +  	void load(Archive &archive);  	void initModule(const Common::String &moduleName, const Common::String &pageName, Archive *saveFile);  	void changeScene(Page *page); | 
