From a83947edbfb249e4ee230341b02eb22f37846f76 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Fri, 10 Feb 2017 23:04:00 +0000 Subject: [PATCH] Basic validation of added scenery paths. Try to catch uses adding parent directories and hence missing scenery. --- src/GUI/PathsDialog.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/GUI/PathsDialog.cxx b/src/GUI/PathsDialog.cxx index ae52f6afc..ca19002f5 100644 --- a/src/GUI/PathsDialog.cxx +++ b/src/GUI/PathsDialog.cxx @@ -102,6 +102,25 @@ void AddOnsPage::onAddSceneryPath() { QString path = QFileDialog::getExistingDirectory(this, tr("Choose scenery folder")); if (!path.isEmpty()) { + // validation + + SGPath p(path.toStdString()); + SGPath objectsPath = p / "Objects"; + SGPath terrainPath = p / "Terrain"; + + if (!objectsPath.exists() && !terrainPath.exists()) { + QMessageBox mb; + mb.setText(QString("The folder '%1' doesn't appear to contain scenery - add anyway?").arg(path)); + mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + mb.setDefaultButton(QMessageBox::No); + mb.setInformativeText("Added scenery should contain folders called 'Objects' and / or 'Terrain'"); + mb.exec(); + + if (mb.result() == QMessageBox::No) { + return; + } + } + m_ui->sceneryPathsList->addItem(path); saveSceneryPaths(); }