From 2e0cbf393a5320dbf5448ca44a9b5905314b0be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 29 Jul 2013 00:59:35 +0200 Subject: [PATCH] Massive renaming in the backend folder, all around restructure in the same. --- .../src/appsettings.cpp => AppSettings.cpp | 2 +- .../include/appsettings.h => AppSettings.h | 9 +- libmultimc/src/version.cpp => AppVersion.cpp | 2 +- libmultimc/include/version.h => AppVersion.h | 8 +- CMakeLists.txt | 19 +- .../instance.cpp => backend/BaseInstance.cpp | 52 ++- .../instance.h => backend/BaseInstance.h | 57 +-- backend/CMakeLists.txt | 91 +++++ .../InstanceFactory.cpp | 20 +- .../InstanceFactory.h | 21 +- .../InstanceVersion.cpp | 4 +- .../InstanceVersion.h | 5 +- backend/LegacyInstance.cpp | 0 backend/LegacyInstance.h | 1 + .../MinecraftProcess.cpp | 54 +-- .../MinecraftProcess.h | 22 +- .../MinecraftVersion.cpp | 13 +- .../MinecraftVersion.h | 47 +-- backend/OneSixInstance.cpp | 0 backend/OneSixInstance.h | 1 + .../library.cpp => backend/OneSixVersion.cpp | 44 ++- .../library.h => backend/OneSixVersion.h | 89 ++++- .../VersionFactory.cpp | 16 +- .../VersionFactory.h | 0 .../include => backend}/libmmc_config.h | 5 +- .../lists/InstVersionList.cpp | 4 +- .../lists/InstVersionList.h | 5 +- .../lists/InstanceList.cpp | 25 +- .../lists/InstanceList.h | 11 +- .../lists/LwjglVersionList.cpp | 2 +- .../lists/LwjglVersionList.h | 4 +- .../lists/MinecraftVersionList.cpp | 4 +- .../lists/MinecraftVersionList.h | 11 +- .../tasks/GameUpdateTask.cpp | 18 +- .../tasks/GameUpdateTask.h | 14 +- .../tasks/LoginResponse.cpp | 2 +- .../tasks/LoginResponse.h | 4 +- .../tasks/LoginTask.cpp | 2 +- .../logintask.h => backend/tasks/LoginTask.h | 6 +- .../src/task.cpp => backend/tasks/Task.cpp | 2 +- .../include/task.h => backend/tasks/Task.h | 0 .../tasks/UserInfo.cpp | 2 +- .../userinfo.h => backend/tasks/UserInfo.h | 0 gui/consolewindow.h | 2 +- gui/instancemodel.cpp | 6 +- gui/instancemodel.h | 2 +- gui/legacymodeditdialog.cpp | 4 +- gui/legacymodeditdialog.h | 4 +- gui/lwjglselectdialog.cpp | 2 +- gui/mainwindow.cpp | 78 ++-- gui/mainwindow.h | 14 +- gui/modeditdialog.cpp | 4 +- gui/modeditdialog.h | 4 +- gui/modeditwindow.cpp | 4 +- gui/newinstancedialog.cpp | 10 +- gui/settingsdialog.cpp | 2 +- gui/taskdialog.cpp | 2 +- gui/versionselectdialog.cpp | 6 +- .../property_tree/detail/json_parser_read.hpp | 333 ------------------ libmultimc/CMakeLists.txt | 102 ------ libmultimc/include/fullversion.h | 76 ---- libmultimc/src/fullversion.cpp | 29 -- libutil/CMakeLists.txt | 2 +- libutil/include/cmdutils.h | 9 +- libutil/src/cmdutils.cpp | 50 +++ main.cpp | 10 +- 66 files changed, 491 insertions(+), 962 deletions(-) rename libmultimc/src/appsettings.cpp => AppSettings.cpp (98%) rename libmultimc/include/appsettings.h => AppSettings.h (82%) rename libmultimc/src/version.cpp => AppVersion.cpp (98%) rename libmultimc/include/version.h => AppVersion.h (92%) rename libmultimc/src/instance.cpp => backend/BaseInstance.cpp (82%) rename libmultimc/include/instance.h => backend/BaseInstance.h (89%) create mode 100644 backend/CMakeLists.txt rename libmultimc/src/instanceloader.cpp => backend/InstanceFactory.cpp (64%) rename libmultimc/include/instanceloader.h => backend/InstanceFactory.h (79%) rename libmultimc/src/instversion.cpp => backend/InstanceVersion.cpp (96%) rename libmultimc/include/instversion.h => backend/InstanceVersion.h (98%) create mode 100644 backend/LegacyInstance.cpp create mode 100644 backend/LegacyInstance.h rename libmultimc/src/minecraftprocess.cpp => backend/MinecraftProcess.cpp (84%) rename libmultimc/include/minecraftprocess.h => backend/MinecraftProcess.h (83%) rename libmultimc/src/minecraftversion.cpp => backend/MinecraftVersion.cpp (86%) rename libmultimc/include/minecraftversion.h => backend/MinecraftVersion.h (64%) create mode 100644 backend/OneSixInstance.cpp create mode 100644 backend/OneSixInstance.h rename libmultimc/src/library.cpp => backend/OneSixVersion.cpp (64%) rename libmultimc/include/library.h => backend/OneSixVersion.h (65%) rename libmultimc/src/fullversionfactory.cpp => backend/VersionFactory.cpp (95%) rename libmultimc/include/fullversionfactory.h => backend/VersionFactory.h (100%) rename {libmultimc/include => backend}/libmmc_config.h (88%) rename libmultimc/src/instversionlist.cpp => backend/lists/InstVersionList.cpp (97%) rename libmultimc/include/instversionlist.h => backend/lists/InstVersionList.h (98%) rename libmultimc/src/instancelist.cpp => backend/lists/InstanceList.cpp (90%) rename libmultimc/include/instancelist.h => backend/lists/InstanceList.h (92%) rename libmultimc/src/lwjglversionlist.cpp => backend/lists/LwjglVersionList.cpp (99%) rename libmultimc/include/lwjglversionlist.h => backend/lists/LwjglVersionList.h (97%) rename libmultimc/src/minecraftversionlist.cpp => backend/lists/MinecraftVersionList.cpp (99%) rename libmultimc/include/minecraftversionlist.h => backend/lists/MinecraftVersionList.h (93%) rename libmultimc/src/gameupdatetask.cpp => backend/tasks/GameUpdateTask.cpp (94%) rename libmultimc/include/gameupdatetask.h => backend/tasks/GameUpdateTask.h (92%) rename libmultimc/src/loginresponse.cpp => backend/tasks/LoginResponse.cpp (98%) rename libmultimc/include/loginresponse.h => backend/tasks/LoginResponse.h (96%) rename libmultimc/src/logintask.cpp => backend/tasks/LoginTask.cpp (99%) rename libmultimc/include/logintask.h => backend/tasks/LoginTask.h (93%) rename libmultimc/src/task.cpp => backend/tasks/Task.cpp (98%) rename libmultimc/include/task.h => backend/tasks/Task.h (100%) rename libmultimc/src/userinfo.cpp => backend/tasks/UserInfo.cpp (98%) rename libmultimc/include/userinfo.h => backend/tasks/UserInfo.h (100%) delete mode 100644 hacks/boost/property_tree/detail/json_parser_read.hpp delete mode 100644 libmultimc/CMakeLists.txt delete mode 100644 libmultimc/include/fullversion.h delete mode 100644 libmultimc/src/fullversion.cpp diff --git a/libmultimc/src/appsettings.cpp b/AppSettings.cpp similarity index 98% rename from libmultimc/src/appsettings.cpp rename to AppSettings.cpp index 7c886fdb..835d42ac 100644 --- a/libmultimc/src/appsettings.cpp +++ b/AppSettings.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "appsettings.h" +#include "AppSettings.h" #include diff --git a/libmultimc/include/appsettings.h b/AppSettings.h similarity index 82% rename from libmultimc/include/appsettings.h rename to AppSettings.h index 8447d58b..d8f21de1 100644 --- a/libmultimc/include/appsettings.h +++ b/AppSettings.h @@ -13,20 +13,17 @@ * limitations under the License. */ -#ifndef APPSETTINGS_H -#define APPSETTINGS_H +#pragma once #include #include -#include "libmmc_config.h" - -class LIBMULTIMC_EXPORT AppSettings : public INISettingsObject +class AppSettings : public INISettingsObject { Q_OBJECT public: explicit AppSettings(QObject *parent = 0); }; -#endif // APPSETTINGS_H + diff --git a/libmultimc/src/version.cpp b/AppVersion.cpp similarity index 98% rename from libmultimc/src/version.cpp rename to AppVersion.cpp index eec50e13..2db3da26 100644 --- a/libmultimc/src/version.cpp +++ b/AppVersion.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "version.h" +#include "AppVersion.h" #include "config.h" diff --git a/libmultimc/include/version.h b/AppVersion.h similarity index 92% rename from libmultimc/include/version.h rename to AppVersion.h index 3025260b..504f1d17 100644 --- a/libmultimc/include/version.h +++ b/AppVersion.h @@ -13,17 +13,14 @@ * limitations under the License. */ -#ifndef VERSION_H -#define VERSION_H +#pragma once #include -#include "libmmc_config.h" - /*! * \brief The Version class represents a MultiMC version number. */ -class LIBMULTIMC_EXPORT Version : public QObject +class Version : public QObject { Q_OBJECT public: @@ -66,4 +63,3 @@ public: static Version current; }; -#endif // VERSION_H diff --git a/CMakeLists.txt b/CMakeLists.txt index f8df3260..e858d888 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,6 @@ ENDIF() ################################ INCLUDE LIBRARIES ################################ -# First, include header overrides -include_directories(hacks) - ######## 3rd Party Libs ######## # Find the required Qt parts @@ -68,7 +65,7 @@ add_subdirectory(libsettings) include_directories(${LIBSETTINGS_INCLUDE_DIR}) # Add the instance library. -add_subdirectory(libmultimc) +add_subdirectory(backend) include_directories(${LIBMULTIMC_INCLUDE_DIR}) # Add the group view library. @@ -161,6 +158,10 @@ ADD_DEFINITIONS(-DQUAZIP_STATIC) ######## Headers ######## SET(MULTIMC_HEADERS +multimc_pragma.h +AppVersion.h +AppSettings.h + gui/mainwindow.h gui/modeditdialog.h gui/legacymodeditdialog.h @@ -178,8 +179,6 @@ gui/lwjglselectdialog.h gui/iconcache.h gui/instancesettings.h -multimc_pragma.h - java/annotations.h java/classfile.h java/constants.h @@ -193,6 +192,8 @@ java/membuffer.h ######## Sources ######## SET(MULTIMC_SOURCES main.cpp +AppVersion.cpp +AppSettings.cpp gui/mainwindow.cpp gui/modeditdialog.cpp @@ -270,9 +271,9 @@ ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 # Link QT5_USE_MODULES(MultiMC Widgets Network WebKitWidgets) TARGET_LINK_LIBRARIES(MultiMC quazip patchlib -libUtil libSettings libMultiMC libGroupView +libUtil libSettings backend libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS}) -ADD_DEPENDENCIES(MultiMC MultiMCLauncher libUtil libSettings libMultiMC libGroupView) +ADD_DEPENDENCIES(MultiMC MultiMCLauncher libUtil libSettings backend libGroupView) option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF) @@ -288,7 +289,7 @@ IF(BUILD_ASSET_TEST) # test.cpp ADD_EXECUTABLE(AssetTest asset_test.cpp) QT5_USE_MODULES(AssetTest Core Network) - TARGET_LINK_LIBRARIES(AssetTest libUtil libMultiMC libSettings) + TARGET_LINK_LIBRARIES(AssetTest libUtil backend libSettings) ENDIF() diff --git a/libmultimc/src/instance.cpp b/backend/BaseInstance.cpp similarity index 82% rename from libmultimc/src/instance.cpp rename to backend/BaseInstance.cpp index 5fdb5064..c2ffa664 100644 --- a/libmultimc/src/instance.cpp +++ b/backend/BaseInstance.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "include/instance.h" +#include "BaseInstance.h" #include @@ -22,19 +22,18 @@ #include "overridesetting.h" #include "pathutils.h" -#include +#include -Instance::Instance(const QString &rootDir, QObject *parent) : +BaseInstance::BaseInstance(const QString &rootDir, QObject *parent) : QObject(parent) { m_rootDir = rootDir; - m_settings = new INISettingsObject(configFile(), this); + m_settings = new INISettingsObject(PathCombine(rootDir, "instance.cfg"), this); settings().registerSetting(new Setting("name", "Unnamed Instance")); settings().registerSetting(new Setting("iconKey", "default")); settings().registerSetting(new Setting("notes", "")); settings().registerSetting(new Setting("NeedsRebuild", true)); - settings().registerSetting(new Setting("IsForNewLauncher", false)); settings().registerSetting(new Setting("ShouldUpdate", false)); settings().registerSetting(new Setting("JarVersion", "Unknown")); settings().registerSetting(new Setting("LwjglVersion", "2.9.0")); @@ -77,17 +76,17 @@ Instance::Instance(const QString &rootDir, QObject *parent) : settings().registerSetting(new Setting("OverrideCommands", false)); } -QString Instance::id() const +QString BaseInstance::id() const { return QFileInfo(rootDir()).fileName(); } -QString Instance::rootDir() const +QString BaseInstance::rootDir() const { return m_rootDir; } -InstanceList *Instance::instList() const +InstanceList *BaseInstance::instList() const { if (parent()->inherits("InstanceList")) return (InstanceList *)parent(); @@ -95,7 +94,7 @@ InstanceList *Instance::instList() const return NULL; } -QString Instance::minecraftDir() const +QString BaseInstance::minecraftDir() const { QFileInfo mcDir(PathCombine(rootDir(), "minecraft")); QFileInfo dotMCDir(PathCombine(rootDir(), ".minecraft")); @@ -106,78 +105,73 @@ QString Instance::minecraftDir() const return mcDir.filePath(); } -QString Instance::instModsDir() const +QString BaseInstance::instModsDir() const { return PathCombine(rootDir(), "instMods"); } -QString Instance::binDir() const +QString BaseInstance::binDir() const { return PathCombine(minecraftDir(), "bin"); } -QString Instance::savesDir() const +QString BaseInstance::savesDir() const { return PathCombine(minecraftDir(), "saves"); } -QString Instance::mlModsDir() const +QString BaseInstance::mlModsDir() const { return PathCombine(minecraftDir(), "mods"); } -QString Instance::coreModsDir() const +QString BaseInstance::coreModsDir() const { return PathCombine(minecraftDir(), "coremods"); } -QString Instance::resourceDir() const +QString BaseInstance::resourceDir() const { return PathCombine(minecraftDir(), "resources"); } -QString Instance::screenshotsDir() const +QString BaseInstance::screenshotsDir() const { return PathCombine(minecraftDir(), "screenshots"); } -QString Instance::texturePacksDir() const +QString BaseInstance::texturePacksDir() const { return PathCombine(minecraftDir(), "texturepacks"); } -QString Instance::mcJar() const +QString BaseInstance::mcJar() const { return PathCombine(binDir(), "minecraft.jar"); } -QString Instance::mcBackup() const +QString BaseInstance::mcBackup() const { return PathCombine(binDir(), "mcbackup.jar"); } -QString Instance::configFile() const -{ - return PathCombine(rootDir(), "instance.cfg"); -} - -QString Instance::modListFile() const +QString BaseInstance::modListFile() const { return PathCombine(rootDir(), "modlist"); } -InstVersionList *Instance::versionList() const +InstVersionList *BaseInstance::versionList() const { return &MinecraftVersionList::getMainList(); } -bool Instance::shouldUpdateCurrentVersion() const +bool BaseInstance::shouldUpdateCurrentVersion() const { QFileInfo jar(mcJar()); return jar.lastModified().toUTC().toMSecsSinceEpoch() != lastCurrentVersionUpdate(); } -void Instance::updateCurrentVersion(bool keepCurrent) +void BaseInstance::updateCurrentVersion(bool keepCurrent) { QFileInfo jar(mcJar()); @@ -199,7 +193,7 @@ void Instance::updateCurrentVersion(bool keepCurrent) } } -SettingsObject &Instance::settings() const +SettingsObject &BaseInstance::settings() const { return *m_settings; } diff --git a/libmultimc/include/instance.h b/backend/BaseInstance.h similarity index 89% rename from libmultimc/include/instance.h rename to backend/BaseInstance.h index 36db7ffb..51f55b5e 100644 --- a/libmultimc/include/instance.h +++ b/backend/BaseInstance.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef INSTANCE_H -#define INSTANCE_H +#pragma once #include #include @@ -22,7 +21,7 @@ #include #include "inifile.h" -#include "instversionlist.h" +#include "lists/InstVersionList.h" #include "libmmc_config.h" @@ -36,7 +35,7 @@ class InstanceList; * To create a new instance type, create a new class inheriting from this class * and implement the pure virtual functions. */ -class LIBMULTIMC_EXPORT Instance : public QObject +class LIBMULTIMC_EXPORT BaseInstance : public QObject { Q_OBJECT @@ -67,6 +66,14 @@ class LIBMULTIMC_EXPORT Instance : public QObject //! The instance's group. Q_PROPERTY(QString group READ group WRITE setGroup) + /*! + * Gets the time that the instance was last launched. + * Stored in milliseconds since epoch. + * This value is usually used for things like sorting instances by the time + * they were last launched. + */ + Q_PROPERTY(qint64 lastLaunch READ lastLaunch WRITE setLastLaunch) + /*! * Whether or not the instance's minecraft.jar needs to be rebuilt. * If this is true, when the instance launches, its jar mods will be @@ -100,14 +107,6 @@ class LIBMULTIMC_EXPORT Instance : public QObject Q_PROPERTY(QString lwjglVersion READ lwjglVersion WRITE setLWJGLVersion) - /*! - * Gets the time that the instance was last launched. - * Stored in milliseconds since epoch. - * This value is usually used for things like sorting instances by the time - * they were last launched. - */ - Q_PROPERTY(qint64 lastLaunch READ lastLaunch WRITE setLastLaunch) - /*! * Gets the last time that the current version was checked. * This is checked against the last modified time on the jar file to see if @@ -115,11 +114,6 @@ class LIBMULTIMC_EXPORT Instance : public QObject */ Q_PROPERTY(qint64 lastCurrentVersionUpdate READ lastCurrentVersionUpdate WRITE setLastCurrentVersionUpdate) - /*! - * Is the instance a new launcher instance? Get/Set - */ - Q_PROPERTY(bool isForNewLauncher READ isForNewLauncher WRITE setIsForNewLauncher) - // Dirs //! Path to the instance's .minecraft folder. Q_PROPERTY(QString minecraftDir READ minecraftDir STORED false) @@ -156,22 +150,11 @@ class LIBMULTIMC_EXPORT Instance : public QObject //! Path to the instance's mcbackup.jar Q_PROPERTY(QString mcBackup READ mcBackup STORED false) - //! Path to the instance's config file. - Q_PROPERTY(QString configFile READ configFile STORED false) - //! Path to the instance's modlist file. Q_PROPERTY(QString modListFile READ modListFile STORED false) public: - explicit Instance(const QString &rootDir, QObject *parent = 0); - - // Please, for the sake of my (and everyone else's) sanity, at least keep this shit - // *somewhat* organized. Also, documentation is semi-important here. Please don't - // leave undocumented stuff behind. - // As a side-note, doxygen processes comments for accessor functions and - // properties separately, so please document properties in the massive block of - // Q_PROPERTY declarations above rather than documenting their accessors. - + explicit BaseInstance(const QString &rootDir, QObject *parent = 0); //////// STUFF //////// virtual QString id() const; @@ -252,16 +235,6 @@ public: virtual qint64 lastCurrentVersionUpdate() const { return settings().get("lastVersionUpdate").value(); } virtual void setLastCurrentVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); } - virtual bool isForNewLauncher() - { - return settings().get("IsForNewLauncher").value(); - } - - virtual void setIsForNewLauncher(bool value = true) - { - settings().set("IsForNewLauncher", value); - } - ////// Directories ////// QString minecraftDir() const; QString instModsDir() const; @@ -277,7 +250,6 @@ public: ////// Files ////// QString mcJar() const; QString mcBackup() const; - QString configFile() const; QString modListFile() const; @@ -328,7 +300,7 @@ signals: /*! * \brief Signal emitted when properties relevant to the instance view change */ - void propertiesChanged(Instance * inst); + void propertiesChanged(BaseInstance * inst); private: QString m_rootDir; @@ -337,6 +309,5 @@ private: }; // pointer for lazy people -typedef QSharedPointer InstancePtr; +typedef QSharedPointer InstancePtr; -#endif // INSTANCE_H diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt new file mode 100644 index 00000000..a17b7dfe --- /dev/null +++ b/backend/CMakeLists.txt @@ -0,0 +1,91 @@ +project(libMultiMC) + +set(CMAKE_AUTOMOC ON) + +# Find Qt +find_package(Qt5Core REQUIRED) +find_package(Qt5Network REQUIRED) +find_package(Qt5Xml REQUIRED) + +# Include Qt headers. +include_directories(${Qt5Base_INCLUDE_DIRS}) +include_directories(${Qt5Network_INCLUDE_DIRS}) + +# Include utility library. +include_directories(${CMAKE_SOURCE_DIR}/libutil/include) + +# Include settings library. +include_directories(${CMAKE_SOURCE_DIR}/libsettings/include) + +SET(LIBINST_HEADERS +libmmc_config.h + +# Instance Stuff +BaseInstance.h +LegacyInstance.h +OneSixInstance.h +InstanceFactory.h + +# Versions +InstanceVersion.h +MinecraftVersion.h +OneSixVersion.h +VersionFactory.h + +# Lists +lists/InstanceList.h +lists/InstVersionList.h +lists/MinecraftVersionList.h +lists/LwjglVersionList.h + +# Tasks +tasks/Task.h +tasks/LoginTask.h +tasks/LoginResponse.h +tasks/UserInfo.h +tasks/GameUpdateTask.h + +MinecraftProcess.h +) + +SET(LIBINST_SOURCES +# Instance Stuff +BaseInstance.cpp +LegacyInstance.cpp +OneSixInstance.cpp +InstanceFactory.cpp + +# Versions +InstanceVersion.cpp +MinecraftVersion.cpp +OneSixVersion.cpp +VersionFactory.cpp + +# Lists +lists/InstanceList.cpp +lists/InstVersionList.cpp +lists/MinecraftVersionList.cpp +lists/LwjglVersionList.cpp + +# Tasks +tasks/Task.cpp +tasks/LoginTask.cpp +tasks/GameUpdateTask.cpp +tasks/UserInfo.cpp +tasks/LoginResponse.cpp + +MinecraftProcess.cpp +) + +# Set the include dir path. +SET(LIBMULTIMC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE) + +# Include self. +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_BINARY_DIR}/include) + +add_definitions(-DLIBMULTIMC_LIBRARY) + +add_library(backend SHARED ${LIBINST_SOURCES} ${LIBINST_HEADERS}) +qt5_use_modules(backend Core Network Xml) +target_link_libraries(backend libUtil libSettings) diff --git a/libmultimc/src/instanceloader.cpp b/backend/InstanceFactory.cpp similarity index 64% rename from libmultimc/src/instanceloader.cpp rename to backend/InstanceFactory.cpp index e30435a9..318650ae 100644 --- a/libmultimc/src/instanceloader.cpp +++ b/backend/InstanceFactory.cpp @@ -13,28 +13,28 @@ * limitations under the License. */ -#include "include/instanceloader.h" +#include "InstanceFactory.h" #include #include -#include "include/instance.h" +#include "BaseInstance.h" #include "inifile.h" #include "pathutils.h" -InstanceLoader InstanceLoader::loader; +InstanceFactory InstanceFactory::loader; -InstanceLoader::InstanceLoader() : +InstanceFactory::InstanceFactory() : QObject(NULL) { } -InstanceLoader::InstLoadError InstanceLoader::loadInstance(Instance *&inst, const QString &instDir) +InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst, const QString &instDir) { - Instance *loadedInst = new Instance(instDir, this); + BaseInstance *loadedInst = new BaseInstance(instDir, this); // TODO: Sanity checks to verify that the instance is valid. @@ -44,18 +44,18 @@ InstanceLoader::InstLoadError InstanceLoader::loadInstance(Instance *&inst, cons } -InstanceLoader::InstCreateError InstanceLoader::createInstance(Instance *&inst, const QString &instDir) +InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&inst, const QString &instDir) { QDir rootDir(instDir); qDebug(instDir.toUtf8()); if (!rootDir.exists() && !rootDir.mkpath(".")) { - return InstanceLoader::CantCreateDir; + return InstanceFactory::CantCreateDir; } - inst = new Instance(instDir, this); + inst = new BaseInstance(instDir, this); //FIXME: really, how do you even know? - return InstanceLoader::NoCreateError; + return InstanceFactory::NoCreateError; } diff --git a/libmultimc/include/instanceloader.h b/backend/InstanceFactory.h similarity index 79% rename from libmultimc/include/instanceloader.h rename to backend/InstanceFactory.h index af5bf92d..0dd4c5d8 100644 --- a/libmultimc/include/instanceloader.h +++ b/backend/InstanceFactory.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef INSTANCELOADER_H -#define INSTANCELOADER_H +#pragma once #include #include @@ -22,19 +21,19 @@ #include "libmmc_config.h" -class Instance; +class BaseInstance; /*! - * The InstanceLoader is a singleton that manages loading and creating instances. + * The \bInstanceFactory\b is a singleton that manages loading and creating instances. */ -class LIBMULTIMC_EXPORT InstanceLoader : public QObject +class LIBMULTIMC_EXPORT InstanceFactory : public QObject { Q_OBJECT public: /*! * \brief Gets a reference to the instance loader. */ - static InstanceLoader &get() { return loader; } + static InstanceFactory &get() { return loader; } enum InstLoadError { @@ -61,7 +60,7 @@ public: * - InstExists if the given instance directory is already an instance. * - CantCreateDir if the given instance directory cannot be created. */ - InstCreateError createInstance(Instance *&inst, const QString &instDir); + InstCreateError createInstance(BaseInstance *&inst, const QString &instDir); /*! * \brief Loads an instance from the given directory. @@ -71,12 +70,10 @@ public: * \return An InstLoadError error code. * - NotAnInstance if the given instance directory isn't a valid instance. */ - InstLoadError loadInstance(Instance *&inst, const QString &instDir); + InstLoadError loadInstance(BaseInstance *&inst, const QString &instDir); private: - InstanceLoader(); + InstanceFactory(); - static InstanceLoader loader; + static InstanceFactory loader; }; - -#endif // INSTANCELOADER_H diff --git a/libmultimc/src/instversion.cpp b/backend/InstanceVersion.cpp similarity index 96% rename from libmultimc/src/instversion.cpp rename to backend/InstanceVersion.cpp index 4e42c364..1b9b0a5b 100644 --- a/libmultimc/src/instversion.cpp +++ b/backend/InstanceVersion.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "include/instversion.h" -#include "include/instversionlist.h" +#include "InstanceVersion.h" +#include "lists/InstVersionList.h" InstVersion::InstVersion(const QString &descriptor, const QString &name, diff --git a/libmultimc/include/instversion.h b/backend/InstanceVersion.h similarity index 98% rename from libmultimc/include/instversion.h rename to backend/InstanceVersion.h index af632939..5ebae41e 100644 --- a/libmultimc/include/instversion.h +++ b/backend/InstanceVersion.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef INSTVERSION_H -#define INSTVERSION_H +#pragma once #include @@ -120,5 +119,3 @@ protected: QString m_name; qint64 m_timestamp; }; - -#endif // INSTVERSION_H diff --git a/backend/LegacyInstance.cpp b/backend/LegacyInstance.cpp new file mode 100644 index 00000000..e69de29b diff --git a/backend/LegacyInstance.h b/backend/LegacyInstance.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/backend/LegacyInstance.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/libmultimc/src/minecraftprocess.cpp b/backend/MinecraftProcess.cpp similarity index 84% rename from libmultimc/src/minecraftprocess.cpp rename to backend/MinecraftProcess.cpp index e8b9959e..e53feb5b 100644 --- a/libmultimc/src/minecraftprocess.cpp +++ b/backend/MinecraftProcess.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "minecraftprocess.h" +#include "MinecraftProcess.h" #include #include @@ -23,57 +23,17 @@ //#include #include -#include "instance.h" +#include "BaseInstance.h" #include "osutils.h" #include "pathutils.h" +#include "cmdutils.h" #define LAUNCHER_FILE "MultiMCLauncher.jar" #define IBUS "@im=ibus" -// commandline splitter -QStringList MinecraftProcess::splitArgs(QString args) -{ - QStringList argv; - QString current; - bool escape = false; - QChar inquotes; - for (int i=0; iiconKey()).save(destination); } @@ -83,14 +43,14 @@ inline void MinecraftProcess::extractLauncher(QString destination) QFile(":/launcher/launcher.jar").copy(destination); } -void MinecraftProcess::prepare(Instance *inst) +void MinecraftProcess::prepare(BaseInstance *inst) { extractLauncher(PathCombine(inst->minecraftDir(), LAUNCHER_FILE)); extractIcon(inst, PathCombine(inst->minecraftDir(), "icon.png")); } // constructor -MinecraftProcess::MinecraftProcess(Instance *inst, QString user, QString session) : +MinecraftProcess::MinecraftProcess(BaseInstance *inst, QString user, QString session) : m_instance(inst), m_user(user), m_session(session) { connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(finish(int, QProcess::ExitStatus))); @@ -245,7 +205,7 @@ void MinecraftProcess::genArgs() windowTitle.append("MultiMC: ").append(m_instance->name()); // Java arguments - m_arguments.append(splitArgs(m_instance->settings().get("JvmArgs").toString())); + m_arguments.append(Util::Commandline::splitArgs(m_instance->settings().get("JvmArgs").toString())); #ifdef OSX // OSX dock icon and name diff --git a/libmultimc/include/minecraftprocess.h b/backend/MinecraftProcess.h similarity index 83% rename from libmultimc/include/minecraftprocess.h rename to backend/MinecraftProcess.h index eb861236..c846f5f4 100644 --- a/libmultimc/include/minecraftprocess.h +++ b/backend/MinecraftProcess.h @@ -14,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINECRAFTPROCESS_H -#define MINECRAFTPROCESS_H +#pragma once #include -#include "instance.h" +#include "BaseInstance.h" #include "libmmc_config.h" @@ -54,7 +53,7 @@ public: * @param session the minecraft session id * @param console the instance console window */ - MinecraftProcess(Instance *inst, QString user, QString session); + MinecraftProcess(BaseInstance *inst, QString user, QString session); /** * @brief launch minecraft @@ -66,7 +65,7 @@ public: * @param inst the instance * @param destination the destination path */ - static inline void extractIcon(Instance *inst, QString destination); + static inline void extractIcon(BaseInstance *inst, QString destination); /** * @brief extract the MultiMC launcher.jar @@ -78,14 +77,7 @@ public: * @brief prepare the launch by extracting icon and launcher * @param inst the instance */ - static void prepare(Instance *inst); - - /** - * @brief split a string into argv items like a shell would do - * @param args the argument string - * @return a QStringList containing all arguments - */ - static QStringList splitArgs(QString args); + static void prepare(BaseInstance *inst); signals: /** @@ -101,7 +93,7 @@ signals: void log(QString text, MessageLevel::Enum level=MessageLevel::MultiMC); protected: - Instance *m_instance; + BaseInstance *m_instance; QString m_user; QString m_session; QString m_err_leftover; @@ -117,5 +109,3 @@ protected slots: void on_stdOut(); }; - -#endif // MINECRAFTPROCESS_H diff --git a/libmultimc/src/minecraftversion.cpp b/backend/MinecraftVersion.cpp similarity index 86% rename from libmultimc/src/minecraftversion.cpp rename to backend/MinecraftVersion.cpp index 36ba87f8..6f3b1b86 100644 --- a/libmultimc/src/minecraftversion.cpp +++ b/backend/MinecraftVersion.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "minecraftversion.h" +#include "MinecraftVersion.h" MinecraftVersion::MinecraftVersion(QString descriptor, QString name, @@ -23,7 +23,6 @@ MinecraftVersion::MinecraftVersion(QString descriptor, InstVersionList *parent) : InstVersion(descriptor, name, timestamp, parent), m_dlUrl(dlUrl), m_etag(etag) { - m_isNewLauncherVersion = false; } QString MinecraftVersion::descriptor() const @@ -85,14 +84,14 @@ QString MinecraftVersion::etag() const return m_etag; } -MinecraftVersion::LauncherVersion MinecraftVersion::launcherVersion() const +MinecraftVersion::VersionSource MinecraftVersion::versionSource() const { - return m_launcherVersion; + return m_versionSource; }; -void MinecraftVersion::setLauncherVersion(LauncherVersion launcherVersion) +void MinecraftVersion::setVersionSource(VersionSource launcherVersion) { - m_launcherVersion = launcherVersion; + m_versionSource = launcherVersion; } InstVersion *MinecraftVersion::copyVersion(InstVersionList *newParent) const @@ -100,6 +99,6 @@ InstVersion *MinecraftVersion::copyVersion(InstVersionList *newParent) const MinecraftVersion *version = new MinecraftVersion( descriptor(), name(), timestamp(), downloadURL(), etag(), newParent); version->setVersionType(versionType()); - version->setLauncherVersion(launcherVersion()); + version->setVersionSource(VersionSource()); return version; } diff --git a/libmultimc/include/minecraftversion.h b/backend/MinecraftVersion.h similarity index 64% rename from libmultimc/include/minecraftversion.h rename to backend/MinecraftVersion.h index 6f9b7879..a69b4710 100644 --- a/libmultimc/include/minecraftversion.h +++ b/backend/MinecraftVersion.h @@ -13,38 +13,16 @@ * limitations under the License. */ -#ifndef MINECRAFTVERSION_H -#define MINECRAFTVERSION_H +#pragma once #include "libmmc_config.h" -#include "instversion.h" +#include "InstanceVersion.h" class LIBMULTIMC_EXPORT MinecraftVersion : public InstVersion { Q_OBJECT - /*! - * This version's type. Used internally to identify what kind of version this is. - */ - Q_PROPERTY(VersionType versionType READ versionType WRITE setVersionType) - - /*! - * This version's launcher. Used to identify the launcher version this is intended for. - */ - Q_PROPERTY(LauncherVersion versionType READ launcherVersion WRITE setLauncherVersion) - - /*! - * The URL that this version will be downloaded from. - */ - Q_PROPERTY(QString downloadURL READ downloadURL) - - /*! - * ETag/MD5 Used to verify the integrity of the downloaded minecraft.jar. - */ - Q_PROPERTY(QString etag READ etag) - - public: explicit MinecraftVersion(QString descriptor, QString name, @@ -64,7 +42,7 @@ public: MCNostalgia }; - enum LauncherVersion + enum VersionSource { Unknown = -1, Legacy = 0, // the legacy launcher that's been around since ... forever @@ -79,8 +57,8 @@ public: virtual VersionType versionType() const; virtual void setVersionType(VersionType typeName); - virtual LauncherVersion launcherVersion() const; - virtual void setLauncherVersion(LauncherVersion launcherVersion); + virtual VersionSource versionSource() const; + virtual void setVersionSource(VersionSource launcherVersion); virtual QString downloadURL() const; virtual QString etag() const; @@ -88,12 +66,15 @@ public: virtual InstVersion *copyVersion(InstVersionList *newParent) const; private: + /// The URL that this version will be downloaded from. maybe. QString m_dlUrl; - QString m_etag; - VersionType m_type; - LauncherVersion m_launcherVersion; - bool m_isNewLauncherVersion; + /// ETag/MD5 Used to verify the integrity of the downloaded minecraft.jar. + QString m_etag; + + /// This version's type. Used internally to identify what kind of version this is. + VersionType m_type; + + /// Whete to get the full version info (or, where did we get this version from originally) + VersionSource m_versionSource; }; - -#endif // MINECRAFTVERSION_H diff --git a/backend/OneSixInstance.cpp b/backend/OneSixInstance.cpp new file mode 100644 index 00000000..e69de29b diff --git a/backend/OneSixInstance.h b/backend/OneSixInstance.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/backend/OneSixInstance.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/libmultimc/src/library.cpp b/backend/OneSixVersion.cpp similarity index 64% rename from libmultimc/src/library.cpp rename to backend/OneSixVersion.cpp index 691786e8..b58870ce 100644 --- a/libmultimc/src/library.cpp +++ b/backend/OneSixVersion.cpp @@ -1,19 +1,4 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "include/library.h" +#include "OneSixVersion.h" RuleAction RuleAction_fromString(QString name) { @@ -78,4 +63,29 @@ void Library::finalize() m_is_active = m_is_active && m_native_suffixes.contains ( currentSystem ); } } -// default url for lib: + +QList > FullVersion::getActiveNormalLibs() +{ + QList > output; + for ( auto lib: libraries ) + { + if (lib->getIsActive() && !lib->getIsNative()) + { + output.append(lib); + } + } + return output; +} + +QList > FullVersion::getActiveNativeLibs() +{ + QList > output; + for ( auto lib: libraries ) + { + if (lib->getIsActive() && lib->getIsNative()) + { + output.append(lib); + } + } + return output; +} diff --git a/libmultimc/include/library.h b/backend/OneSixVersion.h similarity index 65% rename from libmultimc/include/library.h rename to backend/OneSixVersion.h index ed377ddd..762e8f3e 100644 --- a/libmultimc/include/library.h +++ b/backend/OneSixVersion.h @@ -1,20 +1,4 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - #pragma once - #include class Library; @@ -206,3 +190,76 @@ public: return m_is_native; } }; + + +class FullVersion +{ +public: + /// the ID - determines which jar to use! ACTUALLY IMPORTANT! + QString id; + /// Last updated time - as a string + QString time; + /// Release time - as a string + QString releaseTime; + /// Release type - "release" or "snapshot" + QString type; + /** + * DEPRECATED: Old versions of the new vanilla launcher used this + * ex: "username_session_version" + */ + QString processArguments; + /** + * arguments that should be used for launching minecraft + * + * ex: "--username ${auth_player_name} --session ${auth_session} + * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" + */ + QString minecraftArguments; + /** + * the minimum launcher version required by this version ... current is 4 (at point of writing) + */ + int minimumLauncherVersion; + /** + * The main class to load first + */ + QString mainClass; + + /// the list of libs - both active and inactive, native and java + QList > libraries; + + /** + * is this actually a legacy version? if so, none of the other stuff here will be ever used. + * added by FullVersionFactory + */ + bool isLegacy; + + /* + FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. + + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx", + "version": "^10\\.5\\.\\d$" + } + } + ], + "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" + } + */ + // QList rules; + +public: + FullVersion() + { + minimumLauncherVersion = 0xDEADBEEF; + isLegacy = false; + } + + QList > getActiveNormalLibs(); + QList > getActiveNativeLibs(); +}; \ No newline at end of file diff --git a/libmultimc/src/fullversionfactory.cpp b/backend/VersionFactory.cpp similarity index 95% rename from libmultimc/src/fullversionfactory.cpp rename to backend/VersionFactory.cpp index bb55b4a9..d0242f17 100644 --- a/libmultimc/src/fullversionfactory.cpp +++ b/backend/VersionFactory.cpp @@ -1,17 +1,5 @@ -#include "fullversionfactory.h" -#include "fullversion.h" -#include - -class LibraryFinalizer -{ -public: - LibraryFinalizer(QSharedPointer library) - { - m_library = library; - } - - QSharedPointer m_library; -}; +#include "VersionFactory.h" +#include "OneSixVersion.h" // Library rules (if any) QList > FullVersionFactory::parse4rules(QJsonObject & baseObj) diff --git a/libmultimc/include/fullversionfactory.h b/backend/VersionFactory.h similarity index 100% rename from libmultimc/include/fullversionfactory.h rename to backend/VersionFactory.h diff --git a/libmultimc/include/libmmc_config.h b/backend/libmmc_config.h similarity index 88% rename from libmultimc/include/libmmc_config.h rename to backend/libmmc_config.h index 0ff2154a..6d967f5f 100644 --- a/libmultimc/include/libmmc_config.h +++ b/backend/libmmc_config.h @@ -13,8 +13,7 @@ * limitations under the License. */ -//#ifndef LIBINSTANCE_CONFIG_H -//#define LIBINSTANCE_CONFIG_H +#pragma once #include @@ -23,5 +22,3 @@ #else # define LIBMULTIMC_EXPORT Q_DECL_IMPORT #endif - -//#endif // LIBINSTANCE_CONFIG_H diff --git a/libmultimc/src/instversionlist.cpp b/backend/lists/InstVersionList.cpp similarity index 97% rename from libmultimc/src/instversionlist.cpp rename to backend/lists/InstVersionList.cpp index 74a8c898..c65770a9 100644 --- a/libmultimc/src/instversionlist.cpp +++ b/backend/lists/InstVersionList.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "instversionlist.h" -#include "instversion.h" +#include "InstVersionList.h" +#include "InstanceVersion.h" InstVersionList::InstVersionList(QObject *parent) : QAbstractListModel(parent) diff --git a/libmultimc/include/instversionlist.h b/backend/lists/InstVersionList.h similarity index 98% rename from libmultimc/include/instversionlist.h rename to backend/lists/InstVersionList.h index 5abfb91d..97e00383 100644 --- a/libmultimc/include/instversionlist.h +++ b/backend/lists/InstVersionList.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef INSTVERSIONLIST_H -#define INSTVERSIONLIST_H +#pragma once #include #include @@ -120,5 +119,3 @@ protected slots: */ virtual void updateListData(QList versions) = 0; }; - -#endif // INSTVERSIONLIST_H diff --git a/libmultimc/src/instancelist.cpp b/backend/lists/InstanceList.cpp similarity index 90% rename from libmultimc/src/instancelist.cpp rename to backend/lists/InstanceList.cpp index 1a7dc10d..101d52c5 100644 --- a/libmultimc/src/instancelist.cpp +++ b/backend/lists/InstanceList.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ -#include "include/instancelist.h" - #include #include #include @@ -24,8 +22,9 @@ #include #include -#include "include/instance.h" -#include "include/instanceloader.h" +#include "lists/InstanceList.h" +#include "BaseInstance.h" +#include "InstanceFactory.h" #include "pathutils.h" @@ -139,20 +138,20 @@ InstanceList::InstListError InstanceList::loadList() if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) continue; - Instance *instPtr = NULL; - auto &loader = InstanceLoader::get(); + BaseInstance *instPtr = NULL; + auto &loader = InstanceFactory::get(); auto error = loader.loadInstance(instPtr, subDir); switch(error) { - case InstanceLoader::NoLoadError: + case InstanceFactory::NoLoadError: break; - case InstanceLoader::NotAnInstance: + case InstanceFactory::NotAnInstance: break; } - if (error != InstanceLoader::NoLoadError && - error != InstanceLoader::NotAnInstance) + if (error != InstanceFactory::NoLoadError && + error != InstanceFactory::NotAnInstance) { QString errorMsg = QString("Failed to load instance %1: "). arg(QFileInfo(subDir).baseName()).toUtf8(); @@ -173,7 +172,7 @@ InstanceList::InstListError InstanceList::loadList() } else { - QSharedPointer inst(instPtr); + QSharedPointer inst(instPtr); auto iter = groupMap.find(inst->id()); if(iter != groupMap.end()) { @@ -182,7 +181,7 @@ InstanceList::InstListError InstanceList::loadList() qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8()); inst->setParent(this); m_instances.append(inst); - connect(instPtr, SIGNAL(propertiesChanged(Instance*)),this, SLOT(propertiesChanged(Instance*))); + connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*))); } } emit invalidated(); @@ -220,7 +219,7 @@ InstancePtr InstanceList::getInstanceById(QString instId) return iter.peekPrevious(); } -void InstanceList::propertiesChanged(Instance * inst) +void InstanceList::propertiesChanged(BaseInstance * inst) { for(int i = 0; i < m_instances.count(); i++) { diff --git a/libmultimc/include/instancelist.h b/backend/lists/InstanceList.h similarity index 92% rename from libmultimc/include/instancelist.h rename to backend/lists/InstanceList.h index bd8d0627..8c9965e5 100644 --- a/libmultimc/include/instancelist.h +++ b/backend/lists/InstanceList.h @@ -13,16 +13,15 @@ * limitations under the License. */ -#ifndef INSTANCELIST_H -#define INSTANCELIST_H +#pragma once #include #include -#include "instance.h" +#include "BaseInstance.h" #include "libmmc_config.h" -class Instance; +class BaseInstance; class LIBMULTIMC_EXPORT InstanceList : public QObject { @@ -85,11 +84,9 @@ signals: void invalidated(); private slots: - void propertiesChanged(Instance * inst); + void propertiesChanged(BaseInstance * inst); protected: QString m_instDir; QList< InstancePtr > m_instances; }; - -#endif // INSTANCELIST_H diff --git a/libmultimc/src/lwjglversionlist.cpp b/backend/lists/LwjglVersionList.cpp similarity index 99% rename from libmultimc/src/lwjglversionlist.cpp rename to backend/lists/LwjglVersionList.cpp index 6069f65c..824d0906 100644 --- a/libmultimc/src/lwjglversionlist.cpp +++ b/backend/lists/LwjglVersionList.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "include/lwjglversionlist.h" +#include "LwjglVersionList.h" #include diff --git a/libmultimc/include/lwjglversionlist.h b/backend/lists/LwjglVersionList.h similarity index 97% rename from libmultimc/include/lwjglversionlist.h rename to backend/lists/LwjglVersionList.h index 25b5c4c3..f3e7799a 100644 --- a/libmultimc/include/lwjglversionlist.h +++ b/backend/lists/LwjglVersionList.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef LWJGLVERSIONLIST_H -#define LWJGLVERSIONLIST_H +#pragma once #include #include @@ -131,4 +130,3 @@ private slots: virtual void netRequestComplete(); }; -#endif // LWJGLVERSIONLIST_H diff --git a/libmultimc/src/minecraftversionlist.cpp b/backend/lists/MinecraftVersionList.cpp similarity index 99% rename from libmultimc/src/minecraftversionlist.cpp rename to backend/lists/MinecraftVersionList.cpp index 17737b1e..d576397f 100644 --- a/libmultimc/src/minecraftversionlist.cpp +++ b/backend/lists/MinecraftVersionList.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "include/minecraftversionlist.h" +#include "MinecraftVersionList.h" #include @@ -295,7 +295,7 @@ bool MCVListLoadTask::loadFromVList() MinecraftVersion *mcVersion = new MinecraftVersion( versionID, versionID, versionTime.toMSecsSinceEpoch(), dlUrl, ""); - mcVersion->setLauncherVersion(MinecraftVersion::Launcher16); + mcVersion->setVersionSource(MinecraftVersion::Launcher16); mcVersion->setVersionType(versionType); tempList.append(mcVersion); } diff --git a/libmultimc/include/minecraftversionlist.h b/backend/lists/MinecraftVersionList.h similarity index 93% rename from libmultimc/include/minecraftversionlist.h rename to backend/lists/MinecraftVersionList.h index 81d5ac2f..10570b01 100644 --- a/libmultimc/include/minecraftversionlist.h +++ b/backend/lists/MinecraftVersionList.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef MINECRAFTVERSIONLIST_H -#define MINECRAFTVERSIONLIST_H +#pragma once #include @@ -22,11 +21,11 @@ #include -#include "instversionlist.h" +#include "InstVersionList.h" -#include "task.h" +#include "tasks/Task.h" -#include "minecraftversion.h" +#include "MinecraftVersion.h" #include "libmmc_config.h" @@ -105,5 +104,3 @@ protected: bool processedMCNReply; }; - -#endif // MINECRAFTVERSIONLIST_H diff --git a/libmultimc/src/gameupdatetask.cpp b/backend/tasks/GameUpdateTask.cpp similarity index 94% rename from libmultimc/src/gameupdatetask.cpp rename to backend/tasks/GameUpdateTask.cpp index bae85c17..0a1df0e1 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/backend/tasks/GameUpdateTask.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "gameupdatetask.h" +#include "GameUpdateTask.h" #include @@ -24,14 +24,14 @@ #include -#include "minecraftversionlist.h" -#include "fullversionfactory.h" -#include +#include "lists/MinecraftVersionList.h" +#include "VersionFactory.h" +#include "OneSixVersion.h" #include "pathutils.h" -GameUpdateTask::GameUpdateTask(const LoginResponse &response, Instance *inst, QObject *parent) : +GameUpdateTask::GameUpdateTask(const LoginResponse &response, BaseInstance *inst, QObject *parent) : Task(parent), m_response(response) { m_inst = inst; @@ -60,7 +60,7 @@ void GameUpdateTask::executeTask() setState(StateDetermineURLs); - if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16) + if (targetVersion->versionSource() == MinecraftVersion::Launcher16) { determineNewVersion(); } @@ -141,7 +141,7 @@ void GameUpdateTask::jarlibFinished() { m_inst->setCurrentVersion(targetVersion->descriptor()); m_inst->setShouldUpdate(false); - m_inst->setIsForNewLauncher(true); + // m_inst->setIsForNewLauncher(true); exit(1); } @@ -173,7 +173,7 @@ void GameUpdateTask::getLegacyJar() // This will be either 'minecraft' or the version number, depending on where // we're downloading from. QString jarFilename = "minecraft"; - if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16) + if (targetVersion->versionSource() == MinecraftVersion::Launcher16) { jarFilename = targetVersion->descriptor(); } @@ -196,7 +196,7 @@ void GameUpdateTask::legacyJarFinished() { setState(StateFinished); emit gameUpdateComplete(m_response); - m_inst->setIsForNewLauncher(true); + // m_inst->setIsForNewLauncher(true); exit(1); } diff --git a/libmultimc/include/gameupdatetask.h b/backend/tasks/GameUpdateTask.h similarity index 92% rename from libmultimc/include/gameupdatetask.h rename to backend/tasks/GameUpdateTask.h index b56c448b..94e798f1 100644 --- a/libmultimc/include/gameupdatetask.h +++ b/backend/tasks/GameUpdateTask.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef GAMEUPDATETASK_H -#define GAMEUPDATETASK_H +#pragma once #include @@ -24,9 +23,9 @@ #include #include "dlqueue.h" -#include "task.h" -#include "loginresponse.h" -#include "instance.h" +#include "Task.h" +#include "tasks/LoginResponse.h" +#include "BaseInstance.h" #include "libmmc_config.h" @@ -51,7 +50,7 @@ class LIBMULTIMC_EXPORT GameUpdateTask : public Task */ Q_PROPERTY(QString subStatus READ subStatus WRITE setSubStatus) public: - explicit GameUpdateTask(const LoginResponse &response, Instance *inst, QObject *parent = 0); + explicit GameUpdateTask(const LoginResponse &response, BaseInstance *inst, QObject *parent = 0); ///////////////////////// @@ -119,7 +118,7 @@ private: // STUFF // /////////// - Instance *m_inst; + BaseInstance *m_inst; LoginResponse m_response; //////////////////////////// @@ -156,4 +155,3 @@ private: }; -#endif // GAMEUPDATETASK_H diff --git a/libmultimc/src/loginresponse.cpp b/backend/tasks/LoginResponse.cpp similarity index 98% rename from libmultimc/src/loginresponse.cpp rename to backend/tasks/LoginResponse.cpp index 99a618ad..218f51c1 100644 --- a/libmultimc/src/loginresponse.cpp +++ b/backend/tasks/LoginResponse.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "loginresponse.h" +#include "tasks/LoginResponse.h" LoginResponse::LoginResponse(const QString& username, const QString& sessionID, qint64 latestVersion, QObject *parent) : diff --git a/libmultimc/include/loginresponse.h b/backend/tasks/LoginResponse.h similarity index 96% rename from libmultimc/include/loginresponse.h rename to backend/tasks/LoginResponse.h index 0b06a972..60875619 100644 --- a/libmultimc/include/loginresponse.h +++ b/backend/tasks/LoginResponse.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef LOGINRESPONSE_H -#define LOGINRESPONSE_H +#pragma once #include @@ -93,4 +92,3 @@ private: Q_DECLARE_METATYPE(LoginResponse) -#endif // LOGINRESPONSE_H diff --git a/libmultimc/src/logintask.cpp b/backend/tasks/LoginTask.cpp similarity index 99% rename from libmultimc/src/logintask.cpp rename to backend/tasks/LoginTask.cpp index 4a55037c..11f58f28 100644 --- a/libmultimc/src/logintask.cpp +++ b/backend/tasks/LoginTask.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "logintask.h" +#include "LoginTask.h" #include diff --git a/libmultimc/include/logintask.h b/backend/tasks/LoginTask.h similarity index 93% rename from libmultimc/include/logintask.h rename to backend/tasks/LoginTask.h index 15d715bd..e23ea9e9 100644 --- a/libmultimc/include/logintask.h +++ b/backend/tasks/LoginTask.h @@ -16,10 +16,10 @@ #ifndef LOGINTASK_H #define LOGINTASK_H -#include "task.h" +#include "Task.h" -#include "userinfo.h" -#include "loginresponse.h" +#include "UserInfo.h" +#include "tasks/LoginResponse.h" #include "libmmc_config.h" diff --git a/libmultimc/src/task.cpp b/backend/tasks/Task.cpp similarity index 98% rename from libmultimc/src/task.cpp rename to backend/tasks/Task.cpp index 780c3b38..7831ee58 100644 --- a/libmultimc/src/task.cpp +++ b/backend/tasks/Task.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "task.h" +#include "Task.h" Task::Task(QObject *parent) : QThread(parent) diff --git a/libmultimc/include/task.h b/backend/tasks/Task.h similarity index 100% rename from libmultimc/include/task.h rename to backend/tasks/Task.h diff --git a/libmultimc/src/userinfo.cpp b/backend/tasks/UserInfo.cpp similarity index 98% rename from libmultimc/src/userinfo.cpp rename to backend/tasks/UserInfo.cpp index 0bb5da11..82225309 100644 --- a/libmultimc/src/userinfo.cpp +++ b/backend/tasks/UserInfo.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "userinfo.h" +#include "UserInfo.h" UserInfo::UserInfo(const QString &username, const QString &password, QObject *parent) : QObject(parent) diff --git a/libmultimc/include/userinfo.h b/backend/tasks/UserInfo.h similarity index 100% rename from libmultimc/include/userinfo.h rename to backend/tasks/UserInfo.h diff --git a/gui/consolewindow.h b/gui/consolewindow.h index 5490bc92..3ea02ad9 100644 --- a/gui/consolewindow.h +++ b/gui/consolewindow.h @@ -2,7 +2,7 @@ #define CONSOLEWINDOW_H #include -#include "minecraftprocess.h" +#include "MinecraftProcess.h" namespace Ui { class ConsoleWindow; diff --git a/gui/instancemodel.cpp b/gui/instancemodel.cpp index 8db985e8..6f130fd5 100644 --- a/gui/instancemodel.cpp +++ b/gui/instancemodel.cpp @@ -53,7 +53,7 @@ QVariant InstanceModel::data ( const QModelIndex& index, int role ) const { return QVariant(); } - Instance *pdata = static_cast ( index.internalPointer() ); + BaseInstance *pdata = static_cast ( index.internalPointer() ); switch ( role ) { case InstancePointerRole: @@ -114,8 +114,8 @@ InstanceProxyModel::InstanceProxyModel ( QObject *parent ) bool InstanceProxyModel::subSortLessThan ( const QModelIndex& left, const QModelIndex& right ) const { - Instance *pdataLeft = static_cast ( left.internalPointer() ); - Instance *pdataRight = static_cast ( right.internalPointer() ); + BaseInstance *pdataLeft = static_cast ( left.internalPointer() ); + BaseInstance *pdataRight = static_cast ( right.internalPointer() ); //kDebug() << *pdataLeft << *pdataRight; return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0; //return pdataLeft->name() < pdataRight->name(); diff --git a/gui/instancemodel.h b/gui/instancemodel.h index 208ee68e..3938da45 100644 --- a/gui/instancemodel.h +++ b/gui/instancemodel.h @@ -2,7 +2,7 @@ #include #include "kcategorizedsortfilterproxymodel.h" -#include "instancelist.h" +#include "lists/InstanceList.h" #include class InstanceModel : public QAbstractListModel diff --git a/gui/legacymodeditdialog.cpp b/gui/legacymodeditdialog.cpp index 83d36218..319705f9 100644 --- a/gui/legacymodeditdialog.cpp +++ b/gui/legacymodeditdialog.cpp @@ -15,9 +15,9 @@ #include "legacymodeditdialog.h" #include "ui_legacymodeditdialog.h" -#include "instance.h" +#include "BaseInstance.h" -LegacyModEditDialog::LegacyModEditDialog(QWidget *parent, Instance* m_inst) : +LegacyModEditDialog::LegacyModEditDialog(QWidget *parent, BaseInstance* m_inst) : QDialog(parent), ui(new Ui::LegacyModEditDialog) { diff --git a/gui/legacymodeditdialog.h b/gui/legacymodeditdialog.h index 5310f769..54dceffe 100644 --- a/gui/legacymodeditdialog.h +++ b/gui/legacymodeditdialog.h @@ -18,7 +18,7 @@ #include -#include "instance.h" +#include "BaseInstance.h" namespace Ui { class LegacyModEditDialog; @@ -29,7 +29,7 @@ class LegacyModEditDialog : public QDialog Q_OBJECT public: - explicit LegacyModEditDialog(QWidget *parent = 0, Instance* m_inst = 0); + explicit LegacyModEditDialog(QWidget *parent = 0, BaseInstance* m_inst = 0); ~LegacyModEditDialog(); private slots: diff --git a/gui/lwjglselectdialog.cpp b/gui/lwjglselectdialog.cpp index ded299cf..d4a42b59 100644 --- a/gui/lwjglselectdialog.cpp +++ b/gui/lwjglselectdialog.cpp @@ -16,7 +16,7 @@ #include "lwjglselectdialog.h" #include "ui_lwjglselectdialog.h" -#include "lwjglversionlist.h" +#include "lists/LwjglVersionList.h" LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) : QDialog(parent), diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 341fa7bf..c403ea25 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -48,22 +48,22 @@ #include "kcategorizedview.h" #include "kcategorydrawer.h" -#include "instancelist.h" -#include "appsettings.h" -#include "version.h" +#include "lists/InstanceList.h" +#include "AppSettings.h" +#include "AppVersion.h" -#include "logintask.h" -#include "gameupdatetask.h" +#include "tasks/LoginTask.h" +#include "tasks/GameUpdateTask.h" -#include "instance.h" -#include "instanceloader.h" -#include "minecraftprocess.h" +#include "BaseInstance.h" +#include "InstanceFactory.h" +#include "MinecraftProcess.h" #include "instancemodel.h" #include "instancedelegate.h" -#include "minecraftversionlist.h" -#include "lwjglversionlist.h" +#include "lists/MinecraftVersionList.h" +#include "lists/LwjglVersionList.h" // Opens the given file in the default application. // TODO: Move this somewhere. @@ -89,16 +89,16 @@ MainWindow::MainWindow ( QWidget *parent ) : view->setPalette(pal); */ -// view->setStyleSheet( -// "QListView\ -// {\ -// background-image: url(:/backgrounds/kitteh);\ -// background-attachment: fixed;\ -// background-clip: padding;\ -// background-position: top right;\ -// background-repeat: none;\ -// background-color:palette(base);\ -// }"); + view->setStyleSheet( + "QListView\ + {\ + background-image: url(:/backgrounds/kitteh);\ + background-attachment: fixed;\ + background-clip: padding;\ + background-position: top right;\ + background-repeat: none;\ + background-color:palette(base);\ + }"); view->setSelectionMode ( QAbstractItemView::SingleSelection ); //view->setSpacing( KDialog::spacingHint() ); @@ -168,7 +168,7 @@ void MainWindow::instanceActivated ( QModelIndex index ) { if(!index.isValid()) return; - Instance * inst = (Instance *) index.data(InstanceModel::InstancePointerRole).value(); + BaseInstance * inst = (BaseInstance *) index.data(InstanceModel::InstancePointerRole).value(); doLogin(); } @@ -186,29 +186,29 @@ void MainWindow::on_actionAddInstance_triggered() if (!newInstDlg->exec()) return; - Instance *newInstance = NULL; + BaseInstance *newInstance = NULL; QString instDirName = DirNameFromString(newInstDlg->instName()); QString instDir = PathCombine(globalSettings->get("InstanceDir").toString(), instDirName); - auto &loader = InstanceLoader::get(); + auto &loader = InstanceFactory::get(); auto error = loader.createInstance(newInstance, instDir); QString errorMsg = QString("Failed to create instance %1: ").arg(instDirName); switch (error) { - case InstanceLoader::NoCreateError: + case InstanceFactory::NoCreateError: newInstance->setName(newInstDlg->instName()); newInstance->setIntendedVersion(newInstDlg->selectedVersion()->descriptor()); instList.add(InstancePtr(newInstance)); return; - case InstanceLoader::InstExists: + case InstanceFactory::InstExists: errorMsg += "An instance with the given directory name already exists."; QMessageBox::warning(this, "Error", errorMsg); break; - case InstanceLoader::CantCreateDir: + case InstanceFactory::CantCreateDir: errorMsg += "Failed to create the instance directory."; QMessageBox::warning(this, "Error", errorMsg); break; @@ -222,7 +222,7 @@ void MainWindow::on_actionAddInstance_triggered() void MainWindow::on_actionChangeInstGroup_triggered() { - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if(inst) { bool ok = false; @@ -291,7 +291,7 @@ void MainWindow::on_mainToolBar_visibilityChanged ( bool ) void MainWindow::on_actionDeleteInstance_triggered() { - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if (inst) { int response = QMessageBox::question(this, "CAREFUL", @@ -306,7 +306,7 @@ void MainWindow::on_actionDeleteInstance_triggered() void MainWindow::on_actionRenameInstance_triggered() { - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if(inst) { bool ok = false; @@ -324,7 +324,7 @@ void MainWindow::on_actionRenameInstance_triggered() void MainWindow::on_actionViewSelectedInstFolder_triggered() { - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if(inst) { QString str = inst->rootDir(); @@ -335,7 +335,7 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() void MainWindow::on_actionEditInstMods_triggered() { //TODO: Needs to do current ModEditDialog too - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if (inst) { LegacyModEditDialog dialog ( this, inst ); @@ -362,7 +362,7 @@ void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos instContextMenu->exec ( view->mapToGlobal ( pos ) ); } -Instance* MainWindow::selectedInstance() +BaseInstance* MainWindow::selectedInstance() { QAbstractItemView * iv = view; auto smodel = iv->selectionModel(); @@ -375,7 +375,7 @@ Instance* MainWindow::selectedInstance() if(mindex.isValid()) { - return (Instance *) mindex.data(InstanceModel::InstancePointerRole).value(); + return (BaseInstance *) mindex.data(InstanceModel::InstancePointerRole).value(); } else return nullptr; @@ -384,7 +384,7 @@ Instance* MainWindow::selectedInstance() void MainWindow::on_actionLaunchInstance_triggered() { - Instance* inst = selectedInstance(); + BaseInstance* inst = selectedInstance(); if(inst) { doLogin(); @@ -450,12 +450,12 @@ void MainWindow::launchInstance(LoginResponse response) void MainWindow::launchInstance(QString instID, LoginResponse response) { - Instance *instance = instList.getInstanceById(instID).data(); + BaseInstance *instance = instList.getInstanceById(instID).data(); Q_ASSERT_X(instance != NULL, "launchInstance", "instance ID does not correspond to a valid instance"); launchInstance(instance, response); } -void MainWindow::launchInstance(Instance *instance, LoginResponse response) +void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response) { Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL"); @@ -531,7 +531,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered() if (view->selectionModel()->selectedIndexes().count() < 1) return; - Instance *inst = selectedInstance(); + BaseInstance *inst = selectedInstance(); VersionSelectDialog *vselect = new VersionSelectDialog(inst->versionList(), this); if (vselect->exec() && vselect->selectedVersion()) @@ -542,7 +542,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered() void MainWindow::on_actionChangeInstLWJGLVersion_triggered() { - Instance *inst = selectedInstance(); + BaseInstance *inst = selectedInstance(); if (!inst) return; @@ -559,7 +559,7 @@ void MainWindow::on_actionInstanceSettings_triggered() if (view->selectionModel()->selectedIndexes().count() < 1) return; - Instance *inst = selectedInstance(); + BaseInstance *inst = selectedInstance(); SettingsObject *s; s = &inst->settings(); InstanceSettings settings(s, this); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index a10d570c..67ae859e 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -18,9 +18,9 @@ #include -#include "instancelist.h" -#include "loginresponse.h" -#include "instance.h" +#include "lists/InstanceList.h" +#include "tasks/LoginResponse.h" +#include "BaseInstance.h" class InstanceModel; class InstanceProxyModel; @@ -41,7 +41,7 @@ class MainWindow : public QMainWindow /*! * The currently selected instance. */ - Q_PROPERTY(Instance* selectedInstance READ selectedInstance STORED false) + Q_PROPERTY(BaseInstance* selectedInstance READ selectedInstance STORED false) public: explicit MainWindow(QWidget *parent = 0); @@ -53,7 +53,7 @@ public: void openWebPage(QUrl url); - Instance *selectedInstance(); + BaseInstance *selectedInstance(); private slots: void on_actionAbout_triggered(); @@ -119,7 +119,7 @@ public slots: void launchInstance(LoginResponse response); void launchInstance(QString instID, LoginResponse response); - void launchInstance(Instance *inst, LoginResponse response); + void launchInstance(BaseInstance *inst, LoginResponse response); private: Ui::MainWindow *ui; @@ -134,7 +134,7 @@ private: // A pointer to the instance we are actively doing stuff with. // This is set when the user launches an instance and is used to refer to that // instance throughout the launching process. - Instance *m_activeInst; + BaseInstance *m_activeInst; Task *m_versionLoadTask; }; diff --git a/gui/modeditdialog.cpp b/gui/modeditdialog.cpp index 945a5a91..2f437101 100644 --- a/gui/modeditdialog.cpp +++ b/gui/modeditdialog.cpp @@ -15,9 +15,9 @@ #include "modeditdialog.h" #include "ui_modeditdialog.h" -#include "instance.h" +#include "BaseInstance.h" -ModEditDialog::ModEditDialog(QWidget *parent, Instance* m_inst) : +ModEditDialog::ModEditDialog(QWidget *parent, BaseInstance* m_inst) : QDialog(parent), ui(new Ui::ModEditDialog) { diff --git a/gui/modeditdialog.h b/gui/modeditdialog.h index 648b9c08..329a1b4e 100644 --- a/gui/modeditdialog.h +++ b/gui/modeditdialog.h @@ -18,7 +18,7 @@ #include -#include "instance.h" +#include "BaseInstance.h" namespace Ui { class ModEditDialog; @@ -29,7 +29,7 @@ class ModEditDialog : public QDialog Q_OBJECT public: - explicit ModEditDialog(QWidget *parent = 0, Instance* m_inst = 0); + explicit ModEditDialog(QWidget *parent = 0, BaseInstance* m_inst = 0); ~ModEditDialog(); private slots: diff --git a/gui/modeditwindow.cpp b/gui/modeditwindow.cpp index 322197ef..a7d4fbbb 100644 --- a/gui/modeditwindow.cpp +++ b/gui/modeditwindow.cpp @@ -15,11 +15,11 @@ #include "modeditwindow.h" #include "ui_modeditwindow.h" -#include "instance.h" +#include "BaseInstance.h" #include -ModEditWindow::ModEditWindow(QWidget *parent, Instance* m_inst) : +ModEditWindow::ModEditWindow(QWidget *parent, BaseInstance* m_inst) : QDialog(parent), ui(new Ui::ModEditWindow) { diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp index cf005429..a5c902b4 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/newinstancedialog.cpp @@ -16,12 +16,12 @@ #include "newinstancedialog.h" #include "ui_newinstancedialog.h" -#include "instanceloader.h" +#include "InstanceFactory.h" -#include "instversionlist.h" -#include "instversion.h" +#include +#include "InstanceVersion.h" -#include "task.h" +#include "tasks/Task.h" #include "versionselectdialog.h" #include "taskdialog.h" @@ -29,7 +29,7 @@ #include #include -#include + NewInstanceDialog::NewInstanceDialog(QWidget *parent) : QDialog(parent), diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 38844509..52867169 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -16,7 +16,7 @@ #include "settingsdialog.h" #include "ui_settingsdialog.h" -#include "appsettings.h" +#include "AppSettings.h" #include #include diff --git a/gui/taskdialog.cpp b/gui/taskdialog.cpp index a74b7718..efa64256 100644 --- a/gui/taskdialog.cpp +++ b/gui/taskdialog.cpp @@ -18,7 +18,7 @@ #include -#include "task.h" +#include "tasks/Task.h" TaskDialog::TaskDialog(QWidget *parent) : QDialog(parent), diff --git a/gui/versionselectdialog.cpp b/gui/versionselectdialog.cpp index 63a2ac26..9f1a8653 100644 --- a/gui/versionselectdialog.cpp +++ b/gui/versionselectdialog.cpp @@ -22,9 +22,9 @@ #include -#include -#include -#include +#include +#include +#include VersionSelectDialog::VersionSelectDialog(InstVersionList *vlist, QWidget *parent) : QDialog(parent), diff --git a/hacks/boost/property_tree/detail/json_parser_read.hpp b/hacks/boost/property_tree/detail/json_parser_read.hpp deleted file mode 100644 index 9a22e75b..00000000 --- a/hacks/boost/property_tree/detail/json_parser_read.hpp +++ /dev/null @@ -1,333 +0,0 @@ -// ---------------------------------------------------------------------------- -// Copyright (C) 2002-2006 Marcin Kalicinski -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see www.boost.org -// ---------------------------------------------------------------------------- -#ifndef BOOST_PROPERTY_TREE_DETAIL_JSON_PARSER_READ_HPP_INCLUDED -#define BOOST_PROPERTY_TREE_DETAIL_JSON_PARSER_READ_HPP_INCLUDED - -//#define BOOST_SPIRIT_DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace property_tree { namespace json_parser -{ - - /////////////////////////////////////////////////////////////////////// - // Json parser context - - template - struct context - { - - typedef typename Ptree::key_type::value_type Ch; - typedef std::basic_string Str; - typedef typename std::vector::iterator It; - - Str string; - Str name; - Ptree root; - std::vector stack; - - struct a_object_s - { - context &c; - a_object_s(context &c): c(c) { } - void operator()(Ch) const - { - if (c.stack.empty()) - c.stack.push_back(&c.root); - else - { - Ptree *parent = c.stack.back(); - Ptree *child = &parent->push_back(std::make_pair(c.name, Ptree()))->second; - c.stack.push_back(child); - c.name.clear(); - } - } - }; - - struct a_object_e - { - context &c; - a_object_e(context &c): c(c) { } - void operator()(Ch) const - { - BOOST_ASSERT(c.stack.size() >= 1); - c.stack.pop_back(); - } - }; - - struct a_name - { - context &c; - a_name(context &c): c(c) { } - void operator()(It, It) const - { - c.name.swap(c.string); - c.string.clear(); - } - }; - - struct a_string_val - { - context &c; - a_string_val(context &c): c(c) { } - void operator()(It, It) const - { - BOOST_ASSERT(c.stack.size() >= 1); - c.stack.back()->push_back(std::make_pair(c.name, Ptree(c.string))); - c.name.clear(); - c.string.clear(); - } - }; - - struct a_literal_val - { - context &c; - a_literal_val(context &c): c(c) { } - void operator()(It b, It e) const - { - BOOST_ASSERT(c.stack.size() >= 1); - c.stack.back()->push_back(std::make_pair(c.name, - Ptree(Str(b, e)))); - c.name.clear(); - c.string.clear(); - } - }; - - struct a_char - { - context &c; - a_char(context &c): c(c) { } - void operator()(It b, It e) const - { - c.string += *b; - } - }; - - struct a_escape - { - context &c; - a_escape(context &c): c(c) { } - void operator()(Ch ch) const - { - switch (ch) - { - case Ch('\"'): c.string += Ch('\"'); break; - case Ch('\\'): c.string += Ch('\\'); break; - case Ch('/'): c.string += Ch('/'); break; - case Ch('b'): c.string += Ch('\b'); break; - case Ch('f'): c.string += Ch('\f'); break; - case Ch('n'): c.string += Ch('\n'); break; - case Ch('r'): c.string += Ch('\r'); break; - case Ch('t'): c.string += Ch('\t'); break; - default: BOOST_ASSERT(0); - } - } - }; - - struct a_unicode - { - context &c; - a_unicode(context &c): c(c) { } - void operator()(unsigned long u) const - { - //u = (std::min)(u, static_cast((std::numeric_limits::max)())); - c.string += Ch(u); - } - }; - - }; - - /////////////////////////////////////////////////////////////////////// - // Json grammar - - template - struct json_grammar : - public boost::spirit::classic::grammar > - { - - typedef context Context; - typedef typename Ptree::key_type::value_type Ch; - - mutable Context c; - - template - struct definition - { - - boost::spirit::classic::rule - root, object, member, array, item, value, string, number; - boost::spirit::classic::rule< - typename boost::spirit::classic::lexeme_scanner::type> - character, escape; - - definition(const json_grammar &self) - { - - using namespace boost::spirit::classic; - // There's a boost::assertion too, so another explicit using - // here: - using boost::spirit::classic::assertion; - - // Assertions - assertion expect_root("expected object or array"); - assertion expect_eoi("expected end of input"); - assertion expect_objclose("expected ',' or '}'"); - assertion expect_arrclose("expected ',' or ']'"); - assertion expect_name("expected object name"); - assertion expect_colon("expected ':'"); - assertion expect_value("expected value"); - assertion expect_escape("invalid escape sequence"); - - // JSON grammar rules - root - = expect_root(object | array) - >> expect_eoi(end_p) - ; - - object - = ch_p('{')[typename Context::a_object_s(self.c)] - >> (ch_p('}')[typename Context::a_object_e(self.c)] - | (list_p(member, ch_p(',')) - >> expect_objclose(ch_p('}')[typename Context::a_object_e(self.c)]) - ) - ) - ; - - member - = expect_name(string[typename Context::a_name(self.c)]) - >> expect_colon(ch_p(':')) - >> expect_value(value) - ; - - array - = ch_p('[')[typename Context::a_object_s(self.c)] - >> (ch_p(']')[typename Context::a_object_e(self.c)] - | (list_p(item, ch_p(',')) - >> expect_arrclose(ch_p(']')[typename Context::a_object_e(self.c)]) - ) - ) - ; - - item - = expect_value(value) - ; - - value - = string[typename Context::a_string_val(self.c)] - | (number | str_p("true") | "false" | "null")[typename Context::a_literal_val(self.c)] - | object - | array - ; - - number - = !ch_p("-") >> - (ch_p("0") | (range_p(Ch('1'), Ch('9')) >> *digit_p)) >> - !(ch_p(".") >> +digit_p) >> - !(chset_p(detail::widen("eE").c_str()) >> - !chset_p(detail::widen("-+").c_str()) >> - +digit_p) - ; - - string - = +(lexeme_d[confix_p('\"', *character, '\"')]) - ; - - character - = (anychar_p - "\\" - "\"") - [typename Context::a_char(self.c)] - | ch_p("\\") >> expect_escape(escape) - ; - - escape - = chset_p(detail::widen("\"\\/bfnrt").c_str()) - [typename Context::a_escape(self.c)] - | 'u' >> uint_parser() - [typename Context::a_unicode(self.c)] - ; - - // Debug - BOOST_SPIRIT_DEBUG_RULE(root); - BOOST_SPIRIT_DEBUG_RULE(object); - BOOST_SPIRIT_DEBUG_RULE(member); - BOOST_SPIRIT_DEBUG_RULE(array); - BOOST_SPIRIT_DEBUG_RULE(item); - BOOST_SPIRIT_DEBUG_RULE(value); - BOOST_SPIRIT_DEBUG_RULE(string); - BOOST_SPIRIT_DEBUG_RULE(number); - BOOST_SPIRIT_DEBUG_RULE(escape); - BOOST_SPIRIT_DEBUG_RULE(character); - - } - - const boost::spirit::classic::rule &start() const - { - return root; - } - - }; - - }; - - template - unsigned long count_lines(It begin, It end) - { - return static_cast(std::count(begin, end, Ch('\n')) + 1); - } - - template - void read_json_internal(std::basic_istream &stream, - Ptree &pt, - const std::string &filename) - { - - using namespace boost::spirit::classic; - typedef typename Ptree::key_type::value_type Ch; - typedef typename std::vector::iterator It; - - // Load data into vector - std::vector v(std::istreambuf_iterator(stream.rdbuf()), - std::istreambuf_iterator()); - if (!stream.good()) - BOOST_PROPERTY_TREE_THROW(json_parser_error("read error", filename, 0)); - - // Prepare grammar - json_grammar g; - - // Parse - try - { - parse_info pi = parse(v.begin(), v.end(), g, - space_p | comment_p("//") | comment_p("/*", "*/")); - if (!pi.hit || !pi.full) - BOOST_PROPERTY_TREE_THROW((parser_error(v.begin(), "syntax error"))); - } - catch (parser_error &e) - { - BOOST_PROPERTY_TREE_THROW(json_parser_error(e.descriptor, filename, count_lines(v.begin(), e.where))); - } - - // Swap grammar context root and pt - pt.swap(g.c.root); - - } - -} } } - -#endif - diff --git a/libmultimc/CMakeLists.txt b/libmultimc/CMakeLists.txt deleted file mode 100644 index 8adee1ec..00000000 --- a/libmultimc/CMakeLists.txt +++ /dev/null @@ -1,102 +0,0 @@ -project(libMultiMC) - -set(CMAKE_AUTOMOC ON) - -# Find Qt -find_package(Qt5Core REQUIRED) -find_package(Qt5Network REQUIRED) -find_package(Qt5Xml REQUIRED) - -# Include Qt headers. -include_directories(${Qt5Base_INCLUDE_DIRS}) -include_directories(${Qt5Network_INCLUDE_DIRS}) - -# Include utility library. -include_directories(${CMAKE_SOURCE_DIR}/libutil/include) - -# Include settings library. -include_directories(${CMAKE_SOURCE_DIR}/libsettings/include) - -SET(LIBINST_HEADERS -include/libmmc_config.h - - -# Instance Stuff -include/instance.h -include/instancelist.h -include/instanceloader.h - -include/instversion.h -include/instversionlist.h - -include/minecraftversion.h -include/minecraftversionlist.h - -include/library.h -include/fullversion.h -include/fullversionfactory.h - -# Tasks -include/task.h -include/logintask.h -include/gameupdatetask.h - - -# Login Data -include/userinfo.h -include/loginresponse.h - - -# Misc Data -include/version.h -include/appsettings.h -include/minecraftprocess.h -include/lwjglversionlist.h -) - -SET(LIBINST_SOURCES -# Instance Stuff -src/instance.cpp -src/instancelist.cpp -src/instanceloader.cpp - -src/instversion.cpp -src/instversionlist.cpp - -src/minecraftversion.cpp -src/minecraftversionlist.cpp - -src/library.cpp -src/fullversion.cpp -src/fullversionfactory.cpp - -# Tasks -src/task.cpp -src/logintask.cpp -src/gameupdatetask.cpp - - -# Login Data -src/userinfo.cpp -src/loginresponse.cpp - - -# Misc Data -src/version.cpp -src/appsettings.cpp -src/minecraftprocess.cpp -src/lwjglversionlist.cpp -) - -# Set the include dir path. -SET(LIBMULTIMC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) - -# Include self. -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -include_directories(${CMAKE_BINARY_DIR}/include) - -add_definitions(-DLIBMULTIMC_LIBRARY) - -add_library(libMultiMC SHARED ${LIBINST_SOURCES} ${LIBINST_HEADERS}) -qt5_use_modules(libMultiMC Core Network Xml) -target_link_libraries(libMultiMC libUtil libSettings) diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h deleted file mode 100644 index 8547960f..00000000 --- a/libmultimc/include/fullversion.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once -#include - -class Library; - -class FullVersion -{ -public: - /// the ID - determines which jar to use! ACTUALLY IMPORTANT! - QString id; - /// Last updated time - as a string - QString time; - /// Release time - as a string - QString releaseTime; - /// Release type - "release" or "snapshot" - QString type; - /** - * DEPRECATED: Old versions of the new vanilla launcher used this - * ex: "username_session_version" - */ - QString processArguments; - /** - * arguments that should be used for launching minecraft - * - * ex: "--username ${auth_player_name} --session ${auth_session} - * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" - */ - QString minecraftArguments; - /** - * the minimum launcher version required by this version ... current is 4 (at point of writing) - */ - int minimumLauncherVersion; - /** - * The main class to load first - */ - QString mainClass; - - /// the list of libs - both active and inactive, native and java - QList > libraries; - - /** - * is this actually a legacy version? if so, none of the other stuff here will be ever used. - * added by FullVersionFactory - */ - bool isLegacy; - - /* - FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. - - "rules": [ - { - "action": "allow" - }, - { - "action": "disallow", - "os": { - "name": "osx", - "version": "^10\\.5\\.\\d$" - } - } - ], - "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" - } - */ - // QList rules; - -public: - FullVersion() - { - minimumLauncherVersion = 0xDEADBEEF; - isLegacy = false; - } - - QList > getActiveNormalLibs(); - QList > getActiveNativeLibs(); -}; \ No newline at end of file diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp deleted file mode 100644 index 24047c9f..00000000 --- a/libmultimc/src/fullversion.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "fullversion.h" -#include - -QList > FullVersion::getActiveNormalLibs() -{ - QList > output; - for ( auto lib: libraries ) - { - if (lib->getIsActive() && !lib->getIsNative()) - { - output.append(lib); - } - } - return output; -} - -QList > FullVersion::getActiveNativeLibs() -{ - QList > output; - for ( auto lib: libraries ) - { - if (lib->getIsActive() && lib->getIsNative()) - { - output.append(lib); - } - } - return output; -} diff --git a/libutil/CMakeLists.txt b/libutil/CMakeLists.txt index 864c7714..d3f90a1d 100644 --- a/libutil/CMakeLists.txt +++ b/libutil/CMakeLists.txt @@ -51,5 +51,5 @@ SET(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) add_definitions(-DLIBUTIL_LIBRARY) add_library(libUtil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS}) -qt5_use_modules(libUtil Core) +qt5_use_modules(libUtil Core Network) target_link_libraries(libUtil) diff --git a/libutil/include/cmdutils.h b/libutil/include/cmdutils.h index 83397e73..a6379397 100644 --- a/libutil/include/cmdutils.h +++ b/libutil/include/cmdutils.h @@ -29,12 +29,19 @@ /** * @file libutil/include/cmdutils.h - * @brief commandline parsing utilities + * @brief commandline parsing and processing utilities */ namespace Util { namespace Commandline { +/** + * @brief split a string into argv items like a shell would do + * @param args the argument string + * @return a QStringList containing all arguments + */ +LIBUTIL_EXPORT QStringList splitArgs(QString args); + /** * @brief The FlagStyle enum * Specifies how flags are decorated diff --git a/libutil/src/cmdutils.cpp b/libutil/src/cmdutils.cpp index 13db503d..80ba719d 100644 --- a/libutil/src/cmdutils.cpp +++ b/libutil/src/cmdutils.cpp @@ -24,6 +24,56 @@ namespace Util { namespace Commandline { +// commandline splitter +QStringList splitArgs(QString args) +{ + QStringList argv; + QString current; + bool escape = false; + QChar inquotes; + for (int i=0; i