aboutsummaryrefslogtreecommitdiff
path: root/primedev/plugins/plugins.h
diff options
context:
space:
mode:
Diffstat (limited to 'primedev/plugins/plugins.h')
-rw-r--r--primedev/plugins/plugins.h91
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;