diff options
| -rw-r--r-- | engines/sherlock/objects.cpp | 12 | ||||
| -rw-r--r-- | engines/sherlock/objects.h | 18 | ||||
| -rw-r--r-- | engines/sherlock/scene.cpp | 118 | ||||
| -rw-r--r-- | engines/sherlock/scene.h | 49 | ||||
| -rw-r--r-- | engines/sherlock/sherlock.cpp | 2 | 
5 files changed, 152 insertions, 47 deletions
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp index 73387261c8..3e8838cb79 100644 --- a/engines/sherlock/objects.cpp +++ b/engines/sherlock/objects.cpp @@ -1141,6 +1141,18 @@ void CAnim::load(Common::SeekableReadStream &s, bool isRoseTattoo) {  /*----------------------------------------------------------------*/ +CAnimStream::CAnimStream() { +	_stream = nullptr; +	_frameSize = 0; +	_images = nullptr; +	_imageFrame = nullptr; +	_flags = 0; +	_scaleVal = 0; +	_zPlacement = 0; +} + +/*----------------------------------------------------------------*/ +  SceneImage::SceneImage() {  	_images = nullptr;  	_maxFrames = 0; diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index 99746c9956..ec5c2e7897 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -413,6 +413,24 @@ struct CAnim {  	void load(Common::SeekableReadStream &s, bool isRoseTattoo);  }; +struct CAnimStream { +	Common::SeekableReadStream *_stream;	// Stream to read frames from +	int _frameSize;					// Temporary used to store the frame size + +	void *_images;					// TOOD: FIgure out hwo to hook up ImageFile with streaming support +	ImageFrame *_imageFrame; + +	Common::Point _position;		// Animation position +	Common::Rect _oldBounds;		// Bounds of previous frame +	Common::Rect _removeBounds;		// Remove area for just drawn frame + +	int _flags;						// Flags +	int _scaleVal;					// Specifies the scale amount +	int _zPlacement;				// Used by doBgAnim for determining Z order + +	CAnimStream(); +}; +  struct SceneImage {  	ImageFile *_images;				// Object images  	int _maxFrames;					// How many frames in object diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index a1a165e805..63203e1859 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -150,6 +150,13 @@ void ScaleZone::load(Common::SeekableReadStream &s) {  /*----------------------------------------------------------------*/ +Scene *Scene::init(SherlockEngine *vm) { +	if (vm->getGameID() == GType_SerratedScalpel) +		return new ScalpelScene(vm); +	else +		return new TattooScene(vm); +} +  Scene::Scene(SherlockEngine *vm): _vm(vm) {  	for (int idx = 0; idx < SCENES_COUNT; ++idx)  		Common::fill(&_sceneStats[idx][0], &_sceneStats[idx][65], false); @@ -978,42 +985,6 @@ Exit *Scene::checkForExit(const Common::Rect &r) {  	return nullptr;  } -void Scene::checkBgShapes() { -	People &people = *_vm->_people; -	Person &holmes = people._player; -	Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER); - -	// Iterate through the shapes -	for (uint idx = 0; idx < _bgShapes.size(); ++idx) { -		Object &obj = _bgShapes[idx]; -		if (obj._type == STATIC_BG_SHAPE || obj._type == ACTIVE_BG_SHAPE) { -			if ((obj._flags & 5) == 1) { -				obj._misc = (pt.y < (obj._position.y + obj.frameHeight() - 1)) ? -					NORMAL_FORWARD : NORMAL_BEHIND; -			} else if (!(obj._flags & OBJ_BEHIND)) { -				obj._misc = BEHIND; -			} else if (obj._flags & OBJ_FORWARD) { -				obj._misc = FORWARD; -			} -		} -	} - -	// Iterate through the canimshapes -	for (uint idx = 0; idx < _canimShapes.size(); ++idx) { -		Object &obj = _canimShapes[idx]; -		if (obj._type == STATIC_BG_SHAPE || obj._type == ACTIVE_BG_SHAPE) { -			if ((obj._flags & 5) == 1) { -				obj._misc = (pt.y < (obj._position.y + obj._imageFrame->_frame.h - 1)) ? -				NORMAL_FORWARD : NORMAL_BEHIND; -			} else if (!(obj._flags & 1)) { -				obj._misc = BEHIND; -			} else if (obj._flags & 4) { -				obj._misc = FORWARD; -			} -		} -	} -} -  int Scene::startCAnim(int cAnimNum, int playRate) {  	Events &events = *_vm->_events;  	Map &map = *_vm->_map; @@ -1658,5 +1629,80 @@ void Scene::setNPCPath(int npc) {  	talk.talkTo(pathFile);  } +void Scene::checkBgShapes() { +	People &people = *_vm->_people; +	Person &holmes = people._player; +	Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER); + +	// Iterate through the shapes +	for (uint idx = 0; idx < _bgShapes.size(); ++idx) { +		Object &obj = _bgShapes[idx]; +		if (obj._type == ACTIVE_BG_SHAPE || (IS_SERRATED_SCALPEL && obj._type == STATIC_BG_SHAPE)) { +			if ((obj._flags & 5) == 1) { +				obj._misc = (pt.y < (obj._position.y + obj.frameHeight() - 1)) ? +					NORMAL_FORWARD : NORMAL_BEHIND; +			} else if (!(obj._flags & OBJ_BEHIND)) { +				obj._misc = BEHIND; +			} else if (obj._flags & OBJ_FORWARD) { +				obj._misc = FORWARD; +			} +		} +	} +} + +/*----------------------------------------------------------------*/ + +void ScalpelScene::checkBgShapes() { +	People &people = *_vm->_people; +	Person &holmes = people._player; +	Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER); + +	// Call the base scene method to handle bg shapes +	Scene::checkBgShapes(); + +	// Iterate through the canim list +	for (uint idx = 0; idx < _canimShapes.size(); ++idx) { +		Object &obj = _canimShapes[idx]; +		if (obj._type == STATIC_BG_SHAPE || obj._type == ACTIVE_BG_SHAPE) { +			if ((obj._flags & 5) == 1) { +				obj._misc = (pt.y < (obj._position.y + obj._imageFrame->_frame.h - 1)) ? +				NORMAL_FORWARD : NORMAL_BEHIND; +			} else if (!(obj._flags & 1)) { +				obj._misc = BEHIND; +			} else if (obj._flags & 4) { +				obj._misc = FORWARD; +			} +		} +	} +} + +/*----------------------------------------------------------------*/ + +void TattooScene::checkBgShapes() { +	People &people = *_vm->_people; +	Person &holmes = people._player; +	Common::Point pt(holmes._position.x / FIXED_INT_MULTIPLIER, holmes._position.y / FIXED_INT_MULTIPLIER); + +	// Call the base scene method to handle bg shapes +	Scene::checkBgShapes(); + +	// Check for any active playing animation +	if (_activeCAnim._images && _activeCAnim._zPlacement != REMOVE) { +		switch (_activeCAnim._flags & 3) { +		case 0: +			_activeCAnim._zPlacement = BEHIND; +			break; +		case 1: +			_activeCAnim._zPlacement = ((_activeCAnim._position.y + _activeCAnim._imageFrame->_frame.h - 1)) ? +				NORMAL_FORWARD : NORMAL_BEHIND; +			break; +		case 2: +			_activeCAnim._zPlacement = FORWARD; +			break; +		default: +			break; +		} +	} +}  } // End of namespace Sherlock diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 806726868a..50f8f07ef4 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -140,7 +140,6 @@ struct SceneTripEntry {  class Scene {  private: -	SherlockEngine *_vm;  	Common::String _rrmName;  	bool _loadingSavedGame; @@ -180,13 +179,6 @@ private:  	void transitionToScene();  	/** -	 * Checks all the background shapes. If a background shape is animating, -	 * it will flag it as needing to be drawn. If a non-animating shape is -	 * colliding with another shape, it will also flag it as needing drawing -	 */ -	void checkBgShapes(); - -	/**  	 * Restores objects to the correct status. This ensures that things like being opened or moved  	 * will remain the same on future visits to the scene  	 */ @@ -196,6 +188,17 @@ private:  	 * Draw all the shapes, people and NPCs in the correct order  	 */  	void drawAllShapes(); +protected: +	SherlockEngine *_vm; + +	/** +	 * Checks all the background shapes. If a background shape is animating, +	 * it will flag it as needing to be drawn. If a non-animating shape is +	 * colliding with another shape, it will also flag it as needing drawing +	 */ +	virtual void checkBgShapes(); + +	Scene(SherlockEngine *vm);  public:  	int _currentScene;  	int _goToScene; @@ -228,8 +231,8 @@ public:  	int _cAnimFramePause;  	Common::Array<SceneTripEntry> _sceneTripCounters;  public: -	Scene(SherlockEngine *vm); -	~Scene(); +	static Scene *init(SherlockEngine *vm); +	virtual ~Scene();  	/**  	 * Handles loading the scene specified by _goToScene @@ -315,6 +318,32 @@ public:  	void setNPCPath(int npc);  }; +class ScalpelScene : public Scene { +protected: +	/** +	 * Checks all the background shapes. If a background shape is animating, +	 * it will flag it as needing to be drawn. If a non-animating shape is +	 * colliding with another shape, it will also flag it as needing drawing +	 */ +	virtual void checkBgShapes(); +public: +	ScalpelScene(SherlockEngine *vm) : Scene(vm) {} +}; + +class TattooScene : public Scene { +private: +	CAnimStream _activeCAnim; +protected: +	/** +	 * Checks all the background shapes. If a background shape is animating, +	 * it will flag it as needing to be drawn. If a non-animating shape is +	 * colliding with another shape, it will also flag it as needing drawing +	 */ +	virtual void checkBgShapes(); +public: +	TattooScene(SherlockEngine *vm) : Scene(vm) {} +}; +  } // End of namespace Sherlock  #endif diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 497841faac..03c10554e8 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -92,7 +92,7 @@ void SherlockEngine::initialize() {  	_journal = new Journal(this);  	_people = new People(this);  	_saves = new SaveManager(this, _targetName); -	_scene = new Scene(this); +	_scene = Scene::init(this);  	_screen = new Screen(this);  	_sound = new Sound(this, _mixer);  	_talk = Talk::init(this);  | 
