diff options
author | uniboi <64006268+uniboi@users.noreply.github.com> | 2024-02-04 02:14:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 02:14:46 +0100 |
commit | edf013952ca2d110f190dc8cd16e5529846656e4 (patch) | |
tree | ca219c17665810d94f2cb23b27f58fa9c82f3a62 /primedev/plugins/plugins.h | |
parent | 6ad955ae0aab8b79910cb4a12777419a78a42a90 (diff) | |
download | NorthstarLauncher-edf013952ca2d110f190dc8cd16e5529846656e4.tar.gz NorthstarLauncher-edf013952ca2d110f190dc8cd16e5529846656e4.zip |
Plugin interfaces (plugins v4) (#615)v1.23.1-rc2v1.23.1-rc1v1.23.1v1.23.0-rc2v1.23.0-rc1v1.23.0
Replaces the current plugin api with source interfaces.
- backwards compatible
- no more json in binaries (wtf)
- does not rely on structs from third party libraries (wtf)
- actually initializes variables
- no more basically unused classes
The launcher exposes almost everything required by plugins in interfaces that allow for backwards compatibility.
The only thing that's passed to a plugin directly is the northstar dll HWND and a struct of data that's different for each plugin.
Diffstat (limited to 'primedev/plugins/plugins.h')
-rw-r--r-- | primedev/plugins/plugins.h | 91 |
1 files changed, 41 insertions, 50 deletions
diff --git a/primedev/plugins/plugins.h b/primedev/plugins/plugins.h index 4e841f27..d004038c 100644 --- a/primedev/plugins/plugins.h +++ b/primedev/plugins/plugins.h @@ -1,59 +1,50 @@ #pragma once -#include "plugin_abi.h" - -const int IDR_RCDATA1 = 101; +#include "core/sourceinterface.h" +#include "plugins/interfaces/interface.h" +#include "plugins/interfaces/IPluginId.h" +#include "plugins/interfaces/IPluginCallbacks.h" class Plugin { -public: - std::string name; - std::string displayName; - std::string dependencyName; - std::string description; - - std::string api_version; - std::string version; - - // For now this is just implemented as the index into the plugins array - // Maybe a bit shit but it works - int handle; +private: + CreateInterfaceFn m_pCreateInterface; + IPluginId* m_pluginId = 0; + IPluginCallbacks* m_callbacks = 0; - std::shared_ptr<ColoredLogger> logger; + std::shared_ptr<ColoredLogger> m_logger; - bool run_on_client = false; - bool run_on_server = false; + bool m_valid = false; + std::string m_name; + std::string m_logName; + std::string m_dependencyName; + std::string m_location; // path of the dll + bool m_runOnServer; + bool m_runOnClient; public: - PLUGIN_INIT_TYPE init; - PLUGIN_INIT_SQVM_TYPE init_sqvm_client; - PLUGIN_INIT_SQVM_TYPE init_sqvm_server; - PLUGIN_INFORM_SQVM_CREATED_TYPE inform_sqvm_created; - PLUGIN_INFORM_SQVM_DESTROYED_TYPE inform_sqvm_destroyed; - - PLUGIN_INFORM_DLL_LOAD_TYPE inform_dll_load; - - PLUGIN_RUNFRAME run_frame; + HMODULE m_handle; + PluginNorthstarData m_initData; + + Plugin(std::string path); + bool Unload() const; + void Reload() const; + + // sys + void Log(spdlog::level::level_enum level, char* msg) const; + + // callbacks + bool IsValid() const; + const std::string& GetName() const; + const std::string& GetLogName() const; + const std::string& GetDependencyName() const; + const std::string& GetLocation() const; + bool ShouldRunOnServer() const; + bool ShouldRunOnClient() const; + void* CreateInterface(const char* pName, int* pStatus) const; + void Init(bool reloaded) const; + void Finalize() const; + void OnSqvmCreated(CSquirrelVM* sqvm) const; + void OnSqvmDestroying(CSquirrelVM* sqvm) const; + void OnLibraryLoaded(HMODULE module, const char* name) const; + void RunFrame() const; }; - -class PluginManager -{ -public: - std::vector<Plugin> m_vLoadedPlugins; - -public: - bool LoadPlugins(); - std::optional<Plugin> LoadPlugin(fs::path path, PluginInitFuncs* funcs, PluginNorthstarData* data); - - void InformSQVMLoad(ScriptContext context, SquirrelFunctions* s); - void InformSQVMCreated(ScriptContext context, CSquirrelVM* sqvm); - void InformSQVMDestroyed(ScriptContext context); - - void InformDLLLoad(const char* dll, void* data, void* dllPtr); - - void RunFrame(); - -private: - std::string pluginPath; -}; - -extern PluginManager* g_pPluginManager; |