mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-03 19:41:32 +00:00
Merge branch 'launcher_log' into 'master'
Setup launcher configuration manager and logging before initializing UI See merge request OpenMW/openmw!2851
This commit is contained in:
commit
1741a06cd1
9 changed files with 35 additions and 25 deletions
|
@ -122,7 +122,7 @@ namespace Launcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
Launcher::DataFilesPage::DataFilesPage(const Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
||||||
Config::LauncherSettings& launcherSettings, MainDialog* parent)
|
Config::LauncherSettings& launcherSettings, MainDialog* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, mMainDialog(parent)
|
, mMainDialog(parent)
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Launcher
|
||||||
Ui::DataFilesPage ui;
|
Ui::DataFilesPage ui;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DataFilesPage(Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
explicit DataFilesPage(const Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
||||||
Config::LauncherSettings& launcherSettings, MainDialog* parent = nullptr);
|
Config::LauncherSettings& launcherSettings, MainDialog* parent = nullptr);
|
||||||
|
|
||||||
QAbstractItemModel* profilesModel() const;
|
QAbstractItemModel* profilesModel() const;
|
||||||
|
@ -104,7 +104,7 @@ namespace Launcher
|
||||||
TextInputDialog* mNewProfileDialog;
|
TextInputDialog* mNewProfileDialog;
|
||||||
TextInputDialog* mCloneProfileDialog;
|
TextInputDialog* mCloneProfileDialog;
|
||||||
|
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
const Files::ConfigurationManager& mCfgMgr;
|
||||||
|
|
||||||
Config::GameSettings& mGameSettings;
|
Config::GameSettings& mGameSettings;
|
||||||
Config::LauncherSettings& mLauncherSettings;
|
Config::LauncherSettings& mLauncherSettings;
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/files/qtconversion.hpp>
|
#include <components/files/qtconversion.hpp>
|
||||||
|
|
||||||
#include "utils/textinputdialog.hpp"
|
#include "utils/textinputdialog.hpp"
|
||||||
|
|
||||||
using namespace Process;
|
using namespace Process;
|
||||||
|
|
||||||
Launcher::ImportPage::ImportPage(Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
Launcher::ImportPage::ImportPage(const Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
||||||
Config::LauncherSettings& launcherSettings, MainDialog* parent)
|
Config::LauncherSettings& launcherSettings, MainDialog* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, mCfgMgr(cfg)
|
, mCfgMgr(cfg)
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Launcher
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImportPage(Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
explicit ImportPage(const Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings,
|
||||||
Config::LauncherSettings& launcherSettings, MainDialog* parent = nullptr);
|
Config::LauncherSettings& launcherSettings, MainDialog* parent = nullptr);
|
||||||
~ImportPage() override;
|
~ImportPage() override;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ namespace Launcher
|
||||||
Process::ProcessInvoker* mWizardInvoker;
|
Process::ProcessInvoker* mWizardInvoker;
|
||||||
Process::ProcessInvoker* mImporterInvoker;
|
Process::ProcessInvoker* mImporterInvoker;
|
||||||
|
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
const Files::ConfigurationManager& mCfgMgr;
|
||||||
|
|
||||||
Config::GameSettings& mGameSettings;
|
Config::GameSettings& mGameSettings;
|
||||||
Config::LauncherSettings& mLauncherSettings;
|
Config::LauncherSettings& mLauncherSettings;
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include <boost/program_options/options_description.hpp>
|
||||||
|
#include <boost/program_options/variables_map.hpp>
|
||||||
|
|
||||||
#include <components/debug/debugging.hpp>
|
#include <components/debug/debugging.hpp>
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/platform/platform.hpp>
|
#include <components/platform/platform.hpp>
|
||||||
|
|
||||||
#ifdef MAC_OS_X_VERSION_MIN_REQUIRED
|
#ifdef MAC_OS_X_VERSION_MIN_REQUIRED
|
||||||
|
@ -18,6 +22,14 @@ int runLauncher(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Platform::init();
|
Platform::init();
|
||||||
|
|
||||||
|
boost::program_options::variables_map variables;
|
||||||
|
boost::program_options::options_description description;
|
||||||
|
Files::ConfigurationManager configurationManager;
|
||||||
|
configurationManager.addCommonOptions(description);
|
||||||
|
configurationManager.readConfiguration(variables, description, true);
|
||||||
|
|
||||||
|
setupLogging(configurationManager.getLogPath(), "Launcher");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -34,7 +46,7 @@ int runLauncher(int argc, char* argv[])
|
||||||
|
|
||||||
QDir::setCurrent(dir.absolutePath());
|
QDir::setCurrent(dir.absolutePath());
|
||||||
|
|
||||||
Launcher::MainDialog mainWin;
|
Launcher::MainDialog mainWin(configurationManager);
|
||||||
|
|
||||||
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
Launcher::FirstRunDialogResult result = mainWin.showFirstRunDialog();
|
||||||
if (result == Launcher::FirstRunDialogResultFailure)
|
if (result == Launcher::FirstRunDialogResultFailure)
|
||||||
|
@ -47,9 +59,9 @@ int runLauncher(int argc, char* argv[])
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
Log(Debug::Error) << "Unexpected exception: " << e.what();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "maindialog.hpp"
|
#include "maindialog.hpp"
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/files/conversion.hpp>
|
#include <components/files/conversion.hpp>
|
||||||
#include <components/files/qtconversion.hpp>
|
#include <components/files/qtconversion.hpp>
|
||||||
#include <components/misc/helpviewer.hpp>
|
#include <components/misc/helpviewer.hpp>
|
||||||
|
@ -13,9 +14,6 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
#include <boost/program_options/options_description.hpp>
|
|
||||||
#include <boost/program_options/variables_map.hpp>
|
|
||||||
|
|
||||||
#include <components/debug/debugging.hpp>
|
#include <components/debug/debugging.hpp>
|
||||||
#include <components/files/conversion.hpp>
|
#include <components/files/conversion.hpp>
|
||||||
#include <components/files/qtconfigpath.hpp>
|
#include <components/files/qtconfigpath.hpp>
|
||||||
|
@ -39,8 +37,9 @@ void cfgError(const QString& title, const QString& msg)
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher::MainDialog::MainDialog(QWidget* parent)
|
Launcher::MainDialog::MainDialog(const Files::ConfigurationManager& configurationManager, QWidget* parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
, mCfgMgr(configurationManager)
|
||||||
, mGameSettings(mCfgMgr)
|
, mGameSettings(mCfgMgr)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -418,12 +417,7 @@ bool Launcher::MainDialog::setupGraphicsSettings()
|
||||||
Settings::Manager::clear(); // Ensure to clear previous settings in case we had already loaded settings.
|
Settings::Manager::clear(); // Ensure to clear previous settings in case we had already loaded settings.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::program_options::variables_map variables;
|
|
||||||
boost::program_options::options_description desc;
|
|
||||||
mCfgMgr.addCommonOptions(desc);
|
|
||||||
mCfgMgr.readConfiguration(variables, desc, true);
|
|
||||||
Settings::Manager::load(mCfgMgr);
|
Settings::Manager::load(mCfgMgr);
|
||||||
setupLogging(mCfgMgr.getLogPath(), "Launcher");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#define MAINDIALOG_H
|
#define MAINDIALOG_H
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include <components/files/configurationmanager.hpp>
|
|
||||||
|
|
||||||
#include <components/process/processinvoker.hpp>
|
#include <components/process/processinvoker.hpp>
|
||||||
|
|
||||||
#include <components/config/gamesettings.hpp>
|
#include <components/config/gamesettings.hpp>
|
||||||
|
@ -17,6 +15,11 @@ class QStackedWidget;
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
|
namespace Files
|
||||||
|
{
|
||||||
|
struct ConfigurationManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Launcher
|
namespace Launcher
|
||||||
{
|
{
|
||||||
class GraphicsPage;
|
class GraphicsPage;
|
||||||
|
@ -41,7 +44,7 @@ namespace Launcher
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainDialog(QWidget* parent = nullptr);
|
explicit MainDialog(const Files::ConfigurationManager& configurationManager, QWidget* parent = nullptr);
|
||||||
~MainDialog() override;
|
~MainDialog() override;
|
||||||
|
|
||||||
FirstRunDialogResult showFirstRunDialog();
|
FirstRunDialogResult showFirstRunDialog();
|
||||||
|
@ -93,7 +96,7 @@ namespace Launcher
|
||||||
Process::ProcessInvoker* mGameInvoker;
|
Process::ProcessInvoker* mGameInvoker;
|
||||||
Process::ProcessInvoker* mWizardInvoker;
|
Process::ProcessInvoker* mWizardInvoker;
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
const Files::ConfigurationManager& mCfgMgr;
|
||||||
|
|
||||||
Config::GameSettings mGameSettings;
|
Config::GameSettings mGameSettings;
|
||||||
Config::LauncherSettings mLauncherSettings;
|
Config::LauncherSettings mLauncherSettings;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::GameSettings::GameSettings(Files::ConfigurationManager& cfg)
|
Config::GameSettings::GameSettings(const Files::ConfigurationManager& cfg)
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Config
|
||||||
class GameSettings
|
class GameSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameSettings(Files::ConfigurationManager& cfg);
|
explicit GameSettings(const Files::ConfigurationManager& cfg);
|
||||||
|
|
||||||
inline QString value(const QString& key, const QString& defaultValue = QString())
|
inline QString value(const QString& key, const QString& defaultValue = QString())
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ namespace Config
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
const Files::ConfigurationManager& mCfgMgr;
|
||||||
|
|
||||||
void validatePaths();
|
void validatePaths();
|
||||||
QMultiMap<QString, QString> mSettings;
|
QMultiMap<QString, QString> mSettings;
|
||||||
|
|
Loading…
Reference in a new issue