Skip to content

Commit

Permalink
PINK: added more constants
Browse files Browse the repository at this point in the history
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent ec96a3b commit 888f5b6
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 24 deletions.
28 changes: 28 additions & 0 deletions engines/pink/constants.h
Expand Up @@ -138,13 +138,41 @@ enum {
kBroMinorVersion = 0,
};

enum {
kTimersUpdateTime = 0x64,
kCursorsUpdateTime = 0xC8
};

enum {
kSampleRate = 22050
};

static const char *kPinkGame = "PinkGame";

static const char *kPokus = "pokus";
static const char *kPeril = "peril";

static const char *kUndefined = "UNDEFINED";


static const char *kCloseAction = "Close";
static const char *kIdleAction = "Idle";
static const char *kOpenAction = "Open";
static const char *kPlayAction = "Play";
static const char *kShowAction = "Show";
static const char *kHideAction = "Hide";

static const char *kInventoryWindowActor = "InventoryWindow";
static const char *kInventoryItemActor = "InventoryItem";
static const char *kInventoryRightArrowActor = "InventoryWindow";
static const char *kInventoryLeftArrowActor = "InventoryWindow";

static const char *kCursorNameExitUp = "ExitUp";
static const char *kCursorNameExitLeft = "ExitLeft";
static const char *kCursorNameExitRight = "ExitRight";
static const char *kCursorNameExitForward = "ExitForward";


} // End of namespace Pink

#endif
9 changes: 5 additions & 4 deletions engines/pink/cursor_mgr.cpp
Expand Up @@ -53,7 +53,7 @@ void CursorMgr::update() {
return;

uint newTime = _game->getTotalPlayTime();
if (newTime - _time > 0xC8){
if (newTime - _time > kCursorsUpdateTime){
_time = newTime;
_isSecondFrame = !_isSecondFrame;
_game->setCursor(_firstFrameIndex + _isSecondFrame);
Expand All @@ -62,15 +62,16 @@ void CursorMgr::update() {

void CursorMgr::setCursor(Common::String &cursorName, Common::Point point) {
uint index;
if (cursorName == "ExitLeft") {
if (cursorName == kCursorNameExitLeft) {
index = kExitLeftCursor;
}
else if (cursorName == "ExitRight"){
else if (cursorName == kCursorNameExitRight){
index = kExitRightCursor;
}
else if (cursorName == "ExitForward" || cursorName == "ExitUp")
else if (cursorName == kCursorNameExitForward || cursorName == kCursorNameExitUp)
index = kExitForwardCursor;
else assert(0);

setCursor(index, point);
}

Expand Down
1 change: 1 addition & 0 deletions engines/pink/cursor_mgr.h
Expand Up @@ -50,6 +50,7 @@ class CursorMgr : public Object {

uint _time;
uint _firstFrameIndex;

bool _isPlayingAnimation;
bool _isSecondFrame;
};
Expand Down
4 changes: 2 additions & 2 deletions engines/pink/objects/actors/actor.cpp
Expand Up @@ -62,7 +62,7 @@ GamePage *Actor::getPage() const {

void Actor::init(bool unk) {
if (!_action) {
_action = findAction({"Idle"});
_action = findAction(kIdleAction);
}

if (!_action) {
Expand All @@ -75,7 +75,7 @@ void Actor::init(bool unk) {
}

void Actor::hide() {
setAction({"Hide"});
setAction(kHideAction);
}

void Actor::endAction() {
Expand Down
24 changes: 21 additions & 3 deletions engines/pink/objects/handlers/handler_mgr.cpp
@@ -1,6 +1,24 @@
//
// Created by andrei on 3/21/18.
//
/* 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 "handler_mgr.h"
#include "handler.h"
Expand Down
27 changes: 14 additions & 13 deletions engines/pink/objects/inventory.cpp
Expand Up @@ -113,13 +113,13 @@ bool InventoryMgr::start(bool playOpening) {
return false;
}

_window = _lead->getPage()->findActor("InventoryWindow");
_itemActor = _lead->getPage()->findActor("InventoryItem");
_rightArrow = _lead->getPage()->findActor("InventoryRightArrow");
_leftArrow = _lead->getPage()->findActor("InventoryLeftArrow");
_window = _lead->getPage()->findActor(kInventoryWindowActor);
_itemActor = _lead->getPage()->findActor(kInventoryItemActor);
_rightArrow = _lead->getPage()->findActor(kInventoryRightArrowActor);
_leftArrow = _lead->getPage()->findActor(kInventoryLeftArrowActor);

if (playOpening){
_window->setAction("Open");
_window->setAction(kOpenAction);
_state = kOpening;
}

Expand All @@ -130,16 +130,17 @@ void InventoryMgr::update() {
if (_state == kOpening && !_window->isPlaying()){
_state = kReady;
_itemActor->setAction(_item->getName());
_window->setAction("Show");
_leftArrow->setAction("Show");
_rightArrow->setAction("Show");
_window->setAction(kShowAction);
_leftArrow->setAction(kShowAction);
_rightArrow->setAction(kShowAction);
}
else if (_state == kClosing && !_window->isPlaying()){
_window->setAction("Idle");
_window->setAction(kIdleAction);

_lead->onInventoryClosed(_isClickedOnItem);

_state = kIdle;

_window = nullptr;
_itemActor = nullptr;
_isClickedOnItem = false;
Expand All @@ -164,10 +165,10 @@ void InventoryMgr::onClick(Common::Point point) {
void InventoryMgr::close() {
_state = kClosing;

_window->setAction("Close");
_itemActor->setAction("Idle");
_leftArrow->setAction("Idle");
_rightArrow->setAction("Idle");
_window->setAction(kCloseAction);
_itemActor->setAction(kIdleAction);
_leftArrow->setAction(kIdleAction);
_rightArrow->setAction(kIdleAction);
}

void InventoryMgr::showNextItem(bool direction) {
Expand Down
2 changes: 1 addition & 1 deletion engines/pink/objects/sequences/sequencer.cpp
Expand Up @@ -104,7 +104,7 @@ void Sequencer::skipToLastSubSequence() {

void Sequencer::updateTimers() {
uint time = _page->getGame()->getTotalPlayTime();
if (time - _time <= 0x64) {
if (time - _time <= kTimersUpdateTime) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion engines/pink/sound.cpp
Expand Up @@ -25,6 +25,7 @@
#include <audio/decoders/adpcm.h>
#include <common/substream.h>
#include "sound.h"
#include "constants.h"

namespace Pink {

Expand Down Expand Up @@ -76,7 +77,7 @@ void Sound::setBalance(int8 balance) {
}

uint32 Sound::getCurrentSample() {
return _mixer->getSoundElapsedTime(_handle) * 22050 / 1000;
return _mixer->getSoundElapsedTime(_handle) * kSampleRate / 1000;
}

} // End of namespace Pink

0 comments on commit 888f5b6

Please sign in to comment.