From f8055bc2067d369e13b056d723512f198c10f973 Mon Sep 17 00:00:00 2001 From: whitertandrek Date: Sat, 17 Mar 2018 20:27:03 +0200 Subject: PINK: split declaration and definition and some fixes --- engines/pink/archive.cpp | 9 ++++--- engines/pink/objects/actor.cpp | 27 +++++++++++++++++++ engines/pink/objects/actor.h | 42 +++++++++++++++++++++++++++++ engines/pink/objects/inventory.h | 1 - engines/pink/objects/module.cpp | 19 ++++++++----- engines/pink/objects/module.h | 17 ++++-------- engines/pink/objects/page.cpp | 58 ++++++++++++++++++++++++++++++++++++++++ engines/pink/objects/page.h | 19 +++---------- engines/pink/pink.cpp | 2 +- 9 files changed, 155 insertions(+), 39 deletions(-) create mode 100644 engines/pink/objects/actor.cpp create mode 100644 engines/pink/objects/actor.h create mode 100644 engines/pink/objects/page.cpp (limited to 'engines/pink') diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp index ab6ab781b8..e4605af31d 100644 --- a/engines/pink/archive.cpp +++ b/engines/pink/archive.cpp @@ -33,7 +33,6 @@ enum { kNullObject = 0 }; - enum { kActionHide, kActionLoop, @@ -90,21 +89,23 @@ static const struct RuntimeClass { int id; } classMap[] = { {"GamePage", kGamePage}, + {"InventoryItem", kInventoryItem}, {"ModuleProxy", kModuleProxy} }; static Object* createObject(int objectId){ switch (objectId){ case kGamePage: - return new GamePage(); + return new GamePage; + case kInventoryItem: + return new InventoryItem; case kModuleProxy: - return new ModuleProxy(); + return new ModuleProxy; default: return nullptr; } } - Archive::Archive(Common::File &file) : _file(file) { diff --git a/engines/pink/objects/actor.cpp b/engines/pink/objects/actor.cpp new file mode 100644 index 0000000000..c90afb7901 --- /dev/null +++ b/engines/pink/objects/actor.cpp @@ -0,0 +1,27 @@ +/* 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. + * + */ + +namespace Pink { + + + +} // End of namespace Pink diff --git a/engines/pink/objects/actor.h b/engines/pink/objects/actor.h new file mode 100644 index 0000000000..a9c0ff8844 --- /dev/null +++ b/engines/pink/objects/actor.h @@ -0,0 +1,42 @@ +/* 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 PINK_ACTOR_H +#define PINK_ACTOR_H + +namespace Pink { + +class GamePage; + +class Actor { +public: + +private: + GamePage *page; + //int possibly_isActionNotExist; + //CAction *action; + //CObArray actions; +}; + +} // End of namespace Pink + +#endif diff --git a/engines/pink/objects/inventory.h b/engines/pink/objects/inventory.h index f693811a97..6dacd8743c 100644 --- a/engines/pink/objects/inventory.h +++ b/engines/pink/objects/inventory.h @@ -43,7 +43,6 @@ public: virtual void deserialize(Archive &archive); - private: Common::Array _invItems; // other fields. haven't RE them yet diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp index 3d33c1625f..505b8fba11 100644 --- a/engines/pink/objects/module.cpp +++ b/engines/pink/objects/module.cpp @@ -25,20 +25,27 @@ namespace Pink { +ModuleProxy::ModuleProxy(const Common::String &name) + : NamedObject(name) +{} -void Module::deserialize(Archive &archive){ +ModuleProxy::ModuleProxy() {} + +Module::Module(PinkEngine *game, const Common::String &name) + : NamedObject(name), _game(game), _page(nullptr) +{} + +void Module::load(Archive &archive){ archive.mapObject(this); NamedObject::deserialize(archive); - archive.readString(); // skip directory - //_invMgr.load(archive); - // intro has 0 items so we will skip - archive.readCount(); + archive.readString(); // skip directory + _invMgr.deserialize(archive); archive >> _pages; } -void Module::initPage(bool isLoadingSave, const Common::String *pageName) { +void Module::init(bool isLoadingSave, const Common::String *pageName) { // debugging original // 0 0 - new game // 0 1 - module changed diff --git a/engines/pink/objects/module.h b/engines/pink/objects/module.h index c6dbdbe31a..ea2eceef7d 100644 --- a/engines/pink/objects/module.h +++ b/engines/pink/objects/module.h @@ -36,24 +36,18 @@ namespace Pink { class ModuleProxy : public NamedObject { public: - ModuleProxy(){}; - ModuleProxy(const Common::String &name) - : NamedObject(name) - {} - - + ModuleProxy(); + ModuleProxy(const Common::String &name); }; class PinkEngine; class Module : public NamedObject { public: - Module(PinkEngine *game, const Common::String &name) - : NamedObject(name), _game(game), _page(nullptr) - {} + Module(PinkEngine *game, const Common::String &name); - void deserialize(Archive &archive); - void initPage(bool isLoadingSave, const Common::String *pageName); + void load(Archive &archive); + void init(bool isLoadingSave, const Common::String *pageName); void OnLeftButtonDown(); void OnMouseMove(); @@ -61,7 +55,6 @@ public: private: PinkEngine *_game; - //Common::String _directory; doesn't need this because it was used when game had data in directories GamePage *_page; PagesArray _pages; InventoryMgr _invMgr; diff --git a/engines/pink/objects/page.cpp b/engines/pink/objects/page.cpp new file mode 100644 index 0000000000..31bb48b40c --- /dev/null +++ b/engines/pink/objects/page.cpp @@ -0,0 +1,58 @@ +/* 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. + * + */ + +#include "page.h" + +namespace Pink { + +void Page::load(Archive &archive) { + archive.mapObject(this); + NamedObject::deserialize(archive); + archive.readString(); //skip directory + // deserialize actors +} + +void GamePage::deserialize(Archive &archive) { + Page::deserialize(archive); + _module = static_cast(archive.readObject()); + assert(dynamic_cast(_module) != 0); +} + +void GamePage::load(Archive &archive) { + //archive.mapObject(_cursorMgr); + //archive.mapObject(_walkMgr); + //archive.mapObject(_sequencer); + //_leadActor = archive.readObject() + //serialize ccursormgr NullSub + //serialize walkmgr + //serialize sequencer + //serialize handlers +} + +void GamePage::init(bool isLoadingSave) { + if (isLoadingSave){ + assert(perhapsIsLoaded == 0); + // loadSerialize + } +} + +} // End of namespace Pink diff --git a/engines/pink/objects/page.h b/engines/pink/objects/page.h index 1055a710e1..f2ef83cc6b 100644 --- a/engines/pink/objects/page.h +++ b/engines/pink/objects/page.h @@ -33,7 +33,7 @@ class Archive; class Page : public NamedObject { public: - + void load(Archive &archive); private: /* @@ -48,23 +48,12 @@ private: class GamePage : public Page { public: - void deserialize(Archive &archive){ - Page::deserialize(archive); - _module = static_cast(archive.readObject()); - assert(dynamic_cast(_module) != 0); - } - - void load(Archive &archive){ + void deserialize(Archive &archive); - } + void load(Archive &archive); - void init(bool isLoadingSave){ - if (isLoadingSave){ - assert(perhapsIsLoaded == 0); - // loadSerialize - } - } + void init(bool isLoadingSave); private: int perhapsIsLoaded; Module *_module; diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index aaaa2b13d7..4df3dfe8b7 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -157,7 +157,7 @@ void PinkEngine::initModule() { assert(i < _modules.size()); _module = static_cast(_modules[i]); - _module->initPage(LoadingNotSave, 0); //TODO change to constants + _module->init(LoadingNotSave, 0); } -- cgit v1.2.3