summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-11-07 16:51:55 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2020-11-07 20:16:26 -0500
commitd288587b002b19c54dc08d08ae267d301aa2ac81 (patch)
treec4b6df6d09d3235d19457d4544c43c5a269aaa3a /src/main.cpp
parenta8187e7dc47cd344fd309a2be3675e4687f95aaa (diff)
moved instance setup/selection to instancemanager.cpp
comments
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp181
1 files changed, 3 insertions, 178 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a8ea2601..fdd09872 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,20 +34,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "commandline.h"
#include "shared/util.h"
#include "shared/appconfig.h"
-
+#include "shared/error_report.h"
#include <imoinfo.h>
#include <report.h>
#include <usvfs.h>
#include <log.h>
#include <utility.h>
-// see addDllsToPath() below
-#pragma comment(linker, "/manifestDependency:\"" \
- "name='dlls' " \
- "processorArchitecture='x86' " \
- "version='1.0.0.0' " \
- "type='win32' \"")
-
using namespace MOBase;
using namespace MOShared;
@@ -171,174 +164,6 @@ std::optional<int> handleCommandLine(
return {};
}
-std::optional<Instance> selectInstance()
-{
- auto& m = InstanceManager::singleton();
-
- NexusInterface ni(nullptr);
- PluginContainer pc(nullptr);
- pc.loadPlugins();
-
- if (!m.hasAnyInstances()) {
- // no instances configured
- CreateInstanceDialog dlg(pc, nullptr);
- if (dlg.exec() != QDialog::Accepted) {
- return {};
- }
-
- return m.currentInstance();
- }
-
-
- InstanceManagerDialog dlg(pc);
- dlg.setRestartOnSelect(false);
-
- dlg.show();
- dlg.activateWindow();
- dlg.raise();
-
- if (dlg.exec() != QDialog::Accepted) {
- return {};
- }
-
- return m.currentInstance();
-}
-
-enum class SetupInstanceResults
-{
- Ok,
- TryAgain,
- SelectAnother,
- Exit
-};
-
-
-void criticalOnTop(const QString& message)
-{
- QMessageBox mb(QMessageBox::Critical, QObject::tr("Mod Organizer"), message);
-
- mb.show();
- mb.activateWindow();
- mb.raise();
- mb.exec();
-}
-
-
-SetupInstanceResults setupInstance(Instance& instance, PluginContainer& pc)
-{
- const auto setupResult = instance.setup(pc);
-
- switch (setupResult)
- {
- case Instance::SetupResults::Ok:
- {
- return SetupInstanceResults::Ok;
- }
-
- case Instance::SetupResults::BadIni:
- {
- criticalOnTop(
- QObject::tr("Cannot open instance '%1', failed to read INI file %2.")
- .arg(instance.name()).arg(instance.iniPath()));
-
- return SetupInstanceResults::SelectAnother;
- }
-
- case Instance::SetupResults::IniMissingGame:
- {
- criticalOnTop(
- QObject::tr(
- "Cannot open instance '%1', the managed game was not found in the INI "
- "file %2. Select the game managed by this instance.")
- .arg(instance.name()).arg(instance.iniPath()));
-
- CreateInstanceDialog dlg(pc, nullptr);
- dlg.setSinglePage<cid::GamePage>(instance.name());
-
- dlg.show();
- dlg.activateWindow();
- dlg.raise();
-
- if (dlg.exec() != QDialog::Accepted) {
- return SetupInstanceResults::Exit;
- }
-
- instance.setGame(
- dlg.creationInfo().game->gameName(),
- dlg.creationInfo().gameLocation);
-
- return SetupInstanceResults::TryAgain;
- }
-
- case Instance::SetupResults::PluginGone:
- {
- criticalOnTop(
- QObject::tr(
- "Cannot open instance '%1', the game plugin '%2' doesn't exist. It "
- "may have been deleted by an antivirus. Select another instance.")
- .arg(instance.name()).arg(instance.gameName()));
-
- return SetupInstanceResults::SelectAnother;
- }
-
- case Instance::SetupResults::GameGone:
- {
- criticalOnTop(
- QObject::tr(
- "Cannot open instance '%1', the game directory '%2' doesn't exist or "
- "the game plugin '%3' doesn't recognize it. Select the game managed "
- "by this instance.")
- .arg(instance.name())
- .arg(instance.gameDirectory())
- .arg(instance.gameName()));
-
- CreateInstanceDialog dlg(pc, nullptr);
- dlg.setSinglePage<cid::GamePage>(instance.name());
-
- dlg.show();
- dlg.activateWindow();
- dlg.raise();
-
- if (dlg.exec() != QDialog::Accepted) {
- return SetupInstanceResults::Exit;
- }
-
- instance.setGame(
- dlg.creationInfo().game->gameName(),
- dlg.creationInfo().gameLocation);
-
- return SetupInstanceResults::TryAgain;
- }
-
- case Instance::SetupResults::MissingVariant:
- {
- CreateInstanceDialog dlg(pc, nullptr);
-
- dlg.getPage<cid::GamePage>()->select(
- instance.gamePlugin(), instance.gameDirectory());
-
- dlg.setSinglePage<cid::VariantsPage>(instance.name());
-
- dlg.show();
- dlg.activateWindow();
- dlg.raise();
-
- if (dlg.exec() != QDialog::Accepted) {
- return SetupInstanceResults::Exit;
- }
-
- instance.setVariant(dlg.creationInfo().gameVariant);
-
- return SetupInstanceResults::TryAgain;
- }
-
- default:
- {
- return SetupInstanceResults::Exit;
- }
- }
-}
-
int runApplication(
MOApplication &application, const cl::CommandLine& cl,
SingleInstance &instance, const QString &dataPath,
@@ -561,11 +386,11 @@ int doOneRun(
// the previously used instance doesn't exist anymore
if (m.hasAnyInstances()) {
- criticalOnTop(QObject::tr(
+ MOShared::criticalOnTop(QObject::tr(
"Instance at '%1' not found. Select another instance.")
.arg(currentInstance->directory()));
} else {
- criticalOnTop(QObject::tr(
+ MOShared::criticalOnTop(QObject::tr(
"Instance at '%1' not found. You must create a new instance")
.arg(currentInstance->directory()));
}