Fix problems with extensions in config tool (#669)

This commit is contained in:
VoxelTek 2025-08-13 00:30:36 +10:00 committed by GitHub
parent 5c99921bfc
commit f4a28f27f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 8 deletions

View File

@ -312,7 +312,11 @@ void CMainDialog::UpdateInterface()
m_ui->savePath->setText(QString::fromStdString(currentConfigApp->m_save_path)); m_ui->savePath->setText(QString::fromStdString(currentConfigApp->m_save_path));
m_ui->textureCheckBox->setChecked(currentConfigApp->m_texture_load); 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->texturePath->setEnabled(currentConfigApp->m_texture_load);
m_ui->texturePathOpen->setEnabled(currentConfigApp->m_texture_load); m_ui->texturePathOpen->setEnabled(currentConfigApp->m_texture_load);
@ -324,6 +328,11 @@ void CMainDialog::UpdateInterface()
m_ui->customAssetPaths->clear(); m_ui->customAssetPaths->clear();
assetPaths = QString::fromStdString(currentConfigApp->m_custom_asset_path).split(u','); 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->customAssetPaths->addItems(assetPaths);
m_ui->aspectRatioComboBox->setCurrentIndex(currentConfigApp->m_aspect_ratio); m_ui->aspectRatioComboBox->setCurrentIndex(currentConfigApp->m_aspect_ratio);
@ -584,7 +593,12 @@ void CMainDialog::AFChanged(int value)
void CMainDialog::SelectTexturePathDialog() void CMainDialog::SelectTexturePathDialog()
{ {
QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path));
QString texture_path = 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);
}
texture_path = data_path.absoluteFilePath(texture_path);
texture_path = QFileDialog::getExistingDirectory( texture_path = QFileDialog::getExistingDirectory(
this, this,
tr("Open Directory"), tr("Open Directory"),
@ -592,10 +606,10 @@ void CMainDialog::SelectTexturePathDialog()
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
); );
QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path));
if (data_path.exists(texture_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; m_modified = true;
} }
UpdateInterface(); UpdateInterface();
@ -606,8 +620,13 @@ void CMainDialog::TexturePathEdited()
QString texture_path = m_ui->texturePath->text(); QString texture_path = m_ui->texturePath->text();
QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); 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)) { 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; m_modified = true;
} }
UpdateInterface(); UpdateInterface();
@ -622,16 +641,20 @@ void CMainDialog::AddCustomAssetPath()
data_path.absolutePath(), data_path.absolutePath(),
"Interleaf files (*.si)" "Interleaf files (*.si)"
); );
if (!new_files.isEmpty()) {
for (QString& item : new_files) { for (QString& item : new_files) {
item = data_path.relativeFilePath(item); item = data_path.relativeFilePath(item);
} }
assetPaths += new_files; assetPaths += new_files;
m_modified = true;
}
UpdateAssetPaths(); UpdateAssetPaths();
} }
void CMainDialog::RemoveCustomAssetPath() void CMainDialog::RemoveCustomAssetPath()
{ {
assetPaths.removeAt(m_ui->customAssetPaths->currentRow()); assetPaths.removeAt(m_ui->customAssetPaths->currentRow());
m_modified = true;
UpdateAssetPaths(); UpdateAssetPaths();
} }
@ -653,6 +676,7 @@ void CMainDialog::EditCustomAssetPath()
if (!new_file.isEmpty()) { if (!new_file.isEmpty()) {
new_file = data_path.relativeFilePath(new_file); new_file = data_path.relativeFilePath(new_file);
assetPaths[m_ui->customAssetPaths->currentRow()] = new_file; assetPaths[m_ui->customAssetPaths->currentRow()] = new_file;
m_modified = true;
} }
UpdateAssetPaths(); UpdateAssetPaths();
} }
@ -660,6 +684,12 @@ void CMainDialog::EditCustomAssetPath()
void CMainDialog::UpdateAssetPaths() void CMainDialog::UpdateAssetPaths()
{ {
assetPaths.removeDuplicates(); assetPaths.removeDuplicates();
for (QString& path : assetPaths) {
if (!path.startsWith(QDir::separator())) {
path.prepend(QDir::separator());
}
}
currentConfigApp->m_custom_asset_path = assetPaths.join(u',').toStdString(); currentConfigApp->m_custom_asset_path = assetPaths.join(u',').toStdString();
UpdateInterface(); UpdateInterface();
} }

View File

@ -368,6 +368,7 @@ void CConfigApp::WriteRegisterSettings() const
dictionary* dict = dictionary_new(0); dictionary* dict = dictionary_new(0);
iniparser_set(dict, "isle", NULL); iniparser_set(dict, "isle", NULL);
iniparser_set(dict, "extensions", NULL); iniparser_set(dict, "extensions", NULL);
iniparser_set(dict, "texture loader", NULL);
iniparser_set(dict, "si loader", NULL); iniparser_set(dict, "si loader", NULL);
if (m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device) >= 0) { if (m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device) >= 0) {