Skip to content

Commit

Permalink
PINK: add PDAButtonActor(Pokus) implementation
Browse files Browse the repository at this point in the history
Peril's pda actor is different
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent 9f23b42 commit 127e2fd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
34 changes: 29 additions & 5 deletions engines/pink/objects/actors/pda_button_actor.cpp
Expand Up @@ -20,23 +20,47 @@
*
*/

#include "pink/constants.h"
#include "pink/cursor_mgr.h"
#include "pink/pink.h"
#include "pink/objects/pages/page.h"
#include "pink/objects/actors/pda_button_actor.h"

namespace Pink {

void PDAButtonActor::deserialize(Archive &archive) {
Actor::deserialize(archive);
_x = archive.readDWORD();
_y = archive.readDWORD();
_hideOnStop = (bool) archive.readDWORD();
_opaque = (bool) archive.readDWORD();

int comm = archive.readDWORD();
assert(comm <= 4);
_command = (Command) comm;
int type = archive.readDWORD();
assert(type != 0);
_command.type = (Command::CommandType) type;
_command.arg = archive.readString();
}

void PDAButtonActor::toConsole() {
debug("PDAButtonActor: _name = %s, _x = %u _y = %u _hideOnStop = %u, _opaque = %u, _command = %u",
_name.c_str(), _x, _y, _hideOnStop, _opaque, (int) _command);
debug("PDAButtonActor: _name = %s, _x = %u _y = %u _hideOnStop = %u, _opaque = %u, _commandType = %u, _arg = %s",
_name.c_str(), _x, _y, _hideOnStop, _opaque, (int) _command.type, _command.arg.c_str());
}

void PDAButtonActor::onClick() {
if (isActive()) {
_page->getGame()->getPdaMgr().execute(_command);
}
}

void PDAButtonActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
if (_command.type == Command::Unk || !isActive())
mgr->setCursor(kPDADefaultCursor, point, Common::String());
else
mgr->setCursor(kPDAClickableFirstFrameCursor, point, Common::String());
}

bool PDAButtonActor::isActive() {
return _name != "Inactive";
}

} // End of namespace Pink
22 changes: 18 additions & 4 deletions engines/pink/objects/actors/pda_button_actor.h
Expand Up @@ -27,21 +27,35 @@

namespace Pink {

struct Command {
// commands in peril are different
/*enum PerilCommandType {Null, GoToPage, GoToPreviousPage, GoToDomain, GoToHelp,
NavigateToDomain, IncrementCountry, DecrementCountry, IncrementDomain,
DecrementDomain, Close, IncrementFrame, DecrementFrame};*/
enum CommandType {Null = 0, GoToPage = 1, Close = 2, Unk = 3};

CommandType type;
Common::String arg;
};

class PDAButtonActor : public Actor {
public:
enum Command {Null = 0, GoToPage = 1, Close = 2, Unk = 4};

void deserialize(Archive &archive) override;
void toConsole() override;

void onClick();
void onMouseOver(Common::Point point, CursorMgr *mgr);

private:
bool isActive();

Command _command;

int _x;
int _y;

bool _hideOnStop;
bool _opaque;

Command _command;
};

} // End of namespace Pink
Expand Down

0 comments on commit 127e2fd

Please sign in to comment.