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,178 @@
/* 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/pink.h"
#include "pink/objects/side_effect.h"
#include "pink/objects/condition.h"
#include "pink/objects/actors/actor.h"
#include "pink/objects/handlers/handler.h"
#include "pink/objects/pages/game_page.h"
#include "pink/objects/sequences/sequencer.h"
#include "pink/objects/sequences/sequence.h"
namespace Pink {
void Handler::deserialize(Archive &archive) {
_conditions.deserialize(archive);
_sideEffects.deserialize(archive);
}
bool Handler::isSuitable(const Actor *actor) const {
for (uint i = 0; i < _conditions.size(); ++i) {
if (!_conditions[i]->evaluate(actor))
return false;
}
return true;
}
void Handler::executeSideEffects(Actor *actor) {
for (uint i = 0; i < _sideEffects.size(); ++i) {
_sideEffects[i]->execute(actor);
}
}
void Handler::handle(Actor *actor) {
executeSideEffects(actor);
}
Handler::~Handler() {
for (uint i = 0; i < _sideEffects.size(); ++i) {
delete _sideEffects[i];
}
for (uint i = 0; i < _conditions.size(); ++i) {
delete _conditions[i];
}
}
void HandlerSequences::deserialize(Archive &archive) {
Handler::deserialize(archive);
_sequences.deserialize(archive);
}
void HandlerSequences::handle(Actor *actor) {
Handler::handle(actor);
Sequencer *sequencer = actor->getPage()->getSequencer();
assert(!_sequences.empty());
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
uint index = rnd.getRandomNumber(_sequences.size() - 1);
Sequence *sequence = sequencer->findSequence(_sequences[index]);
assert(sequence);
authorSequence(sequencer, sequence);
}
void HandlerSequences::authorSequence(Sequencer *sequencer, Sequence *sequence) {
sequencer->authorSequence(sequence, false);
}
void HandlerLeftClick::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerLeftClick:");
debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
for (uint i = 0; i < _sideEffects.size(); ++i) {
_sideEffects[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
for (uint i = 0; i < _conditions.size(); ++i) {
_conditions[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tSequences:");
for (uint i = 0; i < _sequences.size(); ++i) {
debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _sequences[i].c_str());
}
}
void HandlerUseClick::deserialize(Archive &archive) {
HandlerSequences::deserialize(archive);
_inventoryItem = archive.readString();
_recipient = archive.readString();
}
void HandlerUseClick::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerUseClick: _inventoryItem=%s, _recipient=%s", _inventoryItem.c_str(), _recipient.c_str());
debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
for (uint i = 0; i < _sideEffects.size(); ++i) {
_sideEffects[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
for (uint i = 0; i < _conditions.size(); ++i) {
_conditions[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tSequences:");
for (uint i = 0; i < _sequences.size(); ++i) {
debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _sequences[i].c_str());
}
}
void HandlerTimerActions::deserialize(Archive &archive) {
Handler::deserialize(archive);
_actions.deserialize(archive);
}
void HandlerTimerActions::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerTimerActions:");
debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
for (uint i = 0; i < _sideEffects.size(); ++i) {
_sideEffects[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
for (uint i = 0; i < _conditions.size(); ++i) {
_conditions[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tActions:");
for (uint i = 0; i < _actions.size(); ++i) {
debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _actions[i].c_str());
}
}
void HandlerTimerActions::handle(Actor *actor) {
Handler::handle(actor);
if (!actor->isPlaying() && !_actions.empty()) {
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
uint index = rnd.getRandomNumber(_actions.size() - 1);
Action *action = actor->findAction(_actions[index]);
assert(action);
actor->setAction(action);
}
}
void HandlerStartPage::authorSequence(Sequencer *sequencer, Sequence *sequence) {
HandlerSequences::authorSequence(sequencer, sequence);
sequence->allowSkipping();
}
void HandlerTimerSequences::authorSequence(Sequencer *sequencer, Sequence *sequence) {
sequencer->authorParallelSequence(sequence, false);
}
} // End of namespace Pink

View File

@@ -0,0 +1,103 @@
/* 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_HANDLER_H
#define PINK_HANDLER_H
#include "common/str-array.h"
#include "pink/objects/object.h"
namespace Pink {
class Condition;
class SideEffect;
class LeadActor;
class Actor;
class Handler : public Object {
public:
~Handler() override;
void deserialize(Archive &archive) override;
virtual void handle(Actor *actor);
bool isSuitable(const Actor *actor) const;
protected:
void executeSideEffects(Actor *actor);
Array<Condition *> _conditions;
Array<SideEffect *> _sideEffects;
};
class Sequence;
class Sequencer;
class HandlerSequences : public Handler {
public:
void deserialize(Archive &archive) override;
void handle(Actor *actor) override;
protected:
virtual void authorSequence(Sequencer *sequencer, Sequence *sequence);
protected:
StringArray _sequences;
};
class HandlerStartPage : public HandlerSequences {
void authorSequence(Sequencer *sequencer, Sequence *sequence) override;
};
class HandlerLeftClick : public HandlerSequences {
public:
void toConsole() const override;
};
class HandlerUseClick : public HandlerSequences {
public:
void deserialize(Archive &archive) override;
void toConsole() const override;
const Common::String &getInventoryItem() const { return _inventoryItem; }
const Common::String &getRecipient() const { return _recipient; }
private:
Common::String _inventoryItem;
Common::String _recipient;
};
class HandlerTimerActions : public Handler {
public:
void toConsole() const override;
void deserialize(Archive &archive) override;
void handle(Actor *actor) override;
private:
StringArray _actions;
};
class HandlerTimerSequences : public HandlerSequences {
void authorSequence(Sequencer *sequencer, Sequence *sequence) override;
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,108 @@
/* 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/pink.h"
#include "pink/objects/inventory.h"
#include "pink/objects/handlers/handler.h"
#include "pink/objects/handlers/handler_mgr.h"
namespace Pink {
void HandlerMgr::deserialize(Archive &archive) {
_leftClickHandlers.deserialize(archive);
_useClickHandlers.deserialize(archive);
_timerHandlers.deserialize(archive);
}
void HandlerMgr::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerMgr:");
for (uint i = 0; i < _leftClickHandlers.size(); ++i) {
_leftClickHandlers[i]->toConsole();
}
for (uint i = 0; i < _useClickHandlers.size(); ++i) {
_useClickHandlers[i]->toConsole();
}
for (uint i = 0; i < _timerHandlers.size(); ++i) {
_timerHandlers[i]->toConsole();
}
}
void HandlerMgr::onTimerMessage(Actor *actor) {
Handler *handler = findSuitableHandlerTimer(actor);
if (handler)
handler->handle(actor);
}
void HandlerMgr::onLeftClickMessage(Actor *actor) {
Handler *handler = findSuitableHandlerLeftClick(actor);
assert(handler);
handler->handle(actor);
}
void HandlerMgr::onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr) {
HandlerUseClick *handler = findSuitableHandlerUseClick(actor, item->getName());
assert(handler);
if (!handler->getRecipient().empty())
mgr->setItemOwner(handler->getRecipient(), item);
handler->handle(actor);
}
Handler *HandlerMgr::findSuitableHandlerTimer(const Actor *actor) {
for (uint i = 0; i < _timerHandlers.size(); ++i) {
if (_timerHandlers[i]->isSuitable(actor))
return _timerHandlers[i];
}
return nullptr;
}
HandlerLeftClick *HandlerMgr::findSuitableHandlerLeftClick(const Actor *actor) const {
for (uint i = 0; i < _leftClickHandlers.size(); ++i) {
if (_leftClickHandlers[i]->isSuitable(actor))
return _leftClickHandlers[i];
}
return nullptr;
}
HandlerUseClick *HandlerMgr::findSuitableHandlerUseClick(const Actor *actor, const Common::String &itemName) const {
for (uint i = 0; i < _useClickHandlers.size(); ++i) {
if (itemName == _useClickHandlers[i]->getInventoryItem() && _useClickHandlers[i]->isSuitable(actor))
return _useClickHandlers[i];
}
return nullptr;
}
HandlerMgr::~HandlerMgr() {
for (uint i = 0; i < _leftClickHandlers.size(); ++i) {
delete _leftClickHandlers[i];
}
for (uint j = 0; j < _useClickHandlers.size(); ++j) {
delete _useClickHandlers[j];
}
for (uint k = 0; k < _timerHandlers.size(); ++k) {
delete _timerHandlers[k];
}
}
} // End of namespace Pink

View File

@@ -0,0 +1,63 @@
/* 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_HANDLER_MGR_H
#define PINK_HANDLER_MGR_H
#include "pink/objects/object.h"
namespace Pink {
class InventoryItem;
class InventoryMgr;
class Handler;
class HandlerLeftClick;
class HandlerUseClick;
class HandlerTimer;
class Actor;
class HandlerMgr : public Object {
public:
~HandlerMgr() override;
void deserialize(Archive &archive) override;
void toConsole() const override;
HandlerUseClick *findSuitableHandlerUseClick(const Actor *actor, const Common::String &itemName) const;
HandlerLeftClick *findSuitableHandlerLeftClick(const Actor *actor) const;
void onTimerMessage(Actor *actor);
void onLeftClickMessage(Actor *actor);
void onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr);
private:
Handler *findSuitableHandlerTimer(const Actor *actor);
Array<HandlerLeftClick *> _leftClickHandlers;
Array<HandlerUseClick *> _useClickHandlers;
Array<Handler *> _timerHandlers;
};
}
#endif