diff options
author | Le Philousophe | 2019-03-13 08:27:02 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-06-01 22:43:48 +0200 |
commit | c83f86a245dae1ae13c2cc170aa4374cae01230b (patch) | |
tree | f46cfc579ca374f534579f537b96d9c2f5396035 | |
parent | 3a12d53ffc72fd99cdfbb9627bb699236d32f235 (diff) | |
download | scummvm-rg350-c83f86a245dae1ae13c2cc170aa4374cae01230b.tar.gz scummvm-rg350-c83f86a245dae1ae13c2cc170aa4374cae01230b.tar.bz2 scummvm-rg350-c83f86a245dae1ae13c2cc170aa4374cae01230b.zip |
CRYOMNI3D: Fix file names for Macintosh version
Add a function to unify extensions handling.
That lets us substitute dashes by underscore on PC versions of
Versailles and fix dashes for Macintosh.
-rw-r--r-- | engines/cryomni3d/cryomni3d.cpp | 52 | ||||
-rw-r--r-- | engines/cryomni3d/cryomni3d.h | 7 | ||||
-rw-r--r-- | engines/cryomni3d/fixed_image.cpp | 13 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/dialogs_manager.cpp | 20 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/documentation.cpp | 2 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/engine.cpp | 14 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/engine.h | 7 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/logic.cpp | 8 | ||||
-rw-r--r-- | engines/cryomni3d/versailles/music.cpp | 3 |
9 files changed, 68 insertions, 58 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp index e663e5d995..d1968d0fa0 100644 --- a/engines/cryomni3d/cryomni3d.cpp +++ b/engines/cryomni3d/cryomni3d.cpp @@ -80,11 +80,9 @@ void CryOmni3DEngine::pauseEngineIntern(bool pause) { */ } -void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::SoundType soundType) { - Common::String fname(filename); - - Video::VideoDecoder *videoDecoder = new Video::HNMDecoder(); - videoDecoder->setSoundType(soundType); +Common::String CryOmni3DEngine::prepareFileName(const Common::String &baseName, + const char *const *extensions) const { + Common::String fname(baseName); int lastDotPos = fname.size() - 1; for (; lastDotPos >= 0; --lastDotPos) { @@ -92,17 +90,36 @@ void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::Soun break; } } + + int extBegin; if (lastDotPos > -1) { - fname.erase(lastDotPos); + extBegin = lastDotPos + 1; + fname.erase(extBegin); } else { - lastDotPos = fname.size(); + fname += "."; + extBegin = fname.size(); } - fname += ".hnm"; - if (!Common::File::exists(fname)) { - fname.erase(lastDotPos); - fname += ".hns"; + while (*extensions != nullptr) { + fname += *extensions; + debug("Trying file %s", fname.c_str()); + if (Common::File::exists(fname)) { + return fname; + } + fname.erase(extBegin); + extensions++; } + fname.deleteLastChar(); + warning("Failed to find file %s/%s", baseName.c_str(), fname.c_str()); + return baseName; +} + +void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::SoundType soundType) { + const char *const extensions[] = { "hns", "hnm", nullptr }; + Common::String fname(prepareFileName(filename, extensions)); + + Video::VideoDecoder *videoDecoder = new Video::HNMDecoder(); + videoDecoder->setSoundType(soundType); if (!videoDecoder->loadFile(fname)) { warning("Failed to open movie file %s/%s", filename.c_str(), fname.c_str()); @@ -143,23 +160,12 @@ void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::Soun } Image::ImageDecoder *CryOmni3DEngine::loadHLZ(const Common::String &filename) { - Common::String fname(filename); + Common::String fname(prepareFileName(filename, "hlz")); Image::ImageDecoder *imageDecoder = new Image::HLZFileDecoder(); Common::File file; - int lastDotPos = fname.size() - 1; - for (; lastDotPos >= 0; --lastDotPos) { - if (fname[lastDotPos] == '.') { - break; - } - } - if (lastDotPos > -1) { - fname.erase(lastDotPos); - } - fname += ".hlz"; - if (!file.open(fname)) { warning("Failed to open hlz file %s/%s", filename.c_str(), fname.c_str()); return nullptr; diff --git a/engines/cryomni3d/cryomni3d.h b/engines/cryomni3d/cryomni3d.h index 9d2c4e98e7..c06df5b69f 100644 --- a/engines/cryomni3d/cryomni3d.h +++ b/engines/cryomni3d/cryomni3d.h @@ -124,6 +124,13 @@ public: void setAutoRepeatClick(unsigned int millis); DragStatus getDragStatus() { return _dragStatus; } + Common::String prepareFileName(const Common::String &baseName, const char *extension) const { + const char *const extensions[] = { extension, nullptr }; + return prepareFileName(baseName, extensions); + } + virtual Common::String prepareFileName(const Common::String &baseName, + const char *const *extensions) const; + virtual bool displayToolbar(const Graphics::Surface *original) = 0; virtual bool hasPlaceDocumentation() = 0; virtual bool displayPlaceDocumentation() = 0; diff --git a/engines/cryomni3d/fixed_image.cpp b/engines/cryomni3d/fixed_image.cpp index 4522f2af5f..0fb951342f 100644 --- a/engines/cryomni3d/fixed_image.cpp +++ b/engines/cryomni3d/fixed_image.cpp @@ -109,18 +109,7 @@ void ZonFixedImage::display() const { void ZonFixedImage::loadZones(const Common::String &image) { _zones.clear(); - Common::String fname(image); - - int lastDotPos = fname.size() - 1; - for (; lastDotPos >= 0; --lastDotPos) { - if (fname[lastDotPos] == '.') { - break; - } - } - if (lastDotPos > -1) { - fname.erase(lastDotPos); - } - fname += ".zon"; + Common::String fname(_engine.prepareFileName(image, "zon")); Common::File zonFile; if (!zonFile.open(fname)) { diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp index 59bcedd093..3ebc4cf0c0 100644 --- a/engines/cryomni3d/versailles/dialogs_manager.cpp +++ b/engines/cryomni3d/versailles/dialogs_manager.cpp @@ -88,16 +88,14 @@ void Versailles_DialogsManager::executeShow(const Common::String &show) { void Versailles_DialogsManager::playDialog(const Common::String &video, const Common::String &sound, const Common::String &text, const SubtitlesSettings &settings) { - Common::String videoFName(video); - Common::String soundFName(sound); - - videoFName += ".hnm"; // Don't look for HNS file here + Common::String videoFName(_engine->prepareFileName(video, "hnm")); + Common::String soundFName(sound); while (soundFName.size() < 8) { soundFName += '_'; } - soundFName += ".wav"; + soundFName = _engine->prepareFileName(soundFName, "wav"); Video::HNMDecoder *videoDecoder = new Video::HNMDecoder(true); @@ -344,17 +342,7 @@ unsigned int Versailles_DialogsManager::askPlayerQuestions(const Common::String } void Versailles_DialogsManager::loadFrame(const Common::String &video) { - Common::String videoFName(video); - int lastDotPos = videoFName.size() - 1; - for (; lastDotPos >= 0; --lastDotPos) { - if (videoFName[lastDotPos] == '.') { - break; - } - } - if (lastDotPos > -1) { - videoFName.erase(lastDotPos); - } - videoFName += ".hnm"; + Common::String videoFName(_engine->prepareFileName(video, "hnm")); Video::HNMDecoder *videoDecoder = new Video::HNMDecoder(); diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp index bbc924290c..79c6001ca7 100644 --- a/engines/cryomni3d/versailles/documentation.cpp +++ b/engines/cryomni3d/versailles/documentation.cpp @@ -1442,7 +1442,7 @@ void Versailles_Documentation::drawRecordData(Graphics::ManagedSurface &surface, } else { background = _currentRecord; } - background += ".HLZ"; + background = _engine->prepareFileName(background, "hlz"); Common::File backgroundFl; if (!backgroundFl.open(background)) { background = displayMap ? "pas_fonP.hlz" : "pas_fond.hlz"; diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp index 398bf3c02b..3baaf81458 100644 --- a/engines/cryomni3d/versailles/engine.cpp +++ b/engines/cryomni3d/versailles/engine.cpp @@ -221,6 +221,20 @@ Common::Error CryOmni3DEngine_Versailles::run() { return Common::kNoError; } +Common::String CryOmni3DEngine_Versailles::prepareFileName(const Common::String &baseName, + const char *const *extensions) const { + Common::String baseName_(baseName); + if (getPlatform() != Common::kPlatformMacintosh) { + // Replace dashes by underscores for PC versions + char *p = baseName_.begin(); + while ((p = strchr(p, '-')) != nullptr) { + *p = '_'; + p++; + } + } + return CryOmni3DEngine::prepareFileName(baseName_, extensions); +} + void CryOmni3DEngine_Versailles::setupFonts() { Common::Array<Common::String> fonts; diff --git a/engines/cryomni3d/versailles/engine.h b/engines/cryomni3d/versailles/engine.h index 74d8c9640c..cb677cd94c 100644 --- a/engines/cryomni3d/versailles/engine.h +++ b/engines/cryomni3d/versailles/engine.h @@ -218,6 +218,13 @@ public: CryOmni3DEngine_Versailles(OSystem *syst, const CryOmni3DGameDescription *gamedesc); virtual ~CryOmni3DEngine_Versailles(); + Common::String prepareFileName(const Common::String &baseName, const char *extension) const { + const char *const extensions[] = { extension, nullptr }; + return prepareFileName(baseName, extensions); + } + virtual Common::String prepareFileName(const Common::String &baseName, + const char *const *extensions) const override; + void setupPalette(const byte *colors, uint start, uint num) override { setupPalette(colors, start, num, true); } void makeTranslucent(Graphics::Surface &dst, const Graphics::Surface &src) const override; diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp index e87bc60102..e824031539 100644 --- a/engines/cryomni3d/versailles/logic.cpp +++ b/engines/cryomni3d/versailles/logic.cpp @@ -1000,7 +1000,7 @@ IMG_CB(41802) { setGameTime(3, 1); } else if (objID == 96) { // Pamphlet about arts - playInGameVideo("PAP_BRUL"); + playInGameVideo("PAP-BRUL"); // Force reload of the place if (_nextPlaceId == -1u) { _nextPlaceId = _currentPlaceId; @@ -1047,7 +1047,7 @@ IMG_CB(41802b) { setGameTime(3, 1); } else if (objID == 96) { // Pamphlet about arts - playInGameVideo("PAP_BRUL"); + playInGameVideo("PAP-BRUL"); // Force reload of the place if (_nextPlaceId == -1u) { _nextPlaceId = _currentPlaceId; @@ -1092,7 +1092,7 @@ IMG_CB(41802c) { setGameTime(3, 1); } else if (objID == 96) { // Pamphlet about arts - playInGameVideo("PAP_BRUL"); + playInGameVideo("PAP-BRUL"); // Force reload of the place if (_nextPlaceId == -1u) { _nextPlaceId = _currentPlaceId; @@ -1127,7 +1127,7 @@ IMG_CB(41802d) { setGameTime(3, 1); } else if (objID == 96) { // Pamphlet about arts - playInGameVideo("PAP_BRUL"); + playInGameVideo("PAP-BRUL"); // Force reload of the place if (_nextPlaceId == -1u) { _nextPlaceId = _currentPlaceId; diff --git a/engines/cryomni3d/versailles/music.cpp b/engines/cryomni3d/versailles/music.cpp index 524c5244a4..a19e82a538 100644 --- a/engines/cryomni3d/versailles/music.cpp +++ b/engines/cryomni3d/versailles/music.cpp @@ -67,8 +67,7 @@ void CryOmni3DEngine_Versailles::musicUpdate() { // New file, stop the old one first musicStop(); - Common::String musicFName = musicBName; - musicFName += ".wav"; + Common::String musicFName(prepareFileName(musicBName, "wav")); Common::File *musicFile = new Common::File(); if (!musicFile->open(musicFName)) { |