diff options
author | Emma Miler <emma.pi@protonmail.com> | 2023-04-11 20:49:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 20:49:16 +0200 |
commit | 450d0b1ed437cf37b4309af952af8904f3f07768 (patch) | |
tree | 3f0fd39b5663b5c3f4b9e76c70cc4987f22d66c7 /NorthstarDLL/plugins/plugins.h | |
parent | 72da1da5b4c04ccc1154853a308cab6459c60b79 (diff) | |
download | NorthstarLauncher-450d0b1ed437cf37b4309af952af8904f3f07768.tar.gz NorthstarLauncher-450d0b1ed437cf37b4309af952af8904f3f07768.zip |
Plugin system v2 (#343)
* Some work
* Rewrite gamestate presence
* Add plugin system logger
* Format changes
* Format chjange
* Fix gamestate stuff
* some callback stuff
* move around invite stuff
* move invite to funcs
* fix presence server data
* Actually call InformSQVMCreated
* bruh
* Fix TODO's
* Formatting
* Fix filters
* Add InformDLLLoads
* Fix plugin handle always being 0
* Formatting
* Fix merge issues
* Formatting
* Mods can add files compiled at SQVM init
* Some Small Fixes
* Add changes from review
* Fix load failure
* Add new squirrel functions
* actually call InformSQVMDestroyed
* add CreateObject function
* answers to complaints
* remove snake cases from GameStatePresence
---------
Co-authored-by: cat_or_not <41955154+catornot@users.noreply.github.com>
Diffstat (limited to 'NorthstarDLL/plugins/plugins.h')
-rw-r--r-- | NorthstarDLL/plugins/plugins.h | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/NorthstarDLL/plugins/plugins.h b/NorthstarDLL/plugins/plugins.h index 953801a2..ffa277d0 100644 --- a/NorthstarDLL/plugins/plugins.h +++ b/NorthstarDLL/plugins/plugins.h @@ -1,17 +1,57 @@ #pragma once #include "plugin_abi.h" -int getServerInfoChar(char* out_buf, size_t out_buf_len, ServerInfoType var); -int getServerInfoInt(int* out_ptr, ServerInfoType var); -int getServerInfoBool(bool* out_ptr, ServerInfoType var); +const int IDR_RCDATA1 = 101; -int getGameStateChar(char* out_buf, size_t out_buf_len, GameStateInfoType var); -int getGameStateInt(int* out_ptr, GameStateInfoType var); -int getGameStateBool(bool* out_ptr, GameStateInfoType var); +class Plugin +{ + public: + std::string name; + std::string displayName; + std::string dependencyName; + std::string description; -int getPlayerInfoChar(char* out_buf, size_t out_buf_len, PlayerInfoType var); -int getPlayerInfoInt(int* out_ptr, PlayerInfoType var); -int getPlayerInfoBool(bool* out_ptr, PlayerInfoType var); + std::string api_version; + std::string version; -void initGameState(); -void* getPluginObject(PluginObject var); + // For now this is just implemented as the index into the plugins array + // Maybe a bit shit but it works + int handle; + + std::shared_ptr<ColoredLogger> logger; + + bool run_on_client = false; + bool run_on_server = false; + + 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_PUSH_PRESENCE_TYPE push_presence; + PLUGIN_INFORM_DLL_LOAD_TYPE inform_dll_load; +}; + +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 PushPresence(PluginGameStatePresence* data); + + void InformDLLLoad(PluginLoadDLL dll, void* data); + + private: + std::string pluginPath; +}; + +extern PluginManager* g_pPluginManager; |