diff options
author | Paul Gilbert | 2011-04-05 20:58:05 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-04-05 20:58:05 +1000 |
commit | 92aac3addc190f19c4fd063fb825651c9f31f725 (patch) | |
tree | 9317e8ff0b1a50c47042e9152b1350cd24c3c96c /engines/tsage | |
parent | 78e83134a7dea1bf2563255fd8669f78e9e5dae2 (diff) | |
download | scummvm-rg350-92aac3addc190f19c4fd063fb825651c9f31f725.tar.gz scummvm-rg350-92aac3addc190f19c4fd063fb825651c9f31f725.tar.bz2 scummvm-rg350-92aac3addc190f19c4fd063fb825651c9f31f725.zip |
TSAGE: Reimplemented the old _sceneObjectListeners as _altSceneObjects
Diffstat (limited to 'engines/tsage')
-rw-r--r-- | engines/tsage/core.cpp | 4 | ||||
-rw-r--r-- | engines/tsage/core.h | 4 | ||||
-rw-r--r-- | engines/tsage/ringworld_scenes10.cpp | 3 | ||||
-rw-r--r-- | engines/tsage/scenes.cpp | 43 | ||||
-rw-r--r-- | engines/tsage/scenes.h | 4 |
5 files changed, 43 insertions, 15 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 10a51349e5..cbe9fd37b2 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -3499,7 +3499,7 @@ void SceneHandler::dispatch() { _globals->_scenePalette.signalListeners(); // Dispatch to any objects registered in the scene - _globals->_sceneObjects->recurse(SceneHandler::handleListener); + _globals->_sceneObjects->recurse(SceneHandler::dispatchObject); // If a scene is active, then dispatch to it if (_globals->_sceneManager._scene) @@ -3521,7 +3521,7 @@ void SceneHandler::dispatch() { _globals->_events.delay(_delayTicks); } -void SceneHandler::handleListener(EventHandler *obj) { +void SceneHandler::dispatchObject(EventHandler *obj) { obj->dispatch(); } diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 61282ffd03..a65cec06b9 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -712,12 +712,12 @@ public: class SceneObjectList: public SavedObject { private: void checkIntersection(Common::Array<SceneObject *> &ObjList, uint ObjIndex, int PaneNum); - void sortList(Common::Array<SceneObject *> &ObjList); List<SceneObject *> _objList; bool _listAltered; public: SceneObjectList() { _listAltered = false; } + void sortList(Common::Array<SceneObject *> &ObjList); virtual Common::String getClassName() { return "SceneObjectList"; } virtual void synchronise(Serialiser &s); @@ -944,7 +944,7 @@ public: virtual void process(Event &event); virtual void dispatch(); - static void handleListener(EventHandler *obj); + static void dispatchObject(EventHandler *obj); static void saveListener(Serialiser &ser); }; diff --git a/engines/tsage/ringworld_scenes10.cpp b/engines/tsage/ringworld_scenes10.cpp index bebf199a2d..77c195b4f8 100644 --- a/engines/tsage/ringworld_scenes10.cpp +++ b/engines/tsage/ringworld_scenes10.cpp @@ -37,8 +37,7 @@ Scene2::Scene2() { } void Object9350::postInit(SceneObjectList *OwnerList) { - warning("Object9350::postInit - Weird cast to be verified"); - _globals->_sceneManager.postInit((SceneObjectList*) &_globals->_sceneManager._sceneChangeListeners); + _globals->_sceneManager.postInit(&_globals->_sceneManager._altSceneObjects); } void Object9350::draw() { diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index de5fe1e5cb..ad6d1f9620 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -54,7 +54,7 @@ void SceneManager::checkScene() { _nextSceneNumber = -1; } - _globals->_sceneListeners.forEach(SceneHandler::handleListener); + _globals->_sceneListeners.forEach(SceneHandler::dispatchObject); } void SceneManager::sceneChange() { @@ -70,8 +70,13 @@ void SceneManager::sceneChange() { sceneObj->removeObject(); } - // Clear the scene change listeners - _globals->_sceneManager._sceneChangeListeners.clear(); + // Clear the secondary scene object list + io = _globals->_sceneManager._altSceneObjects.begin(); + while (io != _globals->_sceneManager._altSceneObjects.end()) { + SceneObject *sceneObj = *io; + ++io; + sceneObj->removeObject(); + } // Clear the hotspot list List<SceneItem *>::iterator ii = _globals->_sceneItems.begin(); @@ -204,7 +209,7 @@ void SceneManager::setBgOffset(const Common::Point &pt, int loadCount) { void SceneManager::listenerSynchronise(Serialiser &s) { s.validate("SceneManager"); - _sceneChangeListeners.synchronise(s); + _altSceneObjects.synchronise(s); s.syncAsSint32LE(_sceneNumber); if (s.isLoading()) { @@ -398,12 +403,36 @@ void Scene::refreshBackground(int xAmount, int yAmount) { } if (changedFlag) { - signalListeners(); + drawAltObjects(); } } -void Scene::signalListeners() { - // TODO: Figure out method +void Scene::drawAltObjects() { + Common::Array<SceneObject *> objList; + + // Initial loop to set the priority for entries in the list + for (List<SceneObject *>::iterator i = _globals->_sceneManager._altSceneObjects.begin(); + i != _globals->_sceneManager._altSceneObjects.end(); ++i) { + SceneObject *obj = *i; + objList.push_back(obj); + + // Handle updating object priority + if (!(obj->_flags & OBJFLAG_FIXED_PRIORITY)) { + obj->_priority = MIN((int)obj->_position.y - 1, + (int)_globals->_sceneManager._scene->_backgroundBounds.bottom); + } + } + + // Sort the list by priority + _globals->_sceneManager._altSceneObjects.sortList(objList); + + // Drawing loop + for (uint objIndex = 0; objIndex < objList.size(); ++objIndex) { + SceneObject *obj = objList[objIndex]; + + obj->reposition(); + obj->draw(); + } } void Scene::setZoomPercents(int yStart, int minPercent, int yEnd, int maxPercent) { diff --git a/engines/tsage/scenes.h b/engines/tsage/scenes.h index 85e7c7251e..9d969c906b 100644 --- a/engines/tsage/scenes.h +++ b/engines/tsage/scenes.h @@ -36,7 +36,7 @@ namespace tSage { class Scene: public StripCallback { private: - void signalListeners(); + void drawAltObjects(); public: int _field12; int _sceneNumber; @@ -87,7 +87,7 @@ public: Common::Point _sceneBgOffset; int _sceneLoadCount; Rect _scrollerRect; - List<EventHandler *> _sceneChangeListeners; + SceneObjectList _altSceneObjects; public: SceneManager(); virtual ~SceneManager(); |