-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUeberSichtOptions.pas
358 lines (332 loc) · 11.4 KB
/
UeberSichtOptions.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
unit UeberSichtOptions;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, Gauges, Notizen, Ogame_Types, Menus, ImgList, Inifiles,
ExtCtrls, VirtualTrees, Prog_Unit, Languages;
type
TMarkerTyp = (mtNotiz,mtPlayer,mtAlly);
TMarker = record
Typ: TMarkerTyp;
Color: TColor;
Bezeichner: TPlayerName;
NotizIndex: integer;
Aktive: Boolean;
end;
TFRM_Marker = class(TForm)
Label1: TLabel;
PopupMenu1: TPopupMenu;
Markierunghinzufgen1: TMenuItem;
Lschen1: TMenuItem;
ImageList1: TImageList;
Panel1: TPanel;
Button1: TButton;
Button3: TButton;
Button4: TButton;
Button2: TButton;
Panel2: TPanel;
Label2: TLabel;
CB_Typ: TComboBox;
Label3: TLabel;
CB_Notizen: TComboBox;
TXT_Bezeichner: TEdit;
P_Color: TPanel;
Label4: TLabel;
ColorDialog1: TColorDialog;
LV_Options: TVirtualStringTree;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure Markierunghinzufgen1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Lschen1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure CB_TypChange(Sender: TObject);
procedure P_ColorClick(Sender: TObject);
procedure LV_OptionsGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
procedure LV_OptionsChecked(Sender: TBaseVirtualTree;
Node: PVirtualNode);
procedure LV_OptionsPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType);
procedure LV_OptionsInitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
procedure LV_OptionsBeforeItemPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect;
var CustomDraw: Boolean);
procedure LV_OptionsFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
procedure CB_NotizenKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
IniFile: String;
SetVal: Boolean;
{ Private-Deklarationen }
public
procedure Generate;
procedure Load;
procedure Save;
{ Public-Deklarationen }
end;
var
FRM_Marker: TFRM_Marker;
implementation
uses Uebersicht;
{$R *.DFM}
procedure TFRM_Marker.Generate;
var g, s, p, j, k: integer;
List: TNotizArray;
pos: TPlanetPosition;
notizen: Boolean;
node: PVirtualNode;
nodeData: ^TMarker;
begin
SetLength(List,0);
SetLength(frm_Uebersicht.UUni,0);
notizen := false;
node := LV_Options.GetFirst;
while node <> nil do
begin
nodeData := LV_Options.GetNodeData(Node);
if nodeData^.Aktive and(nodeData^.Typ = mtNotiz) then notizen := true;
node := LV_Options.GetNext(node);
end;
ProgressBar1.Max := max_Galaxy*max_Systems;
ProgressBar1.Position := 0;
for g := 1 to max_Galaxy do
for s := 1 to max_Systems do
begin
for p := 1 to max_Planeten do
begin
if notizen then
begin
pos.P[0] := g;
pos.P[1] := s;
pos.P[2] := p;
pos.Mond := false;
List := FRM_Notizen.GetPlanetInfo(pos);
end;
node := LV_Options.GetFirst;
while node <> nil do
begin
nodeData := LV_Options.GetNodeData(Node);
//-------------------------------------------------------------------
if nodeData^.Aktive then
with nodeData^ do
begin
j := length(FRM_Uebersicht.UUni);
case Typ of
mtNotiz:
for k := 0 to length(List)-1 do
if (List[k].Image = NotizIndex) then
begin
SetLength(FRM_Uebersicht.UUni,j+1);
FRM_Uebersicht.UUni[j].Color := Color;
FRM_Uebersicht.UUni[j].Pos.p[0] := g;
FRM_Uebersicht.UUni[j].Pos.p[1] := s;
FRM_Uebersicht.UUni[j].Pos.p[2] := p;
end;
mtPlayer:
if (ODataBase.Uni[g,s].SystemCopy >= 0)and(UpperCase(ODataBase.Systeme[ODataBase.Uni[g,s].SystemCopy].Planeten[p].Player) = UpperCase(Bezeichner)) then
begin
SetLength(FRM_Uebersicht.UUni,j+1);
FRM_Uebersicht.UUni[j].Color := Color;
FRM_Uebersicht.UUni[j].Pos.p[0] := g;
FRM_Uebersicht.UUni[j].Pos.p[1] := s;
FRM_Uebersicht.UUni[j].Pos.p[2] := p;
end;
mtAlly:
if (ODataBase.Uni[g,s].SystemCopy >= 0)and(UpperCase(ODataBase.Systeme[ODataBase.Uni[g,s].SystemCopy].Planeten[p].Ally) = UpperCase(Bezeichner)) then
begin
SetLength(FRM_Uebersicht.UUni,j+1);
FRM_Uebersicht.UUni[j].Color := Color;
FRM_Uebersicht.UUni[j].Pos.p[0] := g;
FRM_Uebersicht.UUni[j].Pos.p[1] := s;
FRM_Uebersicht.UUni[j].Pos.p[2] := p;
end;
end;
end;
//-------------------------------------------------------------------
node := LV_Options.GetNext(node);
end;
end;
ProgressBar1.Position := (g-1)*max_Systems + s;
Application.ProcessMessages;
end;
FRM_Uebersicht.PB_Uni.Refresh;
end;
procedure TFRM_Marker.Button1Click(Sender: TObject);
begin
Generate;
end;
procedure TFRM_Marker.Markierunghinzufgen1Click(Sender: TObject);
var node: PVirtualNode;
begin
node := LV_Options.AddChild(nil);
with TMarker(LV_Options.GetNodeData(node)^) do
begin
Color := clYellow;
Aktive := True;
end;
Node.CheckState := csCheckedNormal;
end;
procedure TFRM_Marker.Button2Click(Sender: TObject);
begin
close;
end;
procedure TFRM_Marker.Lschen1Click(Sender: TObject);
var node: PVirtualNode;
begin
node := LV_Options.GetFirstSelected;
LV_Options.Selected[LV_Options.GetNext(node)] := True; //prüft anscheinend selber ob node da oder nicht!
LV_Options.DeleteNode(node);
end;
procedure TFRM_Marker.Load;
var ini: TMemIniFile;
node: PVirtualNode;
nodeData: ^TMarker;
begin
ini := TMemIniFile.Create(IniFile);
LV_Options.RootNodeCount := ini.ReadInteger('OverviewMarker','Count',0);
node := LV_Options.GetFirst;
while node <> nil do
begin
nodeData := LV_Options.GetNodeData(node);
with nodeData^ do
begin
Typ := TMarkerTyp(ini.ReadInteger('OverviewMarker','MTyp'+inttostr(node.Index),0));
Color := ini.ReadInteger('OverviewMarker','MColor'+inttostr(node.Index),clred);
Bezeichner := ini.ReadString('OverviewMarker','MBezeichner'+inttostr(node.Index),'');
NotizIndex := ini.ReadInteger('OverviewMarker','MNotizIndex'+inttostr(node.Index),0);
Aktive := ini.ReadBool('OverviewMarker','MChecked'+inttostr(node.Index),False);
end;
node := LV_Options.GetNext(node);
end;
end;
procedure TFRM_Marker.Save;
var ini: TMemIniFile;
node: PVirtualNode;
nodeData: ^TMarker;
begin
ini := TMemIniFile.Create(IniFile);
ini.WriteInteger('OverviewMarker','Count',LV_Options.RootNodeCount);
node := LV_Options.GetFirst;
while node <> nil do
begin
nodeData := LV_Options.GetNodeData(node);
with nodeData^ do
begin
ini.WriteInteger('OverviewMarker','MTyp'+inttostr(node.Index),integer(Typ));
ini.WriteInteger('OverviewMarker','MColor'+inttostr(node.Index),Color);
ini.WriteString('OverviewMarker','MBezeichner'+inttostr(node.Index),Bezeichner);
ini.WriteInteger('OverviewMarker','MNotizIndex'+inttostr(node.Index),NotizIndex);
ini.WriteBool('OverviewMarker','MChecked'+inttostr(node.Index),Aktive);
end;
node := LV_Options.GetNext(node);
end;
ini.UpdateFile;
ini.free;
end;
procedure TFRM_Marker.FormCreate(Sender: TObject);
begin
LV_Options.NodeDataSize := sizeof(TMarker);
IniFile := ODataBase.PlayerInf;
Load;
CB_Typ.ItemIndex := 0;
CB_TypChange(self);
CB_Notizen.OnDrawItem := FRM_Notizen.CB_Image.OnDrawItem;
CB_Notizen.Items := FRM_Notizen.CB_Image.Items;
CB_Notizen.ItemIndex := 0;
if SaveCaptions then SaveAllCaptions(Self,LangFile);
if LoadCaptions then LoadAllCaptions(Self,LangFile);
end;
procedure TFRM_Marker.FormDestroy(Sender: TObject);
begin
Save;
end;
procedure TFRM_Marker.CB_TypChange(Sender: TObject);
begin
TXT_Bezeichner.Visible := not (CB_Typ.ItemIndex = 0);
CB_Notizen.Visible := (CB_Typ.ItemIndex = 0);
if (LV_Options.FocusedNode <> nil)and(not SetVal) then
with TMarker(LV_Options.GetNodeData(LV_Options.FocusedNode)^) do
begin
Typ := TMarkerTyp(CB_Typ.ItemIndex);
Color := P_Color.Color;
Bezeichner := TXT_Bezeichner.Text;
NotizIndex := CB_Notizen.ItemIndex;
LV_Options.Refresh;
end;
end;
procedure TFRM_Marker.P_ColorClick(Sender: TObject);
begin
if (LV_Options.FocusedNode <> nil) then
begin
if (ColorDialog1.Execute) then
begin
P_Color.Color := ColorDialog1.Color;
CB_TypChange(self);
end;
end else ShowMessage(STR_Marker_Eintrag_markieren);
end;
procedure TFRM_Marker.LV_OptionsGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var nodeData: ^TMarker;
begin
nodeData := LV_Options.GetNodeData(Node);
case Column of
0: if nodeData^.Typ = mtNotiz then CellText := CB_Notizen.Items[nodeData^.NotizIndex] else CellText := nodeData^.Bezeichner;
1: CellText := CB_Typ.Items[integer(nodeData^.Typ)];
end;
end;
procedure TFRM_Marker.LV_OptionsChecked(Sender: TBaseVirtualTree;
Node: PVirtualNode);
begin
TMarker(LV_Options.GetNodeData(node)^).Aktive := Node.CheckState = csCheckedNormal;
end;
procedure TFRM_Marker.LV_OptionsPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType);
var
data: ^TMarker;
begin
data := LV_Options.GetNodeData(node);
TargetCanvas.Font.Color := data^.Color;
end;
procedure TFRM_Marker.LV_OptionsInitNode(Sender: TBaseVirtualTree;
ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates);
begin
node.CheckType := ctCheckBox;
end;
procedure TFRM_Marker.LV_OptionsBeforeItemPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect;
var CustomDraw: Boolean);
begin
if TMarker(LV_Options.GetNodeData(Node)^).Aktive then
Node^.CheckState := csCheckedNormal else Node^.CheckState := csUncheckedNormal;
end;
procedure TFRM_Marker.LV_OptionsFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
begin
if (node <> nil)and(vsSelected in Node^.States) then
with TMarker(LV_Options.GetNodeData(Node)^) do
begin
SetVal := true;
CB_Typ.ItemIndex := integer(Typ);
CB_TypChange(Self);
TXT_Bezeichner.Text := Bezeichner;
P_Color.Color := Color;
CB_Notizen.ItemIndex := NotizIndex;
SetVal := false;
end;
end;
procedure TFRM_Marker.CB_NotizenKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
CB_Notizen.Items := FRM_Notizen.CB_Image.Items;
end;
end.