From f4a28f27f9d4b0e3511a86170d5b626c86720841 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Wed, 13 Aug 2025 00:30:36 +1000 Subject: [PATCH] Fix problems with extensions in config tool (#669) --- CONFIG/MainDlg.cpp | 46 ++++++++++++++++++++++++++++++++++++++-------- CONFIG/config.cpp | 1 + 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index 59f321b7..a1a07cf9 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -312,7 +312,11 @@ void CMainDialog::UpdateInterface() m_ui->savePath->setText(QString::fromStdString(currentConfigApp->m_save_path)); m_ui->textureCheckBox->setChecked(currentConfigApp->m_texture_load); - m_ui->texturePath->setText(QString::fromStdString(currentConfigApp->m_texture_path)); + QString texture_path = QString::fromStdString(currentConfigApp->m_texture_path); + if (texture_path.startsWith(QDir::separator())) { + texture_path.remove(0, 1); + } + m_ui->texturePath->setText(texture_path); m_ui->texturePath->setEnabled(currentConfigApp->m_texture_load); m_ui->texturePathOpen->setEnabled(currentConfigApp->m_texture_load); @@ -324,6 +328,11 @@ void CMainDialog::UpdateInterface() m_ui->customAssetPaths->clear(); assetPaths = QString::fromStdString(currentConfigApp->m_custom_asset_path).split(u','); + for (QString& path : assetPaths) { + if (path.startsWith(QDir::separator())) { + path.remove(0, 1); + } + } m_ui->customAssetPaths->addItems(assetPaths); m_ui->aspectRatioComboBox->setCurrentIndex(currentConfigApp->m_aspect_ratio); @@ -584,7 +593,12 @@ void CMainDialog::AFChanged(int value) void CMainDialog::SelectTexturePathDialog() { + QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); QString texture_path = QString::fromStdString(currentConfigApp->m_texture_path); + if (texture_path.startsWith(QDir::separator())) { + texture_path.remove(0, 1); + } + texture_path = data_path.absoluteFilePath(texture_path); texture_path = QFileDialog::getExistingDirectory( this, tr("Open Directory"), @@ -592,10 +606,10 @@ void CMainDialog::SelectTexturePathDialog() QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); - QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); - if (data_path.exists(texture_path)) { - currentConfigApp->m_texture_path = data_path.relativeFilePath(texture_path).toStdString(); + texture_path = data_path.relativeFilePath(texture_path); + texture_path.prepend(QDir::separator()); + currentConfigApp->m_texture_path = texture_path.toStdString(); m_modified = true; } UpdateInterface(); @@ -606,8 +620,13 @@ void CMainDialog::TexturePathEdited() QString texture_path = m_ui->texturePath->text(); QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); + if (texture_path.startsWith(QDir::separator())) { + texture_path.remove(0, 1); + } if (data_path.exists(texture_path)) { - currentConfigApp->m_texture_path = data_path.relativeFilePath(texture_path).toStdString(); + texture_path = data_path.relativeFilePath(texture_path); + texture_path.prepend(QDir::separator()); + currentConfigApp->m_texture_path = texture_path.toStdString(); m_modified = true; } UpdateInterface(); @@ -622,16 +641,20 @@ void CMainDialog::AddCustomAssetPath() data_path.absolutePath(), "Interleaf files (*.si)" ); - for (QString& item : new_files) { - item = data_path.relativeFilePath(item); + if (!new_files.isEmpty()) { + for (QString& item : new_files) { + item = data_path.relativeFilePath(item); + } + assetPaths += new_files; + m_modified = true; } - assetPaths += new_files; UpdateAssetPaths(); } void CMainDialog::RemoveCustomAssetPath() { assetPaths.removeAt(m_ui->customAssetPaths->currentRow()); + m_modified = true; UpdateAssetPaths(); } @@ -653,6 +676,7 @@ void CMainDialog::EditCustomAssetPath() if (!new_file.isEmpty()) { new_file = data_path.relativeFilePath(new_file); assetPaths[m_ui->customAssetPaths->currentRow()] = new_file; + m_modified = true; } UpdateAssetPaths(); } @@ -660,6 +684,12 @@ void CMainDialog::EditCustomAssetPath() void CMainDialog::UpdateAssetPaths() { assetPaths.removeDuplicates(); + + for (QString& path : assetPaths) { + if (!path.startsWith(QDir::separator())) { + path.prepend(QDir::separator()); + } + } currentConfigApp->m_custom_asset_path = assetPaths.join(u',').toStdString(); UpdateInterface(); } diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index f75838f6..4e9d414d 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -368,6 +368,7 @@ void CConfigApp::WriteRegisterSettings() const dictionary* dict = dictionary_new(0); iniparser_set(dict, "isle", NULL); iniparser_set(dict, "extensions", NULL); + iniparser_set(dict, "texture loader", NULL); iniparser_set(dict, "si loader", NULL); if (m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device) >= 0) {