Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

New Level to $sceneFolder\folderItShouldbe when loaded a scene from outside, and it doesn't have scenes.xml, but sandbox is current project

Abel You4b46ee1e8f02
diff --git a/toonz/sources/include/toonz/toonzscene.h b/toonz/sources/include/toonz/toonzscene.h
index 9cc89159b..edea75165 100644
--- a/toonz/sources/include/toonz/toonzscene.h
+++ b/toonz/sources/include/toonz/toonzscene.h
@@ -259,6 +259,9 @@ If \b scene is in +scenes/name.tnz return name,
// if the path is codable with $scenefolder alias, replace it and return true
bool codeFilePathWithSceneFolder(TFilePath &path) const;
+
+ // return false if the scene doesn't belong to any project
+ bool isLonelyScene() const;
bool isLoading() { return m_isLoading; }
void setIsLoading(bool isLoading) { m_isLoading = isLoading; }
diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp
index afbd5a691..4dedf5919 100644
--- a/toonz/sources/toonz/iocommand.cpp
+++ b/toonz/sources/toonz/iocommand.cpp
@@ -1931,8 +1931,9 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
QString msg;
msg = QObject::tr(
"It is not possible to load the scene %1 because it does not "
- "belong to any project.")
- .arg(QString::fromStdWString(scenePath.getWideString()));
+ "belong to any project.\n"
+ "Please delete scenes.xml if this scene dones't belong to any project.")
+ .arg(QString::fromStdWString(scenePath.getWideString()));
DVGui::warning(msg);
}
if (sceneProject && !sceneProject->isCurrent()) {
diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp
index bce5788e3..ea31c5008 100644
--- a/toonz/sources/toonzlib/toonzscene.cpp
+++ b/toonz/sources/toonzlib/toonzscene.cpp
@@ -1366,7 +1366,6 @@ TFilePath ToonzScene::codeFilePath(const TFilePath &path) const {
//-----------------------------------------------------------------------------
// if the path is codable with $scenefolder alias, replace it and return true
-
bool ToonzScene::codeFilePathWithSceneFolder(TFilePath &path) const {
// if the scene is untitled, then do nothing and return false
if (isUntitled()) return false;
@@ -1378,6 +1377,11 @@ bool ToonzScene::codeFilePathWithSceneFolder(TFilePath &path) const {
return false;
}
+bool ToonzScene::isLonelyScene() const {
+ TFilePath sceneFolderPath = getProject()->getFolder("scenes", true);
+ return !sceneFolderPath.isAncestorOf(m_scenePath);
+}
+
//-----------------------------------------------------------------------------
TFilePath ToonzScene::getDefaultLevelPath(int levelType,
@@ -1406,11 +1410,15 @@ TFilePath ToonzScene::getDefaultLevelPath(int levelType,
levelPath = TFilePath(levelName + L"..png");
}
- if (!isUntitled() && Preferences::instance()->getPathAliasPriority() ==
- Preferences::SceneFolderAlias)
- return TFilePath("$scenefolder") + levelPath;
+ // In case scene is loaded from outside
+ if (!isUntitled() &&
+ Preferences::instance()->getPathAliasPriority() == Preferences::SceneFolderAlias)
+ return TFilePath("$scenefolder") + levelPath;
std::string folderName = getFolderName(levelType);
+ if (!isUntitled() && isLonelyScene())
+ return TFilePath("$scenefolder") + TFilePath(folderName) + levelPath;
+
if (project->getUseScenePath(folderName))
return TFilePath("+" + folderName) + getSavePath() + levelPath;
else