project64/Source/Project64-core/Plugins/PluginBase.h

79 lines
2.6 KiB
C
Raw Permalink Normal View History

#pragma once
2022-10-10 00:22:17 +00:00
#include <Common/DynamicLibrary.h>
#include <Project64-core/Plugins/Plugin.h>
2015-12-06 09:59:58 +00:00
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-core/TraceModulesProject64.h>
2023-09-21 04:55:07 +00:00
#include <Project64-plugin-spec/Base.h>
2015-12-06 09:59:58 +00:00
class CPlugin :
2023-09-21 04:55:07 +00:00
protected CDebugSettings
{
public:
2015-11-08 06:08:15 +00:00
CPlugin();
virtual ~CPlugin();
2022-10-10 00:22:17 +00:00
inline const char * PluginName() const
{
return m_PluginInfo.Name;
}
inline bool Initialized()
{
return m_Initialized;
}
2015-11-08 06:08:15 +00:00
virtual int32_t GetDefaultSettingStartRange() const = 0;
virtual int32_t GetSettingStartRange() const = 0;
2015-11-08 06:08:15 +00:00
bool Load(const char * FileName);
void RomOpened(RenderWindow * Render);
void RomClose(RenderWindow * Render);
void GameReset(RenderWindow * Render);
void Close(RenderWindow * Render);
2022-10-10 00:22:17 +00:00
void(CALL * DllAbout)(void * hWnd);
void(CALL * DllConfig)(void * hParent);
2015-12-10 18:23:00 +00:00
static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo);
2015-11-08 06:08:15 +00:00
protected:
void UnloadPlugin();
const char * PluginType() const;
TraceModuleProject64 PluginTraceType() const;
2015-11-08 06:08:15 +00:00
virtual void UnloadPluginDetails() = 0;
virtual PLUGIN_TYPE type() = 0;
virtual bool LoadFunctions(void) = 0;
2022-10-10 00:22:17 +00:00
void(CALL * CloseDLL)(void);
void(CALL * RomOpen)(void);
void(CALL * RomClosed)(void);
void(CALL * PluginOpened)(void);
2022-10-10 00:22:17 +00:00
void(CALL * SetSettingInfo)(PLUGIN_SETTINGS *);
void(CALL * SetSettingInfo2)(PLUGIN_SETTINGS2 *);
void(CALL * SetSettingInfo3)(PLUGIN_SETTINGS3 *);
void(CALL * SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *);
void(CALL * SetPluginNotification)(PLUGIN_NOTIFICATION *);
DynLibHandle m_LibHandle;
bool m_Initialized, m_RomOpen;
2015-11-08 06:08:15 +00:00
PLUGIN_INFO m_PluginInfo;
2015-11-08 06:08:15 +00:00
// Loads a function pointer from the currently loaded DLL
void _LoadFunctionVoid(const char * szFunctionName, void ** functionPointer)
{
*functionPointer = DynamicLibraryGetProc(m_LibHandle, szFunctionName);
2015-11-08 06:08:15 +00:00
}
2015-11-08 06:08:15 +00:00
// Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments
// i.e. _LoadFunction("CloseDLL", CloseDLL);
#define LoadFunction(functionName) _LoadFunctionVoid(#functionName, (void **)&functionName)
2022-10-10 00:22:17 +00:00
#define _LoadFunction(functionName, function) _LoadFunctionVoid(functionName, (void **)&function)
2017-04-18 11:32:43 +00:00
private:
static void DisplayError(const char * Message);
static void FatalError(const char * Message);
static void DisplayMessage(int DisplayTime, const char * Message);
static void DisplayMessage2(const char * Message);
static void BreakPoint(const char * FileName, int32_t LineNumber);
};