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,201 @@
/* 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/cursor_mgr.h"
#include "pink/pink.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/handlers/handler.h"
#include "pink/objects/pages/game_page.h"
#include "pink/objects/sequences/sequencer.h"
#include "pink/objects/walk/walk_mgr.h"
namespace Pink {
GamePage::GamePage()
: _module(nullptr), _cursorMgr(nullptr), _walkMgr(nullptr),
_sequencer(nullptr), _isLoaded(false), _memFile(nullptr) {}
GamePage::~GamePage() {
clear();
delete _memFile;
}
void GamePage::toConsole() const {
Page::toConsole();
_walkMgr->toConsole();
_sequencer->toConsole();
for (uint i = 0; i < _handlers.size(); ++i) {
_handlers[i]->toConsole();
}
}
void GamePage::deserialize(Archive &archive) {
Page::deserialize(archive);
_module = static_cast<Module *>(archive.readObject());
assert(dynamic_cast<Module *>(_module) != nullptr);
}
void GamePage::load(Archive &archive) {
debugC(6, kPinkDebugLoadingObjects, "GamePage load");
archive.mapObject(_cursorMgr);
archive.mapObject(_walkMgr);
archive.mapObject(_sequencer);
Page::load(archive);
_leadActor = static_cast<LeadActor *>(archive.readObject());
_walkMgr->deserialize(archive);
_sequencer->deserialize(archive);
_handlers.deserialize(archive);
}
void GamePage::init(bool isLoadingSave) {
if (!_isLoaded)
loadManagers();
toConsole();
initPalette();
LeadActor::State state = _leadActor->getState();
bool paused = (state == LeadActor::kInventory || state == LeadActor::kPDA);
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->init(paused);
}
bool isHandler = false;
if (!isLoadingSave)
isHandler = initHandler();
_leadActor->start(isHandler);
}
bool GamePage::initHandler() {
for (uint i = 0; i < _handlers.size(); ++i) {
if (_handlers[i]->isSuitable(_leadActor)) {
_handlers[i]->handle(_leadActor);
return true;
}
}
return false;
}
void GamePage::loadManagers() {
_isLoaded = true;
_cursorMgr = new CursorMgr(_module->getGame(), this);
_walkMgr = new WalkMgr;
_sequencer = new Sequencer(this);
debugC(6, kPinkDebugGeneral, "ResMgr init");
_resMgr.init(_module->getGame(), this);
if (_memFile != nullptr) {
loadStateFromMem();
delete _memFile;
_memFile = nullptr;
}
}
bool GamePage::checkValueOfVariable(const Common::String &variable, const Common::String &value) const {
if (!_variables.contains(variable))
return value == kUndefinedValue;
return _variables[variable] == value;
}
void GamePage::setVariable(Common::String &variable, Common::String &value) {
_variables[variable] = value;
_leadActor->onVariableSet();
}
void GamePage::loadStateFromMem() {
Archive archive(static_cast<Common::SeekableReadStream *>(_memFile));
_variables.deserialize(archive);
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->loadState(archive);
}
}
void GamePage::saveStateToMem() {
_memFile = new Common::MemoryReadWriteStream(DisposeAfterUse::YES);
Archive archive(static_cast<Common::WriteStream *>(_memFile));
_variables.serialize(archive);
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->saveState(archive);
}
}
void GamePage::loadState(Archive &archive) {
uint size = archive.readDWORD();
if (size) {
_memFile = new Common::MemoryReadWriteStream(DisposeAfterUse::YES);
for (uint i = 0; i < size; ++i) {
_memFile->writeByte(archive.readByte());
}
}
}
void GamePage::saveState(Archive &archive) {
if (this == _module->getPage()) {
saveStateToMem();
archive.writeDWORD(_memFile->size());
archive.write(_memFile->getData(), _memFile->size());
delete _memFile;
_memFile = nullptr;
} else {
if (_memFile != nullptr) {
archive.writeDWORD(_memFile->size());
archive.write(_memFile->getData(), _memFile->size());
} else {
archive.writeDWORD(0);
}
}
}
void GamePage::unload() {
_leadActor->setAction(_leadActor->findAction(kIdleAction));
saveStateToMem();
clear();
_isLoaded = false;
}
void GamePage::clear() {
Page::clear();
_variables.clear(true);
for (uint i = 0; i < _handlers.size(); ++i) {
delete _handlers[i];
}
_handlers.clear();
delete _cursorMgr; _cursorMgr = nullptr;
delete _sequencer; _sequencer = nullptr;
delete _walkMgr; _walkMgr = nullptr;
}
} // End of namespace Pink

View File

@@ -0,0 +1,79 @@
/* 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_GAME_PAGE_H
#define PINK_GAME_PAGE_H
#include "common/memstream.h"
#include "pink/objects/pages/page.h"
namespace Pink {
class CursorMgr;
class HandlerSequences;
class GamePage : public Page {
public:
GamePage();
~GamePage() override;
void toConsole() const override;
void deserialize(Archive &archive) override;
void loadState(Archive &archive);
void saveState(Archive &archive);
void load(Archive &archive) override;
void unload();
void loadManagers();
void init(bool isLoadingSave);
Sequencer *getSequencer() override { return _sequencer; }
WalkMgr *getWalkMgr() override { return _walkMgr; }
Module *getModule() override { return _module; }
const Module *getModule() const override { return _module; }
bool checkValueOfVariable(const Common::String &variable, const Common::String &value) const override;
void setVariable(Common::String &variable, Common::String &value) override;
void clear() override;
friend class Console;
private:
bool initHandler();
void loadStateFromMem();
void saveStateToMem();
bool _isLoaded;
Common::MemoryReadWriteStream *_memFile;
Module *_module;
CursorMgr *_cursorMgr;
WalkMgr *_walkMgr;
Sequencer *_sequencer;
Array<HandlerSequences *> _handlers;
StringMap _variables;
};
}
#endif

View File

@@ -0,0 +1,84 @@
/* 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/screen.h"
#include "pink/pink.h"
#include "pink/objects/actors/lead_actor.h"
#include "pink/objects/pages/page.h"
namespace Pink {
Page::~Page() {
clear();
}
void Page::load(Archive &archive) {
debugC(6, kPinkDebugLoadingObjects, "Page load");
archive.mapObject(this);
NamedObject::deserialize(archive);
archive.skipString(); //skip directory
_actors.deserialize(archive);
}
Actor *Page::findActor(const Common::String &name) {
for (uint i = 0; i < _actors.size(); ++i) {
if (_actors[i]->getName() == name) {
return _actors[i];
}
}
return nullptr;
}
void Page::toConsole() const {
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->toConsole();
}
}
void Page::init() {
initPalette();
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->init(false);
}
}
void Page::initPalette() {
for (uint i = 0; i < _actors.size(); ++i) {
if (_actors[i]->initPalette(getGame()->getScreen()))
break;
}
}
void Page::clear() {
for (uint i = 0; i < _actors.size(); ++i) {
delete _actors[i];
}
_actors.clear();
_resMgr.clear();
}
void Page::pause(bool paused) {
for (uint i = 0; i < _actors.size(); ++i) {
_actors[i]->pause(paused);
}
}
} // End of namespace Pink

View File

@@ -0,0 +1,72 @@
/* 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_PAGE_H
#define PINK_PAGE_H
#include "pink/resource_mgr.h"
#include "pink/objects/module.h"
namespace Pink {
class Archive;
class Actor;
class LeadActor;
class WalkMgr;
class Sequencer;
class Page : public NamedObject {
public:
~Page() override;
void toConsole() const override;
void load(Archive &archive) override;
void init();
void initPalette();
Actor *findActor(const Common::String &name);
LeadActor *getLeadActor() { return _leadActor; }
Common::SeekableReadStream *getResourceStream(const Common::String &fileName) { return _resMgr.getResourceStream(fileName); }
virtual void clear();
void pause(bool paused);
PinkEngine *getGame() { return _resMgr.getGame(); }
virtual Sequencer *getSequencer() { return nullptr; }
virtual WalkMgr *getWalkMgr() { return nullptr; }
virtual Module *getModule() { return nullptr; }
virtual const Module *getModule() const { return nullptr; }
virtual bool checkValueOfVariable(const Common::String &variable, const Common::String &value) const { return 0; }
virtual void setVariable(Common::String &variable, Common::String &value) {}
protected:
Array<Actor *> _actors;
ResourceMgr _resMgr;
LeadActor *_leadActor;
};
} // End of namespace Pink
#endif

View File

@@ -0,0 +1,35 @@
/* 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/pda_mgr.h"
#include "pink/objects/actors/actor.h"
#include "pink/objects/pages/pda_page.h"
#include "pink/pink.h"
namespace Pink {
PDAPage::PDAPage(const Common::String& name, PinkEngine *vm) {
_name = name;
_resMgr.init(vm, this);
init();
}
} // End of namespace Pink

View File

@@ -0,0 +1,38 @@
/* 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_PAGE_H
#define PINK_PDA_PAGE_H
#include "pink/objects/pages/page.h"
namespace Pink {
class PDAMgr;
class PDAPage : public Page {
public:
PDAPage(const Common::String& name, PinkEngine* vm);
};
} // End of namespace Pink
#endif