23 #include "gameexecutablepicker.h" 25 #include "configuration/doomseekerconfig.h" 26 #include "filefilter.h" 27 #include "gui/commongui.h" 29 #include "plugins/engineplugin.h" 30 #include "serverapi/exefile.h" 31 #include "serverapi/gameexefactory.h" 32 #include "serverapi/gamefile.h" 33 #include "ui_gameexecutablepicker.h" 34 #include <QFileDialog> 36 DClass<GameExecutablePicker> :
public Ui::GameExecutablePicker
54 GameExecutablePicker::~GameExecutablePicker()
58 void GameExecutablePicker::add(
const QString &path)
60 if (!path.trimmed().isEmpty() && d->executableInput->findText(path) < 0)
61 d->executableInput->addItem(path);
64 void GameExecutablePicker::browse()
67 QString dialogDir = gConfig.doomseeker.previousCreateServerExecDir;
68 QString path = QFileDialog::getOpenFileName(
this, tr(
"Doomseeker - Browse executable"),
69 dialogDir, FileFilter::executableFilesFilter());
74 gConfig.doomseeker.previousCreateServerExecDir = fi.absolutePath();
76 d->executableInput->setCurrentText(fi.absoluteFilePath());
82 GameFileList GameExecutablePicker::gameExecutables()
const 85 GameFileList candidates = GameFiles::allFlagMatchExecutables(files, d->allowedExecs);
86 if (d->allowedExecs & GameFile::Client)
87 candidates.prepend(GameFiles::defaultClientExecutable(files));
88 else if (d->allowedExecs & GameFile::Server)
89 candidates.prepend(GameFiles::defaultServerExecutable(files));
90 else if (d->allowedExecs & GameFile::Offline)
91 candidates.prepend(GameFiles::defaultOfflineExecutable(files));
95 QString GameExecutablePicker::path()
const 97 return d->executableInput->currentText();
100 void GameExecutablePicker::setPath(
const QString &path)
102 d->executableInput->setCurrentText(path);
105 void GameExecutablePicker::setExecutableToDefault()
111 showWarning(tr(
"Plugin doesn't support configuration."));
118 showWarning(tr(
"Game doesn't define any executables for this game setup."));
122 for (
const GameFile &candidate : execs.asQList())
124 QString path = cfg->
value(candidate.configName()).toString();
127 d->executableInput->setCurrentText(path);
131 showWarning(tr(
"Default executable for this game isn't configured."));
136 d->allowedExecs = execs;
140 void GameExecutablePicker::setPlugin(
EnginePlugin *plugin)
146 void GameExecutablePicker::showWarning(
const QString &msg)
148 d->lblWarning->setVisible(!msg.trimmed().isEmpty());
149 d->lblWarning->setToolTip(msg);
152 void GameExecutablePicker::reloadExecutables()
155 if (d->plugin ==
nullptr)
157 showWarning(tr(
"Game plugin not set."));
160 QString currentExec = d->executableInput->currentText();
161 d->executableInput->clear();
165 d->executableInput->setCurrentText(currentExec);
170 for (
const GameFile &file : files.asQList())
174 for (
const ExeFilePath &exe : d->plugin->gameExe()->additionalExecutables(d->allowedExecs))
176 QFileInfo fileInfo(exe.path());
177 if (fileInfo.isFile())
181 if (d->executableInput->findText(currentExec) >= 0)
182 d->executableInput->setCurrentText(currentExec);
184 setExecutableToDefault();
const QString & configName() const
Setting name where path will be stored in plugin's IniSection.
QVariant value(const QString &key) const
Retrieves a variable directly; omits the IniVariable system.
A simple executable path & working dir structure.
INI section representation.
Game file definition allows to browse this file in configuration box.
void setAllowedExecutables(int execs)