diff options
Diffstat (limited to 'src/instancemanager.h')
| -rw-r--r-- | src/instancemanager.h | 110 |
1 files changed, 67 insertions, 43 deletions
diff --git a/src/instancemanager.h b/src/instancemanager.h index 649c2195..79f1f30b 100644 --- a/src/instancemanager.h +++ b/src/instancemanager.h @@ -1,72 +1,96 @@ -/* -Copyright (C) 2016 Sebastian Herbord. All rights reserved. +#ifndef MODORGANIZER_INSTANCEMANAGER_INCLUDED +#define MODORGANIZER_INSTANCEMANAGER_INCLUDED -This file is part of Mod Organizer. +#include <QString> +#include <QSettings> -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +namespace MOBase { class IPluginGame; } -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +class Settings; +class PluginContainer; -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. -*/ +class Instance +{ +public: + enum class SetupResults + { + Ok, + BadIni, + IniMissingGame, + PluginGone, + GameGone, + MissingVariant + }; -#pragma once + Instance(QDir dir, bool portable, QString profileName={}); + SetupResults setup(PluginContainer& plugins); -#include <QString> -#include <QSettings> + void setGame(const QString& name, const QString& dir); + void setVariant(const QString& name); + QString name() const; + QString gameName() const; + QString gameDirectory() const; + QDir directory() const; + MOBase::IPluginGame* gamePlugin() const; + QString profileName() const; + QString iniPath() const; + bool isPortable() const; -class InstanceManager { +private: + QDir m_dir; + bool m_portable; + QString m_gameName, m_gameDir, m_gameVariant; + MOBase::IPluginGame* m_plugin; + QString m_profile; -public: + SetupResults getGamePlugin(PluginContainer& plugins); + void getProfile(const Settings& s); +}; - static InstanceManager &instance(); - QString determineDataPath(); - void clearCurrentInstance(); +class InstanceManager +{ +public: + static InstanceManager& singleton(); void overrideInstance(const QString& instanceName); + void overrideProfile(const QString& profileName); - QString currentInstance() const; + const MOBase::IPluginGame* gamePluginForDirectory( + const QDir& dir, const PluginContainer& plugins) const; + + void clearCurrentInstance(); + std::optional<Instance> currentInstance() const; + void setCurrentInstance(const QString &name); bool allowedToChangeInstance() const; static bool isPortablePath(const QString& dataPath); + static QString portablePath(); + bool portableInstanceExists() const; -private: - - InstanceManager(); - - QString instancePath() const; - - QStringList instances() const; - - bool deleteLocalInstance(const QString &instanceId) const; - - QString manageInstances(const QStringList &instanceList) const; + QString instancesPath() const; + QStringList instanceNames() const; + std::vector<QDir> instancePaths() const; QString sanitizeInstanceName(const QString &name) const; - void setCurrentInstance(const QString &name); - - QString queryInstanceName(const QStringList &instanceList) const; - QString chooseInstance(const QStringList &instanceList) const; + QString makeUniqueName(const QString& instanceName) const; + bool instanceExists(const QString& instanceName) const; + bool validInstanceName(const QString& instanceName) const; + QString instancePath(const QString& instanceName) const; + static QString iniPath(const QDir& instanceDir); - void createDataPath(const QString &dataPath) const; - bool portableInstall() const; +private: + InstanceManager(); bool portableInstallIsLocked() const; private: - - QSettings m_AppSettings; - bool m_Reset {false}; bool m_overrideInstance{false}; QString m_overrideInstanceName; + bool m_overrideProfile{false}; + QString m_overrideProfileName; }; + +#endif // MODORGANIZER_INSTANCEMANAGER_INCLUDED |
