-
Notifications
You must be signed in to change notification settings - Fork 1
/
UPluginFramework.h
86 lines (86 loc) · 3 KB
/
UPluginFramework.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//---------------------------------------------------------------------------
#pragma once
//---------------------------------------------------------------------------
#ifndef UPluginFrameworkH
#define UPluginFrameworkH
//---------------------------------------------------------------------------
#define DLLEXPORT extern "C" __declspec(dllexport) int __stdcall
//---------------------------------------------------------------------------
#include <System.hpp>
#include <Classes.hpp>
//---------------------------------------------------------------------------
// Îïðåäåëåíèÿ èñïîëüçóåìûå â ïëàãèíå:
typedef int __stdcall (*OverrideFunc)(void);
struct TPluginInfo
{
char* szName;
char* szDescription;
char* szAuthor;
bool bHookFileFind;
bool bHookFileUnpack;
bool bHookFilePack;
};
struct TOverrideInfo
{
DWORD Code;
OverrideFunc Function;
HINSTANCE hPlugin;
};
// Êîäû MPQ Repacker
#define CODE_FILE_SEARCH_START 0 // Íà÷àëî ïîèñêà ôàéëîâ
#define CODE_FILE_SEARCH_END 1 // Êîíåö ïîèñêà ôàéëîâ
#define CODE_FILES_UNPACKED 2 // Ôàéëû ðàñïàêîâàíû âî âðåìåííóþ ïàïêó
#define CODE_FILES_PACKED 3 // Ôàéëû çàïàêîâàíû â MPQ àðõèâ
// -----------------
#define OVERRIDE_SEARCH 0 // Èñêàòü ôàéëû ïëàãèíîì
#define OVERRIDE_UNPACK 1 // Ðàñïàêîâûâàòü êàðòó ïëàãèíîì
#define OVERRIDE_PACK 2 // Çàïàêîâûâàòü êàðòó ïëàãèíîì
// -----------------
// Îïðåäåëåíèÿ èñïîëüçóåìûå òîëüêî â ïðîãðàììå:
enum TPFCondition {pfcFileFindHooked, pfcFileUnpackHooked, pfcFilePackHooked}; // Plugin Framework Condition
struct TPlugin
{
UnicodeString Path;
TPluginInfo Info;
bool Enabled;
HINSTANCE hPlugin;
};
struct TOverride
{
bool Enabled;
int PluginIndex;
OverrideFunc Function;
};
struct TMPQRepackerOverrides
{
TOverride Search;
TOverride Unpack;
TOverride Pack;
};
class TPluginFramework : public TObject
{
protected:
void __fastcall FindPlugins();
TPlugin* PluginsList;
unsigned int PluginsCount;
UnicodeString Dir;
TPluginInfo RequestPlgInfo(UnicodeString Path);
void UnregisterOverridesByIndex(const int Index);
public:
TMPQRepackerOverrides Overrides;
__fastcall TPluginFramework(const UnicodeString DirWithPlugins);
__fastcall ~TPluginFramework();
void __fastcall GetPluginList(TStrings* S);
int IndexByName(const UnicodeString Name); // Ïðè îøèáêå âîçâðàùàåò -1
int IndexByHInstance(HINSTANCE hPlg); // Ïðè îøèáêå âîçâðàùàåò -1
void __fastcall UnloadPlugin(const int Index);
void __fastcall LoadPlugin(const int Index);
TPluginInfo GetPluginInfo(const int Index);
int __fastcall SendCode(const int Index, const int Code); // Âîçâðàùàåò îòâåò ïëàãèíà
void SendCodeToAll(const int Code, const TPFCondition IfFlag);
int CallSettings(const unsigned Index, bool Execute = true); // Åñëè Execute == false, òî òîëüêî ïîëó÷àåò àäðåñ è âîçðàùàåò FALSE â ñëó÷àå åñëè íåò ôóíêöèè íàñòðîåê
};
//---------------------------------------------------------------------------
extern TPluginFramework* PluginManager; // Ãëîáàëüíûé ïëàãèí-ìåíåäæåð
//---------------------------------------------------------------------------
#endif