Merge pull request #597 from manongjohn/fix_reading_filenames_from_file
Fix loading scenes from Story Planner
This commit is contained in:
commit
80e2b1794e
3 changed files with 19 additions and 3 deletions
|
@ -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,8 +119,12 @@ 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 {
|
||||
if (levelName == it->withoutParentDir())
|
||||
level->setFrame(TFrameId::NO_FRAME, TImageP());
|
||||
else
|
||||
level->setFrame(it->getFrame(), TImageP());
|
||||
data.push_back(*it);
|
||||
} catch (TMalformedFrameException tmfe) {
|
||||
|
@ -163,6 +171,7 @@ TLevelP TLevelReader::loadInfo() {
|
|||
//-----------------------------------------------------------
|
||||
|
||||
TImageReaderP TLevelReader::getFrameReader(TFrameId fid) {
|
||||
if (fid.isNoFrame()) return TImageReaderP(m_path);
|
||||
return TImageReaderP(m_path.withFrame(fid, m_frameFormat));
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue