diff options
author | Paul Gilbert | 2011-11-16 19:48:52 +1100 |
---|---|---|
committer | Paul Gilbert | 2011-11-16 19:48:52 +1100 |
commit | 4acd90ac1fa57805217210fd8ea788aae7efb29d (patch) | |
tree | 33b209489cff0481c742d876ce2d819aa9e9e674 /engines | |
parent | 3b2fce0091d5238107d363210ed2449a22298aa9 (diff) | |
download | scummvm-rg350-4acd90ac1fa57805217210fd8ea788aae7efb29d.tar.gz scummvm-rg350-4acd90ac1fa57805217210fd8ea788aae7efb29d.tar.bz2 scummvm-rg350-4acd90ac1fa57805217210fd8ea788aae7efb29d.zip |
TSAGE: Implemented R2RW SceneArea and SceneExit classes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tsage/globals.cpp | 3 | ||||
-rw-r--r-- | engines/tsage/globals.h | 1 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 123 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.h | 34 |
4 files changed, 147 insertions, 14 deletions
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index d2999a2603..d21321a201 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -380,7 +380,9 @@ void Ringworld2Globals::reset() { _v57C2C = 0; _v58CE2 = 0; Common::set_to(&_v565F1[0], &_v565F1[MAX_CHARACTERS], 0); + _insetUp = 0; + // Reset fields stored in the player class _player._characterIndex = 1; _player._characterScene[1] = 100; _player._characterScene[2] = 300; @@ -396,6 +398,7 @@ void Ringworld2Globals::synchronize(Serializer &s) { s.syncAsSint16LE(_v58CE2); for (int i = 0; i < MAX_CHARACTERS; ++i) s.syncAsSint16LE(_v565F1[i]); + s.syncAsSint16LE(_insetUp); } } // end of namespace Ringworld2 diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index c4108e175c..d644a02e7c 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -243,6 +243,7 @@ class Ringworld2Globals: public TsAGE2Globals { public: ASoundExt _sound1, _sound2, _sound3, _sound4; PlayStream _playStream; + int _insetUp; int _v565F5; int _v5657C; int _v57C2C; diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index fa8d0be1af..7294b3d726 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -176,18 +176,8 @@ void SceneExt::postInit(SceneObjectList *OwnerList) { } void SceneExt::remove() { -/* - R2_GLOBALS._uiElements.hide(); - R2_GLOBALS._uiElements.resetClear(); - - if (_action) { - if (_action->_endHandler) - _action->_endHandler = NULL; - _action->remove(); - } - - _focusObject = NULL; -*/ + _sceneAreas.clear(); + Scene::remove(); } void SceneExt::process(Event &event) { @@ -338,7 +328,17 @@ void SceneHandlerExt::process(Event &event) { return; } - SceneHandler::process(event); + SceneExt *scene = static_cast<SceneExt *>(R2_GLOBALS._sceneManager._scene); + if (scene) { + // Handle any scene areas that have been registered + SynchronizedList<SceneArea *>::iterator saIter; + for (saIter = scene->_sceneAreas.begin(); saIter != scene->_sceneAreas.end() && !event.handled; ++saIter) { + (*saIter)->process(event); + } + } + + if (!event.handled) + SceneHandler::process(event); } /*--------------------------------------------------------------------------*/ @@ -880,6 +880,103 @@ void SceneActor::setDetails(int resNum, int lookLineNum, int talkLineNum, int us _useLineNum = useLineNum; } +/*--------------------------------------------------------------------------*/ + +SceneArea::SceneArea(): EventHandler() { + _enabled = true; + _insideArea = false; + _savedCursorNum = CURSOR_NONE; + _cursorState = 0; +} + +void SceneArea::synchronize(Serializer &s) { + EventHandler::synchronize(s); + + _bounds.synchronize(s); + s.syncAsSint16LE(_enabled); + s.syncAsSint16LE(_insideArea); + s.syncAsSint16LE(_cursorNum); + s.syncAsSint16LE(_savedCursorNum); + s.syncAsSint16LE(_cursorState); +} + +void SceneArea::remove() { + static_cast<SceneExt *>(R2_GLOBALS._sceneManager._scene)->_sceneAreas.remove(this); +} + +void SceneArea::process(Event &event) { + if (!R2_GLOBALS._insetUp && _enabled && R2_GLOBALS._events.isCursorVisible()) { + CursorType cursor = R2_GLOBALS._events.getCursor(); + + if (_bounds.contains(event.mousePos)) { + // Cursor moving in bounded area + if (cursor != _cursorNum) { + _savedCursorNum = cursor; + _cursorState = 0; + R2_GLOBALS._events.setCursor(_cursorNum); + } + _insideArea = true; + } else if ((event.mousePos.y < 171) && _insideArea && (_cursorNum != cursor) && + (_savedCursorNum != CURSOR_NONE)) { + // Cursor moved outside bounded area + R2_GLOBALS._events.setCursor(_savedCursorNum); + } + } +} + +void SceneArea::setDetails(const Rect &bounds, CursorType cursor) { + _bounds = bounds; + _cursorNum = cursor; + + static_cast<SceneExt *>(R2_GLOBALS._sceneManager._scene)->_sceneAreas.push_front(this); +} + +/*--------------------------------------------------------------------------*/ + +SceneExit::SceneExit(): SceneArea() { + _moving = false; + _destPos = Common::Point(-1, -1); +} + +void SceneExit::synchronize(Serializer &s) { + SceneArea::synchronize(s); + + s.syncAsSint16LE(_moving); + s.syncAsSint16LE(_destPos.x); + s.syncAsSint16LE(_destPos.y); +} + +void SceneExit::setDetails(const Rect &bounds, CursorType cursor, int sceneNumber) { + _sceneNumber = sceneNumber; + SceneArea::setDetails(bounds, cursor); +} + +void SceneExit::changeScene() { + R2_GLOBALS._sceneManager.setNewScene(_sceneNumber); +} + +void SceneExit::process(Event &event) { + if (!R2_GLOBALS._insetUp) { + SceneArea::process(event); + + if (_enabled && (event.eventType == EVENT_BUTTON_DOWN)) { + if (!_bounds.contains(event.mousePos)) + _moving = 0; + else if (!R2_GLOBALS._player._canWalk) { + _moving = 0; + changeScene(); + event.handled = true; + } else { + Common::Point dest((_destPos.x == -1) ? event.mousePos.x : _destPos.x, + (_destPos.y == -1) ? event.mousePos.y : _destPos.y); + ADD_PLAYER_MOVER(dest.x, dest.y); + + _moving = true; + event.handled = true; + } + } + } +} } // End of namespace Ringworld2 diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 4adfc9bc05..152e6f8518 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -42,6 +42,38 @@ public: static Scene *createScene(int sceneNumber); }; +class SceneArea: public EventHandler { +public: + Rect _bounds; + bool _enabled; + bool _insideArea; + CursorType _cursorNum; + CursorType _savedCursorNum; + int _cursorState; +public: + SceneArea(); + void setDetails(const Rect &bounds, CursorType cursor); + + virtual void synchronize(Serializer &s); + virtual void remove(); + virtual void process(Event &event); +}; + +class SceneExit: public SceneArea { +public: + bool _moving; + int _sceneNumber; + Common::Point _destPos; +public: + SceneExit(); + void setDetails(const Rect &bounds, CursorType cursor, int sceneNumber); + void setDest(const Common::Point &p) { _destPos = p; } + void changeScene(); + + virtual void synchronize(Serializer &s); + virtual void process(Event &event); +}; + class SceneExt: public Scene { private: static void startStrip(); @@ -55,6 +87,7 @@ public: SceneObject *_focusObject; Visage _cursorVisage; + SynchronizedList<SceneArea *> _sceneAreas; Rect _v51C34; public: @@ -249,7 +282,6 @@ public: } }; - } // End of namespace Ringworld2 } // End of namespace TsAGE |