Mon, 22 Jun 2015 01:44:30 +0300
Added the ability to automatically look up wad paths from other sources (for now just Doomseeker's configuration). By default, ZCinema will automatically do such a lookup if it fails to find a WAD needed for demo playback. This can also be invoked manually in the config prompt.
commonlib/config.cpp | file | annotate | diff | comparison | revisions | |
commonlib/misc.cpp | file | annotate | diff | comparison | revisions | |
commonlib/misc.h | file | annotate | diff | comparison | revisions | |
config/configwindow.cpp | file | annotate | diff | comparison | revisions | |
config/configwindow.h | file | annotate | diff | comparison | revisions | |
launcher/demo.cpp | file | annotate | diff | comparison | revisions | |
ui/configbox.ui | file | annotate | diff | comparison | revisions |
--- a/commonlib/config.cpp Sun Jun 07 19:56:40 2015 +0300 +++ b/commonlib/config.cpp Mon Jun 22 01:44:30 2015 +0300 @@ -44,6 +44,7 @@ if (defaults.isEmpty()) { // Initialize defaults here. + defaults["autoassimilate"] = true; } return defaults;
--- a/commonlib/misc.cpp Sun Jun 07 19:56:40 2015 +0300 +++ b/commonlib/misc.cpp Mon Jun 22 01:44:30 2015 +0300 @@ -17,6 +17,7 @@ */ #include <QFileDialog> +#include <QSettings> #include "misc.h" #include "config.h" @@ -58,4 +59,59 @@ return QFileDialog::getOpenFileName (parent, "", "", "Zandronum Binaries (" ZAN_EXE_NAME ");;All files (*)"); +} + +// +// ------------------------------------------------------------------------------------------------- +// + +void assimilateWadPaths (QStringList& wadpaths) +{ + QString iniPath; + +#ifdef Q_OS_WIN32 + { + char* appdata = getenv ("APPDATA"); + + if (appdata == NULL) + return; + + iniPath = QString::fromLocal8Bit (appdata) + "/.doomseeker/doomseeker.ini"; + } +#else + iniPath = QDir::homePath() + "/.doomseeker/doomseeker.ini"; +#endif + + if (not QFile (iniPath).exists()) + return; + + QSettings settings (iniPath, QSettings::IniFormat); + QVariant var = settings.value ("Doomseeker/WadPaths"); + QStringList doomseekerPaths; + + if (var.isValid() and var.toList().isEmpty()) + { + doomseekerPaths = var.toString().split (";"); + } + else + { + QVariantList collection = var.toList(); + + for (int i = 0; i < collection.size(); ++i) + { + QVariantList element = collection[i].toList(); + + if (element.size() > 0) + doomseekerPaths.append (element[0].toString()); + } + } + + for (int i = 0; i < doomseekerPaths.size(); ++i) + { + doomseekerPaths[i].replace ("\\", "/"); + QString& path = doomseekerPaths[i]; + + if (not wadpaths.contains (path)) + wadpaths.append (path); + } } \ No newline at end of file
--- a/commonlib/misc.h Sun Jun 07 19:56:40 2015 +0300 +++ b/commonlib/misc.h Mon Jun 22 01:44:30 2015 +0300 @@ -28,6 +28,7 @@ QString basename (const QString& path); bool confirm (const QString& text); QString getBinaryPath (QWidget* parent); +void assimilateWadPaths (QStringList& wadpaths); // // -----------------------------------------------------------------------------
--- a/config/configwindow.cpp Sun Jun 07 19:56:40 2015 +0300 +++ b/config/configwindow.cpp Mon Jun 22 01:44:30 2015 +0300 @@ -21,6 +21,7 @@ #include <QLabel> #include <commonlib/config.h> #include <commonlib/version.h> +#include <commonlib/misc.h> #include "addversionprompt.h" #include "configwindow.h" #include "versionguientry.h" @@ -63,6 +64,7 @@ addWadPath (wadpaths[i]); ui.noDemoPrompt->setChecked (Config::get ("noprompt").toBool()); + ui.autoAssimilate->setChecked (Config::get ("autoassimilate").toBool()); for (int i = 0; i < versions.size(); ++i) { @@ -76,6 +78,7 @@ connect (ui.wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addWadPath())); connect (ui.wad_findPath, SIGNAL (clicked()), this, SLOT (findWadPath())); connect (ui.wad_del, SIGNAL (clicked()), this, SLOT (removeCurrentWadPath())); + connect (ui.wad_autofind, SIGNAL (clicked()), this, SLOT (autoFindWadPaths())); connect (ui.buttonBox, SIGNAL (clicked (QAbstractButton*)), this, SLOT (buttonPressed (QAbstractButton*))); connect (ui.addExePath, SIGNAL (clicked()), this, SLOT (newVersion())); @@ -242,6 +245,7 @@ Config::set ("wadpaths", wadPathList); Config::set ("noprompt", ui.noDemoPrompt->isChecked()); + Config::set ("autoassimilate", ui.autoAssimilate->isChecked()); Config::set ("versions", versions); Config::sync(); } @@ -271,6 +275,24 @@ // ------------------------------------------------------------------------------------------------- // +void ConfigWindow::autoFindWadPaths() +{ + QStringList paths; + + for (int i = 0; i < ui.wad_pathsList->count(); ++i) + paths.append (ui.wad_pathsList->item (i)->text()); + + assimilateWadPaths (paths); + ui.wad_pathsList->clear(); + + for (int i = 0; i < paths.size(); ++i) + addWadPath (paths[i]); +} + +// +// ------------------------------------------------------------------------------------------------- +// + void ConfigWindow::findWadPath() { QString path = QFileDialog::getExistingDirectory (this);
--- a/config/configwindow.h Sun Jun 07 19:56:40 2015 +0300 +++ b/config/configwindow.h Mon Jun 22 01:44:30 2015 +0300 @@ -44,6 +44,7 @@ void addWadPath(); void findWadPath(); void removeCurrentWadPath(); + void autoFindWadPaths(); void buttonPressed (class QAbstractButton* btn); void newVersion(); void removeCurrentVersion();
--- a/launcher/demo.cpp Sun Jun 07 19:56:40 2015 +0300 +++ b/launcher/demo.cpp Mon Jun 22 01:44:30 2015 +0300 @@ -106,19 +106,10 @@ // ------------------------------------------------------------------------------------------------- // -static QString findWAD (QString name) +static QString findWad (QString name) { QStringList wadpaths = Config::get ("wadpaths").toStringList(); - if (wadpaths.empty()) - { - error (tr ("No WAD paths configured!")); - - // Cannot just return an empty string here since that'd trigger another error prompt - skip - // ahead and exit. - exit (1); - } - for (int i = 0; i < wadpaths.size(); ++i) { QString fullpath = QString ("%1/%2").arg (wadpaths[i]).arg (name); @@ -128,6 +119,11 @@ return fullpath; } + // WAD names are case-sensitive under non-Windows and they can appear in uppercase + // so we need to test that too. + if (name != name.toUpper()) + return findWad (name.toUpper()); + return ""; } @@ -318,17 +314,25 @@ QString iwadpath; QStringList pwadpaths; + bool doneAssimilation = false; // Find the WADs for (int i = 0; i < wads.size(); ++i) { const QString& wad = wads[i]; - QString path = findWAD (wad); + QString path = findWad (wad); + + if (path.isEmpty() and not doneAssimilation and Config::get ("autoassimilate").toBool()) + { + QStringList wadpaths = Config::get ("wadpaths").toStringList(); - // WAD names are case-sensitive under non-Windows and they can appear in uppercase - // so we need to test that too. - if (path.isEmpty()) - path = findWAD (wad.toUpper()); + // If there are no wad paths, try assimilate from other sources. + assimilateWadPaths (wadpaths); + Config::set ("wadpaths", wadpaths); + + // Try find the wad again + path = findWad (wad); + } if (path.isEmpty()) {
--- a/ui/configbox.ui Sun Jun 07 19:56:40 2015 +0300 +++ b/ui/configbox.ui Mon Jun 22 01:44:30 2015 +0300 @@ -78,6 +78,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="wad_autofind"> + <property name="text"> + <string>Auto-find</string> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -217,6 +224,13 @@ </widget> </item> <item> + <widget class="QCheckBox" name="autoAssimilate"> + <property name="text"> + <string>Automatically find WAD paths from other sources (i.e. Doomseeker ini) if needed</string> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum>