From dd2e836b4cf4cfa043f9ea2911f58f1d22d4e282 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Feb 2013 19:10:09 -0600 Subject: [PATCH] Split MultiMC up into a few separate libraries. Fixed plugin system. Tons of other stuff... --- CMakeLists.txt | 113 ++++++++---------- data/plugin/instancetypeplugin.h | 41 ------- data/plugin/pluginmanager.cpp | 87 ++++++++------ data/plugin/pluginmanager.h | 17 +-- gui/mainwindow.cpp | 16 ++- gui/mainwindow.h | 2 +- gui/settingsdialog.cpp | 2 +- libinstance/CMakeLists.txt | 50 +++++--- {data/inst => libinstance/include}/instance.h | 14 ++- .../include}/instancelist.h | 6 +- .../include}/instanceloader.h | 28 +++-- .../include/instancetypeinterface.h | 13 +- .../include}/instversion.h | 4 +- .../include}/instversionlist.h | 4 +- .../include/libinstance_config.h | 16 ++- {data/inst => libinstance/src}/instance.cpp | 10 +- .../inst => libinstance/src}/instancelist.cpp | 32 +++-- .../src}/instanceloader.cpp | 25 ++-- .../src}/instversion.cpp | 4 +- .../src}/instversionlist.cpp | 2 +- libsettings/CMakeLists.txt | 30 +++++ {data => libsettings/include}/appsettings.h | 21 ++-- .../include/libsettings_config.h | 24 ++-- {data => libsettings/src}/appsettings.cpp | 2 +- libutil/CMakeLists.txt | 38 ++++++ {util => libutil/include}/apputils.h | 0 {data => libutil/include}/inifile.h | 4 +- .../include/libutil_config.h | 18 +-- {util => libutil/include}/osutils.h | 3 - {util => libutil/include}/pathutils.h | 8 +- {data => libutil/include}/siglist.h | 0 {data => libutil/include}/siglist_impl.h | 0 {data => libutil/src}/inifile.cpp | 2 +- {util => libutil/src}/osutils.cpp | 8 +- {util => libutil/src}/pathutils.cpp | 2 +- main.cpp | 4 +- plugins/stdinstance/CMakeLists.txt | 28 ++++- plugins/stdinstance/stdinstance.cpp | 5 +- plugins/stdinstance/stdinstance.h | 2 +- plugins/stdinstance/stdinstance.json | 9 +- plugins/stdinstance/stdinstancetype.cpp | 2 +- plugins/stdinstance/stdinstancetype.h | 8 +- 42 files changed, 404 insertions(+), 300 deletions(-) delete mode 100644 data/plugin/instancetypeplugin.h rename {data/inst => libinstance/include}/instance.h (97%) rename {data/inst => libinstance/include}/instancelist.h (89%) rename {data/inst => libinstance/include}/instanceloader.h (87%) rename data/inst/instancetype.h => libinstance/include/instancetypeinterface.h (89%) rename {data/version => libinstance/include}/instversion.h (95%) rename {data/version => libinstance/include}/instversionlist.h (93%) rename data/inst/instancetype.cpp => libinstance/include/libinstance_config.h (70%) rename {data/inst => libinstance/src}/instance.cpp (93%) rename {data/inst => libinstance/src}/instancelist.cpp (80%) rename {data/inst => libinstance/src}/instanceloader.cpp (78%) rename {data/version => libinstance/src}/instversion.cpp (92%) rename {data/version => libinstance/src}/instversionlist.cpp (94%) create mode 100644 libsettings/CMakeLists.txt rename {data => libsettings/include}/appsettings.h (85%) rename plugins/stdinstance/stdinstplugin.h => libsettings/include/libsettings_config.h (62%) rename {data => libsettings/src}/appsettings.cpp (96%) create mode 100644 libutil/CMakeLists.txt rename {util => libutil/include}/apputils.h (100%) rename {data => libutil/include}/inifile.h (91%) rename plugins/stdinstance/stdinstplugin.cpp => libutil/include/libutil_config.h (72%) rename {util => libutil/include}/osutils.h (89%) rename {util => libutil/include}/pathutils.h (74%) rename {data => libutil/include}/siglist.h (100%) rename {data => libutil/include}/siglist_impl.h (100%) rename {data => libutil/src}/inifile.cpp (98%) rename {util => libutil/src}/osutils.cpp (78%) rename {util => libutil/src}/pathutils.cpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e8f7a90f..eea4ded54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(MultiMC) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) #### Check for machine endianness #### INCLUDE(TestBigEndian) @@ -32,9 +33,22 @@ add_subdirectory(quazip) add_subdirectory(patchlib) include_directories(patchlib) -# add the java launcher +# Add the java launcher add_subdirectory(launcher) + +# Add the util library. +add_subdirectory(libutil) +include_directories(${LIBMMCUTIL_INCLUDE_DIR}) + +# Add the settings library. +add_subdirectory(libsettings) +include_directories(${LIBMMCSETTINGS_INCLUDE_DIR}) + +# Add the instance library. +add_subdirectory(libinstance) +include_directories(${LIBMMCINST_INCLUDE_DIR}) + # Add the stdinstance plugin. add_subdirectory(plugins/stdinstance) @@ -97,43 +111,6 @@ message(STATUS "Job URL: ${MultiMC_JOB_URL}") configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h") - -SET(MULTIMC_SOURCES -main.cpp - -data/appsettings.cpp -data/inifile.cpp -data/version.cpp -data/userinfo.cpp -data/loginresponse.cpp - -data/inst/instanceloader.cpp -data/inst/instancetype.cpp -data/inst/instance.cpp -data/inst/instancelist.cpp - -data/plugin/pluginmanager.cpp - -data/version/instversion.cpp -data/version/instversionlist.cpp - -gui/mainwindow.cpp -gui/modeditwindow.cpp -gui/settingsdialog.cpp -gui/newinstancedialog.cpp -gui/logindialog.cpp -gui/taskdialog.cpp - -util/pathutils.cpp -util/osutils.cpp - -java/javautils.cpp -java/annotations.cpp - -tasks/task.cpp -tasks/logintask.cpp -) - SET(MULTIMC_HEADERS gui/mainwindow.h gui/modeditwindow.h @@ -142,28 +119,11 @@ gui/newinstancedialog.h gui/logindialog.h gui/taskdialog.h -data/appsettings.h -data/inifile.h data/version.h data/userinfo.h data/loginresponse.h -data/siglist.h -data/siglist_impl.h - -data/inst/instanceloader.h -data/inst/instancetype.h -data/inst/instance.h -data/inst/instancelist.h data/plugin/pluginmanager.h -data/plugin/instancetypeplugin.h - -data/version/instversion.h -data/version/instversionlist.h - -util/apputils.h -util/pathutils.h -util/osutils.h multimc_pragma.h @@ -179,6 +139,29 @@ tasks/task.h tasks/logintask.h ) +SET(MULTIMC_SOURCES +main.cpp + +data/version.cpp +data/userinfo.cpp +data/loginresponse.cpp + +data/plugin/pluginmanager.cpp + +gui/mainwindow.cpp +gui/modeditwindow.cpp +gui/settingsdialog.cpp +gui/newinstancedialog.cpp +gui/logindialog.cpp +gui/taskdialog.cpp + +java/javautils.cpp +java/annotations.cpp + +tasks/task.cpp +tasks/logintask.cpp +) + SET(MULTIMC5_UIS gui/mainwindow.ui gui/modeditwindow.ui @@ -214,8 +197,10 @@ QT5_ADD_RESOURCES(MULTIMC_QRC multimc.qrc) add_executable(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC}) qt5_use_modules(MultiMC Widgets Network) -target_link_libraries(MultiMC quazip patchlib stdinstance ${MultiMC_LINK_ADDITIONAL_LIBS}) -add_dependencies(MultiMC MultiMCLauncher) +target_link_libraries(MultiMC quazip patchlib +libmmcutil libmmcsettings libmmcinst +${MultiMC_LINK_ADDITIONAL_LIBS}) +add_dependencies(MultiMC MultiMCLauncher libmmcutil libmmcsettings libmmcinst) ################ Dirs ################ @@ -225,9 +210,9 @@ SET(QTCONF_DEST_DIR bin) SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") IF(WIN32) - #SET(PLUGIN_DEST_DIR .) - #SET(QTCONF_DEST_DIR .) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC.exe") + SET(PLUGIN_DEST_DIR .) + SET(QTCONF_DEST_DIR .) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") ENDIF() IF(APPLE) SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS) @@ -255,7 +240,7 @@ ENDIF(APPLE) IF(WIN32) INSTALL(TARGETS MultiMC BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION bin COMPONENT Runtime + RUNTIME DESTINATION . COMPONENT Runtime ) ENDIF() IF(UNIX) @@ -287,7 +272,11 @@ INSTALL(CODE " # Dirs to look for dependencies. -SET(DIRS ${QT_LIBRARY_DIRS}) +SET(DIRS "${QT_LIBRARY_DIRS} +${CMAKE_BINARY_DIR}/libutil +${CMAKE_BINARY_DIR}/libsettings +${CMAKE_BINARY_DIR}/libinstance") +message(STATUS "${DIRS}") INSTALL(CODE " file(GLOB_RECURSE QTPLUGINS diff --git a/data/plugin/instancetypeplugin.h b/data/plugin/instancetypeplugin.h deleted file mode 100644 index 8e3febdb2..000000000 --- a/data/plugin/instancetypeplugin.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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. - */ - -#ifndef INSTANCETYPEPLUGIN_H -#define INSTANCETYPEPLUGIN_H - -#include - -#include "data/inst/instancetype.h" - -/*! - * \brief Interface for plugins that want to provide custom instance types. - */ -class InstanceTypePlugin -{ -public: - /*! - * \brief Gets a QList containing the instance types that this plugin provides. - * These instance types are then registered with the InstanceLoader. - * The InstanceType objects should \e not be deleted by the plugin. Once they - * are registered, they belong to the InstanceLoader. - * \return A QList containing this plugin's instance types. - */ - virtual QList getInstanceTypes() = 0; -}; - -Q_DECLARE_INTERFACE(InstanceTypePlugin, "net.forkk.MultiMC.InstanceTypePlugin/0.1") - -#endif // INSTANCETYPEPLUGIN_H diff --git a/data/plugin/pluginmanager.cpp b/data/plugin/pluginmanager.cpp index cd33b285f..2f0662936 100644 --- a/data/plugin/pluginmanager.cpp +++ b/data/plugin/pluginmanager.cpp @@ -18,10 +18,17 @@ #include #include #include +#include + +#include #include -#include "data/plugin/instancetypeplugin.h" +#include "instancetypeinterface.h" + +// MultiMC's API version. This must match the "api" field in each plugin's +// metadata or MultiMC won't consider them valid MultiMC plugin. +#define MMC_API_VERSION "MultiMC5-API-1" PluginManager PluginManager::manager; @@ -33,8 +40,16 @@ PluginManager::PluginManager() : bool PluginManager::loadPlugins(QString pluginDir) { + // Delete the loaded plugins and clear the list. + for (int i = 0; i < m_plugins.count(); i++) + { + delete m_plugins[i]; + } m_plugins.clear(); + qDebug(QString("Loading plugins from directory: %1"). + arg(pluginDir).toUtf8()); + QDir dir(pluginDir); QDirIterator iter(dir); @@ -44,53 +59,47 @@ bool PluginManager::loadPlugins(QString pluginDir) if (pluginFile.exists() && pluginFile.isFile()) { - QPluginLoader pluginLoader(pluginFile.absoluteFilePath()); - pluginLoader.load(); - QObject *plugin = pluginLoader.instance(); - if (plugin) - { - qDebug(QString("Loaded plugin %1."). - arg(pluginFile.baseName()).toUtf8()); - m_plugins.push_back(plugin); - } - else - { - qWarning(QString("Error loading plugin %1. Not a valid plugin."). - arg(pluginFile.baseName()).toUtf8()); - } - } - } - - return true; -} - -bool PluginManager::initInstanceTypes() -{ - for (int i = 0; i < m_plugins.count(); i++) - { - InstanceTypePlugin *plugin = qobject_cast(m_plugins[i]); - if (plugin) - { - QList instanceTypes = plugin->getInstanceTypes(); + qDebug(QString("Attempting to load plugin: %1"). + arg(pluginFile.canonicalFilePath()).toUtf8()); - for (int i = 0; i < instanceTypes.count(); i++) + QPluginLoader *pluginLoader = new QPluginLoader(pluginFile.absoluteFilePath()); + + QJsonObject pluginInfo = pluginLoader->metaData(); + QJsonObject pluginMetadata = pluginInfo.value("MetaData").toObject(); + + if (pluginMetadata.value("api").toString("") != MMC_API_VERSION) { - InstanceLoader::InstTypeError error = - InstanceLoader::loader.registerInstanceType(instanceTypes[i]); - switch (error) - { - case InstanceLoader::TypeIDExists: - qWarning(QString("Instance type %1 already registered."). - arg(instanceTypes[i]->typeID()).toUtf8()); - } + // If "api" is not specified, it's not a MultiMC plugin. + qDebug(QString("Not loading plugin %1. Not a valid MultiMC plugin. " + "API: %2"). + arg(pluginFile.canonicalFilePath(), pluginMetadata.value("api").toString("")).toUtf8()); + continue; } + + qDebug(QString("Loaded plugin: %1"). + arg(pluginInfo.value("IID").toString()).toUtf8()); + m_plugins.push_back(pluginLoader); } } return true; } -QObject *PluginManager::getPlugin(int index) +QPluginLoader *PluginManager::getPlugin(int index) { return m_plugins[index]; } + +void PluginManager::initInstanceTypes() +{ + for (int i = 0; i < m_plugins.count(); i++) + { + InstanceTypeInterface *instType = qobject_cast(m_plugins[i]->instance()); + + if (instType) + { + // TODO: Handle errors + InstanceLoader::get().registerInstanceType(instType); + } + } +} diff --git a/data/plugin/pluginmanager.h b/data/plugin/pluginmanager.h index 8e2dba0da..b93fd6d27 100644 --- a/data/plugin/pluginmanager.h +++ b/data/plugin/pluginmanager.h @@ -41,12 +41,6 @@ public: */ bool loadPlugins(QString pluginDir); - /*! - * \brief Initializes the instance type plugins. - * \return True if successful. False on failure. - */ - bool initInstanceTypes(); - /*! * \brief Checks how many plugins are loaded. * \return The number of plugins. @@ -58,12 +52,19 @@ public: * \param index The index of the plugin to get. * \return The plugin at the given index. */ - QObject *getPlugin(int index); + QPluginLoader *getPlugin(int index); + + /*! + * \brief Initializes and registers all the instance types. + * This is done by going through the plugin list and registering all of the + * plugins that derive from the InstanceTypeInterface with the InstanceLoader. + */ + void initInstanceTypes(); private: PluginManager(); - QList m_plugins; + QList m_plugins; static PluginManager manager; }; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index d19d69dcf..19ff21085 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -21,20 +21,25 @@ #include #include +#include -#include "util/osutils.h" +#include "osutils.h" #include "gui/settingsdialog.h" #include "gui/newinstancedialog.h" #include "gui/logindialog.h" #include "gui/taskdialog.h" -#include "data/inst/instancelist.h" -#include "data/appsettings.h" +#include "instancelist.h" +#include "appsettings.h" #include "data/version.h" #include "tasks/logintask.h" +// Opens the given file in the default application. +// TODO: Move this somewhere. +void openInDefaultProgram(QString filename); + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -156,3 +161,8 @@ void MainWindow::onLoginComplete(LoginResponse response) QString("Logged in as %1 with session ID %2."). arg(response.getUsername(), response.getSessionID())); } + +void openInDefaultProgram(QString filename) +{ + QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath()); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index d286bd0e5..591d06326 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -18,7 +18,7 @@ #include -#include "data/inst/instancelist.h" +#include "instancelist.h" #include "data/loginresponse.h" namespace Ui diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index ab4d18ee9..b3c423803 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -16,7 +16,7 @@ #include "settingsdialog.h" #include "ui_settingsdialog.h" -#include "data/appsettings.h" +#include "appsettings.h" #include #include diff --git a/libinstance/CMakeLists.txt b/libinstance/CMakeLists.txt index 503bda751..d0a9aa085 100644 --- a/libinstance/CMakeLists.txt +++ b/libinstance/CMakeLists.txt @@ -1,31 +1,47 @@ -project(stdinstance) +project(libmmcinst) -ADD_DEFINITIONS(-DQT_PLUGIN) +set(CMAKE_AUTOMOC ON) # Find Qt find_package(Qt5Core REQUIRED) -find_package(Qt5Network REQUIRED) # Include Qt headers. include_directories(${Qt5Base_INCLUDE_DIRS}) include_directories(${Qt5Network_INCLUDE_DIRS}) -# Include MultiMC's headers. -include_directories(../../) +# Include utility library. +include_directories(${CMAKE_SOURCE_DIR}/libutil/include) -SET(STDINST_HEADERS -stdinstplugin.h -stdinstancetype.h -stdinstance.h +# Include utility library. +include_directories(${CMAKE_SOURCE_DIR}/libsettings/include) + +SET(LIBINST_HEADERS +include/libinstance_config.h + +include/instancetypeinterface.h + +include/instance.h +include/instancelist.h +include/instanceloader.h + +include/instversion.h +include/instversionlist.h ) -SET(STDINST_SOURCES -stdinstplugin.cpp -stdinstancetype.cpp -stdinstance.cpp +SET(LIBINST_SOURCES +src/instance.cpp +src/instancelist.cpp +src/instanceloader.cpp + +src/instversion.cpp +src/instversionlist.cpp ) -add_library(stdinstance SHARED ${STDINST_SOURCES} ${STDINST_HEADERS}) -set_target_properties(stdinstance PROPERTIES PREFIX "") -qt5_use_modules(stdinstance Core Network) -target_link_libraries(stdinstance quazip patchlib) +# Set the include dir path. +SET(LIBMMCINST_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) + +add_definitions(-DLIBMMCINST_LIBRARY) + +add_library(libmmcinst SHARED ${LIBINST_SOURCES} ${LIBINST_HEADERS}) +qt5_use_modules(libmmcinst Core) +target_link_libraries(libmmcinst libmmcutil libmmcsettings) diff --git a/data/inst/instance.h b/libinstance/include/instance.h similarity index 97% rename from data/inst/instance.h rename to libinstance/include/instance.h index 035704b93..7b3c001db 100644 --- a/data/inst/instance.h +++ b/libinstance/include/instance.h @@ -19,8 +19,10 @@ #include #include -#include "data/appsettings.h" -#include "data/inifile.h" +#include "appsettings.h" +#include "inifile.h" + +#include "libinstance_config.h" #define DEFINE_OVERRIDDEN_SETTING_ADVANCED(funcName, cfgEntryName, typeName) \ typeName get ## funcName() const { return getField(cfgEntryName, settings->get ## funcName()).value(); } @@ -38,7 +40,7 @@ class InstanceList; * To create a new instance type, create a new class inheriting from this class * and implement the pure virtual functions. */ -class Instance : public SettingsBase +class LIBMMCINST_EXPORT Instance : public SettingsBase { Q_OBJECT public: @@ -62,13 +64,13 @@ public: * * \return The instance's ID. */ - virtual QString id(); + virtual QString id() const; /*! * \brief Gets the path to the instance's root directory. * \return The path to the instance's root directory. */ - virtual QString rootDir(); + virtual QString rootDir() const; /*! * \brief Gets the instance list that this instance is a part of. @@ -76,7 +78,7 @@ public: * (the parent is not an InstanceList). * \return A pointer to the InstanceList containing this instance. */ - virtual InstanceList *instList(); + virtual InstanceList *instList() const; //////// FIELDS AND SETTINGS //////// diff --git a/data/inst/instancelist.h b/libinstance/include/instancelist.h similarity index 89% rename from data/inst/instancelist.h rename to libinstance/include/instancelist.h index c43c4cc08..f6be815c9 100644 --- a/data/inst/instancelist.h +++ b/libinstance/include/instancelist.h @@ -20,11 +20,13 @@ #include -#include "data/siglist.h" +#include "siglist.h" + +#include "libinstance_config.h" class Instance; -class InstanceList : public QObject, public SigList> +class LIBMMCINST_EXPORT InstanceList : public QObject, public SigList> { Q_OBJECT public: diff --git a/data/inst/instanceloader.h b/libinstance/include/instanceloader.h similarity index 87% rename from data/inst/instanceloader.h rename to libinstance/include/instanceloader.h index 60c4e998b..396966392 100644 --- a/data/inst/instanceloader.h +++ b/libinstance/include/instanceloader.h @@ -20,21 +20,26 @@ #include #include -class InstanceType; +#include "libinstance_config.h" + +class InstanceTypeInterface; class Instance; -typedef QList InstTypeList; +typedef QList InstTypeList; /*! * \brief The InstanceLoader is a singleton that manages all of the instance types and handles loading and creating instances. * Instance types are registered with the instance loader through its registerInstType() function. * Creating instances is done through the InstanceLoader's createInstance() function. This function takes */ -class InstanceLoader : public QObject +class LIBMMCINST_EXPORT InstanceLoader : public QObject { Q_OBJECT public: - static InstanceLoader loader; + /*! + * \brief Gets a reference to the instance loader. + */ + static InstanceLoader &get() { return loader; } /*! * \brief Error codes returned by functions in the InstanceLoader and InstanceType classes. @@ -62,15 +67,12 @@ public: /*! * \brief Registers the given InstanceType with the instance loader. - * This causes the instance loader to take ownership of the given - * instance type (meaning the instance type's parent will be set to - * the instance loader). * * \param type The InstanceType to register. * \return An InstTypeError error code. * - TypeIDExists if the given type's is already registered to another instance type. */ - InstTypeError registerInstanceType(InstanceType *type); + InstTypeError registerInstanceType(InstanceTypeInterface *type); /*! * \brief Creates an instance with the given type and stores it in inst. @@ -82,7 +84,7 @@ public: * - TypeNotRegistered if the given type is not registered with the InstanceLoader. * - InstExists if the given instance directory is already an instance. */ - InstTypeError createInstance(Instance *inst, const InstanceType *type, const QString &instDir); + InstTypeError createInstance(Instance *inst, const InstanceTypeInterface *type, const QString &instDir); /*! * \brief Loads an instance from the given directory. @@ -95,7 +97,7 @@ public: * - NotAnInstance if the given instance directory isn't a valid instance. * - WrongInstType if the given instance directory's type isn't the same as the given type. */ - InstTypeError loadInstance(Instance *inst, const InstanceType *type, const QString &instDir); + InstTypeError loadInstance(Instance *inst, const InstanceTypeInterface *type, const QString &instDir); /*! * \brief Loads an instance from the given directory. @@ -115,7 +117,7 @@ public: * \param id The ID of the type to find. * \return The type with the given ID. NULL if none were found. */ - const InstanceType *findType(const QString &id); + const InstanceTypeInterface *findType(const QString &id); /*! * \brief Gets a list of the registered instance types. @@ -127,7 +129,9 @@ public: private: InstanceLoader(); - QMap m_typeMap; + QMap m_typeMap; + + static InstanceLoader loader; }; #endif // INSTANCELOADER_H diff --git a/data/inst/instancetype.h b/libinstance/include/instancetypeinterface.h similarity index 89% rename from data/inst/instancetype.h rename to libinstance/include/instancetypeinterface.h index bd22a17cc..a061b9d2e 100644 --- a/data/inst/instancetype.h +++ b/libinstance/include/instancetypeinterface.h @@ -20,20 +20,21 @@ #include "instanceloader.h" +//! The InstanceTypeInterface's interface ID. +#define InstanceTypeInterface_IID "net.forkk.MultiMC.InstanceTypeInterface/0.1" + /*! - * \brief The InstanceType class is a base class for all instance types. + * \brief The InstanceType class is an interface for all instance types. + * InstanceTypes are usually provided by plugins. * It handles loading and creating instances of a certain type. There should be * one of these for each type of instance and they should be registered with the * InstanceLoader. * To create an instance, the InstanceLoader calls the type's createInstance() * function. Loading is done through the loadInstance() function. */ -class InstanceType : public QObject +class InstanceTypeInterface { - Q_OBJECT public: - explicit InstanceType(QObject *parent = 0); - friend class InstanceLoader; /*! @@ -80,4 +81,6 @@ protected: virtual InstanceLoader::InstTypeError loadInstance(Instance *inst, const QString &instDir) const = 0; }; +Q_DECLARE_INTERFACE(InstanceTypeInterface, InstanceTypeInterface_IID) + #endif // INSTANCETYPE_H diff --git a/data/version/instversion.h b/libinstance/include/instversion.h similarity index 95% rename from data/version/instversion.h rename to libinstance/include/instversion.h index 361563fd7..c505c5a3d 100644 --- a/data/version/instversion.h +++ b/libinstance/include/instversion.h @@ -18,9 +18,11 @@ #include +#include "libinstance_config.h" + class InstVersionList; -class InstVersion : public QObject +class LIBMMCINST_EXPORT InstVersion : public QObject { Q_OBJECT public: diff --git a/data/version/instversionlist.h b/libinstance/include/instversionlist.h similarity index 93% rename from data/version/instversionlist.h rename to libinstance/include/instversionlist.h index f79bc1b03..2cd9ed1e4 100644 --- a/data/version/instversionlist.h +++ b/libinstance/include/instversionlist.h @@ -18,13 +18,15 @@ #include +#include "libinstance_config.h" + class InstVersion; // Class that each instance type's version list derives from. Version lists are // the lists that keep track of the available game versions for that instance. // This list will not be loaded on startup. It will be loaded when the list's // load function is called. -class InstVersionList : public QObject +class LIBMMCINST_EXPORT InstVersionList : public QObject { Q_OBJECT public: diff --git a/data/inst/instancetype.cpp b/libinstance/include/libinstance_config.h similarity index 70% rename from data/inst/instancetype.cpp rename to libinstance/include/libinstance_config.h index 4f27542dd..2e6dc8847 100644 --- a/data/inst/instancetype.cpp +++ b/libinstance/include/libinstance_config.h @@ -13,9 +13,15 @@ * limitations under the License. */ -#include "instancetype.h" +//#ifndef LIBINSTANCE_CONFIG_H +//#define LIBINSTANCE_CONFIG_H -InstanceType::InstanceType(QObject *parent) : - QObject(parent) -{ -} +#include + +#ifdef LIBMMCINST_LIBRARY +# define LIBMMCINST_EXPORT Q_DECL_EXPORT +#else +# define LIBMMCINST_EXPORT Q_DECL_IMPORT +#endif + +//#endif // LIBINSTANCE_CONFIG_H diff --git a/data/inst/instance.cpp b/libinstance/src/instance.cpp similarity index 93% rename from data/inst/instance.cpp rename to libinstance/src/instance.cpp index 5db0be209..c79c02138 100644 --- a/data/inst/instance.cpp +++ b/libinstance/src/instance.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "instance.h" +#include "include/instance.h" #include -#include "util/pathutils.h" +#include "pathutils.h" Instance::Instance(const QString &rootDir, QObject *parent) : SettingsBase(parent) @@ -26,17 +26,17 @@ Instance::Instance(const QString &rootDir, QObject *parent) : config.loadFile(PathCombine(rootDir, "instance.cfg")); } -QString Instance::id() +QString Instance::id() const { return QFileInfo(rootDir()).baseName(); } -QString Instance::rootDir() +QString Instance::rootDir() const { return m_rootDir; } -InstanceList *Instance::instList() +InstanceList *Instance::instList() const { if (parent()->inherits("InstanceList")) return (InstanceList *)parent(); diff --git a/data/inst/instancelist.cpp b/libinstance/src/instancelist.cpp similarity index 80% rename from data/inst/instancelist.cpp rename to libinstance/src/instancelist.cpp index cbb89f051..15f79d05d 100644 --- a/data/inst/instancelist.cpp +++ b/libinstance/src/instancelist.cpp @@ -13,18 +13,18 @@ * limitations under the License. */ -#include "instancelist.h" +#include "include/instancelist.h" -#include "data/siglist_impl.h" +#include "siglist_impl.h" #include #include #include -#include "instance.h" -#include "instanceloader.h" +#include "include/instance.h" +#include "include/instanceloader.h" -#include "util/pathutils.h" +#include "pathutils.h" InstanceList::InstanceList(const QString &instDir, QObject *parent) : @@ -44,16 +44,11 @@ InstanceList::InstListError InstanceList::loadList() if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) { QSharedPointer inst; - InstanceLoader::InstTypeError error = InstanceLoader::loader. + InstanceLoader::InstTypeError error = InstanceLoader::get(). loadInstance(inst.data(), subDir); - if (inst.data() && error == InstanceLoader::NoError) - { - qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8()); - inst->setParent(this); - append(QSharedPointer(inst)); - } - else if (error != InstanceLoader::NotAnInstance) + if (error != InstanceLoader::NoError && + error != InstanceLoader::NotAnInstance) { QString errorMsg = QString("Failed to load instance %1: "). arg(QFileInfo(subDir).baseName()).toUtf8(); @@ -63,6 +58,11 @@ InstanceList::InstListError InstanceList::loadList() case InstanceLoader::TypeNotRegistered: errorMsg += "Instance type not found."; break; + + default: + errorMsg += QString("Unknown instance loader error %1"). + arg(error); + break; } qDebug(errorMsg.toUtf8()); } @@ -71,6 +71,12 @@ InstanceList::InstListError InstanceList::loadList() qDebug(QString("Error loading instance %1. Instance loader returned null."). arg(QFileInfo(subDir).baseName()).toUtf8()); } + else + { + qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8()); + inst->setParent(this); + append(QSharedPointer(inst)); + } } } diff --git a/data/inst/instanceloader.cpp b/libinstance/src/instanceloader.cpp similarity index 78% rename from data/inst/instanceloader.cpp rename to libinstance/src/instanceloader.cpp index e80a0e9e7..eff9d56ee 100644 --- a/data/inst/instanceloader.cpp +++ b/libinstance/src/instanceloader.cpp @@ -13,15 +13,15 @@ * limitations under the License. */ -#include "instanceloader.h" +#include "include/instanceloader.h" #include -#include "instancetype.h" +#include "include/instancetypeinterface.h" -#include "data/inifile.h" +#include "inifile.h" -#include "util/pathutils.h" +#include "pathutils.h" InstanceLoader InstanceLoader::loader; @@ -32,22 +32,25 @@ InstanceLoader::InstanceLoader() : } -InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceType *type) +InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceTypeInterface *type) { // Check to see if the type ID exists. if (m_typeMap.contains(type->typeID())) return TypeIDExists; // Set the parent to this. - type->setParent(this); + // ((QObject *)type)->setParent(this); // Add it to the map. m_typeMap.insert(type->typeID(), type); + + qDebug(QString("Registered instance type %1."). + arg(type->typeID()).toUtf8()); return NoError; } InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst, - const InstanceType *type, + const InstanceTypeInterface *type, const QString &instDir) { // Check if the type is registered. @@ -59,7 +62,7 @@ InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst, } InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst, - const InstanceType *type, + const InstanceTypeInterface *type, const QString &instDir) { // Check if the type is registered. @@ -79,13 +82,13 @@ InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst, INIFile ini; ini.loadFile(instConfig.path()); - QString typeName = ini.get("type", "StdInstance").toString(); - const InstanceType *type = findType(typeName); + QString typeName = ini.get("type", "net.forkk.MultiMC.StdInstance").toString(); + const InstanceTypeInterface *type = findType(typeName); return loadInstance(inst, type, instDir); } -const InstanceType *InstanceLoader::findType(const QString &id) +const InstanceTypeInterface *InstanceLoader::findType(const QString &id) { if (!m_typeMap.contains(id)) return NULL; diff --git a/data/version/instversion.cpp b/libinstance/src/instversion.cpp similarity index 92% rename from data/version/instversion.cpp rename to libinstance/src/instversion.cpp index 1493153af..cedb61df3 100644 --- a/data/version/instversion.cpp +++ b/libinstance/src/instversion.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "instversion.h" -#include "instversionlist.h" +#include "include/instversion.h" +#include "include/instversionlist.h" InstVersion::InstVersion(InstVersionList *parent) : QObject(parent) diff --git a/data/version/instversionlist.cpp b/libinstance/src/instversionlist.cpp similarity index 94% rename from data/version/instversionlist.cpp rename to libinstance/src/instversionlist.cpp index ab57f94c9..e171cfa5a 100644 --- a/data/version/instversionlist.cpp +++ b/libinstance/src/instversionlist.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "instversionlist.h" +#include "include/instversionlist.h" InstVersionList::InstVersionList() : QObject(NULL) diff --git a/libsettings/CMakeLists.txt b/libsettings/CMakeLists.txt new file mode 100644 index 000000000..2cf723653 --- /dev/null +++ b/libsettings/CMakeLists.txt @@ -0,0 +1,30 @@ +project(libmmcsettings) + +# Find Qt +find_package(Qt5Core REQUIRED) + +# Include Qt headers. +include_directories(${Qt5Base_INCLUDE_DIRS}) +include_directories(${Qt5Network_INCLUDE_DIRS}) + +# Include utils library headers. +include_directories(${CMAKE_SOURCE_DIR}/libutil/include) + +SET(LIBSETTINGS_HEADERS +include/libsettings_config.h + +include/appsettings.h +) + +SET(LIBSETTINGS_SOURCES +src/appsettings.cpp +) + +# Set the include dir path. +SET(LIBMMCSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) + +add_definitions(-DLIBMMCSETTINGS_LIBRARY) + +add_library(libmmcsettings SHARED ${LIBSETTINGS_SOURCES} ${LIBSETTINGS_HEADERS}) +qt5_use_modules(libmmcsettings Core) +target_link_libraries(libmmcsettings libmmcutil) diff --git a/data/appsettings.h b/libsettings/include/appsettings.h similarity index 85% rename from data/appsettings.h rename to libsettings/include/appsettings.h index 8a786db02..795156185 100644 --- a/data/appsettings.h +++ b/libsettings/include/appsettings.h @@ -18,11 +18,13 @@ #include #include -#include +//#include #include -#include "util/apputils.h" -#include "util/osutils.h" +#include +#include + +#include "libsettings_config.h" #if WINDOWS #define JPATHKEY "JavaPathWindows" @@ -40,7 +42,7 @@ DEFINE_SETTING_ADVANCED(name, STR_VAL(name), valType, defVal) -class SettingsBase : public QObject +class LIBMMCSETTINGS_EXPORT SettingsBase : public QObject { Q_OBJECT public: @@ -64,9 +66,10 @@ public: DEFINE_SETTING(InstanceToolbarPosition, QPoint, QPoint()) // Console Colors - DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue)) - DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black)) - DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red)) + // Currently commented out because QColor is a part of QtGUI +// DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue)) +// DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black)) +// DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red)) // Window Size DEFINE_SETTING(LaunchCompatMode, bool, false) @@ -93,7 +96,7 @@ public: virtual void setValue(const QString& name, QVariant val) = 0; }; -class AppSettings : public SettingsBase +class LIBMMCSETTINGS_EXPORT AppSettings : public SettingsBase { Q_OBJECT public: @@ -111,6 +114,6 @@ protected: #undef DEFINE_SETTING_ADVANCED #undef DEFINE_SETTING -extern AppSettings* settings; +LIBMMCSETTINGS_EXPORT extern AppSettings* settings; #endif // APPSETTINGS_H diff --git a/plugins/stdinstance/stdinstplugin.h b/libsettings/include/libsettings_config.h similarity index 62% rename from plugins/stdinstance/stdinstplugin.h rename to libsettings/include/libsettings_config.h index f44409bd5..05df5bfae 100644 --- a/plugins/stdinstance/stdinstplugin.h +++ b/libsettings/include/libsettings_config.h @@ -13,21 +13,15 @@ * limitations under the License. */ -#ifndef STDINSTPLUGIN_H -#define STDINSTPLUGIN_H +#ifndef LIBINSTANCE_CONFIG_H +#define LIBINSTANCE_CONFIG_H -#include +#include -#include +#ifdef LIBMMCSETTINGS_LIBRARY +# define LIBMMCSETTINGS_EXPORT Q_DECL_EXPORT +#else +# define LIBMMCSETTINGS_EXPORT Q_DECL_IMPORT +#endif -class StdInstPlugin : public QObject, InstanceTypePlugin -{ - Q_OBJECT - Q_INTERFACES(InstanceTypePlugin) - Q_PLUGIN_METADATA(IID "net.forkk.MultiMC.Plugins.StdInstance") - -public: - virtual QList getInstanceTypes(); -}; - -#endif // STDINSTPLUGIN_H +#endif // LIBINSTANCE_CONFIG_H diff --git a/data/appsettings.cpp b/libsettings/src/appsettings.cpp similarity index 96% rename from data/appsettings.cpp rename to libsettings/src/appsettings.cpp index 1d9c4312a..8fe9b8ad9 100644 --- a/data/appsettings.cpp +++ b/libsettings/src/appsettings.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "appsettings.h" +#include "include/appsettings.h" AppSettings* settings; diff --git a/libutil/CMakeLists.txt b/libutil/CMakeLists.txt new file mode 100644 index 000000000..b6eadf506 --- /dev/null +++ b/libutil/CMakeLists.txt @@ -0,0 +1,38 @@ +project(libmmcutil) + +# Find Qt +find_package(Qt5Core REQUIRED) + +# Include Qt headers. +include_directories(${Qt5Base_INCLUDE_DIRS}) +include_directories(${Qt5Network_INCLUDE_DIRS}) + +SET(LIBUTIL_HEADERS +include/libutil_config.h + +include/apputils.h + +include/pathutils.h +include/osutils.h + +include/inifile.h + +include/siglist.h +include/siglist_impl.h +) + +SET(LIBUTIL_SOURCES +src/pathutils.cpp +src/osutils.cpp + +src/inifile.cpp +) + +# Set the include dir path. +SET(LIBMMCUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE) + +add_definitions(-DLIBMMCUTIL_LIBRARY) + +add_library(libmmcutil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS}) +qt5_use_modules(libmmcutil Core) +target_link_libraries(libmmcutil) diff --git a/util/apputils.h b/libutil/include/apputils.h similarity index 100% rename from util/apputils.h rename to libutil/include/apputils.h diff --git a/data/inifile.h b/libutil/include/inifile.h similarity index 91% rename from data/inifile.h rename to libutil/include/inifile.h index 757838598..1280c7e3d 100644 --- a/data/inifile.h +++ b/libutil/include/inifile.h @@ -20,8 +20,10 @@ #include #include +#include "libutil_config.h" + // Sectionless INI parser (for instance config files) -class INIFile : public QMap +class LIBMMCUTIL_EXPORT INIFile : public QMap { public: explicit INIFile(); diff --git a/plugins/stdinstance/stdinstplugin.cpp b/libutil/include/libutil_config.h similarity index 72% rename from plugins/stdinstance/stdinstplugin.cpp rename to libutil/include/libutil_config.h index 98e12ae0f..41766184b 100644 --- a/plugins/stdinstance/stdinstplugin.cpp +++ b/libutil/include/libutil_config.h @@ -13,15 +13,15 @@ * limitations under the License. */ -#include "stdinstplugin.h" +#ifndef LIBUTIL_CONFIG_H +#define LIBUTIL_CONFIG_H -#include +#include -#include "stdinstancetype.h" +#ifdef LIBMMCUTIL_LIBRARY +# define LIBMMCUTIL_EXPORT Q_DECL_EXPORT +#else +# define LIBMMCUTIL_EXPORT Q_DECL_IMPORT +#endif -QList StdInstPlugin::getInstanceTypes() -{ - QList types; - types.push_back(new StdInstanceType(this)); - return types; -} +#endif // LIBUTIL_CONFIG_H diff --git a/util/osutils.h b/libutil/include/osutils.h similarity index 89% rename from util/osutils.h rename to libutil/include/osutils.h index f779ea2df..c5d4bb613 100644 --- a/util/osutils.h +++ b/libutil/include/osutils.h @@ -26,7 +26,4 @@ #define LINUX 1 #endif -// Opens the given file in the default application. -void openInDefaultProgram(QString filename); - #endif // OSUTILS_H diff --git a/util/pathutils.h b/libutil/include/pathutils.h similarity index 74% rename from util/pathutils.h rename to libutil/include/pathutils.h index 1922e3a08..d5f106efb 100644 --- a/util/pathutils.h +++ b/libutil/include/pathutils.h @@ -18,9 +18,11 @@ #include -QString PathCombine(QString path1, QString path2); -QString PathCombine(QString path1, QString path2, QString path3); +#include "libutil_config.h" -QString AbsolutePath(QString path); +LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2); +LIBMMCUTIL_EXPORT QString PathCombine(QString path1, QString path2, QString path3); + +LIBMMCUTIL_EXPORT QString AbsolutePath(QString path); #endif // PATHUTILS_H diff --git a/data/siglist.h b/libutil/include/siglist.h similarity index 100% rename from data/siglist.h rename to libutil/include/siglist.h diff --git a/data/siglist_impl.h b/libutil/include/siglist_impl.h similarity index 100% rename from data/siglist_impl.h rename to libutil/include/siglist_impl.h diff --git a/data/inifile.cpp b/libutil/src/inifile.cpp similarity index 98% rename from data/inifile.cpp rename to libutil/src/inifile.cpp index 2d68caf6f..43545a4a8 100644 --- a/data/inifile.cpp +++ b/libutil/src/inifile.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "inifile.h" +#include "include/inifile.h" #include #include diff --git a/util/osutils.cpp b/libutil/src/osutils.cpp similarity index 78% rename from util/osutils.cpp rename to libutil/src/osutils.cpp index 6b0955185..9a85d1e54 100644 --- a/util/osutils.cpp +++ b/libutil/src/osutils.cpp @@ -13,13 +13,7 @@ * limitations under the License. */ -#include "osutils.h" +#include "include/osutils.h" -#include #include #include - -void openInDefaultProgram(QString filename) -{ - QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath()); -} diff --git a/util/pathutils.cpp b/libutil/src/pathutils.cpp similarity index 97% rename from util/pathutils.cpp rename to libutil/src/pathutils.cpp index 8610b80d9..8e91bf316 100644 --- a/util/pathutils.cpp +++ b/libutil/src/pathutils.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "pathutils.h" +#include "include/pathutils.h" #include #include diff --git a/main.cpp b/main.cpp index 29c11e875..b78774a8c 100644 --- a/main.cpp +++ b/main.cpp @@ -17,12 +17,12 @@ #include "gui/mainwindow.h" #include -#include "data/appsettings.h" +#include "appsettings.h" #include "data/loginresponse.h" #include "data/plugin/pluginmanager.h" -#include "util/pathutils.h" +#include "pathutils.h" int main(int argc, char *argv[]) { diff --git a/plugins/stdinstance/CMakeLists.txt b/plugins/stdinstance/CMakeLists.txt index 503bda751..0bb466ec5 100644 --- a/plugins/stdinstance/CMakeLists.txt +++ b/plugins/stdinstance/CMakeLists.txt @@ -10,22 +10,40 @@ find_package(Qt5Network REQUIRED) include_directories(${Qt5Base_INCLUDE_DIRS}) include_directories(${Qt5Network_INCLUDE_DIRS}) -# Include MultiMC's headers. -include_directories(../../) +# Include the Java library. +include_directories(${CMAKE_SOURCE_DIR}/java) + +# Include utils library headers. +include_directories(${CMAKE_SOURCE_DIR}/libutil/include) + +# Include settings library headers. +include_directories(${CMAKE_SOURCE_DIR}/libsettings/include) + +# Include instance library headers. +include_directories(${CMAKE_SOURCE_DIR}libinstance/include) SET(STDINST_HEADERS -stdinstplugin.h stdinstancetype.h stdinstance.h ) SET(STDINST_SOURCES -stdinstplugin.cpp stdinstancetype.cpp stdinstance.cpp ) add_library(stdinstance SHARED ${STDINST_SOURCES} ${STDINST_HEADERS}) + set_target_properties(stdinstance PROPERTIES PREFIX "") +set_target_properties(stdinstance PROPERTIES RUNTIME_OUTPUT_DIRECTORY "..") + qt5_use_modules(stdinstance Core Network) -target_link_libraries(stdinstance quazip patchlib) +target_link_libraries(stdinstance +quazip +patchlib + +# Link the util, settings, and instance libraries. +libmmcutil +libmmcsettings +libmmcinst +) diff --git a/plugins/stdinstance/stdinstance.cpp b/plugins/stdinstance/stdinstance.cpp index 194909651..12d86bbcc 100644 --- a/plugins/stdinstance/stdinstance.cpp +++ b/plugins/stdinstance/stdinstance.cpp @@ -17,7 +17,7 @@ #include -#include +#include StdInstance::StdInstance(const QString &rootDir, QObject *parent) : Instance(rootDir, parent) @@ -47,7 +47,8 @@ void StdInstance::updateCurrentVersion(bool keepCurrent) setLastVersionUpdate(time); if (!keepCurrent) { - QString newVersion = javautils::GetMinecraftJarVersion(jar.absoluteFilePath()); + // TODO: Implement GetMinecraftJarVersion function. + QString newVersion = "Unknown";//javautils::GetMinecraftJarVersion(jar.absoluteFilePath()); setCurrentVersion(newVersion); } } diff --git a/plugins/stdinstance/stdinstance.h b/plugins/stdinstance/stdinstance.h index 17c03f15b..d812a9b07 100644 --- a/plugins/stdinstance/stdinstance.h +++ b/plugins/stdinstance/stdinstance.h @@ -16,7 +16,7 @@ #ifndef STDINSTANCE_H #define STDINSTANCE_H -#include +#include class StdInstance : public Instance { diff --git a/plugins/stdinstance/stdinstance.json b/plugins/stdinstance/stdinstance.json index 0967ef424..704f0b733 100644 --- a/plugins/stdinstance/stdinstance.json +++ b/plugins/stdinstance/stdinstance.json @@ -1 +1,8 @@ -{} +{ + "api": "MultiMC5-API-1", + + "name": "Standard Instance Plugin", + "summary": "A plugin that provides standard Minecraft instances.", + "description": "This is a built-in plugin that provides the standard Minecraft instance.", + "version": "0.1" +} diff --git a/plugins/stdinstance/stdinstancetype.cpp b/plugins/stdinstance/stdinstancetype.cpp index 3e9e00a0f..9b7aa9945 100644 --- a/plugins/stdinstance/stdinstancetype.cpp +++ b/plugins/stdinstance/stdinstancetype.cpp @@ -16,7 +16,7 @@ #include "stdinstancetype.h" StdInstanceType::StdInstanceType(QObject *parent) : - InstanceType(parent) + QObject(parent) { } diff --git a/plugins/stdinstance/stdinstancetype.h b/plugins/stdinstance/stdinstancetype.h index 9516aa801..4f659ba74 100644 --- a/plugins/stdinstance/stdinstancetype.h +++ b/plugins/stdinstance/stdinstancetype.h @@ -16,11 +16,15 @@ #ifndef STDINSTANCETYPE_H #define STDINSTANCETYPE_H -#include +#include -class StdInstanceType : public InstanceType +#define StdInstanceType_IID "net.forkk.MultiMC.StdInstanceType/0.1" + +class StdInstanceType : public QObject, InstanceTypeInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID StdInstanceType_IID FILE "stdinstance.json") + Q_INTERFACES(InstanceTypeInterface) public: explicit StdInstanceType(QObject *parent = 0);