Skip to content

Commit

Permalink
DIRECTOR: Support goto command in Score
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent 9524980 commit cc9d17c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion engines/director/director.cpp
Expand Up @@ -56,7 +56,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
_mainArchive = 0;
_macBinary = 0;
_currentPalette = 0;

_movies = new Common::HashMap<Common::String, Score *>();
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
SearchMan.addSubDirectoryMatching(gameDataDir, "install");
Expand Down
3 changes: 2 additions & 1 deletion engines/director/director.h
Expand Up @@ -66,6 +66,8 @@ class DirectorEngine : public ::Engine {
bool hasFeature(EngineFeature f) const;
const byte *getPalette() const { return _currentPalette; }
uint16 getPaletteColorCount() const { return _currentPaletteLength; }
Common::HashMap<Common::String, Score *> *_movies;
Score *_currentScore;

protected:
virtual Common::Error run();
Expand All @@ -90,7 +92,6 @@ class DirectorEngine : public ::Engine {
byte *_currentPalette;
uint16 _currentPaletteLength;
Lingo *_lingo;
Score *_currentScore;
};

} // End of namespace Director
Expand Down
8 changes: 8 additions & 0 deletions engines/director/lingo/lingo-funcs.cpp
Expand Up @@ -191,6 +191,14 @@ void Lingo::func_mciwait(Common::String &s) {

void Lingo::func_goto(Common::String &frame, Common::String &movie) {
warning("STUB: go to %s movie %s", frame.c_str(), movie.c_str());
if (!_vm->_movies->contains(movie))
error("Movie %s does not exist", movie.c_str());

_vm->_currentScore = _vm->_movies->getVal(movie);
_vm->_currentScore->loadArchive();

if (frame.c_str() != "")
_vm->_currentScore->setStartToLabel(frame);
}

}
15 changes: 14 additions & 1 deletion engines/director/score.cpp
Expand Up @@ -338,6 +338,19 @@ void Score::loadScriptText(Common::SeekableReadStream &stream) {
_movieScriptCount++;
}

void Score::setStartToLabel(Common::String label) {
Common::HashMap<uint16, Common::String>::iterator i;

for (i = _labels.begin(); i != _labels.end(); ++i) {
if (i->_value == label) {
_currentFrame = i->_key;
return;
}
}

warning("Label %s not found", label.c_str());
}

void Score::dumpScript(uint16 id, ScriptType type, Common::String script) {
Common::DumpFile out;
Common::String typeName;
Expand Down Expand Up @@ -556,7 +569,7 @@ void Score::startLoop() {
_trailSurface->create(_movieRect.width(), _movieRect.height());

if (_stageColor == 0)
_trailSurface->clear(15);
_trailSurface->clear(_vm->getPaletteColorCount() - 1);
else
_trailSurface->clear(_stageColor);

Expand Down
1 change: 1 addition & 0 deletions engines/director/score.h
Expand Up @@ -333,6 +333,7 @@ class Score {

static Common::Rect readRect(Common::SeekableReadStream &stream);
void loadArchive();
void setStartToLabel(Common::String label);
void startLoop();
void processEvents();

Expand Down

0 comments on commit cc9d17c

Please sign in to comment.