PINK: added thumb moving in PDA

This commit is contained in:
Andrei Prykhodko 2018-06-30 23:29:20 +03:00
parent 21fb38f57a
commit 22f6c66393
6 changed files with 58 additions and 5 deletions

View File

@ -211,6 +211,11 @@ static const char * const kSfx = "SFX";
static const char * const kRightHand = "RightHand";
static const char * const kLeftHand = "LeftHand";
static const char * const kLeft1Name = "Left1";
static const char * const kLeft2Name = "Left2";
static const char * const kLeft3Name = "Left3";
static const char * const kLeft4Name = "Left4";
} // End of namespace Pink
#endif

View File

@ -57,8 +57,8 @@ public:
protected:
virtual void onStart() = 0;
void setFrame(uint frame);
void decodeNext();
void setFrame(uint frame);
void loadDecoder();

View File

@ -65,4 +65,9 @@ void ActionStill::setFrame(uint frame) {
decodeNext();
}
void ActionStill::nextFrameLooped() {
assert(_decoder.getCurFrame() != -1);
setFrame((_decoder.getCurFrame() + 1) % _decoder.getFrameCount());
}
} // End of namespace Pink

View File

@ -39,6 +39,8 @@ public:
void setFrame(uint frame);
void nextFrameLooped();
protected:
void onStart() override;

View File

@ -34,7 +34,8 @@ static const char * const g_domains[] = {"NAT", "CLO", "HIS", "REL", "PLA", "ART
PDAMgr::PDAMgr(Pink::PinkEngine *game)
: _game(game), _page(nullptr), _globalPage(nullptr),
_cursorMgr(game, nullptr), _countryIndex(0), _domainIndex(0) {}
_cursorMgr(game, nullptr), _countryIndex(0), _domainIndex(0),
_iteration(0), _handFrame(0), _leftHandAction(kLeft1) {}
PDAMgr::~PDAMgr() {
delete _globalPage;
@ -111,7 +112,6 @@ void PDAMgr::goToPage(const Common::String &pageName) {
initPerilButtons();
_cursorMgr.setPage(_page);
}
void PDAMgr::onLeftButtonClick(Common::Point point) {
@ -135,6 +135,39 @@ void PDAMgr::onMouseMove(Common::Point point) {
actor->onMouseOver(point, &_cursorMgr);
else
_cursorMgr.setCursor(kPDADefaultCursor, point, Common::String());
if (!_game->isPeril())
return;
float k = (float)point.x / (480 - point.y);
Actor *leftHand = _globalPage->findActor(kLeftHand);
if (k > 0.5) {
if (k > 1) {
if (k > 1.5 && _leftHandAction != kLeft4) {
leftHand->setAction(kLeft4Name);
static_cast<ActionStill*>(leftHand->getAction())->setFrame(_handFrame + 1);
_leftHandAction = kLeft4;
} else if (_leftHandAction != kLeft3) {
leftHand->setAction(kLeft3Name);
static_cast<ActionStill*>(leftHand->getAction())->setFrame(_handFrame + 1);
_leftHandAction = kLeft3;
}
} else if (_leftHandAction != kLeft2) {
leftHand->setAction(kLeft2Name);
static_cast<ActionStill*>(leftHand->getAction())->setFrame(_handFrame + 1);
_leftHandAction = kLeft2;
}
} else if (_leftHandAction != kLeft1) {
leftHand->setAction(kLeft1Name);
static_cast<ActionStill*>(leftHand->getAction())->setFrame(_handFrame + 1);
_leftHandAction = kLeft1;
}
if (_iteration == 0) {
_handFrame = (_handFrame + 1) % 4;
static_cast<ActionStill*>(leftHand->getAction())->nextFrameLooped();
}
_iteration = (_iteration + 1) % 4;
}
void PDAMgr::close() {

View File

@ -79,8 +79,16 @@ private:
CursorMgr _cursorMgr;
Common::String _savedPage;
Common::Stack<Common::String> _previousPages;
uint _countryIndex;
uint _domainIndex;
uint16 _countryIndex;
uint16 _domainIndex;
uint16 _iteration;
uint16 _handFrame;
enum LeftHandAction {
kLeft1,
kLeft2,
kLeft3,
kLeft4
} _leftHandAction;
};
} // End of namespace Pink