23 #include "gameexecutablepicker.h" 25 #include "ui_gameexecutablepicker.h" 26 #include "configuration/doomseekerconfig.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 "filefilter.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)
62 d->executableInput->addItem(path);
66 void GameExecutablePicker::browse()
69 QString dialogDir = gConfig.doomseeker.previousCreateServerExecDir;
70 QString path = QFileDialog::getOpenFileName(
this, tr(
"Doomseeker - Browse executable"),
71 dialogDir, FileFilter::executableFilesFilter());
76 gConfig.doomseeker.previousCreateServerExecDir = fi.absolutePath();
84 GameFileList GameExecutablePicker::gameExecutables()
const 87 GameFileList candidates = GameFiles::allFlagMatchExecutables(files, d->allowedExecs);
88 if (d->allowedExecs & GameFile::Client)
90 candidates.prepend(GameFiles::defaultClientExecutable(files));
92 else if (d->allowedExecs & GameFile::Server)
94 candidates.prepend(GameFiles::defaultServerExecutable(files));
96 else if (d->allowedExecs & GameFile::Offline)
98 candidates.prepend(GameFiles::defaultOfflineExecutable(files));
103 QString GameExecutablePicker::path()
const 105 return d->executableInput->currentText();
108 void GameExecutablePicker::setPath(
const QString &path)
113 void GameExecutablePicker::setExecutableToDefault()
119 showWarning(tr(
"Plugin doesn't support configuration."));
126 showWarning(tr(
"Game doesn't define any executables for this game setup."));
130 foreach (
const GameFile &candidate, execs.asQList())
139 showWarning(tr(
"Default executable for this game isn't configured."));
144 d->allowedExecs = execs;
148 void GameExecutablePicker::setPlugin(
EnginePlugin *plugin)
154 void GameExecutablePicker::showWarning(
const QString &msg)
156 d->lblWarning->setVisible(!msg.trimmed().isEmpty());
157 d->lblWarning->setToolTip(msg);
160 void GameExecutablePicker::reloadExecutables()
163 if (d->plugin == NULL)
165 showWarning(tr(
"Game plugin not set."));
168 QString currentExec = d->executableInput->currentText();
169 d->executableInput->clear();
178 foreach (
const GameFile &file, files.asQList())
182 foreach (
const ExeFilePath &exe, d->plugin->gameExe()->additionalExecutables(d->allowedExecs))
184 QFileInfo fileInfo(exe.path());
185 if (fileInfo.isFile())
191 if (d->executableInput->findText(currentExec) >= 0)
197 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.
static void setCurrentText(QComboBox *box, const QString &text)
Qt4 compliant implementation of Qt5's QComboBox::setCurrentText().
INI section representation.
Game file definition allows to browse this file in configuration box.
void setAllowedExecutables(int execs)