mirror of
https://github.com/R2Northstar/NorthstarLauncher
synced 2026-08-23 20:26:04 -04:00
* Call `Finalize` hook on plugins after loading them Co-authored-by: cat_or_not <41955154+catornot@users.noreply.github.com>
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#pragma once
|
|
#include "core/tier1.h"
|
|
#include "plugins/interfaces/interface.h"
|
|
#include "plugins/interfaces/IPluginId.h"
|
|
#include "plugins/interfaces/IPluginCallbacks.h"
|
|
|
|
class Plugin
|
|
{
|
|
private:
|
|
CreateInterfaceFn m_pCreateInterface;
|
|
IPluginId* m_pluginId = 0;
|
|
IPluginCallbacks* m_callbacks = 0;
|
|
|
|
std::shared_ptr<ColoredLogger> m_logger;
|
|
|
|
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;
|
|
Color m_logColor;
|
|
|
|
public:
|
|
HMODULE m_handle;
|
|
PluginNorthstarData m_initData;
|
|
|
|
Plugin(std::string path);
|
|
bool Unload() const;
|
|
|
|
// Returns the new handle if the plugin has been reloaded or null otherwise.
|
|
std::optional<HMODULE> 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;
|
|
};
|