diff options
author | whiterandrek | 2018-06-01 22:31:35 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 9f23b4238c0643e6e9fa5af52be2747219f0bfe0 (patch) | |
tree | 594285f1df4471d236e02f96a3cdec245f58f644 /engines | |
parent | 11d2c1aa5232148d530713b93d95efff4d322ceb (diff) | |
download | scummvm-rg350-9f23b4238c0643e6e9fa5af52be2747219f0bfe0.tar.gz scummvm-rg350-9f23b4238c0643e6e9fa5af52be2747219f0bfe0.tar.bz2 scummvm-rg350-9f23b4238c0643e6e9fa5af52be2747219f0bfe0.zip |
PINK: add Pokus World Book implementation
Diffstat (limited to 'engines')
-rw-r--r-- | engines/pink/objects/actors/actor.h | 1 | ||||
-rw-r--r-- | engines/pink/objects/actors/lead_actor.cpp | 21 | ||||
-rw-r--r-- | engines/pink/objects/actors/lead_actor.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/inventory.cpp | 4 | ||||
-rw-r--r-- | engines/pink/objects/pages/pda_page.cpp | 60 | ||||
-rw-r--r-- | engines/pink/objects/pages/pda_page.h | 45 | ||||
-rw-r--r-- | engines/pink/pda_mgr.cpp | 113 | ||||
-rw-r--r-- | engines/pink/pda_mgr.h | 63 | ||||
-rw-r--r-- | engines/pink/pink.cpp | 6 | ||||
-rw-r--r-- | engines/pink/pink.h | 4 |
10 files changed, 315 insertions, 4 deletions
diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index 037b8b5408..e39ce844e1 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -72,6 +72,7 @@ public: virtual void onMouseOver(Common::Point point, CursorMgr *mgr); virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr); + virtual void onClick() {}; virtual bool isClickable() { return 0; } diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 90de9a1d8f..17ec0ee49c 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -90,6 +90,7 @@ void LeadActor::update() { getPage()->getModule()->getInventoryMgr()->update(); break; case kPDA: + getPage()->getGame()->getPdaMgr().update(); break; case kPlayingVideo: _sequencer->update(); @@ -162,8 +163,7 @@ void LeadActor::start(bool isHandler) { void LeadActor::onMouseMove(Common::Point point) { if (_state != kPDA) updateCursor(point); - else - error("pda is not supported"); + else _page->getGame()->getPdaMgr().onMouseMove(point); } void LeadActor::updateCursor(Common::Point point) { @@ -229,7 +229,7 @@ void LeadActor::onLeftButtonClick(Common::Point point) { break; } case kPDA: - + _page->getGame()->getPdaMgr().onLeftButtonClick(point); break; case kInventory: invMgr->onClick(point); @@ -351,6 +351,21 @@ void LeadActor::saveState(Archive &archive) { _walkMgr->saveState(archive); } +void LeadActor::loadPDA(const Common::String &pageName) { + if (_state != kPDA) { + if (_state == kMoving) { + _recipient = nullptr; + _nextState = kReady; + } + _state = kPDA; + if (_state != kInventory) + _page->pause(); + _page->getGame()->getDirector()->clear(); + } + _page->getGame()->getPdaMgr().setLead(this); + _page->getGame()->getPdaMgr().goToPage(pageName); +} + void ParlSqPink::toConsole() { debug("ParlSqPink: _name = %s", _name.c_str()); for (uint i = 0; i < _actions.size(); ++i) { diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index d058ec65d4..0e480358b1 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -81,6 +81,8 @@ public: virtual void saveState(Archive &archive); + void loadPDA(const Common::String &pageName); + protected: virtual void updateCursor(Common::Point point); void forceUpdateCursor(); diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index 1b74f4dca8..4836880ec5 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -152,6 +152,10 @@ void InventoryMgr::onClick(Common::Point point) { Actor *actor = _lead->getPage()->getGame()->getDirector()->getActorByPoint(point); if (actor == _itemActor || actor == _window) { + if (actor->getAction()->getName() == "WBook") { + _lead->loadPDA("TOC"); + return; + } _isClickedOnItem = true; close(); } else if (actor == _leftArrow) { diff --git a/engines/pink/objects/pages/pda_page.cpp b/engines/pink/objects/pages/pda_page.cpp new file mode 100644 index 0000000000..1b13c2afaf --- /dev/null +++ b/engines/pink/objects/pages/pda_page.cpp @@ -0,0 +1,60 @@ +/* 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 "pink/pda_mgr.h" +#include "pink/objects/actors/actor.h" +#include "pink/objects/pages/pda_page.h" +#include "pink/pink.h" + +namespace Pink { + + +PDAPage PDAPage::create(const Common::String &pageName, PDAMgr &pdaMgr) { + PDAPage page(pageName, pdaMgr); + page._name = pageName; + page._resMgr.init(pdaMgr.getGame(), &page); + return page; +} + +Array<Actor *> PDAPage::takeActors() { + Array<Actor *> actorsCopy = _actors; + _actors.clear(); + return actorsCopy; +} + +void PDAPage::init() { + for (uint i = 0; i < _actors.size(); ++i) { + if (_actors[i]->initPallete(_pdaMgr.getGame()->getDirector())) + break; + } + + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->init(0); + } +} + +PDAPage::PDAPage(const Common::String &name, PDAMgr &pdaMgr) + : _pdaMgr(pdaMgr) { + _name = name; +} + +} // End of namespace Pink diff --git a/engines/pink/objects/pages/pda_page.h b/engines/pink/objects/pages/pda_page.h new file mode 100644 index 0000000000..f6cf2a5cf0 --- /dev/null +++ b/engines/pink/objects/pages/pda_page.h @@ -0,0 +1,45 @@ +/* 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_PDA_PAGE_H +#define PINK_PDA_PAGE_H + +#include "page.h" + +namespace Pink { + +class PDAMgr; + +class PDAPage : public Page { +public: + static PDAPage create(const Common::String &pageName, PDAMgr &pdaMgr); + + Array<Actor *> takeActors(); + void init(); +private: + PDAPage(const Common::String &name, PDAMgr &pdaMgr); + PDAMgr &_pdaMgr; +}; + +} // End of namespace Pink + +#endif diff --git a/engines/pink/pda_mgr.cpp b/engines/pink/pda_mgr.cpp new file mode 100644 index 0000000000..a931f3096b --- /dev/null +++ b/engines/pink/pda_mgr.cpp @@ -0,0 +1,113 @@ +/* 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 "pink/pda_mgr.h" +#include "pink/pink.h" +#include "pink/objects/actors/pda_button_actor.h" +#include "pink/objects/pages/pda_page.h" + + +namespace Pink { + +PDAMgr::PDAMgr(Pink::PinkEngine *game) + : _game(game), _page(nullptr), _cursorMgr(game, nullptr) {} + +void PDAMgr::update() { + _cursorMgr.update(); +} + +void PDAMgr::execute(const Command &command) { + switch (command.type) { + case Command::GoToPage: + goToPage(command.arg); + break; + case Command::Close: + close(); + break; + default: + break; + } +} + +PinkEngine *PDAMgr::getGame() const { + return _game; +} + +void PDAMgr::goToPage(const Common::String &pageName) { + if (_page && _page->getName() == pageName) + return; + + loadGlobal(); + + delete _page; + _page = new PDAPage(PDAPage::create(pageName, *this)); + + _page->init(); + + for (uint i = 0; i < _globalActors.size(); ++i) { + _globalActors[i]->setPage(_page); + } + + _cursorMgr.setPage(_page); +} + +void PDAMgr::close() { + for (uint i = 0; i < _globalActors.size(); ++i) { + delete _globalActors[i]; + } + _globalActors.clear(); + + delete _page; + _page = nullptr; + + //_lead->onPDAClose(); +} + +void PDAMgr::loadGlobal() { + if (!_globalActors.empty()) + return; + + PDAPage globalPage = PDAPage::create("GLOBAL", *this); + _globalActors = globalPage.takeActors(); + for (uint i = 0; i < _globalActors.size(); ++i) { + _globalActors[i]->init(0); + } +} + +void PDAMgr::setLead(LeadActor *lead) { + _lead = lead; +} + +void PDAMgr::onLeftButtonClick(Common::Point point) { + Actor *actor = _game->getDirector()->getActorByPoint(point); + if (actor) + actor->onClick(); +} + +void PDAMgr::onMouseMove(Common::Point point) { + Actor *actor = _game->getDirector()->getActorByPoint(point); + if (actor && dynamic_cast<PDAButtonActor*>(actor)) + actor->onMouseOver(point, &_cursorMgr); + else _cursorMgr.setCursor(kPDADefaultCursor, point,Common::String()); +} + +} // End of namespace Pink diff --git a/engines/pink/pda_mgr.h b/engines/pink/pda_mgr.h new file mode 100644 index 0000000000..75f28a7c36 --- /dev/null +++ b/engines/pink/pda_mgr.h @@ -0,0 +1,63 @@ +/* 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_PDA_MGR_H +#define PINK_PDA_MGR_H + +#include "pink/cursor_mgr.h" +#include "utils.h" + +namespace Pink { + +class PinkEngine; +class LeadActor; +class Command; +class PDAPage; + +class PDAMgr { +public: + PDAMgr(PinkEngine *game); + void update(); + void execute(const Command &command); + void goToPage(const Common::String &pageName); + + void onLeftButtonClick(Common::Point point); + void onMouseMove(Common::Point point); + + PinkEngine *getGame() const; + + void setLead(LeadActor *lead); + +private: + void close(); + void loadGlobal(); + + PinkEngine *_game; + LeadActor *_lead; + PDAPage *_page; + CursorMgr _cursorMgr; + Array<Actor *> _globalActors; +}; + +} // End of namespace Pink + +#endif diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index a0aa9ef820..53407e6f66 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -41,7 +41,7 @@ namespace Pink { Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc) : Engine(system), _console(nullptr), _rnd("pink"), _desc(*desc), _bro(nullptr), _module(nullptr), - _director(_system) { + _director(_system), _pdaMgr(this) { debug("PinkEngine constructed"); DebugMan.addDebugChannel(kPinkDebugGeneral, "general", "General issues"); @@ -322,6 +322,10 @@ void PinkEngine::pauseEngineIntern(bool pause) { _system->showMouse(!pause); } +PDAMgr &PinkEngine::getPdaMgr() { + return _pdaMgr; +} + Common::String generateSaveName(int slot, const char *gameId) { return Common::String::format("%s.s%02d", gameId, slot); } diff --git a/engines/pink/pink.h b/engines/pink/pink.h index 642a4d1efb..f4d0ad34af 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -36,6 +36,7 @@ #include "pink/director.h" #include "pink/file.h" #include "pink/utils.h" +#include "pink/pda_mgr.h" /* * This is the namespace of the Pink engine. @@ -111,6 +112,8 @@ public: void setVariable(Common::String &variable, Common::String &value); bool checkValueOfVariable(Common::String &variable, Common::String &value); + PDAMgr &getPdaMgr(); + protected: virtual void pauseEngineIntern(bool pause); @@ -137,6 +140,7 @@ private: Array<NamedObject *> _modules; StringMap _variables; + PDAMgr _pdaMgr; const ADGameDescription _desc; }; |