Skip to content

Commit

Permalink
feat: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Dec 25, 2023
1 parent b0de666 commit 200a37c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 38 deletions.
6 changes: 5 additions & 1 deletion src/DllMain.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <ll/api/plugin/Plugin.h>

#include <Plugin.h>
#include "Plugin.h"

namespace plugins {

Expand All @@ -9,6 +9,10 @@ Plugin plugin;

extern "C" {
_declspec(dllexport) bool ll_plugin_load(ll::plugin::Plugin& self) { return plugin.load(self); }

_declspec(dllexport) bool ll_plugin_enable(ll::plugin::Plugin& self) { return plugin.enable(self); }

_declspec(dllexport) bool ll_plugin_disable(ll::plugin::Plugin& self) { return plugin.disable(self); }
}

} // namespace plugins
42 changes: 14 additions & 28 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <Plugin.h>
#include "Plugin.h"

#include <stdexcept>
#include <string_view>
Expand All @@ -8,71 +8,57 @@
namespace plugins {

bool Plugin::load(ll::plugin::Plugin& self) {
if (this->mSelf != nullptr) {
if (mSelf != nullptr) {
throw std::runtime_error("plugin is loaded twice");
}

this->mSelf = &self;
mSelf = &self;

// Code for loading the plugin goes here.

return true;
}

bool Plugin::unload(ll::plugin::Plugin& self) {
if (this->mSelf == nullptr) {
throw std::runtime_error("plugin is unloaded twice");
}
if (this->mSelf != &self) {
throw std::runtime_error("plugin is unloaded by a different instance");
}

// Code for unloading the plugin goes here.

this->mSelf = nullptr;
return true;
}

bool Plugin::enable(ll::plugin::Plugin& self) {
if (this->mSelf == nullptr) {
if (mSelf == nullptr) {
throw std::runtime_error("plugin is enabled before being loaded or after being unloaded");
}
if (this->mSelf != &self) {
if (mSelf != &self) {
throw std::runtime_error("plugin is enabled by a different instance");
}

// Code for enabling the plugin goes here.

this->mIsEnabled = true;
mIsEnabled = true;
return true;
}

bool Plugin::disable(ll::plugin::Plugin& self) {
if (this->mSelf == nullptr) {
if (mSelf == nullptr) {
throw std::runtime_error("plugin is disabled before being loaded or after being unloaded");
}
if (this->mSelf != &self) {
if (mSelf != &self) {
throw std::runtime_error("plugin is disabled by a different instance");
}

// Code for disabling the plugin goes here.

this->mIsEnabled = false;
mIsEnabled = false;
return true;
}

ll::Logger const& Plugin::getLogger() const { return this->getSelf().getLogger(); }
ll::Logger const& Plugin::getLogger() const { return getSelf().getLogger(); }

std::string_view Plugin::getName() const { return this->getSelf().getManifest().name; }
std::string_view Plugin::getName() const { return getSelf().getManifest().name; }

ll::plugin::Plugin& Plugin::getSelf() const {
if (this->mSelf == nullptr) {
if (mSelf == nullptr) {
throw std::runtime_error("plugin is called before being loaded or after being unloaded");
}

return *this->mSelf;
return *mSelf;
}

bool Plugin::isEnabled() const { return this->mIsEnabled; }
bool Plugin::isEnabled() const { return mIsEnabled; }

} // namespace plugins
5 changes: 0 additions & 5 deletions include/Plugin.h → src/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class Plugin {
/// @return True if the plugin was loaded successfully.
bool load(ll::plugin::Plugin& self);

/// @brief Unloads the plugin.
/// @param self The plugin handle.
/// @return True if the plugin was unloaded successfully.
bool unload(ll::plugin::Plugin& self);

/// @brief Enables the plugin.
/// @param self The plugin handle.
/// @return True if the plugin was enabled successfully.
Expand Down
20 changes: 16 additions & 4 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package("levilamina")
add_deps("rapidjson 1.1.0")

-- Dependencies from liteldev-repo.
add_deps("bdslibrary 1.20.41.02")
add_deps("bdslibrary 1.20.50.03")
add_deps("ctre 3.8.1")
add_deps("pcg_cpp 1.0.0")
add_deps("pfr 2.1.1")
Expand All @@ -43,19 +43,30 @@ target("levilamina-plugin-template") -- Change this to your plugin name.
"/w44738",
"/w45204"
)
add_cxxflags(
"-Wno-c++2b-extensions",
"-Wno-microsoft-cast",
"-Wno-pragma-system-header-outside-header",
{tools = {"clang_cl"}}
)
add_undefines(
"_DEBUG"
)
add_defines(
"_AMD64_",
"_CRT_SECURE_NO_WARNINGS",
"_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR",
"NOMINMAX",
"UNICODE",
"WIN32_LEAN_AND_MEAN"
"WIN32_LEAN_AND_MEAN",
"ENTT_PACKED_PAGE=128",
"_HAS_CXX23=1"
)
add_files(
"src/**.cpp"
)
add_includedirs(
"include"
"src"
)
add_packages(
"levilamina"
Expand All @@ -70,7 +81,8 @@ target("levilamina-plugin-template") -- Change this to your plugin name.
)
set_exceptions("none")
set_kind("shared")
set_languages("cxx23")
set_languages("c++20")
set_symbols("debug")
set_strip("all")

after_build(function (target)
Expand Down

0 comments on commit 200a37c

Please sign in to comment.