Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#include "Entry.h"
|
||||
#include "Global.h"
|
||||
#include <fmt/format.h>
|
||||
#include <functional>
|
||||
#include <ll/api/Config.h>
|
||||
#include <ll/api/io/FileUtils.h>
|
||||
#include <ll/api/plugin/NativePlugin.h>
|
||||
#include <ll/api/plugin/PluginManagerRegistry.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
ll::Logger logger(PLUGIN_NAME);
|
||||
|
||||
namespace change_this {
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
||||
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool {
|
||||
logger.info("disabling...");
|
||||
|
||||
// Your code here.
|
||||
|
||||
logger.info("disabled");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool {
|
||||
logger.info("enabling...");
|
||||
|
||||
logger.info("enabled");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
||||
logger.info("loading...");
|
||||
|
||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
||||
|
||||
// Your code here.
|
||||
|
||||
logger.info("loaded");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto unload(ll::plugin::NativePlugin& self) -> bool {
|
||||
auto& logger = self.getLogger();
|
||||
|
||||
logger.info("unloading...");
|
||||
|
||||
selfPluginInstance.reset();
|
||||
|
||||
// Your code here.
|
||||
|
||||
logger.info("unloaded");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
||||
if (!selfPluginInstance) {
|
||||
throw std::runtime_error("selfPluginInstance is null");
|
||||
}
|
||||
|
||||
return *selfPluginInstance;
|
||||
}
|
||||
|
||||
} // namespace change_this
|
||||
|
||||
extern "C" {
|
||||
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
||||
return change_this::disable(self);
|
||||
}
|
||||
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool { return change_this::enable(self); }
|
||||
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool { return change_this::load(self); }
|
||||
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool { return change_this::unload(self); }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <ll/api/plugin/NativePlugin.h>
|
||||
|
||||
namespace change_this {
|
||||
|
||||
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
|
||||
|
||||
} // namespace change_this
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <ll/api/Logger.h>
|
||||
// #include <include_all.h>
|
||||
|
||||
#define PLUGIN_NAME "plugin"
|
||||
|
||||
extern ll::Logger logger;
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file will make your plugin use LeviLamina's memory operators by default.
|
||||
// This improves the memory management of your plugin and is recommended to use.
|
||||
|
||||
#define LL_MEMORY_OPERATORS
|
||||
|
||||
#include <ll/api/memory/MemoryOperators.h>
|
||||
Reference in New Issue
Block a user