Skip to content

Commit

Permalink
refactor: recode template
Browse files Browse the repository at this point in the history
  • Loading branch information
RimuruChan committed Mar 16, 2024
1 parent d1daa32 commit a6ec7ef
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
xmake f -a x64 -m release -p windows -v -y
- run: |
xmake -v -w -y
xmake -v -y
- uses: actions/upload-artifact@v4
with:
Expand Down
58 changes: 0 additions & 58 deletions src/change_this/RenameThis.cpp

This file was deleted.

33 changes: 0 additions & 33 deletions src/change_this/RenameThis.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

#define LL_MEMORY_OPERATORS

#include <ll/api/memory/MemoryOperators.h>
#include "ll/api/memory/MemoryOperators.h" // IWYU pragma: keep
35 changes: 35 additions & 0 deletions src/plugin/MyPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "plugin/MyPlugin.h"

#include <memory>

#include "ll/api/plugin/NativePlugin.h"
#include "ll/api/plugin/RegisterHelper.h"

namespace my_plugin {

std::unique_ptr<MyPlugin>& MyPlugin::getInstance() {
static std::unique_ptr<MyPlugin> instance;
return instance;
}

bool MyPlugin::load() {
getSelf().getLogger().info("Loading...");
// Code for loading the plugin goes here.
return true;
}

bool MyPlugin::enable() {
getSelf().getLogger().info("Enabling...");
// Code for enabling the plugin goes here.
return true;
}

bool MyPlugin::disable() {
getSelf().getLogger().info("Disabling...");
// Code for disabling the plugin goes here.
return true;
}

} // namespace my_plugin

LL_REGISTER_PLUGIN(my_plugin::MyPlugin, my_plugin::MyPlugin::getInstance());
33 changes: 33 additions & 0 deletions src/plugin/MyPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include "ll/api/plugin/NativePlugin.h"

namespace my_plugin {

class MyPlugin {

public:
static std::unique_ptr<MyPlugin>& getInstance();

MyPlugin(ll::plugin::NativePlugin& self) : mSelf(self) {}

[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }

/// @return True if the plugin is loaded successfully.
bool load();

/// @return True if the plugin is enabled successfully.
bool enable();

/// @return True if the plugin is disabled successfully.
bool disable();

// TODO: Implement this method if you need to unload the plugin.
// /// @return True if the plugin is unloaded successfully.
// bool unload();

private:
ll::plugin::NativePlugin& mSelf;
};

} // namespace my_plugin
16 changes: 8 additions & 8 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"format_version": 2,
"tooth": "change-this",
"tooth": "my-plugin",
"version": "0.0.0",
"info": {
"name": "change-this",
"description": "change-this",
"author": "change-this",
"name": "My Plugin Name",
"description": "My Plugin Description",
"author": "My Name",
"tags": [
"levilamina",
"plugin"
]
},
"asset_url": "change-this",
"asset_url": "My Asset Url",
"prerequisites": {
"github.com/LiteLDev/LeviLamina": "change-this"
"github.com/LiteLDev/LeviLamina": "My LeviLamina Dependency Version"
},
"files": {
"place": [
{
"src": "change-this/*",
"dest": "plugins/change-this/"
"src": "my-plugin/*",
"dest": "plugins/my-plugin/"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if not has_config("vs_runtime") then
set_runtimes("MD")
end

target("change-this") -- Change this to your plugin name.
target("my-plugin") -- Change this to your plugin name.
add_cxflags("/EHa", "/utf-8")
add_defines("NOMINMAX", "UNICODE")
add_files("src/**.cpp")
Expand Down

0 comments on commit a6ec7ef

Please sign in to comment.