diff options
author | whitertandrek | 2018-03-22 07:47:45 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 467d3f1ab890bfca77629dd239b670ee4797bfe8 (patch) | |
tree | b534737f1dbafc4ec98a044d576f2457dc919517 | |
parent | 824b3fa38e965e425d09239f2ac81c4853eb43e8 (diff) | |
download | scummvm-rg350-467d3f1ab890bfca77629dd239b670ee4797bfe8.tar.gz scummvm-rg350-467d3f1ab890bfca77629dd239b670ee4797bfe8.tar.bz2 scummvm-rg350-467d3f1ab890bfca77629dd239b670ee4797bfe8.zip |
PINK: did a big file movement for better readability. Almost implemented
conditions and sideEffects. Added more classes. Now engine can play intro's sound.
76 files changed, 1293 insertions, 831 deletions
diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp index b03cf9148c..9e0642050e 100644 --- a/engines/pink/archive.cpp +++ b/engines/pink/archive.cpp @@ -22,20 +22,19 @@ #include <common/debug.h> #include <common/file.h> -#include <engines/pink/actors/actor.h> -#include <engines/pink/walk/walk_location.h> -#include <engines/pink/actions/action_hide.h> -#include <engines/pink/actions/action_play.h> -#include <engines/pink/actions/action_sound.h> -#include <engines/pink/sequences/sequence.h> -#include <engines/pink/items/sequence_item_default_action.h> -#include <engines/pink/items/sequence_item_leader.h> -#include <engines/pink/handlers/handler_start_page.h> -#include <engines/pink/side_effects/side_effect_exit.h> -#include <engines/pink/side_effects/side_effect_module_variable.h> -#include "module.h" -#include "page.h" -#include "actors/lead_actor.h" +#include <engines/pink/objects/object.h> +#include <engines/pink/objects/module.h> +#include <engines/pink/objects/pages/game_page.h> +#include <engines/pink/objects/actors/lead_actor.h> +#include <engines/pink/objects/condition.h> +#include <engines/pink/objects/side_effect.h> +#include <engines/pink/objects/sequences/sequence_item.h> +#include <engines/pink/objects/sequences/sequence.h> +#include <engines/pink/objects/handlers/handler.h> +#include <engines/pink/objects/actions/action_play.h> +#include <engines/pink/objects/actions/action_sound.h> +#include <engines/pink/objects/actions/action_hide.h> +#include <engines/pink/objects/walk/walk_location.h> namespace Pink { @@ -194,15 +193,12 @@ static Object* createObject(int objectId){ Archive::Archive(Common::File &file) : _file(file) { - debug("Archive created"); _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } Archive::~Archive() -{ - debug("Archive destroyed"); -} +{} void Archive::mapObject(Object *obj) { _objectMap.push_back(obj); @@ -222,8 +218,9 @@ Object *Archive::readObject() { bool isCopyReturned; Object *res = parseObject(isCopyReturned); - if (res && !isCopyReturned) + if (res && !isCopyReturned) { res->deserialize(*this); + } return res; } @@ -284,7 +281,7 @@ uint Archive::findObjectId(const char *name) { })); if (!found) - error("Class %s is not implemented", name); + error("Class %s is not in class Map", name); return found->id; } diff --git a/engines/pink/archive.h b/engines/pink/archive.h index 57ee78dc62..906169b373 100644 --- a/engines/pink/archive.h +++ b/engines/pink/archive.h @@ -23,8 +23,8 @@ #ifndef PINK_ARCHIVE_H #define PINK_ARCHIVE_H -#include "utils.h" -#include <engines/pink/object.h> +#include <engines/pink/objects/object.h> +#include <common/str-array.h> namespace Common { @@ -46,7 +46,6 @@ public: Object *readObject(); Common::String readString(); - private: uint findObjectId(const char *name); @@ -62,7 +61,7 @@ inline Archive &operator>>(Archive &archive, Common::Array<T> &arr){ uint size = archive.readCount(); arr.resize(size); for (uint i = 0; i < size; ++i) { - arr[i] = reinterpret_cast<T> (archive.readObject()); // hack; doesn't know better approach + arr[i] = reinterpret_cast<T> (archive.readObject()); } return archive; } @@ -83,7 +82,7 @@ inline Archive &operator>>(Archive &archive, uint32 &num){ return archive; } -inline Archive &operator>>(Archive &archive, StringArray &array){ +inline Archive &operator>>(Archive &archive, Common::StringArray &array){ uint32 size = archive.readCount(); array.resize(size); for (uint i = 0; i < size; ++i) { diff --git a/engines/pink/cursor_mgr.cpp b/engines/pink/cursor_mgr.cpp index 90cbd904d5..b5f9d4c64b 100644 --- a/engines/pink/cursor_mgr.cpp +++ b/engines/pink/cursor_mgr.cpp @@ -24,6 +24,6 @@ namespace Pink { -CursorMgr::CursorMgr(GamePage *page) : page(page) {} +CursorMgr::CursorMgr(GamePage *page) : _page(page) {} } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/cursor_mgr.h b/engines/pink/cursor_mgr.h index cfc16ac930..fac7c2eccc 100644 --- a/engines/pink/cursor_mgr.h +++ b/engines/pink/cursor_mgr.h @@ -23,7 +23,7 @@ #ifndef PINK_CURSOR_MGR_H #define PINK_CURSOR_MGR_H -#include "engines/pink/object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -35,8 +35,8 @@ public: CursorMgr(GamePage *page); private: - Actor *actor; - GamePage *page; + Actor *_actor; + GamePage *_page; }; } // End of namespace Pink diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp index 04e87c287b..996a13d352 100644 --- a/engines/pink/file.cpp +++ b/engines/pink/file.cpp @@ -21,7 +21,7 @@ */ #include <common/str.h> -#include "page.h" +#include "engines/pink/objects/pages/game_page.h" #include "pink.h" namespace Pink { @@ -167,7 +167,7 @@ void ResourceDescription::load(Common::File &file) { uint16 temp; file.read(&temp, sizeof(temp)); - InBro = temp ? true : false; + inBro = temp ? true : false; } } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/file.h b/engines/pink/file.h index 2b1d7cb917..36a6af2026 100644 --- a/engines/pink/file.h +++ b/engines/pink/file.h @@ -24,7 +24,6 @@ #define PINK_FILE_H #include <common/file.h> -#include "sound.h" namespace Pink { @@ -44,7 +43,7 @@ struct ResourceDescription { char name[16]; uint32 offset; uint32 size; - bool InBro; // in original it is short. + bool inBro; // in original it is short. // Don't know what's better to use.(Perhaps no diffrence because of padding) }; diff --git a/engines/pink/handlers/handler.cpp b/engines/pink/handlers/handler.cpp deleted file mode 100644 index d42d01510c..0000000000 --- a/engines/pink/handlers/handler.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* 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 "handler.h" -#include "../archive.h" -#include "../side_effects/side_effect.h" - -namespace Pink { - -void Handler::deserialize(Archive &archive) { - assert(archive.readCount() == 0); // intro has zero conditions, so skip; - archive >> _sideEffects; -} - -bool Handler::initConditions(LeadActor *actor) { - return true; -} - -void Handler::initSideEffects(LeadActor *actor) { - for (int i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->init(actor); - } -} - -} // End of namespace Pink diff --git a/engines/pink/handlers/handler_sequences.cpp b/engines/pink/handlers/handler_sequences.cpp deleted file mode 100644 index c785883210..0000000000 --- a/engines/pink/handlers/handler_sequences.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* 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 "handler_sequences.h" -#include <engines/pink/sequences/sequencer.h> -#include "../archive.h" -#include "../actors/lead_actor.h" - -namespace Pink { - -void HandlerSequences::deserialize(Archive &archive) { - Handler::deserialize(archive); - archive >> _sequences; -} - -void HandlerSequences::initSequence(LeadActor *actor) { - initSideEffects(actor); - - Sequencer *sequencer = actor->getSequencer(); - Sequence *sequence = sequencer->findSequence(_sequences[0]); //actually we must pick random sequence - sequencer->authorSequence(sequence, 0); -} - -} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/handlers/handler_start_page.cpp b/engines/pink/handlers/handler_start_page.cpp deleted file mode 100644 index 8fef49eee2..0000000000 --- a/engines/pink/handlers/handler_start_page.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* 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 "handler_start_page.h" -#include <common/debug.h> -#include "../archive.h" - -namespace Pink { - -void HandlerStartPage::deserialize(Archive &archive) { - debug("HandlerStartPage: "); - HandlerSequences::deserialize(archive); - - for (uint i = 0; i < _sequences.size(); ++i) { - debug("\t%s", _sequences[i].c_str()); - } -} - -} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/handlers/handler_start_page.h b/engines/pink/handlers/handler_start_page.h deleted file mode 100644 index a273e1e354..0000000000 --- a/engines/pink/handlers/handler_start_page.h +++ /dev/null @@ -1,38 +0,0 @@ -/* 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_HANDLER_START_PAGE_H -#define PINK_HANDLER_START_PAGE_H - -#include "handler.h" -#include "handler_sequences.h" - -namespace Pink { - -class HandlerStartPage : public HandlerSequences { -public: - virtual void deserialize(Archive &archive); -}; - -} // End of namespace Pink - -#endif diff --git a/engines/pink/items/sequence_item.cpp b/engines/pink/items/sequence_item.cpp deleted file mode 100644 index ade4e40e9d..0000000000 --- a/engines/pink/items/sequence_item.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* 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 <common/debug.h> -#include <engines/pink/sequences/sequence.h> -#include <engines/pink/sequences/sequencer.h> -#include <engines/pink/actions/action.h> -#include "sequence_item.h" -#include "../archive.h" -#include "sequence_item_leader.h" -#include "sequence_item_default_action.h" -#include "../page.h" -#include "../actors/actor.h" - -namespace Pink { - -void SequenceItem::deserialize(Archive &archive) { - archive >> _actorName >> _actionName; - if (!dynamic_cast<SequenceItemLeader*>(this) && !dynamic_cast<SequenceItemDefaultAction*>(this)) - debug("\t\tSequenceItem: _actor = %s, _action = %s", _actorName.c_str(), _actionName.c_str()); -} - -const Common::String &SequenceItem::getActor() const { - return _actorName; -} - -const Common::String &SequenceItem::getAction() const { - return _actionName; -} - -bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) { - Actor *actor; - Action *action; - if (!(actor = sequence->_sequencer->_page->findActor(_actorName)) || - !(action = actor->findAction(_actionName))) { - return false; - } - - actor->setAction(action, unk2); - Common::Array<SequenceActorState> &states = sequence->_context->_states; - for (int i = 0; i < sequence->_context->_states.size(); ++i) { - if (states[i]._actorName == _actorName){ - states[i]._unk = unk; - sequence->_context->_actor = dynamic_cast<SequenceItemLeader*>(this) ? - actor : sequence->_context->_actor; - // TODO change to virt call - } - } - - return true; -} - -} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/items/sequence_item_default_action.cpp b/engines/pink/items/sequence_item_default_action.cpp deleted file mode 100644 index 3428639f10..0000000000 --- a/engines/pink/items/sequence_item_default_action.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 <engines/pink/archive.h> -#include <common/debug.h> -#include "sequence_item_default_action.h" - -namespace Pink { - -void Pink::SequenceItemDefaultAction::deserialize(Archive &archive) { - SequenceItem::deserialize(archive); - debug("\t\tSequenceItemDefaultAction: _actor = %s, _action = %s", - _actorName.c_str(), _actionName.c_str()); -} - -} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/items/sequence_item_default_action.h b/engines/pink/items/sequence_item_default_action.h deleted file mode 100644 index 99096738b5..0000000000 --- a/engines/pink/items/sequence_item_default_action.h +++ /dev/null @@ -1,37 +0,0 @@ -/* 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_SEQUENCE_ITEM_DEFAULT_ACTION_H -#define PINK_SEQUENCE_ITEM_DEFAULT_ACTION_H - -#include "sequence_item.h" - -namespace Pink { - -class SequenceItemDefaultAction : public SequenceItem { -public: - virtual void deserialize(Archive &archive); -}; - -} // End of namespace Pink - -#endif diff --git a/engines/pink/module.mk b/engines/pink/module.mk index b78f3f16f3..a78312ad5e 100644 --- a/engines/pink/module.mk +++ b/engines/pink/module.mk @@ -8,14 +8,30 @@ MODULE_OBJS = \ sound.o \ file.o \ archive.o \ - object.o \ - module.o \ - page.o \ - inventory.o \ + cursor_mgr.o \ + objects/object.o \ + objects/module.o \ + objects/pages/page.o \ + objects/pages/game_page.o \ + objects/inventory.o \ + objects/side_effect.o \ + objects/condition.o \ resource_mgr.o \ - actions/action.o \ - actors/actor.o \ - actors/lead_actor.o \ + objects/actions/action.o \ + objects/actions/action_cel.o \ + objects/actions/action_hide.o \ + objects/actions/action_play.o \ + objects/actions/action_sound.o \ + objects/actions/action_still.o \ + objects/actors/actor.o \ + objects/actors/lead_actor.o \ + objects/walk/walk_mgr.o \ + objects/walk/walk_location.o \ + objects/sequences/sequence.o \ + objects/sequences/sequence_item.o \ + objects/sequences/sequencer.o \ + objects/handlers/handler.o \ + objects/handlers/handler_timer.o \ # This module can be built as a plugin diff --git a/engines/pink/actions/action.cpp b/engines/pink/objects/actions/action.cpp index dfeed6f2c7..0853e377aa 100644 --- a/engines/pink/actions/action.cpp +++ b/engines/pink/objects/actions/action.cpp @@ -21,8 +21,8 @@ */ #include "action.h" -#include "../actors/actor.h" -#include "../archive.h" +#include "engines/pink/objects/actors/actor.h" +#include "engines/pink/archive.h" namespace Pink { diff --git a/engines/pink/actions/action.h b/engines/pink/objects/actions/action.h index 1037181f44..5b164a3052 100644 --- a/engines/pink/actions/action.h +++ b/engines/pink/objects/actions/action.h @@ -23,7 +23,7 @@ #ifndef PINK_ACTION_H #define PINK_ACTION_H -#include "../object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -32,8 +32,10 @@ class Actor; class Action : public NamedObject { public: virtual void deserialize(Archive &archive); - virtual void play(bool unk_startNow) {}; //?? not sure about parameter + virtual void start(bool unk) {}; virtual void end() {}; + virtual void update() {}; + virtual void toConsole() {}; protected: Actor *_actor; diff --git a/engines/pink/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index a84ea41932..f1c350473f 100644 --- a/engines/pink/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -20,8 +20,9 @@ * */ +#include <common/debug.h> #include "action_cel.h" -#include "../archive.h" +#include "engines/pink/archive.h" namespace Pink { diff --git a/engines/pink/actions/action_cel.h b/engines/pink/objects/actions/action_cel.h index ca481f7747..8c6a61a405 100644 --- a/engines/pink/actions/action_cel.h +++ b/engines/pink/objects/actions/action_cel.h @@ -33,7 +33,7 @@ public: protected: Common::String _fileName; - uint32 _z; // Z coordinate for sprite + uint32 _z; }; } // End of namespace Pink diff --git a/engines/pink/actions/action_hide.cpp b/engines/pink/objects/actions/action_hide.cpp index a63cc49c25..7df43662bc 100644 --- a/engines/pink/actions/action_hide.cpp +++ b/engines/pink/objects/actions/action_hide.cpp @@ -21,7 +21,7 @@ */ #include "action_hide.h" -#include "../actors/actor.h" +#include "engines/pink/objects/actors/actor.h" #include <engines/pink/archive.h> #include <common/debug.h> @@ -30,7 +30,6 @@ namespace Pink { void Pink::ActionHide::deserialize(Archive &archive) { Action::deserialize(archive); - debug("\tActionHide: _name = %s", _name.c_str()); } void ActionHide::play(bool unk_startNow) { @@ -42,4 +41,8 @@ void ActionHide::end() { debug("ActionHide %s is ended", _name.c_str()); } +void ActionHide::toConsole() { + debug("\tActionHide: _name = %s", _name.c_str()); +} + } //End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/actions/action_hide.h b/engines/pink/objects/actions/action_hide.h index e9b3294dab..fa6e717ede 100644 --- a/engines/pink/actions/action_hide.h +++ b/engines/pink/objects/actions/action_hide.h @@ -31,6 +31,8 @@ class ActionHide : public Action { public: virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void play(bool unk_startNow); virtual void end(); }; diff --git a/engines/pink/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp index 9dc2ef479a..5e6b692d30 100644 --- a/engines/pink/actions/action_play.cpp +++ b/engines/pink/objects/actions/action_play.cpp @@ -22,13 +22,16 @@ #include <common/debug.h> #include "action_play.h" -#include "../archive.h" +#include "engines/pink/archive.h" namespace Pink { void ActionPlay::deserialize(Archive &archive) { ActionStill::deserialize(archive); archive >> _stopFrame; +} + +void ActionPlay::toConsole() { debug("\tActionPlay: _name = %s, _fileName = %s, z = %u, _startFrame = %u," " _endFrame = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame); } diff --git a/engines/pink/actions/action_play.h b/engines/pink/objects/actions/action_play.h index 00360d9fc0..d53b44a1d1 100644 --- a/engines/pink/actions/action_play.h +++ b/engines/pink/objects/actions/action_play.h @@ -29,7 +29,9 @@ namespace Pink { class ActionPlay : public ActionStill { +public: virtual void deserialize(Archive &archive); + virtual void toConsole(); private: uint32 _stopFrame; diff --git a/engines/pink/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp index ee85689d4f..f389f97a1a 100644 --- a/engines/pink/actions/action_sound.cpp +++ b/engines/pink/objects/actions/action_sound.cpp @@ -22,18 +22,51 @@ #include <common/debug.h> #include "action_sound.h" -#include "../archive.h" +#include "engines/pink/archive.h" +#include <engines/pink/objects/actors/actor.h> +#include <engines/pink/objects/pages/game_page.h> +#include <engines/pink/sound.h> + namespace Pink { +ActionSound::ActionSound() + : _sound(nullptr), _isStopped(1) +{} + void ActionSound::deserialize(Archive &archive) { Action::deserialize(archive); archive >> _fileName; _volume = archive.readDWORD(); _isLoop = (bool) archive.readDWORD(); _isBackground = (bool) archive.readDWORD(); +} + +void ActionSound::toConsole() { debug("\tActionSound: _name = %s, _fileName = %s, _volume = %u, _isLoop = %u," " _isBackground = %u", _name.c_str(), _fileName.c_str(), _volume, _isLoop, _isBackground); } +void ActionSound::start(bool unk) { + assert(!_sound); + _sound = _actor->getPage()->loadSound(_fileName); + + Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::SoundType::kMusicSoundType + : Audio::Mixer::SoundType::kSpeechSoundType; + _sound->play(soundType, _volume, _isLoop); + if (_isLoop) + _actor->endAction(); +} + +void ActionSound::end() { + _sound->stop(); + delete _sound; + _sound = nullptr; +} + +void ActionSound::update() { + if (!_sound->isPlaying()) + _actor->endAction(); +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h index 15b27d795b..e4bb2f1822 100644 --- a/engines/pink/actions/action_sound.h +++ b/engines/pink/objects/actions/action_sound.h @@ -31,8 +31,15 @@ class Sound; class ActionSound : public Action { public: + ActionSound(); virtual void deserialize(Archive &archive); + virtual void toConsole(); + + virtual void start(bool unk_startNow); + virtual void end(); + virtual void update(); + private: Sound *_sound; Common::String _fileName; diff --git a/engines/pink/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp index b33476a034..3c6bf17cad 100644 --- a/engines/pink/actions/action_still.cpp +++ b/engines/pink/objects/actions/action_still.cpp @@ -22,18 +22,18 @@ #include <common/debug.h> #include "action_still.h" -#include "../archive.h" -#include "action_play.h" +#include "engines/pink/archive.h" namespace Pink { void ActionStill::deserialize(Archive &archive) { ActionCEL::deserialize(archive); archive >> _startFrame; - if (!dynamic_cast<ActionPlay*>(this)){ - debug("\tActionStill: _name = %s, _fileName = %s, _startFrame = %u", - _name.c_str(), _fileName.c_str(), _startFrame); - } +} + +void ActionStill::toConsole() { + debug("\tActionStill: _name = %s, _fileName = %s, _startFrame = %u", + _name.c_str(), _fileName.c_str(), _startFrame); } } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/actions/action_still.h b/engines/pink/objects/actions/action_still.h index 1400766a91..075371a9cc 100644 --- a/engines/pink/actions/action_still.h +++ b/engines/pink/objects/actions/action_still.h @@ -30,6 +30,7 @@ namespace Pink { class ActionStill : public ActionCEL { public: virtual void deserialize(Archive &archive); + virtual void toConsole(); protected: uint32 _startFrame; diff --git a/engines/pink/items/sequence_item_leader.cpp b/engines/pink/objects/actions/walk_action.cpp index 5e19fb4317..39be8f4443 100644 --- a/engines/pink/items/sequence_item_leader.cpp +++ b/engines/pink/objects/actions/walk_action.cpp @@ -20,17 +20,21 @@ * */ +#include "walk_action.h" #include <engines/pink/archive.h> #include <common/debug.h> -#include "sequence_item_leader.h" namespace Pink { +void WalkAction::deserialize(Archive &archive) { + ActionCEL::deserialize(archive); + uint32 calcFramePositions = archive.readDWORD(); + _toCalcFramePositions = calcFramePositions ? true : false; +} -void Pink::SequenceItemLeader::deserialize(Archive &archive) { - SequenceItem::deserialize(archive); - debug("\t\tSequenceItemLeader: _actor = %s, _action = %s", - _actorName.c_str(), _actionName.c_str()); +void WalkAction::toConsole() { + debug("\tWalkAction: _name = %s, _fileName = %s, _calcFramePositions = %u", + _name.c_str(), _fileName.c_str(), _toCalcFramePositions); } -} //End of namespace Pink
\ No newline at end of file +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/items/sequence_item_leader.h b/engines/pink/objects/actions/walk_action.h index b5506ad64d..923811fe47 100644 --- a/engines/pink/items/sequence_item_leader.h +++ b/engines/pink/objects/actions/walk_action.h @@ -20,18 +20,21 @@ * */ -#ifndef PINK_SEQUENCE_ITEM_LEADER_H -#define PINK_SEQUENCE_ITEM_LEADER_H +#ifndef PINK_WALK_ACTION_H +#define PINK_WALK_ACTION_H -#include "sequence_item.h" +#include "action_cel.h" namespace Pink { -class SequenceItemLeader : public SequenceItem { +class WalkAction : public ActionCEL { public: virtual void deserialize(Archive &archive); + virtual void toConsole(); + private: + bool _toCalcFramePositions; }; } diff --git a/engines/pink/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index c10df16919..c02cb67365 100644 --- a/engines/pink/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -21,22 +21,26 @@ */ #include "actor.h" -#include "../page.h" +#include "engines/pink/objects/pages/game_page.h" #include "lead_actor.h" -#include "../actions/action.h" +#include "engines/pink/objects/actions/action.h" namespace Pink { void Actor::deserialize(Archive &archive) { NamedObject::deserialize(archive); _page = static_cast<GamePage*>(archive.readObject()); - if (dynamic_cast<LeadActor*>(this)) - debug("LeadActor: _name = %s", _name.c_str()); - else debug("Actor: _name = %s", _name.c_str()); archive >> _actions; } -Sequencer *Actor::getSequencer() { +void Actor::toConsole() { + debug("Actor: _name = %s", _name.c_str()); + for (int i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } +} + +Sequencer *Actor::getSequencer() const { return _page->getSequencer(); } @@ -61,7 +65,7 @@ void Actor::init(bool unk) { } else { _isActionEnd = 0; - _action->play(unk); + _action->start(unk); } } @@ -86,7 +90,7 @@ void Actor::setAction(Action *newAction) { if (newAction) { _isActionEnd = 0; _action = newAction; - _action->play(0); + _action->start(0); } } @@ -99,4 +103,8 @@ void Actor::setAction(Action *newAction, bool unk) { else setAction(newAction); } +Action *Actor::getAction() const { + return _action; +} + } // End of namespace Pink diff --git a/engines/pink/actors/actor.h b/engines/pink/objects/actors/actor.h index 040a482606..a31f5539d3 100644 --- a/engines/pink/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -24,7 +24,7 @@ #define PINK_ACTOR_H #include <common/array.h> -#include "../object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -40,8 +40,12 @@ public: {}; virtual void deserialize(Archive &archive); - Sequencer *getSequencer(); + virtual void toConsole(); + + Sequencer *getSequencer() const; GamePage *getPage() const; + Action *getAction() const; + virtual void init(bool unk); void hide(); diff --git a/engines/pink/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 12187d61db..2c886126cd 100644 --- a/engines/pink/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -21,12 +21,13 @@ */ #include "lead_actor.h" -#include "../walk/walk_mgr.h" -#include "../cursor_mgr.h" -#include "engines/pink/sequences/sequencer.h" -#include "../archive.h" -#include "../page.h" -#include "../pink.h" +#include <engines/pink/objects/actions/action.h> +#include "engines/pink/objects/walk/walk_mgr.h" +#include "engines/pink/cursor_mgr.h" +#include "engines/pink/objects/sequences/sequencer.h" +#include "engines/pink/archive.h" +#include "engines/pink/objects/pages/game_page.h" +#include "engines/pink/pink.h" namespace Pink { @@ -48,8 +49,15 @@ void LeadActor::init(bool unk) { if (_state == unk_Loading){ _state = Ready; } - //TODO set actor ref to inv mgr + _page->getModule()->getInventoryMgr()->setLeadActor(this); Actor::init(unk); } +void LeadActor::toConsole() { + debug("LeadActor: _name = %s", _name.c_str()); + for (int i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } +} + } // End of namespace Pink diff --git a/engines/pink/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index 3954df1180..762facbf1e 100644 --- a/engines/pink/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -45,8 +45,10 @@ public: }; virtual void deserialize(Archive &archive); - void setNextExecutors (Common::String &nextModule, Common::String &nextPage); + virtual void toConsole(); + + void setNextExecutors (Common::String &nextModule, Common::String &nextPage); virtual void init(bool unk); private: diff --git a/engines/pink/objects/condition.cpp b/engines/pink/objects/condition.cpp new file mode 100644 index 0000000000..71a68d4f3a --- /dev/null +++ b/engines/pink/objects/condition.cpp @@ -0,0 +1,98 @@ +/* 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 <engines/pink/archive.h> +#include <engines/pink/objects/actors/lead_actor.h> +#include <engines/pink/objects/pages/game_page.h> +#include <engines/pink/pink.h> +#include "condition.h" + +namespace Pink { + +void Pink::ConditionVariable::deserialize(Archive &archive) { + archive >> _name >> _value; +} + +bool Pink::ConditionGameVariable::evaluate(LeadActor *leadActor) { + return leadActor->getPage()->getModule()->getGame()->checkValueOfVariable(_name, _value); +} + +void ConditionGameVariable::toConsole() { + debug("\t\tConditionGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + +bool Pink::ConditionModuleVariable::evaluate(LeadActor *leadActor) { + return leadActor->getPage()->getModule()->checkValueOfVariable(_name, _value); +} + +void ConditionModuleVariable::toConsole() { + debug("\t\tConditionModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + +bool Pink::ConditionNotModuleVariable::evaluate(LeadActor *leadActor) { + return !ConditionModuleVariable::evaluate(leadActor); +} + +void ConditionNotModuleVariable::toConsole() { + debug("\t\tConditionNotModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + +bool ConditionPageVariable::evaluate(LeadActor *leadActor) { + return leadActor->getPage()->checkValueOfVariable(_name, _value); +} + +void ConditionPageVariable::toConsole() { + debug("\t\tConditionPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + +bool ConditionNotPageVariable::evaluate(LeadActor *leadActor) { + return !ConditionPageVariable::evaluate(leadActor); +} + +void ConditionNotPageVariable::toConsole() { + debug("\t\tConditionNotPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + +void ConditionInventoryItemOwner::deserialize(Archive &archive) { + archive >> _item >> _owner; +} + +bool ConditionInventoryItemOwner::evaluate(LeadActor *leadActor) { + InventoryMgr *mgr = leadActor->getPage()->getModule()->getInventoryMgr(); + InventoryItem *item = mgr->findInventoryItem(_item); + return item->getCurrentOwner() == _owner; +} + +void ConditionInventoryItemOwner::toConsole() { + debug("\t\tConditionInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); +} + +bool ConditionNotInventoryItemOwner::evaluate(LeadActor *leadActor) { + return !ConditionInventoryItemOwner::evaluate(leadActor); +} + +void ConditionNotInventoryItemOwner::toConsole() { + debug("\t\tConditionNotInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); +} + +} // End of namespace Pink + diff --git a/engines/pink/objects/condition.h b/engines/pink/objects/condition.h new file mode 100644 index 0000000000..6df1920046 --- /dev/null +++ b/engines/pink/objects/condition.h @@ -0,0 +1,106 @@ + /* 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_CONDITION_H +#define PINK_CONDITION_H + +#include <engines/pink/objects/object.h> + +namespace Pink { + +class LeadActor; + +class Condition : public Object { +public: + virtual void deserialize(Archive &archive) = 0; + virtual bool evaluate(LeadActor *leadActor) = 0; +}; + +class ConditionVariable : public Condition { +public: + + virtual void deserialize(Archive &archive); + virtual bool evaluate(LeadActor *leadActor) = 0; + +protected: + Common::String _name; + Common::String _value; +}; + +class ConditionGameVariable : public ConditionVariable { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +/* + * It is not used in games and has evaluate method with infinity recursion +class ConditionNotGameVariable : public ConditionGameVariable { + virtual bool evaluate(LeadActor *leadActor); +}; + */ + +class ConditionModuleVariable : public ConditionVariable { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +class ConditionNotModuleVariable : public ConditionModuleVariable { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +class ConditionPageVariable : public ConditionVariable { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +class ConditionNotPageVariable : public ConditionPageVariable { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +class ConditionInventoryItemOwner : public Condition { +public: + virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual bool evaluate(LeadActor *leadActor); + +protected: + Common::String _item; + Common::String _owner; +}; + +class ConditionNotInventoryItemOwner : public ConditionInventoryItemOwner { +public: + virtual void toConsole(); + virtual bool evaluate(LeadActor *leadActor); +}; + +} // End of namespace Pink + + +#endif diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp new file mode 100644 index 0000000000..6a53832d4a --- /dev/null +++ b/engines/pink/objects/handlers/handler.cpp @@ -0,0 +1,89 @@ +/* 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 "handler.h" +#include "engines/pink/archive.h" +#include "engines/pink/objects/side_effect.h" +#include <engines/pink/objects/condition.h> +#include <engines/pink/objects/sequences/sequencer.h> +#include <engines/pink/objects/sequences/sequence.h> +#include <engines/pink/objects/actors/lead_actor.h> +#include <common/debug.h> + +namespace Pink { + +void Handler::deserialize(Archive &archive) { + archive >> _conditions; + archive >> _sideEffects; +} + +bool Handler::isSuitable(LeadActor *actor) { + for (int i = 0; i < _conditions.size(); ++i) { + if (_conditions[i]->evaluate(actor)){ + return false; + } + } + return true; +} + +void Handler::prepareForNextHandler(LeadActor *actor) { + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->execute(actor); + } +} + +void HandlerSequences::deserialize(Archive &archive) { + Handler::deserialize(archive); + archive >> _sequences; +} + +void HandlerSequences::init(LeadActor *actor) { + prepareForNextHandler(actor); + Sequencer *sequencer = actor->getSequencer(); + Sequence *sequence = sequencer->findSequence(_sequences[0]); //actually we must pick random sequence + sequencer->authorSequence(sequence, 0); +} + +void HandlerStartPage::handle(Sequence *sequence) { + sequence->_unk = 1; +} + +void HandlerStartPage::toConsole() { + debug("HandlerStartPage:"); + + debug("\tSideEffects:"); + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (int i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (int i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } +} + +} // End of namespace Pink diff --git a/engines/pink/handlers/handler.h b/engines/pink/objects/handlers/handler.h index beca2ffa65..4f8cc28779 100644 --- a/engines/pink/handlers/handler.h +++ b/engines/pink/objects/handlers/handler.h @@ -23,25 +23,50 @@ #ifndef PINK_HANDLER_H #define PINK_HANDLER_H -#include <engines/pink/object.h> #include <common/array.h> +#include <common/str-array.h> +#include <engines/pink/objects/object.h> + namespace Pink { +class Condition; class SideEffect; class LeadActor; class Handler : public Object { public: virtual void deserialize(Archive &archive); - bool initConditions(LeadActor *actor); - void initSideEffects(LeadActor *actor); + bool isSuitable(LeadActor *actor); protected: - //_conditions + void prepareForNextHandler(LeadActor *actor); + + Common::Array<Condition*> _conditions; Common::Array<SideEffect*> _sideEffects; }; +class Sequence; + +class HandlerSequences : public Handler { +public: + virtual void deserialize(Archive &archive); + void init(LeadActor *actor); + virtual void handle(Sequence *sequence) = 0; + +protected: + Common::StringArray _sequences; +}; + +class HandlerStartPage : public HandlerSequences { +public: + ~HandlerStartPage() {}; + + virtual void toConsole(); + + virtual void handle(Sequence *sequence); +}; + } // End of namespace Pink #endif diff --git a/engines/pink/objects/handlers/handler_mgr.cpp b/engines/pink/objects/handlers/handler_mgr.cpp new file mode 100644 index 0000000000..9c8d43c0f7 --- /dev/null +++ b/engines/pink/objects/handlers/handler_mgr.cpp @@ -0,0 +1,5 @@ +// +// Created by andrei on 3/21/18. +// + +#include "handler_mgr.h" diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h new file mode 100644 index 0000000000..978f8d91b3 --- /dev/null +++ b/engines/pink/objects/handlers/handler_mgr.h @@ -0,0 +1,14 @@ +// +// Created by andrei on 3/21/18. +// + +#ifndef SCUMMVM_HANDLER_MGR_H +#define SCUMMVM_HANDLER_MGR_H + + +class HandlerMgr { + +}; + + +#endif //SCUMMVM_HANDLER_MGR_H diff --git a/engines/pink/side_effects/side_effect.h b/engines/pink/objects/handlers/handler_timer.cpp index 45099f3126..2c6161b46f 100644 --- a/engines/pink/side_effects/side_effect.h +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -20,22 +20,25 @@ * */ -#ifndef PINK_SIDE_EFFECT_H -#define PINK_SIDE_EFFECT_H - -#include <engines/pink/object.h> +#include "handler_timer.h" namespace Pink { -class LeadActor; -class SideEffect : public Object { -public: - virtual ~SideEffect() {}; - virtual void init(LeadActor *actor) {}; +void HandlerTimerActions::deserialize(Archive &archive) { + Handler::deserialize(archive); +} + +void HandlerTimerActions::handle(LeadActor *actor) { + +} + +void HandlerTimerSequences::deserialize(Archive &archive) { + Handler::deserialize(archive); +} -}; +void HandlerTimerSequences::handle(LeadActor *actor) { } -#endif +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/handlers/handler_sequences.h b/engines/pink/objects/handlers/handler_timer.h index b55d81ce38..21d9518e04 100644 --- a/engines/pink/handlers/handler_sequences.h +++ b/engines/pink/objects/handlers/handler_timer.h @@ -19,23 +19,39 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -#ifndef PINK_HANDLER_SEQUENCES_H -#define PINK_HANDLER_SEQUENCES_H -#include <engines/pink/utils.h> +#ifndef PINK_HANDLER_TIMER_H +#define PINK_HANDLER_TIMER_H + +#include <common/str-array.h> #include "handler.h" namespace Pink { -class HandlerSequences : public Handler { -public: +class LeadActor; + +// This class has difference in games +class HandlerTimer : public Handler { + virtual void handle(LeadActor *actor) = 0; +}; + +class HandlerTimerActions : public HandlerTimer { virtual void deserialize(Archive &archive); - void initSequence(LeadActor *actor); + virtual void handle(LeadActor *actor); -protected: - StringArray _sequences; +private: + Common::StringArray _actions; +}; + +class HandlerTimerSequences : public HandlerTimer { + virtual void deserialize(Archive &archive); + virtual void handle(LeadActor *actor); + +private: + Common::StringArray _sequences; }; } // End of namespace Pink + #endif diff --git a/engines/pink/inventory.cpp b/engines/pink/objects/inventory.cpp index ed2569e7c1..feed41a29b 100644 --- a/engines/pink/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -21,8 +21,9 @@ */ +#include <common/debug.h> #include "inventory.h" -#include "archive.h" +#include "engines/pink/archive.h" namespace Pink { @@ -32,14 +33,40 @@ void Pink::InventoryItem::deserialize(Archive &archive) { _currentOwner = _initialOwner; } +Common::String &InventoryItem::getCurrentOwner() { + return _currentOwner; +} + +void InventoryItem::toConsole() { + debug("\tInventoryItem: _initialOwner=%s _currentOwner=%s", _initialOwner, _currentOwner); +} + InventoryMgr::~InventoryMgr() { - for (uint i = 0; i < _invItems.size(); ++i) { - delete _invItems[i]; + for (uint i = 0; i < _items.size(); ++i) { + delete _items[i]; } } void InventoryMgr::deserialize(Archive &archive) { - archive >> _invItems; + archive >> _items; +} + +InventoryItem *InventoryMgr::findInventoryItem(Common::String &name) { + return *Common::find_if(_items.begin(), _items.end(), [&name] + (InventoryItem *item) { + return name == item->getName(); + });; +} + +void InventoryMgr::setLeadActor(LeadActor *lead) { + _lead = lead; +} + +void InventoryMgr::toConsole() { + debug("InventoryMgr:"); + for (int i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } } // End of namespace Pink diff --git a/engines/pink/inventory.h b/engines/pink/objects/inventory.h index 197c226e5d..ca1ef7fb69 100644 --- a/engines/pink/inventory.h +++ b/engines/pink/objects/inventory.h @@ -25,7 +25,7 @@ #include <common/array.h> -#include "engines/pink/object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -34,19 +34,30 @@ class InventoryItem : public NamedObject { public: virtual void deserialize(Archive &archive); + virtual void toConsole(); + + Common::String &getCurrentOwner(); + private: Common::String _initialOwner; Common::String _currentOwner; }; +class LeadActor; + class InventoryMgr : public Object { public: virtual ~InventoryMgr(); - virtual void deserialize(Archive &archive); + virtual void toConsole(); + + void setLeadActor(LeadActor *lead); + InventoryItem* findInventoryItem(Common::String &name); + private: - Common::Array<InventoryItem*> _invItems; + LeadActor *_lead; + Common::Array<InventoryItem*> _items; // other fields. haven't RE them yet }; diff --git a/engines/pink/module.cpp b/engines/pink/objects/module.cpp index 28ca3549b2..97f78d4637 100644 --- a/engines/pink/module.cpp +++ b/engines/pink/objects/module.cpp @@ -21,7 +21,7 @@ */ #include "module.h" -#include "page.h" +#include "engines/pink/objects/pages/game_page.h" namespace Pink { @@ -95,8 +95,17 @@ PinkEngine *Module::getGame() const { return _game; } -Common::StringMap &Module::getMap() { - return _map; +bool Module::checkValueOfVariable(Common::String &variable, Common::String &value) { + assert(_variables.contains(variable)); + return _variables[variable] == value; +} + +void Module::setVariable(Common::String &variable, Common::String &value) { + _variables[variable] = value; +} + +InventoryMgr *Module::getInventoryMgr() { + return &_invMgr; } } // End of namespace Pink diff --git a/engines/pink/module.h b/engines/pink/objects/module.h index abaf679f63..214ff2a473 100644 --- a/engines/pink/module.h +++ b/engines/pink/objects/module.h @@ -23,13 +23,11 @@ #ifndef PINK_MODULE_H #define PINK_MODULE_H -#include "archive.h" -#include <common/str.h> -#include "engines/pink/object.h" +#include "engines/pink/archive.h" +#include "engines/pink/objects/object.h" #include <common/debug.h> -#include <engines/pink/utils.h> #include <common/hash-str.h> -#include "inventory.h" +#include "engines/pink/objects/inventory.h" namespace Pink { @@ -40,6 +38,7 @@ public: }; class PinkEngine; +class GamePage; class Module : public NamedObject { public: @@ -52,17 +51,19 @@ public: void OnMouseMove(); void OnKeyboardButtonClick(); - Common::StringMap &getMap(); PinkEngine *getGame() const; + InventoryMgr *getInventoryMgr(); + bool checkValueOfVariable(Common::String &variable, Common::String &value); + void setVariable(Common::String &variable, Common::String &value); private: PinkEngine *_game; GamePage *_page; - PagesArray _pages; + Common::Array<GamePage*> _pages; InventoryMgr _invMgr; - Common::StringMap _map; // used for saves and maybe for smth else + Common::StringMap _variables; }; diff --git a/engines/pink/object.cpp b/engines/pink/objects/object.cpp index 3d0a2ae0f6..eac48bdfe6 100644 --- a/engines/pink/object.cpp +++ b/engines/pink/objects/object.cpp @@ -22,7 +22,7 @@ #include <common/debug.h> #include "object.h" -#include "archive.h" +#include "engines/pink/archive.h" namespace Pink { diff --git a/engines/pink/object.h b/engines/pink/objects/object.h index bd058cf958..1f67c3dac7 100644 --- a/engines/pink/object.h +++ b/engines/pink/objects/object.h @@ -36,6 +36,7 @@ public: virtual void store(Archive &){}; virtual void deserialize(Archive &){}; virtual void init() {} + virtual void toConsole() {}; }; class NamedObject : public Object { diff --git a/engines/pink/side_effects/side_effect.cpp b/engines/pink/objects/pages/game_page.cpp index 58d8830ddc..58d8830ddc 100644 --- a/engines/pink/side_effects/side_effect.cpp +++ b/engines/pink/objects/pages/game_page.cpp diff --git a/engines/pink/page.h b/engines/pink/objects/pages/game_page.h index a2458c12ad..f92a9662cc 100644 --- a/engines/pink/page.h +++ b/engines/pink/objects/pages/game_page.h @@ -20,55 +20,37 @@ * */ -#ifndef PINK_PAGE_H -#define PINK_PAGE_H +#ifndef PINK_GAME_PAGE_H +#define PINK_GAME_PAGE_H -#include "engines/pink/object.h" -#include "engines/pink/module.h" -#include "resource_mgr.h" +#include "page.h" namespace Pink { -class Archive; -class Actor; -class LeadActor; - - -class Page : public NamedObject { -public: - - void load(Archive &archive); - Actor *findActor(Common::String &name); - -protected: - ResourceMgr _resMgr; - LeadActor *_leadActor; - Common::Array<Actor*> _actors; - - /* - int unk_1; - CString _str; - */ -}; - - class CursorMgr; class WalkMgr; class Sequencer; class Handler; -class GamePage : public Page { +class GamePage : public Page { public: virtual void deserialize(Archive &archive); + virtual void load(Archive &archive); + void loadManagers(); void init(bool isLoadingSave); PinkEngine *getGame(); Sequencer *getSequencer(); + WalkMgr *getWalkMgr(); + Module *getModule() const; + bool checkValueOfVariable(Common::String &variable, Common::String &value); + void setVariable(Common::String &variable, Common::String &value); + virtual void toConsole(); private: int perhapsIsLoaded; @@ -76,17 +58,16 @@ private: CursorMgr *_cursorMgr; WalkMgr *_walkMgr; Sequencer *_sequencer; - Common::Array<Handler*> _handlers; + Common::Array<Handler *> _handlers; + Common::StringMap _variables; /* - int perhaps_notLoaded; int cunk_1; int memfile; - CMapStringToString map; int unk; */ }; -} // End of namespace Pink +} -#endif
\ No newline at end of file +#endif //SCUMMVM_GAME_PAGE_H diff --git a/engines/pink/page.cpp b/engines/pink/objects/pages/page.cpp index 3d644db759..6eb9ff2b8b 100644 --- a/engines/pink/page.cpp +++ b/engines/pink/objects/pages/page.cpp @@ -20,13 +20,12 @@ * */ -#include <engines/pink/walk/walk_mgr.h> -#include <engines/pink/handlers/handler.h> -#include <engines/pink/handlers/handler_sequences.h> -#include "page.h" -#include "cursor_mgr.h" -#include "actors/lead_actor.h" -#include "engines/pink/sequences/sequencer.h" +#include <engines/pink/objects/walk/walk_mgr.h> +#include <engines/pink/objects/handlers/handler.h> +#include "game_page.h" +#include "engines/pink/cursor_mgr.h" +#include "engines/pink/objects/actors/lead_actor.h" +#include "engines/pink/objects/sequences/sequencer.h" namespace Pink { @@ -44,6 +43,16 @@ Actor *Page::findActor(Common::String &name) { });; } +Sound *Page::loadSound(Common::String &fileName) { + return _resMgr.loadSound(fileName); +} + +void Page::toConsole() { + for (int i = 0; i < _actors.size(); ++i) { + _actors[i]->toConsole(); + } +} + void GamePage::deserialize(Archive &archive) { Page::deserialize(archive); @@ -67,21 +76,24 @@ void GamePage::load(Archive &archive) { } void GamePage::init(bool isLoadingSave) { + if (!isLoadingSave){ //assert(perhapsIsLoaded == 0); loadManagers(); } + toConsole(); + for (int i = 0; i < _actors.size(); ++i) { _actors[i]->init(0); } if (!isLoadingSave) { for (uint i = 0; i < _handlers.size(); ++i) { - if (_handlers[i]->initConditions(_leadActor)){ + if (_handlers[i]->isSuitable(_leadActor)){ HandlerSequences *handlerSequences = dynamic_cast<HandlerSequences*>(_handlers[i]); assert(handlerSequences); - handlerSequences->initSequence(_leadActor); + handlerSequences->init(_leadActor); break; } } @@ -114,5 +126,26 @@ Module *GamePage::getModule() const { return _module; } +bool GamePage::checkValueOfVariable(Common::String &variable, Common::String &value) { + assert(_variables.contains(variable)); + return _variables[variable] == value; +} + +void GamePage::setVariable(Common::String &variable, Common::String &value) { + _variables[variable] = value; +} + +WalkMgr *GamePage::getWalkMgr() { + return _walkMgr; +} + +void GamePage::toConsole() { + Page::toConsole(); + _walkMgr->toConsole(); + _sequencer->toConsole(); + for (int i = 0; i < _handlers.size(); ++i) { + _handlers[i]->toConsole(); + } +} } // End of namespace Pink diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h new file mode 100644 index 0000000000..63d45510e5 --- /dev/null +++ b/engines/pink/objects/pages/page.h @@ -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. + * + */ + +#ifndef PINK_PAGE_H +#define PINK_PAGE_H + +#include "engines/pink/objects/object.h" +#include "engines/pink/objects/module.h" +#include "engines/pink/resource_mgr.h" + +namespace Pink { + +class Archive; +class Actor; +class LeadActor; + +class Page : public NamedObject { +public: + + void load(Archive &archive); + Actor *findActor(Common::String &name); + Sound* loadSound(Common::String &fileName); + + virtual void toConsole(); + +protected: + Common::Array<Actor*> _actors; + ResourceMgr _resMgr; + LeadActor *_leadActor; + + /* + int unk_1; + CString _str; + */ +}; + +} // End of namespace Pink + +#endif
\ No newline at end of file diff --git a/engines/pink/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index 034078f725..0af8f1a3fa 100644 --- a/engines/pink/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -21,22 +21,39 @@ */ #include <common/debug.h> -#include <engines/pink/items/sequence_item_leader.h> +#include "sequence_item.h" #include "sequence.h" #include "sequencer.h" -#include "../archive.h" -#include "../page.h" -#include "../actors/actor.h" +#include "engines/pink/archive.h" +#include "engines/pink/objects/pages/game_page.h" +#include "engines/pink/objects/actors/actor.h" namespace Pink { +Sequence::Sequence() + : _unk(0), _context(nullptr), + _sequencer(nullptr) {} + +Sequence::~Sequence() { + for (int i = 0; i < _items.size(); ++i) { + delete _items[i]; + } +} + void Sequence::deserialize(Archive &archive) { NamedObject::deserialize(archive); - debug("\tSequence %s", _name.c_str()); _sequencer = static_cast<Sequencer*>(archive.readObject()); archive >> _items; } +void Sequence::toConsole() { + debug("\t\tSequence %s", _name.c_str()); + debug("\t\t\tItems:"); + for (int i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } +} + Common::Array<SequenceItem*> &Sequence::getItems() { return _items; } @@ -66,7 +83,7 @@ void Sequence::start(int unk) { uint i; for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ - if (dynamic_cast<SequenceItemLeader*>(_items[i])) + if (_items[i]->isLeader()) break; _items[i]->execute(_context->_unk, this, unk); } @@ -83,7 +100,8 @@ void Sequence::start(int unk) { assert(actor); action = actor->findAction(states[j]._actionName); assert(action); - actor->setAction(action, unk); + if (actor->getAction() != action) + actor->setAction(action, unk); } } _context->_unk++; diff --git a/engines/pink/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index 02f3904d56..f2f324b8ca 100644 --- a/engines/pink/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -23,7 +23,7 @@ #ifndef PINK_SEQUENCE_H #define PINK_SEQUENCE_H -#include <engines/pink/object.h> +#include <engines/pink/objects/object.h> #include <common/array.h> namespace Pink { @@ -34,8 +34,12 @@ class SequenceContext; class Sequence : public NamedObject { public: + Sequence(); + virtual ~Sequence(); virtual void deserialize(Archive &archive); + virtual void toConsole(); + Common::Array<SequenceItem*> &getItems(); void setContext(SequenceContext *context); diff --git a/engines/pink/objects/sequences/sequence_item.cpp b/engines/pink/objects/sequences/sequence_item.cpp new file mode 100644 index 0000000000..732424a075 --- /dev/null +++ b/engines/pink/objects/sequences/sequence_item.cpp @@ -0,0 +1,109 @@ +/* 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 "sequence_item.h" +#include <common/debug.h> +#include <engines/pink/objects/sequences/sequence.h> +#include <engines/pink/objects/sequences/sequencer.h> +#include <engines/pink/objects/actions/action.h> +#include "engines/pink/archive.h" +#include "engines/pink/objects/pages/game_page.h" +#include "engines/pink/objects/actors/actor.h" + +namespace Pink { + +void SequenceItem::deserialize(Archive &archive) { + archive >> _actor >> _action; +} + +void SequenceItem::toConsole() { + debug("\t\t\t\tSequenceItem: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); +} + +const Common::String &SequenceItem::getActor() const { + return _actor; +} + +const Common::String &SequenceItem::getAction() const { + return _action; +} + +bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) { + Actor *actor; + Action *action; + if (!(actor = sequence->_sequencer->_page->findActor(_actor)) || + !(action = actor->findAction(_action))) { + assert(0); + return false; + } + + actor->setAction(action, unk2); + Common::Array<SequenceActorState> &states = sequence->_context->_states; + for (int i = 0; i < sequence->_context->_states.size(); ++i) { + if (states[i]._actorName == _actor){ + states[i]._unk = unk; + sequence->_context->_actor = isLeader() ? actor : sequence->_context->_actor; + break; + } + } + + return true; +} + +bool SequenceItem::isLeader() { + return false; +} + +bool SequenceItemLeader::isLeader() { + return true; +} + +void SequenceItemLeader::toConsole() { + debug("\t\t\t\tSequenceItemLeader: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); +} + + +void SequenceItemLeaderAudio::deserialize(Archive &archive) { + SequenceItem::deserialize(archive); + archive.readDWORD(); +} + +void SequenceItemLeaderAudio::toConsole() { + debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); +} + +bool SequenceItemDefaultAction::execute(int unk, Sequence *sequence, bool unk2) { + Common::Array<SequenceActorState> &actorStates = sequence->_context->_states; + for (int i = 0; i < actorStates.size(); ++i) { + if (actorStates[i]._actorName == _actor){ + actorStates[i]._actionName = _action; + break; + } + } + return true; +} + +void SequenceItemDefaultAction::toConsole() { + debug("\t\t\t\tSequenceItemDefaultAction: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); +} + +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/items/sequence_item.h b/engines/pink/objects/sequences/sequence_item.h index 2b6d2b9728..70fc68d9c7 100644 --- a/engines/pink/items/sequence_item.h +++ b/engines/pink/objects/sequences/sequence_item.h @@ -23,7 +23,7 @@ #ifndef PINK_SEQUENCE_ITEM_H #define PINK_SEQUENCE_ITEM_H -#include <engines/pink/object.h> +#include <engines/pink/objects/object.h> namespace Pink { @@ -33,16 +33,53 @@ class SequenceItem : public Object { public: virtual void deserialize(Archive &archive); + virtual void toConsole(); + const Common::String &getActor() const; const Common::String &getAction() const; virtual bool execute(int unk, Sequence *sequence, bool unk2); + virtual bool isLeader(); protected: - Common::String _actorName; - Common::String _actionName; + Common::String _actor; + Common::String _action; +}; + +class SequenceItemLeader : public SequenceItem { +public: + virtual void toConsole(); + + virtual bool isLeader(); +}; + +class SequenceItemLeaderAudio : public SequenceItemLeader { + virtual void deserialize(Archive &archive); + +public: + virtual void toConsole(); + +private: + //uint32 _sample; // zero in data files and not used; }; +class SequenceItemDefaultAction : public SequenceItem { +public: + virtual bool execute(int unk, Sequence *sequence, bool unk2); + + virtual void toConsole(); +}; + +/* not used in games but is implemented in engine +class SequenceItemSideEffects : public SequenceItemDefaultAction { +public: + virtual void deserialize(Archive &archive); + virtual bool execute(int unk, Sequence *sequence, bool unk2); +private + Common::Array<SideEffect*> _sideEffects +}; + */ + } #endif diff --git a/engines/pink/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 68b72c1ecd..2bddcbd4f3 100644 --- a/engines/pink/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -32,8 +32,13 @@ Sequencer::Sequencer(GamePage *page) : _context(nullptr), _page(page) {} +Sequencer::~Sequencer() { + for (int i = 0; i < _sequences.size(); ++i) { + delete _sequences[i]; + } +} + void Sequencer::deserialize(Archive &archive) { - debug("Sequencer:"); archive >> _sequences; archive.readCount();// intro have 0 timers; //serialize timers; @@ -56,9 +61,16 @@ void Sequencer::authorSequence(Sequence *sequence, bool unk) { _context = new SequenceContext(sequence, this); //unload array of unknown objects _currentSequenceName = sequence->getName(); - + sequence->start(unk); } else _currentSequenceName.clear(); } +void Sequencer::toConsole() { + debug("Sequencer:"); + for (int i = 0; i < _sequences.size(); ++i) { + _sequences[i]->toConsole(); + } +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/sequences/sequencer.h b/engines/pink/objects/sequences/sequencer.h index 0243a4e1aa..d292346314 100644 --- a/engines/pink/sequences/sequencer.h +++ b/engines/pink/objects/sequences/sequencer.h @@ -25,7 +25,7 @@ #define PINK_SEQUENCER_H #include <common/array.h> -#include "engines/pink/object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -36,6 +36,9 @@ class GamePage; class Sequencer : public Object { public: Sequencer(GamePage *page); + ~Sequencer(); + + virtual void toConsole(); virtual void deserialize(Archive &archive); Sequence* findSequence(const Common::String &name); diff --git a/engines/pink/objects/side_effect.cpp b/engines/pink/objects/side_effect.cpp new file mode 100644 index 0000000000..4b290fa054 --- /dev/null +++ b/engines/pink/objects/side_effect.cpp @@ -0,0 +1,126 @@ +/* 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 <common/hash-str.h> +#include "side_effect.h" +#include <engines/pink/archive.h> +#include <engines/pink/objects/actors/lead_actor.h> +#include <engines/pink/objects/pages/game_page.h> +#include <engines/pink/pink.h> +#include <engines/pink/objects/walk/walk_location.h> +#include <engines/pink/objects/walk/walk_mgr.h> + +namespace Pink { + +void SideEffectExit::deserialize(Archive &archive) { + archive >> _nextModule >> _nextPage; +} + +void SideEffectExit::execute(LeadActor *actor) { + actor->setNextExecutors(_nextModule, _nextPage); +} + +void SideEffectExit::toConsole() { + debug("\t\tSideEffectExit: _nextModule=%s, _nextPage=%s", _nextModule.c_str(), _nextPage.c_str()); +} + + +void SideEffectLocation::deserialize(Archive &archive) { + archive >> _location; +} + +void SideEffectLocation::execute(LeadActor *actor) { + WalkMgr *mgr = actor->getPage()->getWalkMgr(); + WalkLocation *location = mgr->findLocation(_location); + //TODO end this method +} + +void SideEffectLocation::toConsole() { + debug("\t\tSideEffectLocation: _location=%s", _location.c_str()); +} + + +void SideEffectInventoryItemOwner::deserialize(Archive &archive) { + archive >> _item >> _owner; +} + +void SideEffectInventoryItemOwner::execute(LeadActor *actor) { + //TODO +} + +void SideEffectInventoryItemOwner::toConsole() { + debug("\t\tSideEffectInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); +} + + +void SideEffectVariable::deserialize(Pink::Archive &archive) { + archive >> _name >> _value; +} + + +void SideEffectGameVariable::execute(LeadActor *actor) { + actor->getPage()->getGame()->setVariable(_name, _value); +} + +void SideEffectGameVariable::toConsole() { + debug("\t\tSideEffectGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + + +void SideEffectModuleVariable::execute(LeadActor *actor) { + actor->getPage()->setVariable(_name, _value); +} + +void SideEffectModuleVariable::toConsole() { + debug("\t\tSideEffectModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + + +void SideEffectPageVariable::execute(LeadActor *actor) { + actor->getPage()->setVariable(_name, _value); +} + +void SideEffectPageVariable::toConsole() { + debug("\t\tSideEffectPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); +} + + +void SideEffectRandomPageVariable::deserialize(Archive &archive) { + archive >> _name >> _values; +} + +void SideEffectRandomPageVariable::execute(LeadActor *actor) { + // TODO think how to get rand gen here + actor->getPage()->setVariable(_name, _values[0]); // temporary solution +} + +void SideEffectRandomPageVariable::toConsole() { + Common::String values("{"); + for (int i = 0; i < _values.size(); ++i) { + values += _values[i]; + values += ','; + } + values += '}'; + debug("\t\tSideEffectRandomPageVariable: _name=%s, _values=%s", _name.c_str(), values.c_str()); +} + +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/side_effect.h b/engines/pink/objects/side_effect.h new file mode 100644 index 0000000000..810dd469b6 --- /dev/null +++ b/engines/pink/objects/side_effect.h @@ -0,0 +1,121 @@ +/* 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_SIDE_EFFECT_H +#define PINK_SIDE_EFFECT_H + +#include <engines/pink/objects/object.h> +#include <common/str-array.h> + +namespace Pink { + +class LeadActor; + +class SideEffect : public Object { +public: + virtual void deserialize(Archive &archive) = 0; + virtual void execute(LeadActor *actor) = 0; +}; + +class SideEffectExit : public SideEffect { +public: + virtual void deserialize(Archive &archive); + + virtual void toConsole(); + + virtual void execute(LeadActor *actor); + +private: + Common::String _nextModule; + Common::String _nextPage; +}; + +class SideEffectLocation : public SideEffect { + virtual void deserialize(Archive &archive); + virtual void execute(LeadActor *actor); + +public: + virtual void toConsole(); + +private: + Common::String _location; +}; + +class SideEffectInventoryItemOwner : public SideEffect { + virtual void deserialize(Archive &archive); + virtual void execute(LeadActor *actor); + +public: + virtual void toConsole(); + +private: + Common::String _item; + Common::String _owner; +}; + +class SideEffectVariable : public SideEffect { +public: + virtual void deserialize(Archive &archive); + virtual void execute(LeadActor *actor) = 0; + +protected: + Common::String _name; + Common::String _value; +}; + +class SideEffectGameVariable : public SideEffectVariable { +public: + virtual void toConsole(); + virtual void execute(LeadActor *actor); +}; + +class SideEffectModuleVariable : public SideEffectVariable { +public: + virtual void toConsole(); + virtual void execute(LeadActor *actor); +}; + +class SideEffectPageVariable : public SideEffectVariable { +public: + virtual void toConsole(); + + virtual void execute(LeadActor *actor); +}; + +class SideEffectRandomPageVariable : public SideEffect +{ + virtual void deserialize(Archive &archive); + +public: + virtual void toConsole(); + +private: + virtual void execute(LeadActor *actor); + +private: + Common::String _name; + Common::StringArray _values; +}; + +} + +#endif diff --git a/engines/pink/walk/walk_location.cpp b/engines/pink/objects/walk/walk_location.cpp index 7bf19eae6e..e5f5ea7535 100644 --- a/engines/pink/walk/walk_location.cpp +++ b/engines/pink/objects/walk/walk_location.cpp @@ -21,7 +21,7 @@ */ #include "walk_location.h" -#include "../archive.h" +#include "engines/pink/archive.h" void Pink::WalkLocation::deserialize(Pink::Archive &archive) { NamedObject::deserialize(archive); diff --git a/engines/pink/walk/walk_location.h b/engines/pink/objects/walk/walk_location.h index da96a14dfd..82e6436b77 100644 --- a/engines/pink/walk/walk_location.h +++ b/engines/pink/objects/walk/walk_location.h @@ -22,9 +22,10 @@ #ifndef PINK_WALK_LOCATION_H #define PINK_WALK_LOCATION_H -#include <engines/pink/object.h> +#include <engines/pink/objects/object.h> #include <common/array.h> -#include <engines/pink/utils.h> +#include <common/str-array.h> + namespace Pink { @@ -33,7 +34,7 @@ public: virtual void deserialize(Archive &archive); private: - StringArray _neighbors; + Common::StringArray _neighbors; }; } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp new file mode 100644 index 0000000000..1b5ceef210 --- /dev/null +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -0,0 +1,20 @@ +// +// Created by andrei on 3/17/18. +// + +#include "walk_mgr.h" +#include "walk_location.h" +#include "engines/pink/objects/actors/lead_actor.h" +#include "engines/pink/archive.h" + + +void Pink::WalkMgr::deserialize(Pink::Archive &archive) { + _leadActor = static_cast<LeadActor*>(archive.readObject()); + archive >> _locations; +} + +Pink::WalkLocation *Pink::WalkMgr::findLocation(Common::String &name) { + return *Common::find_if(_locations.begin(), _locations.end(), [&name] (WalkLocation *location) { + return location->getName() == name; + }); +} diff --git a/engines/pink/walk/walk_mgr.h b/engines/pink/objects/walk/walk_mgr.h index 857268da35..0ae7ef6194 100644 --- a/engines/pink/walk/walk_mgr.h +++ b/engines/pink/objects/walk/walk_mgr.h @@ -24,7 +24,7 @@ #define PINK_WALK_MGR_H #include <common/array.h> -#include "engines/pink/object.h" +#include "engines/pink/objects/object.h" namespace Pink { @@ -34,6 +34,7 @@ class LeadActor; class WalkMgr : public Object { public: virtual void deserialize(Archive &archive); + WalkLocation *findLocation(Common::String &name); private: LeadActor *_leadActor; diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index 950ef23c06..b5edbb1a19 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -24,7 +24,9 @@ #include "console.h" #include <engines/util.h> #include <common/debug-channels.h> -#include "module.h" +#include <video/flic_decoder.h> +#include "engines/pink/objects/module.h" +#include <graphics/surface.h> namespace Pink { @@ -85,6 +87,13 @@ Common::Error Pink::PinkEngine::run() { return error; } + Video::FlicDecoder flicDecoder; + Common::File anim; + anim.open("WANDRBOY.CEL"); + flicDecoder.loadStream(&anim); + flicDecoder.start(); + _system->updateScreen(); + const Graphics::Surface *surface = flicDecoder.decodeNextFrame(); while(!shouldQuit()){ Common::Event event; while(_eventMan->pollEvent(event)){ @@ -110,17 +119,20 @@ Common::Error Pink::PinkEngine::run() { } } //update(); - - g_system->updateScreen(); - g_system->delayMillis(10); + surface = flicDecoder.needsUpdate() ? flicDecoder.decodeNextFrame() : surface; + if (surface) { + _system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h); + _system->updateScreen(); + } + _system->delayMillis(10); } return Common::kNoError; } void PinkEngine::load(Archive &archive) { - debug(archive.readString().c_str()); - debug(archive.readString().c_str()); + archive.readString(); + archive.readString(); archive >> _modules; } @@ -151,7 +163,7 @@ void PinkEngine::initModule() { for (i = 0; i < _modules.size(); ++i) { assert(dynamic_cast<Module*>(_modules[i]) == 0); if (_modules[i]->getName() == _nextModule) { - changeProxyToModule(i); + loadModule(i); break; } } @@ -167,7 +179,7 @@ void PinkEngine::setNextExecutors(const Common::String &nextModule, const Common _nextPage = nextPage; } -void PinkEngine::changeProxyToModule(int index) { +void PinkEngine::loadModule(int index) { assert(dynamic_cast<Module*>(_modules[index]) == 0); Module *module = new Module(this, _modules[index]->getName()); @@ -178,4 +190,13 @@ void PinkEngine::changeProxyToModule(int index) { _modules[index] = module; } +bool PinkEngine::checkValueOfVariable(Common::String &variable, Common::String &value) { + assert(_variables.contains(variable)); + return _variables[variable] == value; +} + +void PinkEngine::setVariable(Common::String &variable, Common::String &value) { + _variables[variable] = value; +} + }
\ No newline at end of file diff --git a/engines/pink/pink.h b/engines/pink/pink.h index 834f787e21..114b475069 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -28,7 +28,6 @@ #include "gui/EventRecorder.h" #include "gui/debugger.h" #include "file.h" -#include "utils.h" /* @@ -47,6 +46,7 @@ namespace Pink { class Console; class Archive; +class NamedObject; class Module; enum { @@ -62,7 +62,6 @@ enum { LoadingNotSave = 0 }; - class PinkEngine : public Engine { public: PinkEngine(OSystem *system, const ADGameDescription *desc); @@ -77,9 +76,12 @@ public: OrbFile *getOrb() { return &_orb; } BroFile *getBro() { return _bro; } + bool checkValueOfVariable(Common::String &variable, Common::String &value); + void setVariable(Common::String &variable, Common::String &value); + private: Common::Error init(); - void changeProxyToModule(int index); + void loadModule(int index); Console *_console; Common::RandomSource _rnd; @@ -91,7 +93,9 @@ private: BroFile *_bro; Module *_module; - ModulesArray _modules; + Common::Array<NamedObject*> _modules; + + Common::StringMap _variables; const ADGameDescription _desc; }; diff --git a/engines/pink/resource_mgr.cpp b/engines/pink/resource_mgr.cpp index 378dded483..158450212b 100644 --- a/engines/pink/resource_mgr.cpp +++ b/engines/pink/resource_mgr.cpp @@ -21,31 +21,56 @@ */ #include <video/flic_decoder.h> +#include <common/substream.h> +#include <graphics/surface.h> #include "resource_mgr.h" #include "file.h" #include "pink.h" -#include "page.h" +#include "sound.h" +#include "engines/pink/objects/pages/game_page.h" namespace Pink { ResourceMgr::ResourceMgr() - : _game(nullptr), _orb(nullptr), _bro(nullptr), - _resDescTable(nullptr), _resCount(0) -{} + : _game(nullptr), _resDescTable(nullptr), + _resCount(0) {} ResourceMgr::~ResourceMgr() { delete[] _resDescTable; } void ResourceMgr::init(PinkEngine *game, GamePage *page) { - _orb = game->getOrb(); - _bro = game->getBro(); + OrbFile *orb = game->getOrb(); _game = game; - ObjectDescription *objDesc = _orb->getObjDesc(page->getName().c_str()); + ObjectDescription *objDesc = orb->getObjDesc(page->getName().c_str()); _resCount = objDesc->resourcesCount; - _orb->loadObject(page, objDesc); - _resDescTable = _orb->getResDescTable(objDesc); + orb->loadObject(page, objDesc); + _resDescTable = orb->getResDescTable(objDesc); +} + +Sound *ResourceMgr::loadSound(Common::String &name) { + return new Sound(_game->_mixer, getResourceStream(name)); +} + +Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name) { + Common::SeekableReadStream *stream; + uint i; + for (i = 0; i < _resCount; ++i) { + if (name.compareToIgnoreCase(_resDescTable[i].name) == 0){ + break; + } + } + assert(i < _resDescTable[i].size); + + if (_resDescTable[i].inBro) + stream = _game->getBro(); + else stream = _game->getOrb(); + + stream->seek(_resDescTable[i].offset); + + return new Common::SeekableSubReadStream(stream, _resDescTable[i].offset, + _resDescTable[i].offset + _resDescTable[i].size); } } // End of namespace Pink diff --git a/engines/pink/resource_mgr.h b/engines/pink/resource_mgr.h index 47c381ad37..8de06b25b2 100644 --- a/engines/pink/resource_mgr.h +++ b/engines/pink/resource_mgr.h @@ -21,6 +21,7 @@ */ #include <common/scummsys.h> +#include <common/stream.h> #ifndef PINK_RESOURCE_MGR_H #define PINK_RESOURCE_MGR_H @@ -48,13 +49,13 @@ public: //move methods to page //compiler must do RVO //Common::String loadText(Common::String &name); - Sound loadSound(Common::String &name); + Sound *loadSound(Common::String &name); // loadCEL(); private: + Common::SeekableReadStream *getResourceStream(Common::String &name); + PinkEngine *_game; - OrbFile *_orb; - BroFile *_bro; ResourceDescription *_resDescTable; uint32 _resCount; }; diff --git a/engines/pink/side_effects/side_effect_exit.cpp b/engines/pink/side_effects/side_effect_exit.cpp deleted file mode 100644 index 0871c2f547..0000000000 --- a/engines/pink/side_effects/side_effect_exit.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 <common/debug.h> -#include "side_effect_exit.h" -#include "../archive.h" -#include "../actors/lead_actor.h" - -namespace Pink { - -void SideEffectExit::deserialize(Archive &archive) { - archive >> _nextModule >> _nextPage; - debug("\tSideEffectExit: _nextModule = %s, _nextPage = %s", - _nextModule.c_str(), _nextPage.c_str()); -} - -void SideEffectExit::init(LeadActor *_actor) { - _actor->setNextExecutors(_nextPage, _nextModule); -} - -} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/side_effects/side_effect_exit.h b/engines/pink/side_effects/side_effect_exit.h deleted file mode 100644 index a324b8274a..0000000000 --- a/engines/pink/side_effects/side_effect_exit.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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_SIDE_EFFECT_EXIT_H -#define PINK_SIDE_EFFECT_EXIT_H - -#include "side_effect.h" - -namespace Pink { - -class SideEffectExit : public SideEffect { -public: - virtual void deserialize(Archive &archive); - - virtual void init(LeadActor *_actor); - -private: - Common::String _nextModule; - Common::String _nextPage; -}; - -} // End of namespace Pink - -#endif diff --git a/engines/pink/side_effects/side_effect_module_variable.cpp b/engines/pink/side_effects/side_effect_module_variable.cpp deleted file mode 100644 index 4e1e173d55..0000000000 --- a/engines/pink/side_effects/side_effect_module_variable.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include <engines/pink/archive.h> -#include <common/debug.h> -#include "side_effect_variable.h" - -/* 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 "side_effect_module_variable.h" -#include "../actors/lead_actor.h" -#include "../page.h" - -namespace Pink { - -void SideEffectModuleVariable::deserialize(Archive &archive) { - SideEffectVariable::deserialize(archive); - debug("\tSideEffectModuleVariable: _name = %s _value = %s", - _name.c_str(), _value.c_str()); -} - -void SideEffectModuleVariable::init(LeadActor *actor) { - Common::StringMap &moduleMap = actor->getPage()->getModule()->getMap(); - moduleMap[_name] = _value; -} - -}
\ No newline at end of file diff --git a/engines/pink/side_effects/side_effect_module_variable.h b/engines/pink/side_effects/side_effect_module_variable.h deleted file mode 100644 index df45bf8c46..0000000000 --- a/engines/pink/side_effects/side_effect_module_variable.h +++ /dev/null @@ -1,38 +0,0 @@ -/* 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_SIDE_EFFECT_MODULE_VARIABLE_H -#define PINK_SIDE_EFFECT_MODULE_VARIABLE_H - -#include "side_effect_variable.h" - -namespace Pink { - -class SideEffectModuleVariable : public SideEffectVariable { -public: - virtual void deserialize(Archive &archive); - - virtual void init(LeadActor *actor); -}; - -} // End of namespace Pink - -#endif
\ No newline at end of file diff --git a/engines/pink/side_effects/side_effect_variable.cpp b/engines/pink/side_effects/side_effect_variable.cpp deleted file mode 100644 index 17481aa5b9..0000000000 --- a/engines/pink/side_effects/side_effect_variable.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* 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 "side_effect_variable.h" -#include "../archive.h" - -namespace Pink { - -void SideEffectVariable::deserialize(Pink::Archive &archive) { - archive >> _name >> _value; -} - -} diff --git a/engines/pink/side_effects/side_effect_variable.h b/engines/pink/side_effects/side_effect_variable.h deleted file mode 100644 index c5b45f1e47..0000000000 --- a/engines/pink/side_effects/side_effect_variable.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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_SIDE_EFFECT_VARIABLE_H -#define PINK_SIDE_EFFECT_VARIABLE_H - -#include "side_effect.h" - -namespace Pink { - -class SideEffectVariable : public SideEffect { -public: - virtual void deserialize(Archive &archive); - -protected: - Common::String _name; - Common::String _value; -}; - -} // End of namespace Pink - -#endif diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp index bdc41c8c9c..cf62f03c93 100644 --- a/engines/pink/sound.cpp +++ b/engines/pink/sound.cpp @@ -27,10 +27,10 @@ namespace Pink { -Sound::Sound(Audio::Mixer *mixer, AudioFormat format, Common::SeekableReadStream *stream) +Sound::Sound(Audio::Mixer *mixer, Common::SeekableReadStream *stream) : _mixer(mixer) { - load(format, stream); + load(stream); } Sound::~Sound() { @@ -67,24 +67,11 @@ void Sound::play(Audio::Mixer::SoundType type, int volume, bool isLoop) { _mixer->playStream(type, &_handle ,_stream); } -bool Sound::load(AudioFormat format, Common::SeekableReadStream *stream) { - //may be mem leak - - // checked vox files in hex editor and they have WAVEfmt . - // It seems strange for me - // linux file says wav and vox are +bool Sound::load(Common::SeekableReadStream *stream) { + // Vox files in pink have wave format. // RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 22050 Hz - switch (format){ - case AudioFormat::kWAV: - _stream = Audio::makeWAVStream(stream, DisposeAfterUse::NO); - break; - case AudioFormat::kVOX: - //TODO - // check for last arg; nBlockAlign(1, 4 or other) - _stream = Audio::makeADPCMStream(stream, DisposeAfterUse::NO, 0, Audio::kADPCMOki, 22050, 1, 0); - break; - } + _stream = Audio::makeWAVStream(stream, DisposeAfterUse::NO); return isLoaded(); } diff --git a/engines/pink/sound.h b/engines/pink/sound.h index 7b60745667..fdd5e23ce2 100644 --- a/engines/pink/sound.h +++ b/engines/pink/sound.h @@ -28,8 +28,6 @@ namespace Pink { -enum class AudioFormat{kWAV, kVOX}; - /*TODO from disasm foreground 100 %, background 80 % dont know how to properly do it @@ -38,10 +36,10 @@ enum class AudioFormat{kWAV, kVOX}; class Sound { public: - Sound(Audio::Mixer *mixer, AudioFormat format, Common::SeekableReadStream *stream); + Sound(Audio::Mixer *mixer, Common::SeekableReadStream *stream); ~Sound(); - bool load(AudioFormat format, Common::SeekableReadStream *stream); + bool load(Common::SeekableReadStream *stream); void play(Audio::Mixer::SoundType type, int volume, bool isLoop); bool isLoaded(); diff --git a/engines/pink/utils.h b/engines/pink/utils.h deleted file mode 100644 index feb164c771..0000000000 --- a/engines/pink/utils.h +++ /dev/null @@ -1,39 +0,0 @@ -/* 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_UTILS_H -#define PINK_UTILS_H - -#include <common/array.h> - -namespace Pink { - class Object; - class NamedObject; - class GamePage; - - using ObArray = Common::Array<Object*>; - using ModulesArray = Common::Array<NamedObject*>; - using PagesArray = Common::Array<GamePage*>; - using StringArray = Common::Array<Common::String>; -} - -#endif diff --git a/engines/pink/walk/walk_mgr.cpp b/engines/pink/walk/walk_mgr.cpp deleted file mode 100644 index ce7690a3e8..0000000000 --- a/engines/pink/walk/walk_mgr.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// -// Created by andrei on 3/17/18. -// - -#include "walk_mgr.h" -#include "../actors/lead_actor.h" -#include "../archive.h" - - -void Pink::WalkMgr::deserialize(Pink::Archive &archive) { - _leadActor = static_cast<LeadActor*>(archive.readObject()); - archive >> _locations; -} |