Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "pink/constants.h"
#include "pink/cursor_mgr.h"
#include "pink/pink.h"
#include "pink/objects/actions/action_cel.h"
#include "pink/objects/actors/actor.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/pages/game_page.h"
namespace Pink {
Actor::Actor()
: _page(nullptr), _action(nullptr),
_isActionEnded(true) {}
Actor::~Actor() {
for (uint i = 0; i < _actions.size(); ++i) {
delete _actions[i];
}
}
void Actor::deserialize(Archive &archive) {
NamedObject::deserialize(archive);
_page = static_cast<Page *>(archive.readObject());
_actions.deserialize(archive);
}
void Actor::loadState(Archive &archive) {
_action = findAction(archive.readString());
}
void Actor::saveState(Archive &archive) {
Common::String actionName;
if (_action)
actionName = _action->getName();
archive.writeString(actionName);
}
void Actor::init(bool paused) {
if (!_action)
_action = findAction(kIdleAction);
if (!_action) {
_isActionEnded = true;
} else {
_isActionEnded = false;
_action->start();
_action->pause(paused);
}
}
bool Actor::initPalette(Screen *screen) {
for (uint i = 0; i < _actions.size(); ++i) {
if (_actions[i]->initPalette(screen))
return true;
}
return false;
}
void Actor::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "Actor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
void Actor::pause(bool paused) {
if (_action)
_action->pause(paused);
}
void Actor::onMouseOver(Common::Point point, CursorMgr *mgr) {
mgr->setCursor(kDefaultCursor, point, Common::String());
}
void Actor::onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
cursorMgr->setCursor(kHoldingItemCursor, point, itemName);
}
Action *Actor::findAction(const Common::String &name) {
for (uint i = 0; i < _actions.size(); ++i) {
if (_actions[i]->getName() == name)
return _actions[i];
}
return nullptr;
}
Common::String Actor::getLocation() const {
return Common::String();
}
void Actor::setAction(Action *newAction) {
if (_action) {
_isActionEnded = true;
_action->end();
}
_action = newAction;
if (newAction) {
_isActionEnded = false;
_action->start();
}
}
void Actor::setAction(Action *newAction, bool loadingSave) {
if (loadingSave) {
_isActionEnded = true;
_action = newAction;
} else {
setAction(newAction);
}
}
InventoryMgr *Actor::getInventoryMgr() const {
return _page->getModule()->getInventoryMgr();
}
Common::String Actor::getPDALink() const {
return Common::String();
}
} // End of namespace Pink

View File

@@ -0,0 +1,100 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_ACTOR_H
#define PINK_ACTOR_H
#include "common/rect.h"
#include "pink/utils.h"
namespace Pink {
class Page;
class Action;
class Sequencer;
class Screen;
class CursorMgr;
class InventoryItem;
class InventoryMgr;
class Actor : public NamedObject {
public:
Actor();
~Actor() override;
void deserialize(Archive &archive) override;
void loadState(Archive &archive);
void saveState(Archive &archive);
virtual void init(bool paused);
bool initPalette(Screen *screen);
void toConsole() const override;
bool isPlaying() const { return !_isActionEnded; }
virtual void pause(bool paused);
void endAction() { _isActionEnded = true; }
virtual bool isSupporting() const { return false; }
virtual bool isCursor() const { return false; }
virtual bool isLeftClickHandlers() const { return false; }
virtual bool isUseClickHandlers(InventoryItem *item) const { return false; }
virtual void onMouseOver(Common::Point point, CursorMgr *mgr);
virtual void onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr);
virtual void onTimerMessage() {}
virtual void onLeftClickMessage() {}
virtual void onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) {}
Action *findAction(const Common::String &name);
Action *getAction() { return _action; }
const Action *getAction() const { return _action; }
Page *getPage() { return _page; }
const Page *getPage() const { return _page; }
InventoryMgr *getInventoryMgr() const;
virtual Common::String getPDALink() const;
virtual Common::String getLocation() const;
void setAction(const Common::String &name) { setAction(findAction(name)); }
void setAction(Action *newAction);
void setAction(Action *newAction, bool loadingSave);
protected:
Page *_page;
Action *_action;
Array<Action *> _actions;
bool _isActionEnded;
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,49 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "pink/pink.h"
#include "pink/objects/actors/audio_info_pda_button.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/pages/page.h"
namespace Pink {
void AudioInfoPDAButton::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "AudioInfoPDAButton: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
void AudioInfoPDAButton::onMouseOver(Common::Point point, CursorMgr *mgr) {
mgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
}
void AudioInfoPDAButton::onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
onMouseOver(point, cursorMgr);
}
void AudioInfoPDAButton::onLeftClickMessage() {
AudioInfoMgr *audioInfoMgr = _page->getLeadActor()->getAudioInfoMgr();
audioInfoMgr->onLeftClick();
}
} // End of namespace Pink

