From 699f38b5fd8ea9a96624840f8c65dc96f1b54f27 Mon Sep 17 00:00:00 2001 From: Andrei Prykhodko Date: Sat, 30 Jun 2018 11:08:42 +0300 Subject: PINK: implemented Peril's PDA init --- engines/pink/constants.h | 10 +++++++++ engines/pink/pda_mgr.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/pink/pda_mgr.h | 12 ++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/engines/pink/constants.h b/engines/pink/constants.h index 185517434e..abf7ba8b95 100644 --- a/engines/pink/constants.h +++ b/engines/pink/constants.h @@ -162,6 +162,7 @@ static const char * const kIdleAction = "Idle"; static const char * const kOpenAction = "Open"; static const char * const kShowAction = "Show"; static const char * const kHideAction = "Hide"; +static const char * const kInactiveAction = "Inactive"; static const char * const kInventoryWindowActor = "InventoryWindow"; static const char * const kInventoryItemActor = "InventoryItem"; @@ -194,6 +195,15 @@ static const char * const kBoyBlocked = "BoyBlocked"; static const char * const kUndefinedValue = "UNDEFINED"; static const char * const kTrueValue = "TRUE"; +static const char * const kCountryWheel = "CountryWheel"; +static const char * const kDomainWheel = "DomainWheel"; + +static const char * const kPreviousPageButton = "PreviousPageButton"; +static const char * const kDomainButton = "DomainButton"; +static const char * const kNavigatorButton = "NavigatorButton"; + +static const char * const kNavigatePage = "NAVIGATE"; + } // End of namespace Pink #endif diff --git a/engines/pink/pda_mgr.cpp b/engines/pink/pda_mgr.cpp index f3ea51a31d..ddf5eb00f2 100644 --- a/engines/pink/pda_mgr.cpp +++ b/engines/pink/pda_mgr.cpp @@ -25,11 +25,16 @@ #include "pink/objects/actors/pda_button_actor.h" #include "pink/objects/actors/lead_actor.h" #include "pink/objects/pages/pda_page.h" +#include "pink/objects/actions/action_cel.h" namespace Pink { +static const char * const g_countries[] = {"BRI", "EGY", "BHU", "AUS", "IND", "CHI"}; +static const char * const g_domains[] = {"NAT", "CLO", "HIS", "REL", "PLA", "ART", "FOO", "PEO"}; + PDAMgr::PDAMgr(Pink::PinkEngine *game) - : _game(game), _page(nullptr), _cursorMgr(game, nullptr) {} + : _game(game), _page(nullptr), _cursorMgr(game, nullptr), + _countryIndex(0), _domainIndex(0) {} PDAMgr::~PDAMgr() { for (uint i = 0; i < _globalActors.size(); ++i) { @@ -86,9 +91,13 @@ void PDAMgr::goToPage(const Common::String &pageName) { _globalActors[i]->setPage(_page); } + _previousPages.push(_page->getName()); + + if (_game->isPeril()) + initPerilButtons(); + _cursorMgr.setPage(_page); - _previousPages.push(_page->getName()); } void PDAMgr::onLeftButtonClick(Common::Point point) { @@ -128,4 +137,48 @@ void PDAMgr::loadGlobal() { } } +void PDAMgr::initPerilButtons() { + Actor *prevPageButton = findGlobalActor(kPreviousPageButton); + if (_previousPages.size() < 2) + prevPageButton->setAction(kInactiveAction); + else + prevPageButton->setAction(kIdleAction); + + Actor *navigatorButton = findGlobalActor(kNavigatorButton); + Actor *domainButton = findGlobalActor(kDomainButton); + if (isNavigate(_page->getName())) { + navigatorButton->setAction(kInactiveAction); + domainButton->setAction(kInactiveAction); + updateWheels(); + } else { + navigatorButton->setAction(kIdleAction); + if (isDomain(_page->getName())) + domainButton->setAction(kInactiveAction); + else + domainButton->setAction(kIdleAction); + } + +} + +Actor *PDAMgr::findGlobalActor(const Common::String &actorName) { + for (uint i = 0; i < _globalActors.size(); ++i) { + if (_globalActors[i]->getName() == actorName) + return _globalActors[i]; + } + return nullptr; +} + +void PDAMgr::updateWheels() { + _page->findActor(kCountryWheel)->setAction(g_countries[_countryIndex]); + _page->findActor(kDomainWheel)->setAction(g_domains[_domainIndex]); +} + +bool PDAMgr::isNavigate(const Common::String &name) { + return !name.compareToIgnoreCase(kNavigatePage); +} + +bool PDAMgr::isDomain(const Common::String &name) { + return name.size() == 6; +} + } // End of namespace Pink diff --git a/engines/pink/pda_mgr.h b/engines/pink/pda_mgr.h index 246679dee1..0ae16e8102 100644 --- a/engines/pink/pda_mgr.h +++ b/engines/pink/pda_mgr.h @@ -62,6 +62,16 @@ private: void close(); void loadGlobal(); + void initPerilButtons(); + + void updateWheels(); + + Actor *findGlobalActor(const Common::String &actorName); + + static bool isNavigate(const Common::String &name); + static bool isDomain(const Common::String &name); + +private: PinkEngine *_game; LeadActor *_lead; PDAPage *_page; @@ -69,6 +79,8 @@ private: Array _globalActors; Common::String _savedPage; Common::Stack _previousPages; + uint _countryIndex; + uint _domainIndex; }; } // End of namespace Pink -- cgit v1.2.3