summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-07-29 00:59:35 +0200
committerPetr Mrázek <peterix@gmail.com>2013-07-29 00:59:35 +0200
commit2e0cbf393a5320dbf5448ca44a9b5905314b0be8 (patch)
tree4baac9cf015ca7b15d83de33c705e0d8d4497d30
parent8808a8b108b82916eaf30f9aca50cd3ab16af230 (diff)
downloadMultiMC-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar
MultiMC-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar.gz
MultiMC-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar.lz
MultiMC-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar.xz
MultiMC-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.zip
Massive renaming in the backend folder, all around restructure in the same.
-rw-r--r--AppSettings.cpp (renamed from libmultimc/src/appsettings.cpp)2
-rw-r--r--AppSettings.h (renamed from libmultimc/include/appsettings.h)9
-rw-r--r--AppVersion.cpp (renamed from libmultimc/src/version.cpp)2
-rw-r--r--AppVersion.h (renamed from libmultimc/include/version.h)8
-rw-r--r--CMakeLists.txt19
-rw-r--r--backend/BaseInstance.cpp (renamed from libmultimc/src/instance.cpp)52
-rw-r--r--backend/BaseInstance.h (renamed from libmultimc/include/instance.h)57
-rw-r--r--backend/CMakeLists.txt91
-rw-r--r--backend/InstanceFactory.cpp (renamed from libmultimc/src/instanceloader.cpp)20
-rw-r--r--backend/InstanceFactory.h (renamed from libmultimc/include/instanceloader.h)21
-rw-r--r--backend/InstanceVersion.cpp (renamed from libmultimc/src/instversion.cpp)4
-rw-r--r--backend/InstanceVersion.h (renamed from libmultimc/include/instversion.h)5
-rw-r--r--backend/LegacyInstance.cpp0
-rw-r--r--backend/LegacyInstance.h1
-rw-r--r--backend/MinecraftProcess.cpp (renamed from libmultimc/src/minecraftprocess.cpp)54
-rw-r--r--backend/MinecraftProcess.h (renamed from libmultimc/include/minecraftprocess.h)22
-rw-r--r--backend/MinecraftVersion.cpp (renamed from libmultimc/src/minecraftversion.cpp)13
-rw-r--r--backend/MinecraftVersion.h (renamed from libmultimc/include/minecraftversion.h)43
-rw-r--r--backend/OneSixInstance.cpp0
-rw-r--r--backend/OneSixInstance.h1
-rw-r--r--backend/OneSixVersion.cpp (renamed from libmultimc/src/library.cpp)44
-rw-r--r--backend/OneSixVersion.h (renamed from libmultimc/include/library.h)89
-rw-r--r--backend/VersionFactory.cpp (renamed from libmultimc/src/fullversionfactory.cpp)16
-rw-r--r--backend/VersionFactory.h (renamed from libmultimc/include/fullversionfactory.h)0
-rw-r--r--backend/libmmc_config.h (renamed from libmultimc/include/libmmc_config.h)5
-rw-r--r--backend/lists/InstVersionList.cpp (renamed from libmultimc/src/instversionlist.cpp)4
-rw-r--r--backend/lists/InstVersionList.h (renamed from libmultimc/include/instversionlist.h)5
-rw-r--r--backend/lists/InstanceList.cpp (renamed from libmultimc/src/instancelist.cpp)25
-rw-r--r--backend/lists/InstanceList.h (renamed from libmultimc/include/instancelist.h)11
-rw-r--r--backend/lists/LwjglVersionList.cpp (renamed from libmultimc/src/lwjglversionlist.cpp)2
-rw-r--r--backend/lists/LwjglVersionList.h (renamed from libmultimc/include/lwjglversionlist.h)4
-rw-r--r--backend/lists/MinecraftVersionList.cpp (renamed from libmultimc/src/minecraftversionlist.cpp)4
-rw-r--r--backend/lists/MinecraftVersionList.h (renamed from libmultimc/include/minecraftversionlist.h)11
-rw-r--r--backend/tasks/GameUpdateTask.cpp (renamed from libmultimc/src/gameupdatetask.cpp)18
-rw-r--r--backend/tasks/GameUpdateTask.h (renamed from libmultimc/include/gameupdatetask.h)14
-rw-r--r--backend/tasks/LoginResponse.cpp (renamed from libmultimc/src/loginresponse.cpp)2
-rw-r--r--backend/tasks/LoginResponse.h (renamed from libmultimc/include/loginresponse.h)4
-rw-r--r--backend/tasks/LoginTask.cpp (renamed from libmultimc/src/logintask.cpp)2
-rw-r--r--backend/tasks/LoginTask.h (renamed from libmultimc/include/logintask.h)6
-rw-r--r--backend/tasks/Task.cpp (renamed from libmultimc/src/task.cpp)2
-rw-r--r--backend/tasks/Task.h (renamed from libmultimc/include/task.h)0
-rw-r--r--backend/tasks/UserInfo.cpp (renamed from libmultimc/src/userinfo.cpp)2
-rw-r--r--backend/tasks/UserInfo.h (renamed from libmultimc/include/userinfo.h)0
-rw-r--r--gui/consolewindow.h2
-rw-r--r--gui/instancemodel.cpp6
-rw-r--r--gui/instancemodel.h2
-rw-r--r--gui/legacymodeditdialog.cpp4
-rw-r--r--gui/legacymodeditdialog.h4
-rw-r--r--gui/lwjglselectdialog.cpp2
-rw-r--r--gui/mainwindow.cpp78
-rw-r--r--gui/mainwindow.h14
-rw-r--r--gui/modeditdialog.cpp4
-rw-r--r--gui/modeditdialog.h4
-rw-r--r--gui/modeditwindow.cpp4
-rw-r--r--gui/newinstancedialog.cpp10
-rw-r--r--gui/settingsdialog.cpp2
-rw-r--r--gui/taskdialog.cpp2
-rw-r--r--gui/versionselectdialog.cpp6
-rw-r--r--hacks/boost/property_tree/detail/json_parser_read.hpp333
-rw-r--r--libmultimc/CMakeLists.txt102
-rw-r--r--libmultimc/include/fullversion.h76
-rw-r--r--libmultimc/src/fullversion.cpp29
-rw-r--r--libutil/CMakeLists.txt2
-rw-r--r--libutil/include/cmdutils.h9
-rw-r--r--libutil/src/cmdutils.cpp50
-rw-r--r--main.cpp10
66 files changed, 489 insertions, 960 deletions
diff --git a/libmultimc/src/appsettings.cpp b/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 <setting.h>
diff --git a/libmultimc/include/appsettings.h b/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 <QObject>
#include <inisettingsobject.h>
-#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
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
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 <QObject>
-#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
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 <QFileInfo>
@@ -22,19 +22,18 @@
#include "overridesetting.h"
#include "pathutils.h"
-#include <minecraftversionlist.h>
+#include <lists/MinecraftVersionList.h>
-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
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 <QObject>
#include <QDateTime>
@@ -22,7 +21,7 @@
#include <settingsobject.h>
#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
@@ -68,6 +67,14 @@ class LIBMULTIMC_EXPORT Instance : public QObject
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
* re-added to a fresh minecraft.jar file.
@@ -101,25 +108,12 @@ class LIBMULTIMC_EXPORT Instance : public QObject
/*!
- * 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
* the current version needs to be checked again.
*/
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<qint64>(); }
virtual void setLastCurrentVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); }
- virtual bool isForNewLauncher()
- {
- return settings().get("IsForNewLauncher").value<bool>();
- }
-
- 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<Instance> InstancePtr;
+typedef QSharedPointer<BaseInstance> 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
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 <QDir>
#include <QFileInfo>
-#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
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 <QObject>
#include <QMap>
@@ -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
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
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 <QObject>
@@ -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
--- /dev/null
+++ b/backend/LegacyInstance.cpp
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
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 <QDataStream>
#include <QFile>
@@ -23,57 +23,17 @@
//#include <QImage>
#include <QProcessEnvironment>
-#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; i<args.length(); i++)
- {
- QChar cchar = args.at(i);
-
- // \ escaped
- if (escape) {
- current += cchar;
- escape = false;
- // in "quotes"
- } else if (!inquotes.isNull()) {
- if (cchar == 0x5C)
- escape = true;
- else if (cchar == inquotes)
- inquotes = 0;
- else
- current += cchar;
- // otherwise
- } else {
- if (cchar == 0x20) {
- if (!current.isEmpty()) {
- argv << current;
- current.clear();
- }
- } else if (cchar == 0x22 || cchar == 0x27)
- inquotes = cchar;
- else
- current += cchar;
- }
- }
- if (!current.isEmpty())
- argv << current;
- return argv;
-}
-
// prepare tools
-inline void MinecraftProcess::extractIcon(Instance *inst, QString destination)
+inline void MinecraftProcess::extractIcon(BaseInstance *inst, QString destination)
{
// QImage(":/icons/instances/" + inst->iconKey()).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
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 <QProcess>
-#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
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
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;
+
+ /// 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;
- LauncherVersion m_launcherVersion;
- bool m_isNewLauncherVersion;
+ /// 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
--- /dev/null
+++ b/backend/OneSixInstance.cpp
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
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<QSharedPointer<Library> > FullVersion::getActiveNormalLibs()
+{
+ QList<QSharedPointer<Library> > output;
+ for ( auto lib: libraries )
+ {
+ if (lib->getIsActive() && !lib->getIsNative())
+ {
+ output.append(lib);
+ }
+ }
+ return output;
+}
+
+QList<QSharedPointer<Library> > FullVersion::getActiveNativeLibs()
+{
+ QList<QSharedPointer<Library> > 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
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 <QtCore>
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<QSharedPointer<Library> > 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<Rule> rules;
+
+public:
+ FullVersion()
+ {
+ minimumLauncherVersion = 0xDEADBEEF;
+ isLegacy = false;
+ }
+
+ QList<QSharedPointer<Library> > getActiveNormalLibs();
+ QList<QSharedPointer<Library> > getActiveNativeLibs();
+}; \ No newline at end of file
diff --git a/libmultimc/src/fullversionfactory.cpp b/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 <library.h>
-
-class LibraryFinalizer
-{
-public:
- LibraryFinalizer(QSharedPointer<Library> library)
- {
- m_library = library;
- }
-
- QSharedPointer<Library> m_library;
-};
+#include "VersionFactory.h"
+#include "OneSixVersion.h"
// Library rules (if any)
QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseObj)
diff --git a/libmultimc/include/fullversionfactory.h b/backend/VersionFactory.h
index 60e5c983..60e5c983 100644
--- a/libmultimc/include/fullversionfactory.h
+++ b/backend/VersionFactory.h
diff --git a/libmultimc/include/libmmc_config.h b/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 <QtCore/QtGlobal>
@@ -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
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
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 <QObject>
#include <QVariant>
@@ -120,5 +119,3 @@ protected slots:
*/
virtual void updateListData(QList<InstVersion *> versions) = 0;
};
-
-#endif // INSTVERSIONLIST_H
diff --git a/libmultimc/src/instancelist.cpp b/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 <QDir>
#include <QFile>
#include <QDirIterator>
@@ -24,8 +22,9 @@
#include <QJsonObject>
#include <QJsonArray>
-#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<Instance> inst(instPtr);
+ QSharedPointer<BaseInstance> 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
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 <QObject>
#include <QSharedPointer>
-#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
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 <QtNetwork>
diff --git a/libmultimc/include/lwjglversionlist.h b/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 <QObject>
#include <QAbstractListModel>
@@ -131,4 +130,3 @@ private slots:
virtual void netRequestComplete();
};
-#endif // LWJGLVERSIONLIST_H
diff --git a/libmultimc/src/minecraftversionlist.cpp b/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 <QDebug>
@@ -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
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 <QObject>
@@ -22,11 +21,11 @@
#include <QList>
-#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
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 <QtNetwork>
@@ -24,14 +24,14 @@
#include <QDebug>
-#include "minecraftversionlist.h"
-#include "fullversionfactory.h"
-#include <fullversion.h>
+#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
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 <QObject>
@@ -24,9 +23,9 @@
#include <QUrl>
#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
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
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 <QObject>
@@ -93,4 +92,3 @@ private:
Q_DECLARE_METATYPE(LoginResponse)
-#endif // LOGINRESPONSE_H
diff --git a/libmultimc/src/logintask.cpp b/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 <QStringList>
diff --git a/libmultimc/include/logintask.h b/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
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
index c8c12c02..c8c12c02 100644
--- a/libmultimc/include/task.h
+++ b/backend/tasks/Task.h
diff --git a/libmultimc/src/userinfo.cpp b/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
index 280f98de..280f98de 100644
--- a/libmultimc/include/userinfo.h
+++ b/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 <QDialog>
-#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<Instance*> ( index.internalPointer() );
+ BaseInstance *pdata = static_cast<BaseInstance*> ( 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<Instance*> ( left.internalPointer() );
- Instance *pdataRight = static_cast<Instance*> ( right.internalPointer() );
+ BaseInstance *pdataLeft = static_cast<BaseInstance*> ( left.internalPointer() );
+ BaseInstance *pdataRight = static_cast<BaseInstance*> ( 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 <QAbstractListModel>
#include "kcategorizedsortfilterproxymodel.h"
-#include "instancelist.h"
+#include "lists/InstanceList.h"
#include <QIcon>
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 <QDialog>
-#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<void *>();
+ BaseInstance * inst = (BaseInstance *) index.data(InstanceModel::InstancePointerRole).value<void *>();
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<void *>();
+ return (BaseInstance *) mindex.data(InstanceModel::InstancePointerRole).value<void *>();
}
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 <QMainWindow>
-#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 <QDialog>
-#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 <QDebug>
-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 <lists/MinecraftVersionList.h>
+#include "InstanceVersion.h"
-#include "task.h"
+#include "tasks/Task.h"
#include "versionselectdialog.h"
#include "taskdialog.h"
@@ -29,7 +29,7 @@
#include <QLayout>
#include <QPushButton>
-#include <minecraftversionlist.h>
+
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 <QFileDialog>
#include <QMessageBox>
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 <QKeyEvent>
-#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 <gui/taskdialog.h>
-#include <instversionlist.h>
-#include <instversion.h>
-#include <task.h>
+#include <lists/InstVersionList.h>
+#include <InstanceVersion.h>
+#include <tasks/Task.h>
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 <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/detail/ptree_utils.hpp>
-#include <boost/property_tree/detail/json_parser_error.hpp>
-#include <boost/spirit/include/classic.hpp>
-#include <boost/limits.hpp>
-#include <string>
-#include <locale>
-#include <istream>
-#include <vector>
-#include <algorithm>
-
-namespace boost { namespace property_tree { namespace json_parser
-{
-
- ///////////////////////////////////////////////////////////////////////
- // Json parser context
-
- template<class Ptree>
- struct context
- {
-
- typedef typename Ptree::key_type::value_type Ch;
- typedef std::basic_string<Ch> Str;
- typedef typename std::vector<Ch>::iterator It;
-
- Str string;
- Str name;
- Ptree root;
- std::vector<Ptree *> 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<unsigned long>((std::numeric_limits<Ch>::max)()));
- c.string += Ch(u);
- }
- };
-
- };
-
- ///////////////////////////////////////////////////////////////////////
- // Json grammar
-
- template<class Ptree>
- struct json_grammar :
- public boost::spirit::classic::grammar<json_grammar<Ptree> >
- {
-
- typedef context<Ptree> Context;
- typedef typename Ptree::key_type::value_type Ch;
-
- mutable Context c;
-
- template<class Scanner>
- struct definition
- {
-
- boost::spirit::classic::rule<Scanner>
- root, object, member, array, item, value, string, number;
- boost::spirit::classic::rule<
- typename boost::spirit::classic::lexeme_scanner<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<std::string> expect_root("expected object or array");
- assertion<std::string> expect_eoi("expected end of input");
- assertion<std::string> expect_objclose("expected ',' or '}'");
- assertion<std::string> expect_arrclose("expected ',' or ']'");
- assertion<std::string> expect_name("expected object name");
- assertion<std::string> expect_colon("expected ':'");
- assertion<std::string> expect_value("expected value");
- assertion<std::string> 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<Ch>("eE").c_str()) >>
- !chset_p(detail::widen<Ch>("-+").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<Ch>("\"\\/bfnrt").c_str())
- [typename Context::a_escape(self.c)]
- | 'u' >> uint_parser<unsigned long, 16, 4, 4>()
- [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<Scanner> &start() const
- {
- return root;
- }
-
- };
-
- };
-
- template<class It, class Ch>
- unsigned long count_lines(It begin, It end)
- {
- return static_cast<unsigned long>(std::count(begin, end, Ch('\n')) + 1);
- }
-
- template<class Ptree>
- void read_json_internal(std::basic_istream<typename Ptree::key_type::value_type> &stream,
- Ptree &pt,
- const std::string &filename)
- {
-
- using namespace boost::spirit::classic;
- typedef typename Ptree::key_type::value_type Ch;
- typedef typename std::vector<Ch>::iterator It;
-
- // Load data into vector
- std::vector<Ch> v(std::istreambuf_iterator<Ch>(stream.rdbuf()),
- std::istreambuf_iterator<Ch>());
- if (!stream.good())
- BOOST_PROPERTY_TREE_THROW(json_parser_error("read error", filename, 0));
-
- // Prepare grammar
- json_grammar<Ptree> g;
-
- // Parse
- try
- {
- parse_info<It> pi = parse(v.begin(), v.end(), g,
- space_p | comment_p("//") | comment_p("/*", "*/"));
- if (!pi.hit || !pi.full)
- BOOST_PROPERTY_TREE_THROW((parser_error<std::string, It>(v.begin(), "syntax error")));
- }
- catch (parser_error<std::string, It> &e)
- {
- BOOST_PROPERTY_TREE_THROW(json_parser_error(e.descriptor, filename, count_lines<It, Ch>(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 <QString>
-
-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<QSharedPointer<Library> > 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<Rule> rules;
-
-public:
- FullVersion()
- {
- minimumLauncherVersion = 0xDEADBEEF;
- isLegacy = false;
- }
-
- QList<QSharedPointer<Library> > getActiveNormalLibs();
- QList<QSharedPointer<Library> > 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 <QtCore>
-#include "fullversion.h"
-#include <library.h>
-
-QList<QSharedPointer<Library> > FullVersion::getActiveNormalLibs()
-{
- QList<QSharedPointer<Library> > output;
- for ( auto lib: libraries )
- {
- if (lib->getIsActive() && !lib->getIsNative())
- {
- output.append(lib);
- }
- }
- return output;
-}
-
-QList<QSharedPointer<Library> > FullVersion::getActiveNativeLibs()
-{
- QList<QSharedPointer<Library> > 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,13 +29,20 @@
/**
* @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<args.length(); i++)
+ {
+ QChar cchar = args.at(i);
+
+ // \ escaped
+ if (escape)
+ {
+ current += cchar;
+ escape = false;
+ // in "quotes"
+ }
+ else if (!inquotes.isNull())
+ {
+ if (cchar == 0x5C)
+ escape = true;
+ else if (cchar == inquotes)
+ inquotes = 0;
+ else
+ current += cchar;
+ // otherwise
+ }
+ else
+ {
+ if (cchar == 0x20)
+ {
+ if (!current.isEmpty())
+ {
+ argv << current;
+ current.clear();
+ }
+ }
+ else if (cchar == 0x22 || cchar == 0x27)
+ inquotes = cchar;
+ else
+ current += cchar;
+ }
+ }
+ if (!current.isEmpty())
+ argv << current;
+ return argv;
+}
+
+
Parser::Parser(FlagStyle::Enum flagStyle, ArgumentStyle::Enum argStyle)
{
m_flagStyle = flagStyle;
diff --git a/main.cpp b/main.cpp
index b9ca3a29..f2217331 100644
--- a/main.cpp
+++ b/main.cpp
@@ -26,11 +26,11 @@
#include "gui/taskdialog.h"
#include "gui/consolewindow.h"
-#include "appsettings.h"
-#include "instancelist.h"
-#include "loginresponse.h"
-#include "logintask.h"
-#include "minecraftprocess.h"
+#include "AppSettings.h"
+#include "lists/InstanceList.h"
+#include "tasks/LoginResponse.h"
+#include "tasks/LoginTask.h"
+#include "MinecraftProcess.h"
#include "pathutils.h"
#include "cmdutils.h"