Skip to content

Commit

Permalink
PINK: implement exit from PDA
Browse files Browse the repository at this point in the history
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent da0adc9 commit 4874ed5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 15 deletions.
14 changes: 8 additions & 6 deletions engines/pink/cursor_mgr.cpp
Expand Up @@ -29,13 +29,11 @@

namespace Pink {

CursorMgr::CursorMgr(PinkEngine *game, GamePage *page)
CursorMgr::CursorMgr(PinkEngine *game, Page *page)
: _actor(nullptr), _page(page), _game(game),
_isPlayingAnimation(0), _firstFrameIndex(0) {}

CursorMgr::~CursorMgr() {}

void CursorMgr::setCursor(uint index, Common::Point point, const Common::String &itemName) {
void CursorMgr::setCursor(uint index, const Common::Point point, const Common::String &itemName) {
if (index == kClickableFirstFrameCursor) {
startAnimation(index);
return hideItem();
Expand All @@ -61,7 +59,7 @@ void CursorMgr::setCursor(uint index, Common::Point point, const Common::String
assert(dynamic_cast<ActionCEL*>(action));

if (action != _actor->getAction()) {
_actor->setAction(action, 0);
_actor->setAction(action);
CelDecoder *decoder = static_cast<ActionCEL*>(action)->getDecoder();
decoder->setX(point.x);
decoder->setY(point.y);
Expand All @@ -85,7 +83,7 @@ void CursorMgr::update() {
}
}

void CursorMgr::setCursor(Common::String &cursorName, Common::Point point) {
void CursorMgr::setCursor(const Common::String &cursorName, const Common::Point point) {
uint index;
if (cursorName == kCursorNameExitLeft)
index = kExitLeftCursor;
Expand Down Expand Up @@ -114,4 +112,8 @@ void CursorMgr::startAnimation(int index) {
}
}

void CursorMgr::setPage(Page *page) {
_page = page;
}

} // End of namespace Pink
13 changes: 7 additions & 6 deletions engines/pink/cursor_mgr.h
Expand Up @@ -33,24 +33,25 @@ namespace Pink {

class Actor;
class Action;
class GamePage;
class Page;
class PinkEngine;

class CursorMgr : public Object {
public:
CursorMgr(PinkEngine *game, GamePage *page);
~CursorMgr();
CursorMgr(PinkEngine *game, Page *page);

void update();
void setCursor(uint index, Common::Point point, const Common::String &itemName);
void setCursor(Common::String &cursorName, Common::Point point);
void setCursor(uint index, const Common::Point point, const Common::String &itemName);
void setCursor(const Common::String &cursorName, const Common::Point point);

void setPage(Page *page);

private:
void hideItem();
void startAnimation(int index);

Actor *_actor;
GamePage *_page;
Page *_page;
PinkEngine *_game;

uint _time;
Expand Down
11 changes: 11 additions & 0 deletions engines/pink/director.cpp
Expand Up @@ -145,4 +145,15 @@ void Director::pause(bool pause) {
}
}

void Director::saveStage() {
_savedSprites = _sprites;
_sprites.clear();
}

void Director::loadStage() {
assert(_sprites.empty());
_sprites = _savedSprites;
_savedSprites.clear();
}

}
4 changes: 4 additions & 0 deletions engines/pink/director.h
Expand Up @@ -53,12 +53,16 @@ class Director {

void pause(bool pause);

void saveStage();
void loadStage();

bool showBounds;

private:
void drawSprite(ActionCEL *sprite);
OSystem *_system;
Common::Array<ActionCEL *> _sprites;
Common::Array<ActionCEL *> _savedSprites;
Common::Array<ActionSound *> _sounds;
};

Expand Down
16 changes: 14 additions & 2 deletions engines/pink/objects/actors/lead_actor.cpp
Expand Up @@ -153,10 +153,13 @@ void LeadActor::loadPDA(const Common::String &pageName) {
_recipient = nullptr;
_nextState = kReady;
}
_state = kPDA;
if (_state != kInventory)
_page->pause(true);
_page->getGame()->getDirector()->clear();

_stateBeforePDA = _state;
_state = kPDA;

_page->getGame()->getDirector()->saveStage();
}
_page->getGame()->getPdaMgr().setLead(this);
_page->getGame()->getPdaMgr().goToPage(pageName);
Expand Down Expand Up @@ -296,6 +299,15 @@ void LeadActor::onWalkEnd() {
}
}

void LeadActor::onPDAClose() {
_page->initPallete();
_page->getGame()->getDirector()->loadStage();

_state = _stateBeforePDA;
if (_state != kInventory)
_page->pause(0);
}

bool LeadActor::isInteractingWith(Actor *actor) {
if (!_isHaveItem)
return actor->isLeftClickHandlers();
Expand Down
2 changes: 2 additions & 0 deletions engines/pink/objects/actors/lead_actor.h
Expand Up @@ -79,6 +79,7 @@ class LeadActor : public Actor {
virtual void onVariableSet();
void onInventoryClosed(bool isItemClicked);
void onWalkEnd();
void onPDAClose();

bool isInteractingWith(Actor *actor);

Expand All @@ -105,6 +106,7 @@ class LeadActor : public Actor {
State _state;
State _nextState;
State _stateCopy;
State _stateBeforePDA;

bool _isHaveItem;
};
Expand Down
3 changes: 2 additions & 1 deletion engines/pink/pda_mgr.cpp
Expand Up @@ -23,6 +23,7 @@
#include "pink/pda_mgr.h"
#include "pink/pink.h"
#include "pink/objects/actors/pda_button_actor.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/pages/pda_page.h"


Expand Down Expand Up @@ -79,7 +80,7 @@ void PDAMgr::close() {
delete _page;
_page = nullptr;

//_lead->onPDAClose();
_lead->onPDAClose();
}

void PDAMgr::loadGlobal() {
Expand Down

0 comments on commit 4874ed5

Please sign in to comment.