summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-11-21 14:45:30 +0100
committerTannin <devnull@localhost>2014-11-21 14:45:30 +0100
commitf2f9e11fdd876821107cff0c1c5b9d8ecf66691f (patch)
treeac27533947a8f7a28545cf1f1901647242c03b53 /src/main.cpp
parentd23466f036618760de16ee874a3c076f05fe6087 (diff)
- started on a refactoring moving functionality out of the MainWindow class
- started on support for game-plugins
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b4139f09..f292eac7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,6 +42,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <inject.h>
#include <appconfig.h>
#include <utility.h>
+#include <scopeguard.h>
#include <stdexcept>
#include "mainwindow.h"
#include "report.h"
@@ -398,6 +399,11 @@ int main(int argc, char *argv[])
QSettings settings(dataPath + "/ModOrganizer.ini", QSettings::IniFormat);
+ OrganizerCore organizer(settings);
+
+ PluginContainer pluginContainer(&organizer);
+ pluginContainer.loadPlugins();
+
QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray());
bool done = false;
@@ -473,9 +479,7 @@ int main(int argc, char *argv[])
#pragma message("edition isn't used?")
qDebug("managing game at %s", qPrintable(QDir::toNativeSeparators(gamePath)));
- ExecutablesList executablesList;
-
- executablesList.init();
+ organizer.updateExecutablesList(settings);
if (!bootstrap()) { // requires gameinfo to be initialised!
return -1;
@@ -483,24 +487,6 @@ int main(int argc, char *argv[])
cleanupDir();
- qDebug("setting up configured executables");
-
- int numCustomExecutables = settings.beginReadArray("customExecutables");
- for (int i = 0; i < numCustomExecutables; ++i) {
- settings.setArrayIndex(i);
- CloseMOStyle closeMO = settings.value("closeOnStart").toBool() ? DEFAULT_CLOSE : DEFAULT_STAY;
- executablesList.addExecutable(settings.value("title").toString(),
- settings.value("binary").toString(),
- settings.value("arguments").toString(),
- settings.value("workingDirectory", "").toString(),
- closeMO,
- settings.value("steamAppID", "").toString(),
- settings.value("custom", true).toBool(),
- settings.value("toolbar", false).toBool());
- }
-
- settings.endArray();
-
qDebug("initializing tutorials");
TutorialManager::init(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getTutorialDir())).append("/"));
@@ -512,11 +498,11 @@ int main(int argc, char *argv[])
int res = 1;
{ // scope to control lifetime of mainwindow
// set up main window and its data structures
- MainWindow mainWindow(argv[0], settings);
+ MainWindow mainWindow(argv[0], settings, organizer, pluginContainer);
+
QObject::connect(&mainWindow, SIGNAL(styleChanged(QString)), &application, SLOT(setStyleFile(QString)));
- QObject::connect(&instance, SIGNAL(messageSent(QString)), &mainWindow, SLOT(externalMessage(QString)));
+ QObject::connect(&instance, SIGNAL(messageSent(QString)), &organizer, SLOT(externalMessage(QString)));
- mainWindow.setExecutablesList(executablesList);
mainWindow.readSettings();
QString selectedProfileName = QString::fromUtf8(settings.value("selected_profile", "").toByteArray());
@@ -571,7 +557,7 @@ int main(int argc, char *argv[])
if ((arguments.size() > 1) &&
(isNxmLink(arguments.at(1)))) {
qDebug("starting download from command line: %s", qPrintable(arguments.at(1)));
- mainWindow.externalMessage(arguments.at(1));
+ organizer.externalMessage(arguments.at(1));
}
splash.finish(&mainWindow);
res = application.exec();