diff options
| -rw-r--r-- | engines/bladerunner/adq.cpp | 151 | ||||
| -rw-r--r-- | engines/bladerunner/adq.h | 74 | ||||
| -rw-r--r-- | engines/bladerunner/bladerunner.cpp | 54 | ||||
| -rw-r--r-- | engines/bladerunner/bladerunner.h | 2 | ||||
| -rw-r--r-- | engines/bladerunner/item.cpp | 4 | ||||
| -rw-r--r-- | engines/bladerunner/item.h | 2 | ||||
| -rw-r--r-- | engines/bladerunner/items.cpp | 24 | ||||
| -rw-r--r-- | engines/bladerunner/items.h | 1 | ||||
| -rw-r--r-- | engines/bladerunner/module.mk | 1 | ||||
| -rw-r--r-- | engines/bladerunner/scene.cpp | 3 | ||||
| -rw-r--r-- | engines/bladerunner/script/script.cpp | 27 | ||||
| -rw-r--r-- | engines/bladerunner/script/script.h | 2 | 
12 files changed, 299 insertions, 46 deletions
| diff --git a/engines/bladerunner/adq.cpp b/engines/bladerunner/adq.cpp new file mode 100644 index 0000000000..7e77d64dd1 --- /dev/null +++ b/engines/bladerunner/adq.cpp @@ -0,0 +1,151 @@ +#include "bladerunner/adq.h" + +#include "bladerunner/bladerunner.h" + +#include "bladerunner/actor.h" +#include "bladerunner/audio_speech.h" +#include "bladerunner/scene.h" + +#include "script/script.h" + +namespace BladeRunner { + +ADQ::ADQEntry::ADQEntry() { +	this->_isNotPause = false; +	this->_isPause = false; +	this->_actorId = -1; +	this->_delay = -1; +	this->_sentenceId = -1; +	this->_animationMode = -1; +} + +ADQ::ADQ(BladeRunnerEngine *vm) { +	_vm = vm; +	clear(); +} + +ADQ::~ADQ() { +} + +void ADQ::add(int actorId, int sentenceId, int animationMode) { +	if (actorId == 0 || actorId == 99) { +		animationMode = -1; +	} +	if (_entries.size() < 25) { +		ADQEntry entry; +		entry._isNotPause = true; +		entry._isPause = false; +		entry._actorId = actorId; +		entry._sentenceId = sentenceId; +		entry._animationMode = animationMode; +		entry._delay = -1; + +		_entries.push_back(entry); +	} +} + +void ADQ::addPause(int delay) { +	if (_entries.size() < 25) { +		ADQEntry entry; +		entry._isNotPause = false; +		entry._isPause = true; +		entry._actorId = -1; +		entry._sentenceId = -1; +		entry._animationMode = -1; +		entry._delay = delay; + +		_entries.push_back(entry); +	} +} + +void ADQ::flush(int a1, bool callScript) { +	if (_isNotPause && _vm->_audioSpeech->isPlaying()) { +		_vm->_audioSpeech->stopSpeech(); +		if (_animationModePrevious >= 0) { +			_vm->_actors[_actorId]->changeAnimationMode(_animationModePrevious, false); +			_animationModePrevious = -1; +		} +		_isNotPause = false; +		_actorId = -1; +		_sentenceId = -1; +		_animationMode = -1; +	} +	if (_isPause) { +		_isPause = false; +		_delay = 0; +		_timeLast = 0; +	} +	clear(); +	if (callScript) { +		_vm->_script->DialogueQueueFlushed(a1); +	} +} + +void ADQ::tick() { +	if (!_vm->_audioSpeech->isPlaying()) { +		if (_isPause) { +			int time = _vm->getTotalPlayTime(); +			int timeDiff = time - _timeLast; +			_timeLast = time; +			_delay -= timeDiff; +			if (_delay > 0) { +				return; +			} +			_isPause = false; +			_delay = 0; +			_timeLast = 0; +			if (_entries.empty()) { +				flush(0, true); +			} +		} +		if (_isNotPause) { +			if (_animationModePrevious >= 0) { +				_vm->_actors[_actorId]->changeAnimationMode(_animationModePrevious, false); +				_animationModePrevious = -1; +			} +			_isNotPause = false; +			_actorId = -1; +			_sentenceId = -1; +			_animationMode = -1; +			if (_entries.empty()) { +				flush(0, true); +			} +		} +		if (!_entries.empty()) { +			ADQEntry firstEntry = _entries.remove_at(0); +			if (firstEntry._isNotPause) { +				_animationMode = firstEntry._animationMode; +				if (_vm->_actors[firstEntry._actorId]->getSetId() != _vm->_scene->getSetId()) { +					_animationMode = -1; +				} +				_vm->_actors[firstEntry._actorId]->speechPlay(firstEntry._sentenceId, false); +				_isNotPause = true; +				_actorId = firstEntry._actorId; +				_sentenceId = firstEntry._sentenceId; +				if (_animationMode >= 0) { +					_animationModePrevious = _vm->_actors[firstEntry._actorId]->getAnimationMode(); +					_vm->_actors[firstEntry._actorId]->changeAnimationMode(_animationMode, false); +				} else { +					_animationModePrevious = -1; +				} +			} else if (firstEntry._isPause) { +				_isPause = true; +				_delay = firstEntry._delay; +				_timeLast = _vm->getTotalPlayTime(); +			} +		} +	} +} + +void ADQ::clear() { +	_entries.clear(); +	_isNotPause = false; +	_actorId = -1; +	_sentenceId = -1; +	_animationMode = -1; +	_animationModePrevious = -1; +	_isPause = false; +	_delay = 0; +	_timeLast = 0; +} +} // End of namespace BladeRunner diff --git a/engines/bladerunner/adq.h b/engines/bladerunner/adq.h new file mode 100644 index 0000000000..20a4c191e2 --- /dev/null +++ b/engines/bladerunner/adq.h @@ -0,0 +1,74 @@ +/* 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 BLADERUNNER_ADQ_H +#define BLADERUNNER_ADQ_H +#include "common/array.h" + +namespace BladeRunner { + +class BladeRunnerEngine; + +// actor dialogue queue?? +class ADQ {  +	BladeRunnerEngine *_vm; + +	class ADQEntry { +	public: +		bool _isNotPause; +		bool _isPause; +		int _actorId; +		int _sentenceId; +		int _animationMode; +		int _delay; + +		ADQEntry(); +	}; + +	Common::Array<ADQEntry> _entries; + +	bool     _isNotPause; +	int      _actorId; +	int      _sentenceId; +	int      _animationMode; +	int      _animationModePrevious; +	bool     _isPause; +	int      _delay; +	int      _timeLast; + + +public: +	ADQ(BladeRunnerEngine *vm); +	~ADQ(); + +	void add(int actorId, int speechId, int animationMode); +	void addPause(int delay); +	void flush(int a1, bool callScript); +	void tick(); + +private: +	void clear(); +}; + +} // End of namespace BladeRunner + +#endif diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 663d17dda9..5320f9972c 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -24,6 +24,7 @@  #include "bladerunner/bladerunner.h"  #include "bladerunner/actor.h" +#include "bladerunner/adq.h"  #include "bladerunner/ambient_sounds.h"  #include "bladerunner/audio_player.h"  #include "bladerunner/audio_speech.h" @@ -68,11 +69,12 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst)  	_gameIsRunning  = true;  	_playerLosesControlCounter = 0; -	_clues = NULL; +	_clues = nullptr;  	_script = new Script(this);  	_settings = new Settings(this);  	_lights = new Lights(this);  	_combat = new Combat(this); +	_adq = new ADQ(this);  	_walkSoundId = -1;  	_walkSoundVolume = 0; @@ -99,7 +101,10 @@ BladeRunnerEngine::~BladeRunnerEngine() {  	// delete[] _zBuffer1;  	// delete[] _zBuffer2; - +	 +	delete _adq; +	delete _combat; +	delete _lights;  	delete _settings;  	delete _script;  } @@ -345,7 +350,7 @@ void BladeRunnerEngine::shutdown() {  	// TODO: Shutdown Esper  	delete _mouse; -	_mouse = 0; +	_mouse = nullptr;  	for (uint i = 0; i != _shapes.size(); ++i) {  		delete _shapes[i]; @@ -359,38 +364,38 @@ void BladeRunnerEngine::shutdown() {  		if (_chapters->hasOpenResources())  			_chapters->closeResources();  		delete _chapters; -		_chapters = 0; +		_chapters = nullptr;  	}  	delete _clues; -	_clues = 0; +	_clues = nullptr;  	delete _sliceRenderer; -	_sliceRenderer = 0; +	_sliceRenderer = nullptr;  	delete _sliceAnimations; -	_sliceAnimations = 0; +	_sliceAnimations = nullptr;  	delete _textActorNames; -	_textActorNames = 0; +	_textActorNames = nullptr;  	delete _textCrimes; -	_textCrimes = 0; +	_textCrimes = nullptr;  	delete _textCluetype; -	_textCluetype = 0; +	_textCluetype = nullptr;  	delete _textKIA; -	_textKIA = 0; +	_textKIA = nullptr;  	delete _textSpindest; -	_textSpindest = 0; +	_textSpindest = nullptr;  	delete _textVK; -	_textVK = 0; +	_textVK = nullptr;  	delete _textOptions; -	_textOptions = 0; +	_textOptions = nullptr;  	// TODO: Delete dialogue menu @@ -418,26 +423,26 @@ void BladeRunnerEngine::shutdown() {  	// TODO: Delete KIA6PT.FON  	delete _items; -	_items = 0; +	_items = nullptr;  	delete _gameFlags; -	_gameFlags = 0; +	_gameFlags = nullptr;  	delete _view; -	_view = 0; +	_view = nullptr;  	delete _sceneObjects; -	_sceneObjects = 0; +	_sceneObjects = nullptr;  	// TODO: Delete sine and cosine lookup tables  	// TODO: Unload AI dll  	delete[] _gameVars; -	_gameVars = 0; +	_gameVars = nullptr;  	delete _waypoints; -	_waypoints = 0; +	_waypoints = nullptr;  	// TODO: Delete Cover waypoints @@ -459,13 +464,13 @@ void BladeRunnerEngine::shutdown() {  	// TODO: Delete proper ZBuf class  	delete[] _zBuffer1; -	_zBuffer1 = 0; +	_zBuffer1 = nullptr;  	delete[] _zBuffer2; -	_zBuffer2 = 0; +	_zBuffer2 = nullptr;  	delete _gameInfo; -	_gameInfo = 0; +	_gameInfo = nullptr;  	// TODO: Delete graphics surfaces here  	_surface1.free(); @@ -548,7 +553,8 @@ void BladeRunnerEngine::gameTick() {  		// TODO: VK  		// TODO: Elevators  		// TODO: Scores - +		 +		_adq->tick();  		if (_scene->didPlayerWalkIn()) {  			_script->PlayerWalkedIn();  		} diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 7c2e74de4e..273449fcf6 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -36,6 +36,7 @@  namespace BladeRunner {  class Actor; +class ADQ;  class AIScripts;  class AmbientSounds;  class AudioPlayer; @@ -65,6 +66,7 @@ public:  	bool      _windowIsActive;  	int       _playerLosesControlCounter; +	ADQ             *_adq;  	AIScripts       *_aiScripts;  	AmbientSounds   *_ambientSounds;  	AudioPlayer     *_audioPlayer; diff --git a/engines/bladerunner/item.cpp b/engines/bladerunner/item.cpp index 74ddf1ad13..f59d6da75a 100644 --- a/engines/bladerunner/item.cpp +++ b/engines/bladerunner/item.cpp @@ -1,7 +1,7 @@  #include "bladerunner/item.h"  #include "bladerunner/bladerunner.h" -//#include "bladerunner/slice_animations.h" +  #include "bladerunner/slice_renderer.h"  namespace BladeRunner { @@ -94,7 +94,7 @@ void Item::setXYZ(Vector3 position) {  	_depth = screenPosition.z * 25.5f;  } -void Item::init(int itemId, int setId, int animationId, Vector3 position, int facing, int height, int width, bool isTargetable, bool isVisible, bool isPoliceMazeEnemy) { +void Item::setup(int itemId, int setId, int animationId, Vector3 position, int facing, int height, int width, bool isTargetable, bool isVisible, bool isPoliceMazeEnemy) {  	_itemId = itemId;  	_setId = setId;  	_animationId = animationId; diff --git a/engines/bladerunner/item.h b/engines/bladerunner/item.h index 95500c3ceb..bdcaea7846 100644 --- a/engines/bladerunner/item.h +++ b/engines/bladerunner/item.h @@ -67,7 +67,7 @@ public:  	bool isTargetable();  	void tick(bool special);  	void setXYZ(Vector3 position); -	void init(int itemId, int setId, int animationId, Vector3 position, int facing, int height, int width, bool isTargetable, bool isVisible, bool isPoliceMazeEnemy); +	void setup(int itemId, int setId, int animationId, Vector3 position, int facing, int height, int width, bool isTargetable, bool isVisible, bool isPoliceMazeEnemy);  };  } diff --git a/engines/bladerunner/items.cpp b/engines/bladerunner/items.cpp index 46ea9e842c..64d8befe80 100644 --- a/engines/bladerunner/items.cpp +++ b/engines/bladerunner/items.cpp @@ -37,13 +37,13 @@ bool Items::add(int itemId, int animationId, int setId, Vector3 position, int fa  	if (_items.size() >= 100) {  		return false;  	} -	int i = findItem(itemId); -	if(i == -1) { -		i = _items.size(); +	int itemIndex = findItem(itemId); +	if(itemIndex == -1) { +		itemIndex = _items.size();  	}  	Item *item = new Item(_vm); -	item->init(itemId, setId, animationId, position, facing, height, width, isTargetable, isVisible, isPoliceMazeEnemy); +	item->setup(itemId, setId, animationId, position, facing, height, width, isTargetable, isVisible, isPoliceMazeEnemy);  	_items.push_back(item);  	if(addToSet && setId == _vm->_scene->getSetId()) { @@ -52,6 +52,22 @@ bool Items::add(int itemId, int animationId, int setId, Vector3 position, int fa  	return true;  } +bool Items::remove(int itemId) { +	if (_items.size() == 0) { +		return false; +	} +	int itemIndex = findItem(itemId); +	if(itemIndex == -1) { +		return false; +	} + +	if (_items[itemIndex]->_setId == _vm->_scene->getSetId()) { +		_vm->_sceneObjects->remove(itemId + SCENE_OBJECTS_ITEMS_OFFSET); +	} +	_items.remove_at(itemIndex); +	return true; +} +  int Items::findItem(int itemId) {  	for (int i = 0; i < (int)_items.size(); i++) {  		if (_items[i]->_itemId == itemId) diff --git a/engines/bladerunner/items.h b/engines/bladerunner/items.h index aa6f41f3f2..e6e1cb2500 100644 --- a/engines/bladerunner/items.h +++ b/engines/bladerunner/items.h @@ -42,6 +42,7 @@ public:  	void getXYZ(int itemId, float *x, float *y, float *z);  	void tick();  	bool add(int itemId, int animationId, int setId, Vector3 position, int facing, int height, int width, bool isTargetable, bool isVisible, bool isPoliceMazeEnemy, bool b); +	bool remove(int itemId);  private:  	int findItem(int itemId);  }; diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk index 60bea4a368..3867331a36 100644 --- a/engines/bladerunner/module.mk +++ b/engines/bladerunner/module.mk @@ -1,6 +1,7 @@  MODULE := engines/bladerunner  MODULE_OBJS = \ +	adq.o \  	actor.o \  	actor_clues.o \  	actor_combat.o \ diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index 0ced4d8b93..06563b7d51 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -25,6 +25,7 @@  #include "bladerunner/bladerunner.h"  #include "bladerunner/actor.h" +#include "bladerunner/adq.h"  #include "bladerunner/chapters.h"  #include "bladerunner/gameinfo.h"  #include "bladerunner/scene_objects.h" @@ -37,7 +38,7 @@ namespace BladeRunner {  bool Scene::open(int setId, int sceneId, bool isLoadingGame) {  	if (!isLoadingGame) { -		// flush ADQ +		_vm->_adq->flush(1, false);  	}  	_setId = setId; diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 2b944f40b8..9f4f5392ef 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -26,6 +26,7 @@  #include "bladerunner/actor.h"  #include "bladerunner/actor_combat.h" +#include "bladerunner/adq.h"  #include "bladerunner/ambient_sounds.h"  #include "bladerunner/audio_player.h"  #include "bladerunner/audio_speech.h" @@ -351,14 +352,14 @@ void ScriptBase::Actor_Set_Targetable(int actorId, bool targetable) {  void ScriptBase::Actor_Says(int actorId, int sentenceId, int animationMode){  	_vm->loopActorSpeaking(); -	//_vm->ADQ->flush(1,1) +	_vm->_adq->flush(1, true);  	Actor_Says_With_Pause(actorId, sentenceId, 0.5f, animationMode);  }  void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause, int animationMode) {  	_vm->gameWaitForActive();  	_vm->loopActorSpeaking(); -	//_vm->ADQ->flush(1,1) +	_vm->_adq->flush(1, true);  	Actor *actor = _vm->_actors[actorId]; @@ -432,8 +433,8 @@ void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) {  void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) {  	_vm->gameWaitForActive();  	_vm->loopActorSpeaking(); -	//_vm->ADQ->flush(1,1) - +	_vm->_adq->flush(1, true); +	  	Actor *actor = _vm->_actors[actorId];  	actor->speechPlay(sentenceId, true); @@ -637,8 +638,7 @@ void ScriptBase::Item_Add_To_World(int itemId, int animationId, int setId, float  }  void ScriptBase::Item_Remove_From_World(int itemId) { -	//TODO -	warning("Item_Remove_From_World(%d)", itemId); +	_vm->_items->remove(itemId);  }  void ScriptBase::Item_Spin_In_World(int itemId) { @@ -930,6 +930,8 @@ int ScriptBase::Ambient_Sounds_Play_Sound(int a1, int a2, int a3, int a4, int a5  // ScriptBase::Ambient_Sounds_Play_Speech_Sound  void ScriptBase::Ambient_Sounds_Remove_All_Non_Looping_Sounds(int time) { +	//TODO +	warning("Ambient_Sounds_Remove_All_Non_Looping_Sounds(%d)", time);  	// _vm->_ambientSounds->removeAllNonLoopingSounds(time);  } @@ -948,6 +950,8 @@ void ScriptBase::Ambient_Sounds_Remove_Looping_Sound(int id, bool a2){  }  void ScriptBase::Ambient_Sounds_Remove_All_Looping_Sounds(int time) { +	//TODO +	warning("Ambient_Sounds_Remove_All_Looping_Sounds(%d)", time);  	// _vm->_ambientSounds->removeAllLoopingSounds(time);  } @@ -1289,18 +1293,15 @@ void ScriptBase::Set_Fog_Density(const char* fogName, float density) {  }  void ScriptBase::ADQ_Flush() { -	//TODO -	warning("ADQ_Flush()"); +	_vm->_adq->flush(0, true);  } -void ScriptBase::ADQ_Add(int a1, int a2, int a3) { -	//TODO -	warning("ADQ_Add(%d, %d, %d)", a1, a2, a3); +void ScriptBase::ADQ_Add(int actorId, int sentenceId, int animationMode) { +	_vm->_adq->add(actorId, sentenceId, animationMode);  }  void ScriptBase::ADQ_Add_Pause(int delay) { -	//TODO -	warning("ADQ_Add_Pause(%d)", delay); +	_vm->_adq->addPause(delay);  }  bool ScriptBase::Game_Over() { diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index 222cd4c935..914462a3a4 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -253,7 +253,7 @@ protected:  	void Set_Fog_Color(const char* fogName, float r, float g, float b);  	void Set_Fog_Density(const char* fogName, float density);  	void ADQ_Flush(); -	void ADQ_Add(int a1, int a2, int a3); +	void ADQ_Add(int actorId, int sentenceId, int animationMode);  	void ADQ_Add_Pause(int delay);  	bool Game_Over();  	void Autosave_Game(int textId); | 
