DIRECTOR: Load Shared Cast from movie directory

This commit is contained in:
Eugene Sandulenko 2020-01-01 14:50:53 +01:00
parent f263ed4bb6
commit 693149ee56
5 changed files with 39 additions and 1 deletions

View File

@ -35,6 +35,7 @@
#include "director/score.h"
#include "director/sound.h"
#include "director/lingo/lingo.h"
#include "director/util.h"
namespace Director {
@ -153,6 +154,7 @@ Common::Error DirectorEngine::run() {
//_mainArchive->openFile("bookshelf_example.mmm");
_currentScore = new Score(this);
_currentPath = getPath(getEXEName());
if (getVersion() < 4) {
if (getPlatform() == Common::kPlatformWindows) {
@ -168,7 +170,7 @@ Common::Error DirectorEngine::run() {
_sharedCastFile = "Shared.dir";
}
loadSharedCastsFrom(_sharedCastFile);
loadSharedCastsFrom(_currentPath + _sharedCastFile);
debug(0, "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\nObtaining score name\n");
loadInitialMovie(getEXEName());
@ -208,6 +210,10 @@ Common::Error DirectorEngine::run() {
delete _currentScore;
_currentPath = getPath(_nextMovie.movie);
loadSharedCastsFrom(_currentPath + _sharedCastFile);
Archive *mov = openMainArchive(_nextMovie.movie);
if (!mov) {

View File

@ -105,6 +105,7 @@ public:
const byte *getPalette() const { return _currentPalette; }
uint16 getPaletteColorCount() const { return _currentPaletteLength; }
void loadSharedCastsFrom(Common::String filename);
void clearSharedCast();
void loadPatterns();
Graphics::MacPatterns &getPatterns();
@ -165,6 +166,7 @@ private:
Lingo *_lingo;
Score *_currentScore;
Common::String _currentPath;
Graphics::MacPatterns _director3Patterns;
Graphics::MacPatterns _director3QuickDrawPatterns;

View File

@ -248,7 +248,26 @@ void DirectorEngine::loadMac(const Common::String movie) {
}
}
void DirectorEngine::clearSharedCast() {
if (!_sharedScore)
return;
delete _sharedScore;
delete _sharedDIB;
delete _sharedSTXT;
delete _sharedSound;
delete _sharedBMP;
}
void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
if (_sharedScore) {
if (_sharedScore->_movieArchive->getFileName().equalsIgnoreCase(filename))
return;
}
clearSharedCast();
Archive *shardcst = createArchive();
debug(0, "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

View File

@ -142,4 +142,13 @@ Common::String convertPath(Common::String &path) {
return res;
}
Common::String getPath(Common::String path) {
const char *s;
if ((s = strrchr(path.c_str(), '/'))) {
return Common::String(path.c_str(), s + 1);
}
return "";
}
} // End of namespace Director

View File

@ -36,6 +36,8 @@ Common::String *toLowercaseMac(Common::String *s);
Common::String convertPath(Common::String &path);
Common::String getPath(Common::String path);
void processQuitEvent(); // events.cpp
} // End of namespace Director