View File

@@ -0,0 +1,46 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_AUDIO_INFO_PDA_BUTTON_H
#define PINK_AUDIO_INFO_PDA_BUTTON_H
#include "common/debug.h"
#include "pink/constants.h"
#include "pink/cursor_mgr.h"
#include "pink/objects/actions/action.h"
#include "pink/objects/actors/actor.h"
namespace Pink {
class AudioInfoPDAButton : public Actor {
public:
void toConsole() const override;
void onMouseOver(Common::Point point, CursorMgr *mgr) override;
void onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override;
void onLeftClickMessage() override;
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,55 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_CURSOR_ACTOR_H
#define PINK_CURSOR_ACTOR_H
#include "common/debug.h"
#include "pink/pink.h"
#include "pink/objects/actions/action_cel.h"
#include "pink/objects/actors/actor.h"
namespace Pink {
class CursorActor : public Actor {
public:
void toConsole() const override {
debugC(6, kPinkDebugLoadingObjects, "CursorActor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
bool isCursor() const override {
return true;
}
void setCursorItem(const Common::String &name, Common::Point point) {
if (!_action || _action->getName() != name)
setAction(name);
static_cast<ActionCEL*>(_action)->setCenter(point);
}
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,50 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_INVENTORY_ACTOR_H
#define PINK_INVENTORY_ACTOR_H
#include "common/debug.h"
#include "pink/objects/actions/action.h"
#include "pink/objects/actors/actor.h"
namespace Pink {
class InventoryActor : public Actor {
public:
void toConsole() const override {
debugC(6, kPinkDebugLoadingObjects, "InventoryActor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
void pause(bool paused) override {}
void init(bool paused) override {
Actor::init(false);
}
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,507 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "pink/archive.h"
#include "pink/cursor_mgr.h"
#include "pink/pink.h"
#include "pink/screen.h"
#include "pink/objects/actions/action.h"
#include "pink/objects/actors/supporting_actor.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/pages/game_page.h"
#include "pink/objects/sequences/sequence_context.h"
#include "pink/objects/sequences/sequencer.h"
namespace Pink {
LeadActor::LeadActor()
: _state(kReady), _nextState(kUndefined), _stateBeforeInventory(kUndefined),
_stateBeforePDA(kUndefined), _isHaveItem(false), _recipient(nullptr),
_cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr),
_audioInfoMgr(this) {}
void LeadActor::deserialize(Archive &archive) {
_state = kReady;
Actor::deserialize(archive);
_cursorMgr = static_cast<CursorMgr *>(archive.readObject());
_walkMgr = static_cast<WalkMgr *>(archive.readObject());
_sequencer = static_cast<Sequencer *>(archive.readObject());
}
void LeadActor::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "LeadActor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
void LeadActor::loadState(Archive &archive) {
_state = (State)archive.readByte();
_nextState = (State)archive.readByte();
_stateBeforeInventory = (State)archive.readByte();
_stateBeforePDA = (State)archive.readByte();
_isHaveItem = archive.readByte();
Common::String recipient = archive.readString();
if (!recipient.empty())
_recipient = _page->findActor(recipient);
else
_recipient = nullptr;
_sequencer->loadState(archive);
_walkMgr->loadState(archive);
_page->getGame()->getPdaMgr().loadState(archive);
_audioInfoMgr.loadState(archive);
}
void LeadActor::saveState(Archive &archive) {
archive.writeByte(_state);
archive.writeByte(_nextState);
archive.writeByte(_stateBeforeInventory);
archive.writeByte(_stateBeforePDA);
archive.writeByte(_isHaveItem);
if (_recipient)
archive.writeString(_recipient->getName());
else
archive.writeString(Common::String());
_sequencer->saveState(archive);
_walkMgr->saveState(archive);
_page->getGame()->getPdaMgr().saveState(archive);
_audioInfoMgr.saveState(archive);
}
void LeadActor::init(bool paused) {
if (_state == kUndefined)
_state = kReady;
getInventoryMgr()->setLeadActor(this);
_page->getGame()->setLeadActor(this);
Actor::init(paused);
}
void LeadActor::start(bool isHandler) {
if (isHandler && _state != kPlayingExitSequence) {
_state = kPlayingSequence;
_nextState = kReady;
}
switch (_state) {
case kInventory:
startInventory(1);
break;
case kPDA:
if (_stateBeforePDA == kInventory)
startInventory(1);
_page->getGame()->getScreen()->saveStage();
loadPDA(_page->getGame()->getPdaMgr().getSavedPageName());
break;
default:
forceUpdateCursor();
break;
}
}
void LeadActor::update() {
switch (_state) {
case kMoving:
_walkMgr->update();
// fall through
case kReady:
_sequencer->update();
_cursorMgr->update();
break;
case kPlayingSequence:
_sequencer->update();
if (!_sequencer->isPlaying()) {
_state = _nextState;
_nextState = kUndefined;
forceUpdateCursor();
}
break;
case kInventory:
getInventoryMgr()->update();
break;
case kPDA:
getPage()->getGame()->getPdaMgr().update();
break;
case kPlayingExitSequence:
_sequencer->update();
if (!_sequencer->isPlaying()) {
_state = kUndefined;
_page->getGame()->changeScene();
}
break;
default:
break;
}
}
void LeadActor::loadPDA(const Common::String &pageName) {
if (_state != kPDA) {
if (_state == kMoving)
cancelInteraction();
if (_state != kInventory && !_page->getGame()->getScreen()->isMenuActive())
_page->pause(true);
_stateBeforePDA = _state;
_state = kPDA;
_page->getGame()->getScreen()->saveStage();
}
_page->getGame()->getPdaMgr().setLead(this);
_page->getGame()->getPdaMgr().goToPage(pageName);
}
void LeadActor::onActionClick(Common::CustomEventType action) {
switch (_state) {
case kMoving:
switch (action) {
case kActionSkipWalkAndCancelInteraction:
cancelInteraction();
// fall through
case kActionSkipWalk:
_walkMgr->skip();
break;
default:
break;
}
break;
case kPlayingSequence:
case kPlayingExitSequence:
switch (action) {
case kActionSkipSubSequence:
_sequencer->skipSubSequence();
break;
case kActionSkipSequence:
_sequencer->skipSequence();
break;
case kActionRestartSequence:
_sequencer->restartSequence();
break;
default:
break;
}
break;
default:
break;
}
}
void LeadActor::onLeftButtonClick(Common::Point point) {
switch (_state) {
case kReady:
case kMoving: {
Actor *clickedActor = getActorByPoint(point);
if (!clickedActor)
return;
if (this == clickedActor) {
_audioInfoMgr.stop();
onLeftClickMessage();
} else if (clickedActor->isSupporting()) {
if (isInteractingWith(clickedActor)) {
_recipient = clickedActor;
_audioInfoMgr.stop();
if (!startWalk()) {
if (_isHaveItem)
sendUseClickMessage(clickedActor);
else
sendLeftClickMessage(clickedActor);
}
}
} else
clickedActor->onLeftClickMessage();
break;
}
case kPDA:
_page->getGame()->getPdaMgr().onLeftButtonClick(point);
break;
case kInventory:
getInventoryMgr()->onClick(point);
break;
default:
break;
}
}
void LeadActor::onLeftButtonUp() {
if (_state == kPDA)
_page->getGame()->getPdaMgr().onLeftButtonUp();
}
void LeadActor::onRightButtonClick(Common::Point point) {
if (_state == kReady || _state == kMoving) {
Actor *clickedActor = getActorByPoint(point);
if (clickedActor && isInteractingWith(clickedActor)) {
_audioInfoMgr.start(clickedActor);
}
if (_state == kMoving)
cancelInteraction();
}
}
void LeadActor::onMouseMove(Common::Point point) {
if (_state != kPDA)
updateCursor(point);
else
_page->getGame()->getPdaMgr().onMouseMove(point);
}
void LeadActor::onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
_cursorMgr->setCursor(kHoldingItemCursor, point, itemName + kClickable);
}
void LeadActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
if (getInventoryMgr()->isPinkOwnsAnyItems())
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
else
Actor::onMouseOver(point, mgr);
}
void LeadActor::onLeftClickMessage() {
if (_isHaveItem) {
_isHaveItem = false;
_nextState = _state != kMoving ? kUndefined : kReady;
forceUpdateCursor();
} else {
if (_state == kMoving)
cancelInteraction();
startInventory(0);
}
}
void LeadActor::onInventoryClosed(bool isItemClicked) {
_isHaveItem = isItemClicked;
_state = _stateBeforeInventory;
_stateBeforeInventory = kUndefined;
_page->pause(false);
forceUpdateCursor();
}
void LeadActor::onWalkEnd(const Common::String &stopName) {
State oldNextState = _nextState;
_state = kReady;
_nextState = kUndefined;
if (_recipient && oldNextState == kPlayingSequence) {
if (_isHaveItem)
sendUseClickMessage(_recipient);
else
sendLeftClickMessage(_recipient);
} else { // on ESC button
Action *action = findAction(stopName);
assert(action);
setAction(action);
}
}
void LeadActor::onPDAClose() {
_page->initPalette();
_page->getGame()->getScreen()->loadStage();
_state = _stateBeforePDA;
_stateBeforePDA = kUndefined;
if (_state != kInventory)
_page->pause(false);
}
bool LeadActor::isInteractingWith(const Actor *actor) const {
if (!_isHaveItem)
return actor->isLeftClickHandlers();
return actor->isUseClickHandlers(getInventoryMgr()->getCurrentItem());
}
void LeadActor::setNextExecutors(const Common::String &nextModule, const Common::String &nextPage) {
if (_state == kReady || _state == kMoving || _state == kPlayingSequence || _state == kInventory || _state == kPDA) {
_state = kPlayingExitSequence;
_page->getGame()->setNextExecutors(nextModule, nextPage);
}
}
void LeadActor::forceUpdateCursor() {
PinkEngine *vm =_page->getGame();
vm->getScreen()->update(); // we have actions, that should be drawn to properly update cursor
Common::Point point = vm->getEventManager()->getMousePos();
updateCursor(point);
}
void LeadActor::updateCursor(Common::Point point) {
switch (_state) {
case kReady:
case kMoving: {
Actor *actor = getActorByPoint(point);
InventoryItem *item = getInventoryMgr()->getCurrentItem();
if (_isHaveItem) {
if (actor) {
actor->onMouseOverWithItem(point, item->getName(), _cursorMgr);
} else
_cursorMgr->setCursor(kHoldingItemCursor, point, item->getName());
} else if (actor)
actor->onMouseOver(point, _cursorMgr);
else
_cursorMgr->setCursor(kDefaultCursor, point, Common::String());
break;
}
case kPlayingSequence:
case kPlayingExitSequence:
_cursorMgr->setCursor(kNotClickableCursor, point, Common::String());
break;
case kPDA:
case kInventory:
_cursorMgr->setCursor(kDefaultCursor, point, Common::String());
break;
default:
break;
}
}
void LeadActor::sendUseClickMessage(Actor *actor) {
InventoryMgr *mgr = getInventoryMgr();
assert(_state != kPlayingExitSequence);
_nextState = kReady;
_state = kPlayingSequence;
InventoryItem *item = mgr->getCurrentItem();
actor->onUseClickMessage(mgr->getCurrentItem(), mgr);
if (item->getCurrentOwner() != this->_name)
_isHaveItem = false;
forceUpdateCursor();
}
void LeadActor::sendLeftClickMessage(Actor *actor) {
assert(_state != kPlayingExitSequence);
_nextState = kReady;
_state = kPlayingSequence;
actor->onLeftClickMessage();
forceUpdateCursor();
}
WalkLocation *LeadActor::getWalkDestination() {
return _walkMgr->findLocation(_recipient->getLocation());
}
Actor *LeadActor::getActorByPoint(Common::Point point) {
return _page->getGame()->getScreen()->getActorByPoint(point);
}
void LeadActor::startInventory(bool paused) {
if (!getInventoryMgr()->start(paused))
return;
if (!paused) {
_isHaveItem = false;
_stateBeforeInventory = _state;
_state = kInventory;
forceUpdateCursor();
}
_page->pause(true);
}
bool LeadActor::startWalk() {
WalkLocation *location = getWalkDestination();
if (location) {
_state = kMoving;
_nextState = kPlayingSequence;
_walkMgr->start(location);
return true;
}
return false;
}
void LeadActor::cancelInteraction() {
_recipient = nullptr;
_nextState = kReady;
}
Actor *LeadActor::findActor(const Common::String &name) {
return _page->findActor(name);
}
void ParlSqPink::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "ParlSqPink: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
WalkLocation *ParlSqPink::getWalkDestination() {
if (_recipient->getName() == kBoy && _page->checkValueOfVariable(kBoyBlocked, kUndefinedValue))
return _walkMgr->findLocation(kSirBaldley);
return LeadActor::getWalkDestination();
}
void PubPink::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "PubPink: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
}
void PubPink::onLeftClickMessage() {
if (!playingMiniGame())
LeadActor::onLeftClickMessage();
}
void PubPink::onVariableSet() {
if (playingMiniGame())
_isHaveItem = true;
}
void PubPink::updateCursor(Common::Point point) {
if (playingMiniGame()) {
Actor *actor = getActorByPoint(point);
assert(actor);
if (_state == kReady && actor->isUseClickHandlers(getInventoryMgr()->getCurrentItem())) {
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
} else
_cursorMgr->setCursor(kDefaultCursor, point, Common::String());
} else {
LeadActor::updateCursor(point);
}
}
void PubPink::sendUseClickMessage(Actor *actor) {
LeadActor::sendUseClickMessage(actor);
if (playingMiniGame())
_isHaveItem = true;
}
WalkLocation *PubPink::getWalkDestination() {
if (playingMiniGame())
return nullptr;
if (_recipient->getName() == kJackson && !_page->checkValueOfVariable(kDrunkLocation, kBolted))
return _walkMgr->findLocation(_page->findActor(kDrunk)->getName());
return LeadActor::getWalkDestination();
}
bool PubPink::playingMiniGame() {
return !(_page->checkValueOfVariable(kFoodPuzzle, kTrueValue) ||
_page->checkValueOfVariable(kFoodPuzzle, kUndefinedValue));
}
void PubPink::onRightButtonClick(Common::Point point) {
if (!playingMiniGame())
LeadActor::onRightButtonClick(point);
}
} // End of namespace Pink

View File

@@ -0,0 +1,162 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_LEAD_ACTOR_H
#define PINK_LEAD_ACTOR_H
#include "common/events.h"
#include "common/rect.h"
#include "common/keyboard.h"
#include "pink/objects/actors/actor.h"
#include "pink/audio_info_mgr.h"
namespace Pink {
class CursorMgr;
class WalkMgr;
class WalkLocation;
class Sequencer;
class SupportingActor;
class InventoryItem;
class LeadActor : public Actor {
public:
LeadActor();
enum State {
kReady = 0,
kMoving = 1,
kPlayingSequence = 2,
kInventory = 3,
kPDA = 4,
kPlayingExitSequence = 6,
kUndefined = 7
};
void deserialize(Archive &archive) override;
void toConsole() const override;
void loadState(Archive &archive);
void saveState(Archive &archive);
void init(bool paused) override;
void start(bool isHandler);
void update();
void loadPDA(const Common::String &pageName);
void onActionClick(Common::CustomEventType action);
void onLeftButtonClick(Common::Point point);
void onLeftButtonUp();
virtual void onRightButtonClick(Common::Point point);
void onMouseMove(Common::Point point);
void onMouseOverWithItem(Common::Point point, const Common::String &itemName, Pink::CursorMgr *cursorMgr) override;
void onMouseOver(Common::Point point, CursorMgr *mgr) override;
void onLeftClickMessage() override;
virtual void onVariableSet() {}
void onInventoryClosed(bool isItemClicked);
void onWalkEnd(const Common::String &stopName);
void onPDAClose();
bool isInteractingWith(const Actor *actor) const;
void setNextExecutors(const Common::String &nextModule, const Common::String &nextPage);
State getState() const { return _state; }
AudioInfoMgr *getAudioInfoMgr() { return &_audioInfoMgr; }
Actor *getActorByPoint(Common::Point point);
Actor *findActor(const Common::String &name);
protected:
void forceUpdateCursor();
virtual void updateCursor(Common::Point point);
virtual void sendUseClickMessage(Actor *actor);
void sendLeftClickMessage(Actor *actor);
virtual WalkLocation *getWalkDestination();
void startInventory(bool paused);
bool startWalk();
void cancelInteraction();
Actor *_recipient;
CursorMgr *_cursorMgr;
WalkMgr *_walkMgr;
Sequencer *_sequencer;
AudioInfoMgr _audioInfoMgr;
State _state;
State _nextState;
State _stateBeforeInventory;
State _stateBeforePDA;
bool _isHaveItem;
};
class ParlSqPink : public LeadActor {
public:
void toConsole() const override;
protected:
WalkLocation *getWalkDestination() override;
};
class PubPink : public LeadActor {
public:
void toConsole() const override;
void onRightButtonClick(Common::Point point) override;
void onLeftClickMessage() override;
void onVariableSet() override;
protected:
void updateCursor(Common::Point point) override;
void sendUseClickMessage(Actor *actor) override;
WalkLocation *getWalkDestination() override;
private:
bool playingMiniGame();
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,95 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#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"
#include "pink/objects/actions/action_cel.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 type = archive.readDWORD();
assert(type != 0 && type != Command::kIncrementFrame && type != Command::kDecrementFrame);
if (_page->getGame()->isPeril()) {
_command.type = (Command::CommandType) type;
} else {
switch (type) {
case 1:
_command.type = Command::kGoToPage;
break;
case 2:
_command.type = Command::kClose;
break;
default:
_command.type = Command::kNull;
break;
}
}
_command.arg = archive.readString();
}
void PDAButtonActor::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "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::onLeftClickMessage() {
if (isActive()) {
_page->getGame()->getPdaMgr().execute(_command);
}
}
void PDAButtonActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
if (_command.type == Command::kNull || !isActive())
mgr->setCursor(kPDADefaultCursor, point, Common::String());
else
mgr->setCursor(kPDAClickableFirstFrameCursor, point, Common::String());
}
bool PDAButtonActor::isActive() const {
return _action && _action->getName() != "Inactive";
}
void PDAButtonActor::init(bool paused) {
if (_x != -1 && _y != -1) {
for (uint i = 0; i < _actions.size(); ++i) {
ActionCEL *action = dynamic_cast<ActionCEL*>(_actions[i]);
assert(action);
action->loadDecoder();
Common::Point center;
center.x = _x + action->getDecoder()->getWidth() / 2;
center.y = _y + action->getDecoder()->getHeight() / 2;
action->setCenter(center);
}
}
Actor::init(paused);
}
} // End of namespace Pink

View File

@@ -0,0 +1,76 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_PDA_BUTTON_ACTOR_H
#define PINK_PDA_BUTTON_ACTOR_H
#include "pink/objects/actors/actor.h"
namespace Pink {
struct Command {
enum CommandType {
kGoToPage = 1,
kGoToPreviousPage,
kGoToDomain,
kGoToHelp, // won't be supported
kNavigateToDomain,
kIncrementCountry,
kDecrementCountry,
kIncrementDomain,
kDecrementDomain,
kClose,
kIncrementFrame, // not used
kDecrementFrame, // not used
kNull
};
CommandType type;
Common::String arg;
};
class PDAButtonActor : public Actor {
public:
void deserialize(Archive &archive) override;
void toConsole() const override;
void init(bool paused) override;
void onMouseOver(Common::Point point, CursorMgr *mgr) override;
void onLeftClickMessage() override;
private:
bool isActive() const;
Command _command;
int16 _x;
int16 _y;
bool _hideOnStop;
bool _opaque;
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,94 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "pink/pink.h"
#include "pink/utils.h"
#include "pink/constants.h"
#include "pink/cursor_mgr.h"
#include "pink/objects/inventory.h"
#include "pink/objects/actions/action.h"
#include "pink/objects/actors/supporting_actor.h"
namespace Pink {
void SupportingActor::deserialize(Archive &archive) {
Actor::deserialize(archive);
_location = archive.readString();
_pdaLink = archive.readString();
_cursor = archive.readString();
_handlerMgr.deserialize(archive);
}
void SupportingActor::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "SupportingActor: _name = %s, _location=%s, _pdaLink=%s, _cursor=%s",
_name.c_str(), _location.c_str(), _pdaLink.c_str(), _cursor.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
_handlerMgr.toConsole();
}
bool SupportingActor::isLeftClickHandlers() const {
return _handlerMgr.findSuitableHandlerLeftClick(this);
}
bool SupportingActor::isUseClickHandlers(InventoryItem *item) const {
return _handlerMgr.findSuitableHandlerUseClick(this, item->getName());
}
void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
if (isLeftClickHandlers()) {
if (!_cursor.empty())
mgr->setCursor(_cursor, point);
else
mgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
} else
Actor::onMouseOver(point, mgr);
}
void SupportingActor::onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
Common::String item = itemName;
if (_handlerMgr.findSuitableHandlerUseClick(this, itemName))
item += kClickable;
cursorMgr->setCursor(kHoldingItemCursor, point, item);
}
void SupportingActor::onTimerMessage() {
_handlerMgr.onTimerMessage(this);
}
void SupportingActor::onLeftClickMessage() {
_handlerMgr.onLeftClickMessage(this);
}
void SupportingActor::onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) {
_handlerMgr.onUseClickMessage(this, item, mgr);
}
Common::String SupportingActor::getLocation() const {
return _location;
}
Common::String SupportingActor::getPDALink() const {
return _pdaLink;
}
} // End of namespace Pink

View File

@@ -0,0 +1,64 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PINK_SUPPORTING_ACTOR_H
#define PINK_SUPPORTING_ACTOR_H
#include "pink/objects/actors/actor.h"
#include "pink/objects/handlers/handler_mgr.h"
namespace Pink {
class InventoryItem;
class InventoryMgr;
class SupportingActor : public Actor {
public:
void deserialize(Archive &archive) override;
void toConsole() const override;
bool isSupporting() const override { return true; }
bool isLeftClickHandlers() const override;
bool isUseClickHandlers(InventoryItem *item) const override;
void onMouseOver(Common::Point point, CursorMgr *mgr) override;
void onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override;
void onTimerMessage() override;
void onLeftClickMessage() override;
void onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) override;
Common::String getPDALink() const override;
Common::String getLocation() const override;
private:
HandlerMgr _handlerMgr;
Common::String _location;
Common::String _pdaLink;
Common::String _cursor;
};
} // End of namespace Pink
#endif