aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/plugins/plugins.h
blob: ffa277d0834d5887aee97d1580f913b739c4cbe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "plugin_abi.h"

const int IDR_RCDATA1 = 101;

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;

	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;