mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 00:42:24 +00:00
PINK: Started implementation of Director class . For now engine can play logo scene, but sprites are at wrong positions because decoder doesn't support getting coordinates from CEL
This commit is contained in:
parent
26f2ff6640
commit
bba35c5f2c
25
engines/pink/cel_decoder.cpp
Normal file
25
engines/pink/cel_decoder.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Pink {
|
||||
|
||||
}
|
38
engines/pink/cel_decoder.h
Normal file
38
engines/pink/cel_decoder.h
Normal 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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_CEL_DECODER_H
|
||||
#define PINK_CEL_DECODER_H
|
||||
|
||||
|
||||
#include <video/flic_decoder.h>
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class CelDecoder : public Video::FlicDecoder {
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -20,7 +20,44 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Pink {
|
||||
#include "director.h"
|
||||
#include <engines/pink/objects/actions/action_cel.h>
|
||||
#include "graphics/surface.h"
|
||||
#include "graphics/palette.h"
|
||||
|
||||
namespace Pink {
|
||||
Director::Director(OSystem *system)
|
||||
: _system(system) {}
|
||||
|
||||
void Director::draw() {
|
||||
bool needUpdate = 0;
|
||||
for (int i = 0; i < _sprites.size(); ++i) {
|
||||
Video::FlicDecoder *decoder = _sprites[i]->getDecoder();
|
||||
if (decoder->needsUpdate()) {
|
||||
const Graphics::Surface *surface = decoder->decodeNextFrame();
|
||||
_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
|
||||
needUpdate = 1;
|
||||
}
|
||||
}
|
||||
if (needUpdate)
|
||||
_system->updateScreen();
|
||||
}
|
||||
|
||||
void Director::addSprite(ActionCEL *sprite) {
|
||||
_sprites.push_back(sprite); //TODO impl sorting
|
||||
}
|
||||
|
||||
void Director::removeSprite(ActionCEL *sprite) {
|
||||
for (int i = 0; i < _sprites.size(); ++i) {
|
||||
if (sprite == _sprites[i]) {
|
||||
_sprites.remove_at(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Director::setPallette(const byte *pallete) {
|
||||
_system->getPaletteManager()->setPalette(pallete, 0, 256);
|
||||
}
|
||||
|
||||
}
|
@ -23,16 +23,28 @@
|
||||
#ifndef PINK_DIRECTOR_H
|
||||
#define PINK_DIRECTOR_H
|
||||
|
||||
#include <common/array.h>
|
||||
#include <common/system.h>
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionCEL;
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director(OSystem *system);
|
||||
//void addSoundObject();
|
||||
//void removeSound();
|
||||
//void updateSoundAction
|
||||
//CActor *getActorByCoords();
|
||||
private:
|
||||
//CActor *getActorByCoords()
|
||||
|
||||
void draw();
|
||||
void addSprite(ActionCEL *sprite);
|
||||
void removeSprite(ActionCEL *sprite);
|
||||
void setPallette(const byte *pallete);
|
||||
private:
|
||||
OSystem *_system;
|
||||
Common::Array<ActionCEL*> _sprites;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -36,6 +36,7 @@ MODULE_OBJS = \
|
||||
objects/pages/game_page.o \
|
||||
objects/sequences/seq_timer.o \
|
||||
objects/sequences/sequence.o \
|
||||
objects/sequences/sequence_context.o \
|
||||
objects/sequences/sequence_item.o \
|
||||
objects/sequences/sequencer.o \
|
||||
objects/walk/walk_mgr.o \
|
||||
|
@ -28,6 +28,7 @@
|
||||
namespace Pink {
|
||||
|
||||
class Actor;
|
||||
class Director;
|
||||
|
||||
class Action : public NamedObject {
|
||||
public:
|
||||
@ -37,6 +38,8 @@ public:
|
||||
virtual void update() {};
|
||||
virtual void toConsole() {};
|
||||
|
||||
virtual bool initPallete(Director *director) { return 0;}
|
||||
|
||||
protected:
|
||||
Actor *_actor;
|
||||
};
|
||||
|
@ -22,13 +22,49 @@
|
||||
|
||||
#include <common/debug.h>
|
||||
#include "action_cel.h"
|
||||
#include <pink/objects/actors/actor.h>
|
||||
#include "engines/pink/archive.h"
|
||||
#include "engines/pink/objects/pages/game_page.h"
|
||||
#include "pink/pink.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
ActionCEL::ActionCEL()
|
||||
: _flicDecoder(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
void ActionCEL::deserialize(Archive &archive) {
|
||||
Action::deserialize(archive);
|
||||
archive >> _fileName >> _z;
|
||||
}
|
||||
|
||||
void ActionCEL::start(bool unk) {
|
||||
if (!_flicDecoder)
|
||||
_flicDecoder = _actor->getPage()->loadCel(_fileName);
|
||||
_actor->getPage()->getGame()->getDirector()->addSprite(this);
|
||||
this->onStart();
|
||||
}
|
||||
|
||||
void ActionCEL::end() {
|
||||
_actor->getPage()->getGame()->getDirector()->removeSprite(this);
|
||||
delete _flicDecoder;
|
||||
_flicDecoder = nullptr;
|
||||
}
|
||||
|
||||
uint32 ActionCEL::getZ() {
|
||||
return _z;
|
||||
}
|
||||
|
||||
Video::FlicDecoder *ActionCEL::getDecoder() {
|
||||
return _flicDecoder;
|
||||
}
|
||||
|
||||
bool ActionCEL::initPallete(Director *director) {
|
||||
_flicDecoder = _actor->getPage()->loadCel(_fileName);
|
||||
_flicDecoder->decodeNextFrame();
|
||||
director->setPallette(_flicDecoder->getPalette());
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
@ -23,15 +23,26 @@
|
||||
#ifndef PINK_ACTION_CEL_H
|
||||
#define PINK_ACTION_CEL_H
|
||||
|
||||
#include <video/flic_decoder.h>
|
||||
#include "action.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class ActionCEL : public Action {
|
||||
public:
|
||||
ActionCEL();
|
||||
virtual void deserialize(Archive &archive);
|
||||
virtual void start(bool unk);
|
||||
virtual void end();
|
||||
|
||||
uint32 getZ();
|
||||
Video::FlicDecoder *getDecoder();
|
||||
|
||||
virtual bool initPallete(Director *director);
|
||||
|
||||
protected:
|
||||
virtual void onStart() {} ;
|
||||
Video::FlicDecoder *_flicDecoder;
|
||||
Common::String _fileName;
|
||||
uint32 _z;
|
||||
};
|
||||
|
@ -30,10 +30,9 @@ namespace Pink {
|
||||
class ActionHide : public Action {
|
||||
public:
|
||||
virtual void deserialize(Archive &archive);
|
||||
|
||||
virtual void toConsole();
|
||||
|
||||
virtual void start(bool unk_startNow);
|
||||
virtual void start(bool unk);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
|
@ -37,12 +37,17 @@ void ActionPlay::toConsole() {
|
||||
" _endFrame = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame);
|
||||
}
|
||||
|
||||
void ActionPlay::start(bool unk) {
|
||||
debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str());
|
||||
}
|
||||
|
||||
void ActionPlay::end() {
|
||||
ActionCEL::end();
|
||||
debug("ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
void ActionPlay::onStart() {
|
||||
debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str());
|
||||
_flicDecoder->seekToFrame(_startFrame);
|
||||
if (_stopFrame != -1)
|
||||
_flicDecoder->setEndFrame(_stopFrame);
|
||||
_flicDecoder->start();
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -33,10 +33,11 @@ public:
|
||||
virtual void deserialize(Archive &archive);
|
||||
virtual void toConsole();
|
||||
|
||||
virtual void start(bool unk);
|
||||
virtual void end();
|
||||
|
||||
protected:
|
||||
virtual void onStart();
|
||||
|
||||
uint32 _stopFrame;
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Pink {
|
||||
|
||||
class ActionSfx;
|
||||
|
||||
class ActionPlayWithSfx : ActionPlay {
|
||||
class ActionPlayWithSfx : public ActionPlay {
|
||||
virtual void deserialize(Archive &archive);
|
||||
virtual void toConsole();
|
||||
|
||||
@ -39,7 +39,7 @@ private:
|
||||
Common::Array<ActionSfx*> _sfxArray;
|
||||
};
|
||||
|
||||
class ActionSfx : Object {
|
||||
class ActionSfx : public Object {
|
||||
public:
|
||||
virtual void deserialize(Archive &archive);
|
||||
virtual void toConsole();
|
||||
|
@ -37,12 +37,14 @@ void ActionStill::toConsole() {
|
||||
_name.c_str(), _fileName.c_str(), _startFrame);
|
||||
}
|
||||
|
||||
void ActionStill::start(bool unk) {
|
||||
debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
|
||||
}
|
||||
|
||||
void ActionStill::end() {
|
||||
ActionCEL::end();
|
||||
debug("ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
|
||||
}
|
||||
|
||||
void ActionStill::onStart() {
|
||||
debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
|
||||
_flicDecoder->seekToFrame(_startFrame);
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
@ -32,11 +32,11 @@ public:
|
||||
virtual void deserialize(Archive &archive);
|
||||
virtual void toConsole();
|
||||
|
||||
virtual void start(bool unk);
|
||||
|
||||
virtual void end();
|
||||
|
||||
protected:
|
||||
virtual void onStart();
|
||||
|
||||
uint32 _startFrame;
|
||||
};
|
||||
|
||||
|
@ -61,10 +61,10 @@ void Actor::init(bool unk) {
|
||||
}
|
||||
|
||||
if (!_action) {
|
||||
_isActionEnd = 1;
|
||||
_isActionEnded = 1;
|
||||
}
|
||||
else {
|
||||
_isActionEnd = 0;
|
||||
_isActionEnded = 0;
|
||||
_action->start(unk);
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ void Actor::hide() {
|
||||
}
|
||||
|
||||
void Actor::endAction() {
|
||||
_isActionEnd = 1;
|
||||
_isActionEnded = 1;
|
||||
}
|
||||
|
||||
void Actor::setAction(const Common::String &name) {
|
||||
@ -84,11 +84,11 @@ void Actor::setAction(const Common::String &name) {
|
||||
|
||||
void Actor::setAction(Action *newAction) {
|
||||
if (_action) {
|
||||
_isActionEnd = 1;
|
||||
_isActionEnded = 1;
|
||||
_action->end();
|
||||
}
|
||||
if (newAction) {
|
||||
_isActionEnd = 0;
|
||||
_isActionEnded = 0;
|
||||
_action = newAction;
|
||||
_action->start(0);
|
||||
}
|
||||
@ -97,7 +97,7 @@ void Actor::setAction(Action *newAction) {
|
||||
void Actor::setAction(Action *newAction, bool unk) {
|
||||
if (unk){
|
||||
assert(0); // want to see this
|
||||
_isActionEnd = 1;
|
||||
_isActionEnded = 1;
|
||||
_action = newAction;
|
||||
}
|
||||
else setAction(newAction);
|
||||
@ -108,7 +108,14 @@ Action *Actor::getAction() const {
|
||||
}
|
||||
|
||||
bool Actor::isPlaying() {
|
||||
return _isActionEnd;
|
||||
return _isActionEnded;
|
||||
}
|
||||
|
||||
bool Actor::initPallete(Director *director) {
|
||||
for (int i = 0; i < _actions.size(); ++i) {
|
||||
if (_actions[i]->initPallete(director))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -31,12 +31,13 @@ namespace Pink {
|
||||
class GamePage;
|
||||
class Action;
|
||||
class Sequencer;
|
||||
class Director;
|
||||
|
||||
class Actor : public NamedObject {
|
||||
public:
|
||||
Actor()
|
||||
: _page(nullptr), _action(nullptr),
|
||||
_isActionEnd(1)
|
||||
_isActionEnded(1)
|
||||
{};
|
||||
virtual void deserialize(Archive &archive);
|
||||
|
||||
@ -46,7 +47,6 @@ public:
|
||||
GamePage *getPage() const;
|
||||
Action *getAction() const;
|
||||
|
||||
|
||||
bool isPlaying();
|
||||
virtual void init(bool unk);
|
||||
void hide();
|
||||
@ -57,11 +57,13 @@ public:
|
||||
void setAction(Action *newAction);
|
||||
void setAction(Action *newAction, bool unk);
|
||||
|
||||
bool initPallete(Director *director);
|
||||
|
||||
protected:
|
||||
GamePage *_page;
|
||||
Action *_action;
|
||||
Common::Array<Action*> _actions;
|
||||
bool _isActionEnd;
|
||||
bool _isActionEnded;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
|
||||
State getState() const;
|
||||
|
||||
void start(bool isHandler);
|
||||
|
||||
private:
|
||||
State _state;
|
||||
CursorMgr *_cursorMgr;
|
||||
|
@ -72,7 +72,7 @@ void HandlerTimerActions::onMessage(LeadActor *actor) {
|
||||
}
|
||||
|
||||
|
||||
void HandlerTimerSequences::handle(LeadActor *actor) {
|
||||
void HandlerTimerSequences::handle(Sequence *sequence) {
|
||||
debug("HandlerTimerSequences function is not implemented");
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,8 @@ private:
|
||||
class HandlerTimerSequences : public HandlerSequences { //originally it was inherited from HandlerTimer
|
||||
public:
|
||||
virtual void toConsole();
|
||||
private:
|
||||
virtual void handle(LeadActor *actor); // very big and hard function
|
||||
protected:
|
||||
virtual void handle(Sequence *sequence); // very big and hard function
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "engines/pink/cursor_mgr.h"
|
||||
#include "engines/pink/objects/actors/lead_actor.h"
|
||||
#include "engines/pink/objects/sequences/sequencer.h"
|
||||
|
||||
#include "pink/pink.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
@ -59,7 +59,18 @@ void GamePage::init(bool isLoadingSave) {
|
||||
|
||||
toConsole();
|
||||
|
||||
Page::init();
|
||||
for (int j = 0; j < _actors.size(); ++j) {
|
||||
if (_actors[j]->initPallete(_module->getGame()->getDirector()))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
LeadActor::State state = _leadActor->getState();
|
||||
bool unk = (state == LeadActor::kInventory || state == LeadActor::kPDA);
|
||||
|
||||
for (int i = 0; i < _actors.size(); ++i) {
|
||||
_actors[i]->init(unk);
|
||||
}
|
||||
|
||||
if (!isLoadingSave)
|
||||
initHandler();
|
||||
|
@ -44,6 +44,12 @@ Sound *Page::loadSound(Common::String &fileName) {
|
||||
return _resMgr.loadSound(fileName);
|
||||
}
|
||||
|
||||
|
||||
Video::FlicDecoder *Page::loadCel(Common::String &fileName) {
|
||||
return _resMgr.loadCEL(fileName);
|
||||
}
|
||||
|
||||
|
||||
void Page::toConsole() {
|
||||
for (int i = 0; i < _actors.size(); ++i) {
|
||||
_actors[i]->toConsole();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#ifndef PINK_PAGE_H
|
||||
#define PINK_PAGE_H
|
||||
|
||||
#include <video/flic_decoder.h>
|
||||
#include "engines/pink/objects/object.h"
|
||||
#include "engines/pink/objects/module.h"
|
||||
#include "engines/pink/resource_mgr.h"
|
||||
@ -39,6 +40,7 @@ public:
|
||||
void load(Archive &archive);
|
||||
Actor *findActor(Common::String &name);
|
||||
Sound* loadSound(Common::String &fileName);
|
||||
Video::FlicDecoder *loadCel(Common::String &fileName);
|
||||
|
||||
virtual void toConsole();
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "engines/pink/archive.h"
|
||||
#include "engines/pink/objects/pages/game_page.h"
|
||||
#include "engines/pink/objects/actors/actor.h"
|
||||
#include "sequence_context.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
@ -77,7 +78,7 @@ void Sequence::start(int unk) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_items[_context->_nextItemIndex]->execute(_context->_unk, this, unk)){
|
||||
if (!_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){
|
||||
//destroy context;
|
||||
}
|
||||
|
||||
@ -85,26 +86,16 @@ void Sequence::start(int unk) {
|
||||
for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){
|
||||
if (_items[i]->isLeader())
|
||||
break;
|
||||
_items[i]->execute(_context->_unk, this, unk);
|
||||
_items[i]->execute(_context->_index, this, unk);
|
||||
}
|
||||
_context->_nextItemIndex = i;
|
||||
|
||||
|
||||
Common::Array<SequenceActorState> &states = _context->_states;
|
||||
for (uint j = 0; j < states.size(); ++j) {
|
||||
if (states[j]._unk != _context->_unk &&
|
||||
!states[j]._actionName.empty()) {
|
||||
Actor *actor;
|
||||
Action *action;
|
||||
actor = _sequencer->_page->findActor(states[j]._actorName);
|
||||
assert(actor);
|
||||
action = actor->findAction(states[j]._actionName);
|
||||
assert(action);
|
||||
if (actor->getAction() != action)
|
||||
actor->setAction(action, unk);
|
||||
}
|
||||
states[j].check(_context->_index, this, unk);
|
||||
}
|
||||
_context->_unk++;
|
||||
_context->_index++;
|
||||
}
|
||||
|
||||
void SequenceAudio::deserialize(Archive &archive) {
|
||||
@ -120,41 +111,4 @@ void SequenceAudio::toConsole() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer)
|
||||
: _sequence(sequence), _sequencer(sequencer),
|
||||
_nextItemIndex(0), _unk(1), _actor(nullptr)
|
||||
{
|
||||
sequence->setContext(this);
|
||||
Common::Array<SequenceItem*> &items = sequence->getItems();
|
||||
debug("SequenceContext for %s", _sequence->getName().c_str());
|
||||
|
||||
for (uint i = 0; i < items.size(); ++i) {
|
||||
bool found = 0;
|
||||
for (uint j = 0; j < _states.size(); ++j) {
|
||||
if (items[i]->getActor() == _states[j].getActor()){
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
debug(items[i]->getActor().c_str());
|
||||
_states.push_back({items[i]->getActor()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SequenceContext::~SequenceContext() {
|
||||
|
||||
}
|
||||
|
||||
SequenceActorState::SequenceActorState(const Common::String &name)
|
||||
:_actorName(name), _unk(0)
|
||||
{}
|
||||
|
||||
const Common::String &SequenceActorState::getActor() const {
|
||||
return _actorName;
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
@ -46,6 +46,7 @@ public:
|
||||
void init(int unk);
|
||||
void start(int unk);
|
||||
|
||||
|
||||
public:
|
||||
SequenceContext *_context;
|
||||
Sequencer *_sequencer;
|
||||
@ -65,34 +66,6 @@ private:
|
||||
int _unk2;
|
||||
};
|
||||
|
||||
class SequenceActorState {
|
||||
public:
|
||||
SequenceActorState(const Common::String &name);
|
||||
|
||||
const Common::String &getActor() const;
|
||||
|
||||
public:
|
||||
Common::String _actorName;
|
||||
Common::String _actionName;
|
||||
int _unk;
|
||||
};
|
||||
|
||||
class Actor;
|
||||
|
||||
class SequenceContext {
|
||||
public:
|
||||
SequenceContext(Sequence *sequence, Sequencer* sequencer);
|
||||
~SequenceContext();
|
||||
|
||||
public:
|
||||
Sequence *_sequence;
|
||||
Sequencer *_sequencer;
|
||||
int _nextItemIndex;
|
||||
Actor *_actor;
|
||||
Common::Array<SequenceActorState> _states;
|
||||
int _unk;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
||||
#endif
|
||||
|
74
engines/pink/objects/sequences/sequence_context.cpp
Normal file
74
engines/pink/objects/sequences/sequence_context.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/* 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 <common/debug.h>
|
||||
#include "sequence_context.h"
|
||||
#include "sequence.h"
|
||||
#include "sequence_item.h"
|
||||
#include "sequencer.h"
|
||||
#include "engines/pink/objects/pages/game_page.h"
|
||||
#include "engines/pink/objects/actors/actor.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
SequenceActorState::SequenceActorState(const Common::String &name)
|
||||
:_actorName(name), _index(0)
|
||||
{}
|
||||
|
||||
const Common::String &SequenceActorState::getActor() const {
|
||||
return _actorName;
|
||||
}
|
||||
|
||||
void SequenceActorState::check(int index, Sequence *sequence, bool unk) {
|
||||
Actor *actor = sequence->_sequencer->_page->findActor(_actorName);
|
||||
debug("%s %s", _actorName.c_str(), _actionName.c_str());
|
||||
if (_index != index && !_actionName.empty()){
|
||||
Action *action = actor->findAction(_actionName);
|
||||
if (actor->getAction() != action)
|
||||
actor->setAction(action, unk);
|
||||
}
|
||||
}
|
||||
|
||||
SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer)
|
||||
: _sequence(sequence), _sequencer(sequencer),
|
||||
_nextItemIndex(0), _index(1), _actor(nullptr)
|
||||
{
|
||||
sequence->setContext(this);
|
||||
Common::Array<SequenceItem*> &items = sequence->getItems();
|
||||
debug("SequenceContext for %s", _sequence->getName().c_str());
|
||||
|
||||
for (uint i = 0; i < items.size(); ++i) {
|
||||
bool found = 0;
|
||||
for (uint j = 0; j < _states.size(); ++j) {
|
||||
if (items[i]->getActor() == _states[j].getActor()){
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
debug(items[i]->getActor().c_str());
|
||||
_states.push_back({items[i]->getActor()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
64
engines/pink/objects/sequences/sequence_context.h
Normal file
64
engines/pink/objects/sequences/sequence_context.h
Normal 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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PINK_SEQUENCE_CONTEXT_H
|
||||
#define PINK_SEQUENCE_CONTEXT_H
|
||||
|
||||
#include <common/array.h>
|
||||
|
||||
namespace Pink {
|
||||
|
||||
class Sequence;
|
||||
class Sequencer;
|
||||
|
||||
class SequenceActorState {
|
||||
public:
|
||||
SequenceActorState(const Common::String &name);
|
||||
|
||||
const Common::String &getActor() const;
|
||||
void check(int index, Sequence *sequence, bool unk);
|
||||
|
||||
public:
|
||||
Common::String _actorName;
|
||||
Common::String _actionName;
|
||||
int _index;
|
||||
};
|
||||
|
||||
class Actor;
|
||||
|
||||
class SequenceContext {
|
||||
public:
|
||||
SequenceContext(Sequence *sequence, Sequencer* sequencer);
|
||||
|
||||
|
||||
public:
|
||||
Sequence *_sequence;
|
||||
Sequencer *_sequencer;
|
||||
int _nextItemIndex;
|
||||
Actor *_actor;
|
||||
Common::Array<SequenceActorState> _states;
|
||||
int _index;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -28,6 +28,7 @@
|
||||
#include "engines/pink/archive.h"
|
||||
#include "engines/pink/objects/pages/game_page.h"
|
||||
#include "engines/pink/objects/actors/actor.h"
|
||||
#include "sequence_context.h"
|
||||
|
||||
namespace Pink {
|
||||
|
||||
@ -47,7 +48,7 @@ const Common::String &SequenceItem::getAction() const {
|
||||
return _action;
|
||||
}
|
||||
|
||||
bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) {
|
||||
bool SequenceItem::execute(int index, Sequence *sequence, bool unk2) {
|
||||
Actor *actor;
|
||||
Action *action;
|
||||
if (!(actor = sequence->_sequencer->_page->findActor(_actor)) ||
|
||||
@ -60,7 +61,7 @@ bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) {
|
||||
Common::Array<SequenceActorState> &states = sequence->_context->_states;
|
||||
for (int i = 0; i < sequence->_context->_states.size(); ++i) {
|
||||
if (states[i]._actorName == _actor){
|
||||
states[i]._unk = unk;
|
||||
states[i]._index = index;
|
||||
sequence->_context->_actor = isLeader() ? actor : sequence->_context->_actor;
|
||||
break;
|
||||
}
|
||||
@ -91,7 +92,7 @@ void SequenceItemLeaderAudio::toConsole() {
|
||||
debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s", _actor.c_str(), _action.c_str());
|
||||
}
|
||||
|
||||
bool SequenceItemDefaultAction::execute(int unk, Sequence *sequence, bool unk2) {
|
||||
bool SequenceItemDefaultAction::execute(int index, Sequence *sequence, bool unk2) {
|
||||
Common::Array<SequenceActorState> &actorStates = sequence->_context->_states;
|
||||
for (int i = 0; i < actorStates.size(); ++i) {
|
||||
if (actorStates[i]._actorName == _actor){
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
const Common::String &getActor() const;
|
||||
const Common::String &getAction() const;
|
||||
|
||||
virtual bool execute(int unk, Sequence *sequence, bool unk2);
|
||||
virtual bool execute(int index, Sequence *sequence, bool unk2);
|
||||
virtual bool isLeader();
|
||||
|
||||
protected:
|
||||
@ -64,7 +64,7 @@ private:
|
||||
|
||||
class SequenceItemDefaultAction : public SequenceItem {
|
||||
public:
|
||||
virtual bool execute(int unk, Sequence *sequence, bool unk2);
|
||||
virtual bool execute(int index, Sequence *sequence, bool unk2);
|
||||
|
||||
virtual void toConsole();
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <common/debug.h>
|
||||
#include "sequencer.h"
|
||||
#include "sequence.h"
|
||||
#include "sequence_context.h"
|
||||
#include "engines/pink/archive.h"
|
||||
|
||||
namespace Pink {
|
||||
|
@ -32,7 +32,7 @@ namespace Pink {
|
||||
|
||||
Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc)
|
||||
: Engine(system), _console(nullptr), _rnd("pink"),
|
||||
_desc(*desc), _bro(nullptr), _module(nullptr)
|
||||
_desc(*desc), _bro(nullptr), _module(nullptr), _director(_system)
|
||||
{
|
||||
debug("PinkEngine constructed");
|
||||
|
||||
@ -87,13 +87,8 @@ Common::Error Pink::PinkEngine::run() {
|
||||
return error;
|
||||
}
|
||||
|
||||
Video::FlicDecoder flicDecoder;
|
||||
Common::File anim;
|
||||
anim.open("WANDRBOY.CEL");
|
||||
flicDecoder.loadStream(&anim);
|
||||
flicDecoder.start();
|
||||
_system->updateScreen();
|
||||
const Graphics::Surface *surface = flicDecoder.decodeNextFrame();
|
||||
|
||||
int i = 0;
|
||||
while(!shouldQuit()){
|
||||
Common::Event event;
|
||||
while(_eventMan->pollEvent(event)){
|
||||
@ -118,12 +113,8 @@ Common::Error Pink::PinkEngine::run() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//update();
|
||||
surface = flicDecoder.needsUpdate() ? flicDecoder.decodeNextFrame() : surface;
|
||||
if (surface) {
|
||||
_system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h);
|
||||
_system->updateScreen();
|
||||
}
|
||||
|
||||
_director.draw();
|
||||
_system->delayMillis(10);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "gui/EventRecorder.h"
|
||||
#include "gui/debugger.h"
|
||||
#include "file.h"
|
||||
#include "director.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -76,6 +77,7 @@ public:
|
||||
OrbFile *getOrb() { return &_orb; }
|
||||
BroFile *getBro() { return _bro; }
|
||||
Common::RandomSource &getRnd();
|
||||
Director *getDirector() { return &_director;}
|
||||
|
||||
bool checkValueOfVariable(Common::String &variable, Common::String &value);
|
||||
void setVariable(Common::String &variable, Common::String &value);
|
||||
@ -93,6 +95,8 @@ private:
|
||||
OrbFile _orb;
|
||||
BroFile *_bro;
|
||||
|
||||
Director _director;
|
||||
|
||||
Module *_module;
|
||||
Common::Array<NamedObject*> _modules;
|
||||
|
||||
|
@ -53,7 +53,7 @@ Sound *ResourceMgr::loadSound(Common::String &name) {
|
||||
return new Sound(_game->_mixer, getResourceStream(name));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name) {
|
||||
Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(Common::String &name) {
|
||||
Common::SeekableReadStream *stream;
|
||||
uint i;
|
||||
for (i = 0; i < _resCount; ++i) {
|
||||
@ -69,7 +69,7 @@ Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name)
|
||||
|
||||
stream->seek(_resDescTable[i].offset);
|
||||
|
||||
return new Common::SeekableSubReadStream(stream, _resDescTable[i].offset,
|
||||
return new Common::SafeSeekableSubReadStream(stream, _resDescTable[i].offset,
|
||||
_resDescTable[i].offset + _resDescTable[i].size);
|
||||
}
|
||||
|
||||
@ -77,4 +77,10 @@ PinkEngine *ResourceMgr::getGame() const {
|
||||
return _game;
|
||||
}
|
||||
|
||||
Video::FlicDecoder *ResourceMgr::loadCEL(Common::String &name) {
|
||||
Video::FlicDecoder *decoder = new Video::FlicDecoder();
|
||||
decoder->loadStream(getResourceStream(name));
|
||||
return decoder;
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <common/scummsys.h>
|
||||
#include <common/stream.h>
|
||||
#include <common/substream.h>
|
||||
|
||||
#ifndef PINK_RESOURCE_MGR_H
|
||||
#define PINK_RESOURCE_MGR_H
|
||||
@ -46,15 +46,14 @@ public:
|
||||
~ResourceMgr();
|
||||
|
||||
void init(PinkEngine *game, GamePage *page);
|
||||
//move methods to page
|
||||
//compiler must do RVO
|
||||
|
||||
//Common::String loadText(Common::String &name);
|
||||
Sound *loadSound(Common::String &name);
|
||||
// loadCEL();
|
||||
Video::FlicDecoder *loadCEL(Common::String &name);
|
||||
PinkEngine *getGame() const;
|
||||
|
||||
private:
|
||||
Common::SeekableReadStream *getResourceStream(Common::String &name);
|
||||
Common::SafeSeekableSubReadStream *getResourceStream(Common::String &name);
|
||||
|
||||
PinkEngine *_game;
|
||||
ResourceDescription *_resDescTable;
|
||||
|
Loading…
x
Reference in New Issue
Block a user