diff --git a/CHANGELOG.md b/CHANGELOG.md index da551cc1..0d64777f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. - Fix crash when saving tilesets with fewer palettes than the maximum. - Fix projects not opening on Windows if the project filepath contains certain characters. +- Fix custom project filepaths not converting Windows file separators. - Fix exported tile images containing garbage pixels after the end of the tiles. - Fix fully transparent pixels rendering with the incorrect color. - Fix the values for some config fields shuffling their order every save. diff --git a/src/config.cpp b/src/config.cpp index d74adbcb..42a59149 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -984,7 +984,7 @@ void ProjectConfig::setFilePath(const QString &pathId, const QString &path) { } QString ProjectConfig::getCustomFilePath(ProjectFilePath pathId) { - return this->filePaths.value(pathId); + return QDir::cleanPath(this->filePaths.value(pathId)); } QString ProjectConfig::getCustomFilePath(const QString &pathId) { @@ -992,14 +992,17 @@ QString ProjectConfig::getCustomFilePath(const QString &pathId) { } QString ProjectConfig::getFilePath(ProjectFilePath pathId) { - const QString customPath = this->getCustomFilePath(pathId); + QString customPath = this->getCustomFilePath(pathId); if (!customPath.isEmpty()) { // A custom filepath has been specified. If the file/folder exists, use that. - const QString absCustomPath = this->projectDir + QDir::separator() + customPath; - if (QFileInfo::exists(absCustomPath)) { + const QString baseDir = this->projectDir + "/"; + if (customPath.startsWith(baseDir)) { + customPath.remove(0, baseDir.length()); + } + if (QFileInfo::exists(QDir::cleanPath(baseDir + customPath))) { return customPath; } else { - logError(QString("Custom project filepath '%1' not found. Using default.").arg(absCustomPath)); + logError(QString("Custom project filepath '%1' not found. Using default.").arg(customPath)); } } return defaultPaths.contains(pathId) ? defaultPaths[pathId].second : QString(); diff --git a/src/ui/customscriptseditor.cpp b/src/ui/customscriptseditor.cpp index c3c412c2..eddbc7ae 100644 --- a/src/ui/customscriptseditor.cpp +++ b/src/ui/customscriptseditor.cpp @@ -11,7 +11,7 @@ CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) : QMainWindow(parent), ui(new Ui::CustomScriptsEditor), - baseDir(userConfig.projectDir + QDir::separator()) + baseDir(userConfig.projectDir + "/") { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index fa84f3e0..34987914 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -20,7 +20,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project) QMainWindow(parent), ui(new Ui::ProjectSettingsEditor), project(project), - baseDir(projectConfig.projectDir + QDir::separator()) + baseDir(projectConfig.projectDir + "/") { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); @@ -388,7 +388,7 @@ QString ProjectSettingsEditor::chooseProjectFile(const QString &defaultFilepath) QString path; if (defaultFilepath.endsWith("/")){ // Default filepath is a folder, choose a new folder - path = FileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + QDir::separator(); + path = FileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + "/"; } else{ // Default filepath is not a folder, choose a new file path = FileDialog::getOpenFileName(this, "Choose Project File", startDir);