diff --git a/toonz/sources/common/timage_io/tlevel_io.cpp b/toonz/sources/common/timage_io/tlevel_io.cpp index 3a6e379f..866fa831 100644 --- a/toonz/sources/common/timage_io/tlevel_io.cpp +++ b/toonz/sources/common/timage_io/tlevel_io.cpp @@ -35,7 +35,8 @@ TLevelReader::TLevelReader(const TFilePath &path) , m_info(0) , m_path(path) , m_contentHistory(0) - , m_frameFormat(TFrameId::FOUR_ZEROS) {} + , m_frameFormat(TFrameId::FOUR_ZEROS) + , m_useExactPath(false) {} //----------------------------------------------------------- @@ -102,6 +103,9 @@ const TImageInfo *TLevelReader::getImageInfo() { TLevelP TLevelReader::loadInfo() { TFilePath parentDir = m_path.getParentDir(); TFilePath levelName(m_path.getLevelName()); + // For scene loading, use what was stored in the file instead + // of auto converting to a level name. + if (useExactPath()) levelName = m_path.withoutParentDir(); // cout << "Parent dir = '" << parentDir << "'" << endl; // cout << "Level name = '" << levelName << "'" << endl; TFilePathSet files; @@ -115,9 +119,13 @@ TLevelP TLevelReader::loadInfo() { for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) { TFilePath ln(it->getLevelName()); // cout << "try " << *it << " " << it->getLevelName() << endl; - if (levelName == TFilePath(it->getLevelName())) { + if (levelName == TFilePath(it->getLevelName()) || + levelName == it->withoutParentDir()) { try { - level->setFrame(it->getFrame(), TImageP()); + if (levelName == it->withoutParentDir()) + level->setFrame(TFrameId::NO_FRAME, TImageP()); + else + level->setFrame(it->getFrame(), TImageP()); data.push_back(*it); } catch (TMalformedFrameException tmfe) { // skip frame named incorrectly warning to the user in the message @@ -163,6 +171,7 @@ TLevelP TLevelReader::loadInfo() { //----------------------------------------------------------- TImageReaderP TLevelReader::getFrameReader(TFrameId fid) { + if (fid.isNoFrame()) return m_path; return TImageReaderP(m_path.withFrame(fid, m_frameFormat)); } diff --git a/toonz/sources/include/tlevel_io.h b/toonz/sources/include/tlevel_io.h index f5bd0ea7..51bde9e2 100644 --- a/toonz/sources/include/tlevel_io.h +++ b/toonz/sources/include/tlevel_io.h @@ -49,6 +49,8 @@ protected: TFilePath m_path; TContentHistory *m_contentHistory; + bool m_useExactPath; + public: TLevelReader(const TFilePath &path); virtual ~TLevelReader(); @@ -95,6 +97,9 @@ public: //! TLevelReader keeps the ownership of TContentHistory. Don't delete it const TContentHistory *getContentHistory() const { return m_contentHistory; } + void setUseExactPath(bool useExactPath) { m_useExactPath = useExactPath; } + bool useExactPath() { return m_useExactPath; } + private: TFrameId::FrameFormat m_frameFormat; }; diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index c5f6d72c..9f92bec7 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -1220,6 +1220,8 @@ void TXshSimpleLevel::load() { TLevelReaderP lr(path); // May throw assert(lr); + lr->setUseExactPath(getScene()->isLoading()); + TLevelP level = lr->loadInfo(); if (level->getFrameCount() > 0) { const TImageInfo *info = lr->getImageInfo(level->begin()->first);