-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelectPlugin.pas
111 lines (96 loc) · 2.86 KB
/
SelectPlugin.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
unit SelectPlugin;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, inifiles, languages;
const
PluginSection = 'ioplugin';
PluginName = 'name';
PluginDomain = 'game_domain';
type
TFRM_SelectPlugin = class(TForm)
CB_PluginA: TComboBox;
LBL_PluginA1: TLabel;
LBL_PluginA2: TLabel;
BTN_OK: TButton;
BTN_Abbrechen: TButton;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BTN_OKClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormShow(Sender: TObject);
private
PluginFileList: TStringList;
PlugInDir: String;
{ Private-Deklarationen }
public
game_domain: String;
PluginFile: String;
constructor Create(AOwner: TComponent; agame_domain: String); reintroduce;
{ Public-Deklarationen }
end;
implementation
uses Prog_Unit;
{$R *.DFM}
procedure TFRM_SelectPlugin.FormCreate(Sender: TObject);
var f: TSearchRec;
ini: TIniFile;
begin
if SaveCaptions then SaveAllCaptions(Self,LangFile);
if LoadCaptions then LoadAllCaptions(Self,LangFile);
ChDir(ExtractFilePath(Application.ExeName));
PlugInDir := 'ioplugins\';
PluginFileList := TStringList.Create;
PluginFileList.Clear;
try
FindFirst(PlugInDir + '*.ini',faanyfile,f);
repeat
if FileExists(PlugInDir + f.Name) then
begin
ini := TIniFile.Create(PlugInDir + f.Name);
if ini.ReadString(PluginSection,PluginDomain,'--n/a--') = game_domain then
begin
PluginFileList.Add(PlugInDir + f.Name);
CB_PluginA.Items.Add(ini.ReadString(PluginSection,PluginName,'--error--'));
end;
ini.free;
end;
until FindNext(f) <> 0;
FindClose(f);
except
ShowMessage('Fehler beim Laden der LangPlugins!');
end;
end;
procedure TFRM_SelectPlugin.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
PluginFileList.Free;
end;
constructor TFRM_SelectPlugin.Create(AOwner: TComponent; agame_domain: String);
begin
game_domain := agame_domain;
inherited Create(AOwner);
end;
procedure TFRM_SelectPlugin.BTN_OKClick(Sender: TObject);
begin
if (CB_PluginA.ItemIndex <> -1) and FileExists(PluginFileList[CB_PluginA.ItemIndex]) then
begin
PluginFile := PluginFileList[CB_PluginA.ItemIndex];
ModalResult := mrOk;
end;
end;
procedure TFRM_SelectPlugin.FormPaint(Sender: TObject);
begin
Application.BringToFront;
end;
procedure TFRM_SelectPlugin.FormShow(Sender: TObject);
var i: integer;
begin
i := PluginFileList.Count-1;
while (i >= 0)and(PluginFileList[i] <> PluginFile) do
begin
dec(i);
end;
CB_PluginA.ItemIndex := i;
end;
end.