Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin API #1879

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "ui/pages/global/LanguagePage.h"
#include "ui/pages/global/LauncherPage.h"
#include "ui/pages/global/MinecraftPage.h"
#include "ui/pages/global/PluginPage.h"
#include "ui/pages/global/ProxyPage.h"

#include "ui/setupwizard/JavaWizardPage.h"
Expand Down Expand Up @@ -119,6 +120,9 @@
#include "meta/Index.h"
#include "translations/TranslationsModel.h"

#include "plugin/PluginContribution.h"
#include "plugin/PluginList.h"

#include <DesktopServices.h>
#include <FileSystem.h>
#include <LocalPeer.h>
Expand Down Expand Up @@ -209,6 +213,8 @@ std::tuple<QDateTime, QString, QString, QString, QString> read_lock_File(const Q

Application::Application(int& argc, char** argv) : QApplication(argc, argv)
{
registerExtensionPoints();

#if defined Q_OS_WIN32
// attach the parent console if stdout not already captured
if (AttachWindowsConsole()) {
Expand Down Expand Up @@ -587,6 +593,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("IconsDir", "icons");
m_settings->registerSetting("DownloadsDir", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
m_settings->registerSetting("DownloadsDirWatchRecursive", false);
m_settings->registerSetting("PluginsDir", "plugins");

// Editors
m_settings->registerSetting("JsonEditor", QString());
Expand Down Expand Up @@ -767,6 +774,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_globalSettingsProvider->addPage<ExternalToolsPage>();
m_globalSettingsProvider->addPage<AccountListPage>();
m_globalSettingsProvider->addPage<APIPage>();
m_globalSettingsProvider->addPage<PluginPage>();
}

PixmapCache::setInstance(new PixmapCache(this));
Expand Down Expand Up @@ -1033,6 +1041,20 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
}
}

// load plugins
{
auto PluginsDirSetting = m_settings->getSetting("PluginsDir");
QString pluginsDir = PluginsDirSetting->get().toString();
qDebug() << "Plugins path : " << pluginsDir;
m_plugins.reset(new PluginList(m_settings, pluginsDir, this));
qDebug() << "Loading Plugins...";
m_plugins->loadList();
qDebug() << "<> Plugins loaded.";
qDebug() << "Enable Plugins...";
m_plugins->enablePlugins();
qDebug() << "<> Plugins enabled.";
}

if (createSetupWizard()) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ITheme;
class MCEditTool;
class ThemeManager;
class IconTheme;
class PluginList;

namespace Meta {
class Index;
Expand Down Expand Up @@ -124,6 +125,8 @@ class Application : public QApplication {

std::shared_ptr<IconList> icons() const { return m_icons; }

std::shared_ptr<PluginList> plugins() const { return m_plugins; }

MCEditTool* mcedit() const { return m_mcedit.get(); }

shared_qobject_ptr<AccountList> accounts() const { return m_accounts; }
Expand Down Expand Up @@ -246,6 +249,7 @@ class Application : public QApplication {
std::unique_ptr<MCEditTool> m_mcedit;
QSet<QString> m_features;
std::unique_ptr<ThemeManager> m_themeManager;
std::shared_ptr<PluginList> m_plugins;

QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;

Expand Down
29 changes: 29 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,23 @@ set(PRISMUPDATER_SOURCES

)

set(PLUGIN_SOURCES
plugin/extension_points/CatPackExtension.h
plugin/extension_points/CatPackExtension.cpp

plugin/Plugin.h
plugin/Plugin.cpp

plugin/PluginContribution.h
plugin/PluginContribution.cpp

plugin/api/PluginInterface.h
plugin/api/PluginInstance.h

plugin/PluginList.h
plugin/PluginList.cpp
)

######## Logging categories ########

ecm_qt_declare_logging_category(CORE_SOURCES
Expand Down Expand Up @@ -700,6 +717,14 @@ ecm_qt_export_logging_category(
EXPORT "${Launcher_Name}"
)

ecm_qt_export_logging_category(
IDENTIFIER pluginLogC
CATEGORY_NAME "launcher.plugins"
DEFAULT_SEVERITY Debug
DESCRIPTION "plugins & plugin loading"
EXPORT "${Launcher_Name}"
)



if(KDE_INSTALL_LOGGINGCATEGORIESDIR) # only install if there is a standard path for this
Expand Down Expand Up @@ -734,6 +759,7 @@ set(LOGIC_SOURCES
${PACKWIZ_SOURCES}
${TECHNIC_SOURCES}
${ATLAUNCHER_SOURCES}
${PLUGIN_SOURCES}
)

if(APPLE AND Launcher_ENABLE_UPDATER)
Expand Down Expand Up @@ -905,6 +931,8 @@ SET(LAUNCHER_SOURCES
ui/pages/global/ProxyPage.h
ui/pages/global/APIPage.cpp
ui/pages/global/APIPage.h
ui/pages/global/PluginPage.cpp
ui/pages/global/PluginPage.h

# GUI - platform pages
ui/pages/modplatform/CustomPage.cpp
Expand Down Expand Up @@ -1127,6 +1155,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/pages/global/JavaPage.ui
ui/pages/global/LauncherPage.ui
ui/pages/global/APIPage.ui
ui/pages/global/PluginPage.ui
ui/pages/global/ProxyPage.ui
ui/pages/global/MinecraftPage.ui
ui/pages/global/ExternalToolsPage.ui
Expand Down
Loading
Loading