-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroodbasicplugin.pas
75 lines (62 loc) · 2.16 KB
/
broodbasicplugin.pas
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
library broodbasicplugin;
{$mode objfpc}{$H+}
uses
Classes, uplugin, uscmdrafttypes, umainform, Windows, uplugintypes;
var
hSCMD2MainWindow: HWND;
{%H-}hSCMD2Instance: THandle;
{%H-}scmd2_malloc: TAllocRamProc;
{%H-}scmd2_free: TDeAllocRamProc;
{%H-}scmd2_realloc: TReAllocRamProc;
function GetPluginVersion: DWord; stdcall;
begin
result := 2;
end;
function InitPlugin( MainWindow: HWND; Instance: THandle;
AllocMem: TAllocRamProc; DeleteMem: TDeAllocRamProc;
ResizeMem: TReAllocRamProc; RequestedSections: PRequestedMenuSections): LongBool; stdcall;
begin
hSCMD2MainWindow := MainWindow;
hSCMD2Instance := Instance;
scmd2_malloc := AllocMem;
scmd2_free := DeleteMem;
scmd2_realloc := ResizeMem;
result := InitMyPlugin(RequestedSections);
end;
function PluginGetMenuString(Section: TMenuSection; MenuStr: PChar; StrLen: Word): LongBool; stdcall;
var
s: String;
begin
s := GetMyPluginMenu(Section);
if length(s) > StrLen then exit(false) else
begin
fillchar(MenuStr^, StrLen, 0);
if s <> '' then
move(s[1], MenuStr^, length(s));
exit(true);
end;
end;
function RunPlugin(EngineData: PEngineData; CurSection: TMenuSection;
Triggers, MissionBriefing, SwitchRenaming,
UnitProperties, UnitPropUsage: PChunkData): LongBool; stdcall;
var
Context: TPluginContext;
begin
if (Triggers = nil) or (MissionBriefing = nil) or (SwitchRenaming = nil) or (UnitProperties = nil) or (UnitPropUsage = nil) then exit(false);
EnableWindow(hSCMD2MainWindow, False);
Context.Section := CurSection;
Context.EngineData := EngineData;
Context.Triggers := Triggers;
Context.MissionBriefing := MissionBriefing;
Context.SwitchRenaming := SwitchRenaming;
Context.UnitPropertiesList := UnitProperties;
Context.UnitPropUsage := UnitPropUsage;
Context.AllocRam := scmd2_malloc;
Context.DeAllocRam := scmd2_free;
Context.ReAllocRam := scmd2_realloc;
result := RunMyPlugin(Context);
EnableWindow(hSCMD2MainWindow, true);
end;
exports GetPluginVersion, InitPlugin, PluginGetMenuString, RunPlugin;
begin
end.