From 39d953c838d459085b4044c9ca5bda0248e47f6b Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 7 Jun 2019 21:03:25 -0400 Subject: load plugin executables after settings, allows for changing the order added warning that an executable is provided by a plugin, disable widgets that can't be changed refactoring EditExecutablesDialog --- src/editexecutablesdialog.cpp | 134 +++++++++++--- src/editexecutablesdialog.h | 9 +- src/editexecutablesdialog.ui | 405 ++++++++++++++++++++++-------------------- src/executableslist.cpp | 4 +- 4 files changed, 328 insertions(+), 224 deletions(-) (limited to 'src') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index f7348889..8494c892 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -47,15 +47,96 @@ EditExecutablesDialog::EditExecutablesDialog( ui->splitter->setStretchFactor(1, 1); refreshExecutablesWidget(); - ui->newFilesModBox->addItems(modList.allMods()); m_ForcedLibraries = m_Profile->determineForcedLibraries(ui->titleEdit->text()); + + updateUI(nullptr); +} + +EditExecutablesDialog::~EditExecutablesDialog() = default; + +void EditExecutablesDialog::updateUI(const Executable* e) +{ + if (e) { + setEdits(*e); + } else { + clearEdits(); + ui->removeButton->setEnabled(false); + } +} + +void EditExecutablesDialog::clearEdits() +{ + ui->titleEdit->clear(); + ui->binaryEdit->clear(); + ui->workingDirEdit->clear(); + ui->argumentsEdit->clear(); + ui->overwriteAppIDBox->setChecked(false); + ui->appIDOverwriteEdit->clear(); + ui->newFilesModCheckBox->setChecked(false); + ui->newFilesModBox->setCurrentIndex(-1); + ui->forceLoadCheckBox->setChecked(false); + ui->useAppIconCheckBox->setChecked(false); + + ui->pluginProvidedLabel->setVisible(false); } -EditExecutablesDialog::~EditExecutablesDialog() +void EditExecutablesDialog::setEdits(const Executable& e) { - delete ui; + ui->titleEdit->setText(e.title()); + ui->binaryEdit->setText(QDir::toNativeSeparators(e.binaryInfo().absoluteFilePath())); + ui->workingDirEdit->setText(QDir::toNativeSeparators(e.workingDirectory())); + ui->argumentsEdit->setText(e.arguments()); + ui->overwriteAppIDBox->setChecked(!e.steamAppID().isEmpty()); + ui->appIDOverwriteEdit->setText(e.steamAppID()); + ui->useAppIconCheckBox->setChecked(e.usesOwnIcon()); + + int modIndex = -1; + + QString customOverwrite = m_Profile->setting("custom_overwrites", e.title()).toString(); + if (!customOverwrite.isEmpty()) { + modIndex = ui->newFilesModBox->findText(customOverwrite); + } + + ui->newFilesModCheckBox->setChecked(modIndex != -1); + ui->newFilesModBox->setCurrentIndex(modIndex); + + const bool forcedLibraries = m_Profile->forcedLibrariesEnabled(e.title()); + ui->forceLoadCheckBox->setChecked(forcedLibraries); + ui->forceLoadButton->setEnabled(forcedLibraries); + + ui->pluginProvidedLabel->setVisible(!e.isCustom()); + + // only enabled for custom executables + ui->titleEdit->setEnabled(e.isCustom()); + ui->binaryEdit->setEnabled(e.isCustom()); + ui->browseBinaryButton->setEnabled(e.isCustom()); + ui->workingDirEdit->setEnabled(e.isCustom()); + ui->browseWorkingDirButton->setEnabled(e.isCustom()); + ui->argumentsEdit->setEnabled(e.isCustom()); + ui->overwriteAppIDBox->setEnabled(e.isCustom()); + ui->appIDOverwriteEdit->setEnabled(e.isCustom()); + ui->useAppIconCheckBox->setEnabled(e.isCustom()); + + // always enabled + ui->newFilesModCheckBox->setEnabled(true); + ui->newFilesModBox->setEnabled(true); + ui->forceLoadCheckBox->setEnabled(true); +} + +void EditExecutablesDialog::resetInput() +{ + ui->binaryEdit->setText(""); + ui->titleEdit->setText(""); + ui->workingDirEdit->clear(); + ui->argumentsEdit->setText(""); + ui->appIDOverwriteEdit->clear(); + ui->overwriteAppIDBox->setChecked(false); + ui->useAppIconCheckBox->setChecked(false); + ui->newFilesModCheckBox->setChecked(false); + ui->forceLoadCheckBox->setChecked(false); + m_CurrentItem = nullptr; } ExecutablesList EditExecutablesDialog::getExecutablesList() const @@ -95,8 +176,8 @@ void EditExecutablesDialog::refreshExecutablesWidget() ui->executablesListBox->addItem(newItem); } - ui->addButton->setEnabled(false); - ui->removeButton->setEnabled(false); + //ui->addButton->setEnabled(false); + //ui->removeButton->setEnabled(false); } @@ -131,20 +212,6 @@ void EditExecutablesDialog::updateButtonStates() ui->addButton->setEnabled(enabled); } -void EditExecutablesDialog::resetInput() -{ - ui->binaryEdit->setText(""); - ui->titleEdit->setText(""); - ui->workingDirEdit->clear(); - ui->argumentsEdit->setText(""); - ui->appIDOverwriteEdit->clear(); - ui->overwriteAppIDBox->setChecked(false); - ui->useAppIconCheckBox->setChecked(false); - ui->newFilesModCheckBox->setChecked(false); - ui->forceLoadCheckBox->setChecked(false); - m_CurrentItem = nullptr; -} - void EditExecutablesDialog::saveExecutable() { @@ -260,7 +327,7 @@ void EditExecutablesDialog::on_browseBinaryButton_clicked() } } -void EditExecutablesDialog::on_browseDirButton_clicked() +void EditExecutablesDialog::on_browseWorkingDirButton_clicked() { QString dirName = FileDialogMemory::getExistingDirectory("editExecutableDirectory", this, tr("Select a directory")); @@ -359,10 +426,27 @@ bool EditExecutablesDialog::executableChanged() } void EditExecutablesDialog::on_executablesListBox_itemSelectionChanged() { - if (ui->executablesListBox->selectedItems().size() == 0) { - // deselected - resetInput(); + const auto selection = ui->executablesListBox->selectedItems(); + + if (selection.empty()) { + updateUI(nullptr); + return; + } + + auto* item = selection[0]; + if (!item) { + return; } + + const auto& title = item->text(); + auto itor = m_ExecutablesList.find(title); + + if (itor == m_ExecutablesList.end()) { + qWarning().nospace() << "selection: executable '" << title << "' not found"; + return; + } + + updateUI(&*itor); } void EditExecutablesDialog::on_overwriteAppIDBox_toggled(bool checked) @@ -395,7 +479,7 @@ void EditExecutablesDialog::on_buttonBox_rejected() } void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex ¤t) -{ +{/* if (current.isValid()) { if (executableChanged()) { @@ -459,7 +543,7 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur bool forcedLibraries = m_Profile->forcedLibrariesEnabled(ui->titleEdit->text()); ui->forceLoadButton->setEnabled(forcedLibraries); ui->forceLoadCheckBox->setChecked(forcedLibraries); - } + }*/ } void EditExecutablesDialog::on_newFilesModCheckBox_toggled(bool checked) diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h index 7f389b24..bb1538ef 100644 --- a/src/editexecutablesdialog.h +++ b/src/editexecutablesdialog.h @@ -87,7 +87,7 @@ private slots: void on_overwriteAppIDBox_toggled(bool checked); - void on_browseDirButton_clicked(); + void on_browseWorkingDirButton_clicked(); void on_buttonBox_accepted(); void on_buttonBox_rejected(); @@ -113,7 +113,7 @@ private: void updateButtonStates(); private: - Ui::EditExecutablesDialog *ui; + std::unique_ptr ui; QListWidgetItem *m_CurrentItem; @@ -124,6 +124,11 @@ private: QList m_ForcedLibraries; const MOBase::IPluginGame *m_GamePlugin; + + + void updateUI(const Executable* e); + void clearEdits(); + void setEdits(const Executable& e); }; #endif // EDITEXECUTABLESDIALOG_H diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index 52bbf187..2c9a74f3 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -7,15 +7,9 @@ 0 0 710 - 293 + 348 - - - 200 - 200 - - Modify Executables @@ -77,9 +71,6 @@ Qt::TargetMoveAction - - QAbstractItemView::ExtendedSelection - @@ -163,197 +154,221 @@ 0 - - - 20 - - - - - Title - - - - - - - Name of the executable. This is only for display purposes. - - - Name of the executable. This is only for display purposes. - - - - - - - Binary - - - - - - - - - Binary to run - - - Binary to run - - - - - - - Browse filesystem - - - Browse filesystem for the executable to run. - - - ... - - - - - - - - - Start in - - - - - - - - - - - - ... - - - - - - - - - Arguments - - - - - - - Arguments to pass to the application - - - Arguments to pass to the application - - - - - - - - - - - Allow the Steam AppID to be used for this executable to be changed. - - - Allow the Steam AppID to be used for this executable to be changed. + + + + 10 + + + + + 20 + + + + + Title + + + + + + + Name of the executable. This is only for display purposes. + + + Name of the executable. This is only for display purposes. + + + + + + + Binary + + + + + + + + + Binary to run + + + Binary to run + + + + + + + Browse filesystem + + + Browse filesystem for the executable to run. + + + ... + + + + + + + + + Start in + + + + + + + + + + + + ... + + + + + + + + + Arguments + + + + + + + Arguments to pass to the application + + + Arguments to pass to the application + + + + + + + + + + + Allow the Steam AppID to be used for this executable to be changed. + + + Allow the Steam AppID to be used for this executable to be changed. Every game/tool distributed through Steam has a unique ID. MO needs to know this ID to start those programs directly, otherwise the program is started by steam and then MO will not work. By default, MO will use the AppID for the game. Right now the only case I know of where this needs to be overwritten is for the Skyrim Creation Kit which has its own AppID. This overwrite is already preconfigured. - - - Overwrite Steam AppID - - - - - - - false - - - Steam AppID to use for this executable that differs from the games AppID. - - - Steam AppID to use for this executable that differs from the games AppID. + + + Overwrite Steam AppID + + + + + + + false + + + Steam AppID to use for this executable that differs from the games AppID. + + + Steam AppID to use for this executable that differs from the games AppID. Every game/tool distributed through Steam has a unique ID. MO needs to know this ID to start those programs directly, otherwise the program is started by steam and then MO will not work. By default, MO will use the AppID for the game (usually 72850). Right now the only case I know of where this needs to be overwritten is for the Skyrim Creation Kit which has its own AppID (usually 202480). This overwrite is already preconfigured. - - - - - - - - - - - If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod. - - - Create Files in Mod instead of Overwrite (*) - - - - - - - false - - - - - - - - - - - If this is enabled, the configured libraries will be automatically loaded when this executable is launched. - - - Force Load Libraries (Profile Specific) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Configure Libraries - - - - + + + + + + + + + + + If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod. + + + Create Files in Mod instead of Overwrite (*) + + + + + + + false + + + + + + + + + + + If this is enabled, the configured libraries will be automatically loaded when this executable is launched. + + + Force Load Libraries (Profile Specific) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Configure Libraries + + + + + + + + + Use Application's Icon for shortcuts + + + + + - + + + + true + + - Use Application's Icon for shortcuts + This executable is provided by the game plugin + + + Qt::AlignCenter @@ -390,7 +405,7 @@ Right now the only case I know of where this needs to be overwritten is for the binaryEdit browseBinaryButton workingDirEdit - browseDirButton + browseWorkingDirButton overwriteAppIDBox appIDOverwriteEdit newFilesModCheckBox diff --git a/src/executableslist.cpp b/src/executableslist.cpp index d884bdf2..8174eb1b 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -65,8 +65,6 @@ bool ExecutablesList::empty() const void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings) { - addFromPlugin(game); - qDebug("setting up configured executables"); int numCustomExecutables = settings.beginReadArray("customExecutables"); @@ -91,6 +89,8 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings) } settings.endArray(); + + addFromPlugin(game); } void ExecutablesList::store(QSettings& settings) -- cgit v1.3.1