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

178 lines
4.9 KiB
C
Raw Normal View History

2016-01-27 09:11:59 +00:00
#pragma once
2018-04-02 18:30:50 +00:00
#include <Project64-core/Settings.h>
2016-01-27 09:11:59 +00:00
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-plugin-spec/Base.h>
2022-10-10 00:22:17 +00:00
#include <list>
2016-01-27 09:11:59 +00:00
// Enums
2016-01-27 09:11:59 +00:00
enum SETTING_DATA_TYPE
{
2022-10-10 00:22:17 +00:00
Data_DWORD_General = 0, // A uint32_t setting used anywhere
Data_String_General = 1, // A string setting used anywhere
Data_DWORD_Game = 2, // A uint32_t associated with the current game
Data_String_Game = 3, // A string associated with the current game
Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database
Data_String_RDB = 5, // A string associated with the current game in the ROM database
Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file
Data_String_RDB_Setting = 7, // A string read from the ROM database, with config file
2016-01-27 09:11:59 +00:00
};
typedef struct
{
2022-10-10 00:22:17 +00:00
uint32_t dwSize;
int32_t DefaultStartRange;
int32_t SettingStartRange;
int32_t MaximumSettings;
int32_t NoDefault;
int32_t DefaultLocation;
2016-01-27 09:11:59 +00:00
void * handle;
2022-10-10 00:22:17 +00:00
uint32_t (*GetSetting)(void * handle, int32_t ID);
const char * (*GetSettingSz)(void * handle, int32_t ID, char * Buffer, int32_t BufferLen);
void (*SetSetting)(void * handle, int32_t ID, uint32_t Value);
void (*SetSettingSz)(void * handle, int32_t ID, const char * Value);
void (*RegisterSetting)(void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type,
SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value);
void (*UseUnregisteredSetting)(int32_t ID);
2016-01-27 09:11:59 +00:00
} PLUGIN_SETTINGS;
typedef struct
{
2022-10-10 00:22:17 +00:00
uint32_t (*FindSystemSettingId)(void * handle, const char * Name);
2016-01-27 09:11:59 +00:00
} PLUGIN_SETTINGS2;
typedef struct
{
2022-10-10 00:22:17 +00:00
void (*FlushSettings)(void * handle);
2016-01-27 09:11:59 +00:00
} PLUGIN_SETTINGS3;
2022-03-04 12:23:30 +00:00
typedef struct _PLUGIN_SETTINGS_NOTIFICATION
{
2022-10-10 00:22:17 +00:00
typedef void (*SettingChangedFunc)(void *);
2022-10-10 00:22:17 +00:00
void (*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
void (*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
} PLUGIN_SETTINGS_NOTIFICATION;
2017-04-18 11:32:43 +00:00
typedef struct
{
2022-10-10 00:22:17 +00:00
void (*DisplayError)(const char * Message);
void (*FatalError)(const char * Message);
void (*DisplayMessage)(int DisplayTime, const char * Message);
void (*DisplayMessage2)(const char * Message);
void (*BreakPoint)(const char * FileName, int32_t LineNumber);
2017-04-18 11:32:43 +00:00
} PLUGIN_NOTIFICATION;
2016-01-27 09:11:59 +00:00
class CSettings;
2022-10-10 00:22:17 +00:00
class CGfxPlugin;
class CAudioPlugin;
class CRSP_Plugin;
class CControl_Plugin;
2016-01-27 09:11:59 +00:00
class CN64System;
class CPlugins;
#if defined(_WIN32)
#include <objbase.h>
#else
2022-10-10 00:22:17 +00:00
#define __interface struct
#endif
2016-01-27 09:11:59 +00:00
__interface RenderWindow
{
#ifdef _WIN32
2016-01-27 09:11:59 +00:00
virtual bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0;
virtual void * GetWindowHandle(void) const = 0;
virtual void * GetStatusBar(void) const = 0;
virtual void * GetModuleInstance(void) const = 0;
#else
virtual void GfxThreadInit() = 0;
virtual void GfxThreadDone() = 0;
virtual void SwapWindow() = 0;
#endif
2016-01-27 09:11:59 +00:00
};
class CPlugins :
private CDebugSettings
{
public:
// Functions
CPlugins(SettingID PluginDirSetting, bool SyncPlugins);
2016-01-27 09:11:59 +00:00
~CPlugins();
bool Initiate(CN64System * System);
void RomOpened(void);
void RomClosed(void);
void SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow);
void ConfigPlugin(void * hParent, PLUGIN_TYPE Type);
bool CopyPlugins(const stdstr & DstDir) const;
void CreatePlugins(void);
bool Reset(CN64System * System);
bool ResetInUiThread(CN64System * System);
void GameReset(void);
2022-10-10 00:22:17 +00:00
inline CGfxPlugin * Gfx(void) const
{
return m_Gfx;
}
inline CAudioPlugin * Audio(void) const
{
return m_Audio;
}
inline CRSP_Plugin * RSP(void) const
{
return m_RSP;
}
inline CControl_Plugin * Control(void) const
{
return m_Control;
}
inline RenderWindow * MainWindow(void) const
{
return m_MainWindow;
}
inline RenderWindow * SyncWindow(void) const
{
return m_SyncWindow;
}
inline bool initilized(void) const
{
return m_initilized;
}
2016-01-27 09:11:59 +00:00
private:
CPlugins(void);
2022-10-10 00:22:17 +00:00
CPlugins(const CPlugins &);
CPlugins & operator=(const CPlugins &);
2016-01-27 09:11:59 +00:00
void DestroyGfxPlugin(void);
void DestroyAudioPlugin(void);
void DestroyRspPlugin(void);
void DestroyControlPlugin(void);
static void PluginChanged(CPlugins * _this);
RenderWindow * m_MainWindow;
RenderWindow * m_SyncWindow;
2016-02-01 06:33:19 +00:00
SettingID m_PluginDirSetting;
stdstr m_PluginDir;
2016-01-27 09:11:59 +00:00
// Plugins
2022-10-10 00:22:17 +00:00
CGfxPlugin * m_Gfx;
CAudioPlugin * m_Audio;
CRSP_Plugin * m_RSP;
2016-01-27 09:11:59 +00:00
CControl_Plugin * m_Control;
stdstr m_GfxFile;
stdstr m_AudioFile;
stdstr m_RSPFile;
stdstr m_ControlFile;
bool m_initilized;
bool m_SyncPlugins;
2016-01-27 09:11:59 +00:00
};
// Dummy Functions
2016-01-27 09:11:59 +00:00
void DummyCheckInterrupts(void);
void DummyFunction(void);