summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 20:44:59 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 20:44:59 +0100
commita0cb500ff0cc40e48536c22ebb7bb2f5009e1def (patch)
tree01cc98ff4513ac65715c9556de239fb67acdbdf9
parent80e44a9e3ade61695b4807a3a900d2866138ecac (diff)
Fix setting game path for games with executable in subfolder.
-rw-r--r--src/settingsdialogpaths.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/settingsdialogpaths.cpp b/src/settingsdialogpaths.cpp
index eb334541..66ba8129 100644
--- a/src/settingsdialogpaths.cpp
+++ b/src/settingsdialogpaths.cpp
@@ -90,14 +90,27 @@ void PathsSettingsTab::update()
settings().paths().setBase("");
}
+ const auto binaryPath = settings().game().plugin()->binaryName();
QFileInfo oldGameExe(
- settings().game().plugin()->gameDirectory().absoluteFilePath(
- settings().game().plugin()->binaryName()));
-
+ settings().game().plugin()->gameDirectory().absoluteFilePath(binaryPath));
QFileInfo newGameExe(ui->managedGameDirEdit->text());
if (oldGameExe != newGameExe) {
- settings().game().setDirectory(newGameExe.absolutePath());
+ QDir folder = newGameExe.absoluteDir();
+ while (folder.exists() && !folder.isRoot()
+ && QFileInfo(folder.filePath(binaryPath)) != newGameExe) {
+ folder.cdUp();
+ }
+
+ if (folder.exists(binaryPath)) {
+ settings().game().setDirectory(folder.absolutePath());
+ }
+ else {
+ QMessageBox::warning(parentWidget(), QObject::tr("Error"),
+ QObject::tr("Failed to extract the game folder from \"%1\". Your version of the game "
+ "might not be supported by the current game plugin.").arg(newGameExe.absoluteFilePath()));
+
+ }
}
}