From 0e11cab2ead8b724ed47a20cd660095ad9efd963 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 31 Oct 2013 20:41:48 -0400 Subject: TSAGE: Cleanup and saving fixes for R2R star-field credits scene --- engines/tsage/globals.cpp | 5 ++++ engines/tsage/ringworld2/ringworld2_scenes0.cpp | 40 ++++++++++++------------- engines/tsage/ringworld2/ringworld2_scenes0.h | 23 +++++++------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index 96a92a27e4..78a82586c2 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -26,6 +26,7 @@ #include "tsage/ringworld/ringworld_demo.h" #include "tsage/ringworld/ringworld_logic.h" #include "tsage/ringworld2/ringworld2_logic.h" +#include "tsage/ringworld2/ringworld2_scenes0.h" #include "tsage/staticres.h" namespace TsAGE { @@ -48,6 +49,10 @@ static SavedObject *classFactoryProc(const Common::String &className) { if (className == "PaletteRotation") return new PaletteRotation(); if (className == "PaletteFader") return new PaletteFader(); if (className == "SceneText") return new SceneText(); + + // Return to Ringworld specific classes + if (className == "Scene205_Star") return new Ringworld2::Star(); + return NULL; } diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index dd69df07e7..9f81fb3f73 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -2356,12 +2356,12 @@ Scene205::Scene205(): SceneExt() { _fontHeight = font.getHeight(); for (int i = 0; i < 3; i++) { - _objList1[i] = nullptr; - _objList2[i] = nullptr; + _starList1[i] = nullptr; + _starList2[i] = nullptr; } for (int i = 0; i < 4; i++) - _objList3[i] = nullptr; + _starList3[i] = nullptr; } void Scene205::postInit(SceneObjectList *OwnerList) { @@ -2383,11 +2383,11 @@ void Scene205::synchronize(Serializer &s) { SceneExt::synchronize(s); for (int idx = 0; idx < 3; ++idx) - SYNC_POINTER(_objList1[idx]); + SYNC_POINTER(_starList1[idx]); for (int idx = 0; idx < 3; ++idx) - SYNC_POINTER(_objList2[idx]); + SYNC_POINTER(_starList2[idx]); for (int idx = 0; idx < 4; ++idx) - SYNC_POINTER(_objList3[idx]); + SYNC_POINTER(_starList3[idx]); s.syncAsSint16LE(_textIndex); s.syncAsSint16LE(_lineNum); @@ -2409,9 +2409,9 @@ void Scene205::process(Event &event) { } void Scene205::dispatch() { - processList(_objList3, 4, Common::Rect(0, 0, 319, 200), 1, 1, 160, 100); - processList(_objList2, 3, Common::Rect(0, 0, 319, 200), 2, 2, 160, 100); - processList(_objList1, 3, Common::Rect(0, 0, 319, 200), 4, 3, 160, 100); + processList(_starList3, 4, Common::Rect(0, 0, 319, 200), 1, 1, 160, 100); + processList(_starList2, 3, Common::Rect(0, 0, 319, 200), 2, 2, 160, 100); + processList(_starList1, 3, Common::Rect(0, 0, 319, 200), 4, 3, 160, 100); Scene::dispatch(); } @@ -2423,10 +2423,10 @@ void Scene205::setup() { Common::Point(140, 149), Common::Point(91, 166), Common::Point(299, 46), Common::Point(314, 10) }; - // Set up the first object list + // Set up the first star list for (int idx = 0; idx < 3; ++idx) { - Object *obj = new Object(); - _objList1[idx] = obj; + Star *obj = new Star(); + _starList1[idx] = obj; obj->postInit(); obj->_flags |= OBJFLAG_CLONED; @@ -2439,10 +2439,10 @@ void Scene205::setup() { obj->fixPriority(12); } - // Setup the second object list + // Setup the second star list for (int idx = 0; idx < 3; ++idx) { - Object *obj = new Object(); - _objList2[idx] = obj; + Star *obj = new Star(); + _starList2[idx] = obj; obj->postInit(); obj->_flags |= OBJFLAG_CLONED; @@ -2455,10 +2455,10 @@ void Scene205::setup() { obj->fixPriority(11); } - // Setup the third object list + // Setup the third star list for (int idx = 0; idx < 4; ++idx) { - Object *obj = new Object(); - _objList3[idx] = obj; + Star *obj = new Star(); + _starList3[idx] = obj; obj->postInit(); obj->_flags |= OBJFLAG_CLONED; @@ -2475,10 +2475,10 @@ void Scene205::setup() { /** * Handles moving a group of stars in the scene background */ -void Scene205::processList(Object **ObjList, int count, const Common::Rect &bounds, +void Scene205::processList(Star **ObjList, int count, const Common::Rect &bounds, int xMultiply, int yMultiply, int xCenter, int yCenter) { for (int idx = 0; idx < count; ++idx) { - Object *obj = ObjList[idx]; + Star *obj = ObjList[idx]; Common::Point pt(obj->_position.x - xCenter, obj->_position.y - yCenter); if ((obj->_position.x <= 319) && (obj->_position.x >= 0) && diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h index 5b2576812e..e5157de073 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.h +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -261,6 +261,13 @@ public: virtual void signal(); }; +class Star: public SceneObject { +public: + int _x100, _y100; +public: + virtual Common::String getClassName() { return "Scene205_Star"; } +}; + class Scene205: public SceneExt { /* Actions */ class Action1: public Action { @@ -269,26 +276,18 @@ class Scene205: public SceneExt { public: virtual void signal(); }; - - /* Objects */ - class Object: public SceneObject { - public: - int _x100, _y100; - public: - // TODO: Check if this derives from DataManager? and flesh out - }; private: void setup(); - void processList(Object **ObjList, int count, const Common::Rect &bounds, + void processList(Star **ObjList, int count, const Common::Rect &bounds, int xMultiply, int yMultiply, int xCenter, int yCenter); void handleText(); public: AnimationPlayer _animationPlayer; int _fontHeight; SceneText _textList[15]; - Object *_objList1[3]; - Object *_objList2[3]; - Object *_objList3[4]; + Star *_starList1[3]; + Star *_starList2[3]; + Star *_starList3[4]; ASound _sound1; Action1 _action1; int _yp; -- cgit v1.2.3