-
Notifications
You must be signed in to change notification settings - Fork 0
/
Favoriten.pas
1780 lines (1588 loc) · 53 KB
/
Favoriten.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Favoriten;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ExtCtrls, Menus, Galaxy_Explorer, OGame_Types, Prog_Unit, IniFiles, Buttons,
StdCtrls, ImgList, VirtualTrees, VSTPopup, VTHeaderPopup, FavFilter,
topmost_uh, frm_pos_size_ini, Notizen, PlanetListInterface;
const filetype = 'cS favlist 1.0';
const filetypelength = 14;
const lpa_col = 34;
const lpi_col = 35;
type
TPlanetItem = class; // prototype
PFav = ^TFav;
TFav = record
InitPointer: TPlanetItem;
Position : TPlanetPosition;
ScanGrpCount: Integer;
LastUpdate: TDateTime;
Raid_dt: TDateTime;
Last24h: Integer;
RaidCount: Integer;
ScanTime: TDateTime;
Fleet, Def: Int64;
Stars: Integer;
Platz, FleetPlatz, Allyplatz: word;
PlayerPunkte, FleetPunkte, Allypunkte: Cardinal;
Ress: Array[0..4] of TcSResource;
Ress_div_Def: TcSResource;
MProduction: TSetRessources;
v_Ress: TSetRessources;
v_Ress_all: TcSResource;
v_Ress_div_Def: TcSResource;
needed_energy: Integer;
prod_faktor: single;
MProductionAll: TcSResource;
TF: TResources;
notes: TNotizArray;
calcMaxTemp: Single;
solsatEnergy: Integer;
lpa, lpi: integer;
thePlayerID: TNameID;
theAllyID: TNameID;
anomalie: Integer;
end;
TPlanetItem = class
private
fPos: TPlanetPosition;
fSterne: Integer;
fShownNode: PVirtualNode; //Gibt den Eintrag in der VST-Liste an, (nil wenn rausgefiltert)
fVSTList: TVirtualStringTree;
public
property pos: TPlanetPosition read fPos;
property sterne: Integer read fSterne write fSterne;
function getVisibleNode: PVirtualNode;
function showNode: PVirtualNode;
procedure hideNode;
constructor Create(const aPos: TPlanetPosition;
const aSterne: Integer; aVSTList: TVirtualStringTree);
destructor Destroy; override;
end;
TFavFileEntry_10_Pos = packed record
Position: packed array[0..2] of Word;
P_Mond: Boolean;
end;
TFavFileEntry_10 = packed record
Position: TFavFileEntry_10_Pos;
Stars: Byte;
end;
TFRM_Fav_PlanetListInterface = class;
TFavListType = (flt_list, flt_all_auto_list);
TFRM_Favoriten = class(TForm)
PopupMenu1: TPopupMenu;
Galaxyansicht1: TMenuItem;
P_Top: TPanel;
StatusBar1: TStatusBar;
lbl_text_adsad: TLabel;
Notiz1: TMenuItem;
BTN_Refresh: TSpeedButton;
BTN_Add: TSpeedButton;
VST_ScanList: TVirtualStringTree;
Raid1: TMenuItem;
ImageList1: TImageList;
ImageList2: TImageList;
N1: TMenuItem;
Kopieren1: TMenuItem;
Lschen1: TMenuItem;
VTHeaderPopupMenu1: TVTHeaderPopupMenu;
BTN_Filter: TButton;
CB_Koords: TComboBox;
Label2: TLabel;
BTN_FilterArea_Anzeigen: TButton;
tim_startsort: TTimer;
IL_ScanSize: TImageList;
PM_Notizen: TPopupMenu;
musternotiz1: TMenuItem;
Spionagesondenschicken1: TMenuItem;
tim_take_focus_again: TTimer;
SpielerStatsnachschlagen1: TMenuItem;
Allynachschlagen1: TMenuItem;
N2: TMenuItem;
procedure musternotiz1Click(Sender: TObject);
procedure VST_ScanListGetPopupMenu(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; const P: TPoint;
var AskParent: Boolean; var PopupMenu: TPopupMenu);
procedure VST_ScanListClick(Sender: TObject);
procedure Galaxyansicht1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BTN_AddClick(Sender: TObject);
procedure Notiz1Click(Sender: TObject);
procedure BTN_RefreshClick(Sender: TObject);
procedure VST_ScanListGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
procedure VST_ScanListHeaderClickX(Sender: TVTHeader;
Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
procedure VST_ScanListFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
procedure FormShow(Sender: TObject);
procedure VST_ScanListGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
procedure VST_ScanListCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure VST_ScanListPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType);
procedure VST_ScanListBeforeCellPaint_(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellRect: TRect);
procedure Raid1Click(Sender: TObject);
procedure VST_ScanListDblClick(Sender: TObject);
procedure VST_ScanListGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
procedure VST_ScanListKeyPress(Sender: TObject; var Key: Char);
procedure VST_ScanListAfterCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellRect: TRect);
procedure Kopieren1Click(Sender: TObject);
procedure Lschen1Click(Sender: TObject);
procedure BTN_FilterClick(Sender: TObject);
procedure CB_KoordsChange(Sender: TObject);
procedure BTN_FilterArea_AnzeigenClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StatusBar1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure VST_ScanListInitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
procedure VST_ScanListFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
procedure tim_startsortTimer(Sender: TObject);
procedure VST_ScanListBeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect;
var ContentRect: TRect);
procedure VST_ScanListMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure VST_ScanListMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure VST_ScanListHeaderClick(Sender: TVTHeader;
HitInfo: TVTHeaderHitInfo);
procedure Spionagesondenschicken1Click(Sender: TObject);
procedure tim_take_focus_againTimer(Sender: TObject);
procedure SpielerStatsnachschlagen1Click(Sender: TObject);
procedure Allynachschlagen1Click(Sender: TObject);
published
private
mListInterface: TFRM_Fav_PlanetListInterface;
//Direction: TSortDirection;
//SColumn: Integer;
IniFile: String;
topmost: boolean;
scanlist_file: TFileStream;
VST_clickpos: TPoint;
fListType: TFavListType;
procedure LoadOptions;
procedure SaveOptions;
function Filter(Scan: TScanbericht): Boolean;
function FleetPoints(Scan: TScanbericht): Int64;
function DefPoints(Scan: TScanbericht): Int64;
procedure updateNode(nd: PVirtualNode);
procedure SavePosition_Count(const i: Integer); overload;
procedure SavePosition_Count(const item: TPlanetItem); overload;
function getfilterinfo: string;
procedure Set_CB_Koords(cb_k: TComboBox = nil);
function getIntValColumn(Column: TColumnIndex; fav: TFav): Int64;
procedure InitFavListFile(filename: string);
procedure FreeFavListFile;
function scanfile_getentrypos(index: integer): Int64;
procedure LoadFavFileData;
procedure LoadOldFromIni;
procedure Refresh_and_delMissing;
function getColumnAt(x: integer): integer;
procedure SetListType(atyp: TFavListType);
{ Private-Deklarationen }
protected
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
PROCEDURE CreateParams(VAR Params: TCreateParams); OVERRIDE;
function GameNow(): TDateTime;
public
FilterOptions: TFilter;
FilterArea: TPlanetRangeList;
ScanList: TList;
FleetDefRessValues: array of Integer; //KA, hat wohl keinen Nutzen?? -> vllt damals wegen TF berechnung !?
FleetDefValues: array of integer;
property ListType: TFavListType read fListType write SetListType;
procedure AddByTime(alter: TDateTime);
function Add(pos: TPlanetPosition; Sterne: integer = 0; load: boolean = False): integer;
function Find(Pos: TPlanetPosition): integer;
procedure Show;
function getSelectedPlanet(): TPlanetPosition;
{ Public-Deklarationen }
end;
TFRM_Fav_PlanetListInterface = class(TPlanetListInterface)
private
mFRM_Fav: TFRM_Favoriten;
public
constructor Create(fav_frm: TFRM_Favoriten); reintroduce;
function selectNextPlanet(out pos: TPlanetPosition): Boolean; override;
function getPlanet(): TPlanetPosition; override;
function selectPreviousPlanet(out pos: TPlanetPosition): Boolean; override;
end;
const
FavSection = 'Favoriten';
var
FRM_Favoriten: TFRM_Favoriten;
implementation
uses Main, Languages, KB_List, DateUtils, Math, Stat_Points,
UniTree, uebersicht, RaidBoard;
const
fcol_Notizen = 30;
{$R *.DFM}
function TFRM_Favoriten.GameNow(): TDateTime;
begin
Result := ODataBase.FleetBoard.GameTime.Time;
end;
procedure TFRM_Favoriten.SetListType(atyp: TFavListType);
begin
fListType := atyp;
BTN_Add.Visible := not (ListType = flt_all_auto_list);
Lschen1.Enabled := BTN_Add.Visible;
end;
PROCEDURE TFRM_Favoriten.CreateParams;
begin
INHERITED;
//if Typ = 0 then
begin
Params.ExStyle := Params.ExStyle OR WS_EX_APPWINDOW;
Params.WndParent:= 0;//Application.Handle;
end;
end;
procedure TFRM_Favoriten.Galaxyansicht1Click(Sender: TObject);
begin
if VST_ScanList.GetFirstSelected <> nil then
with TFav(VST_ScanList.GetNodeData(VST_ScanList.GetFirstSelected)^) do
FRM_Main.ShowGalaxie(position);
end;
procedure TFRM_Favoriten.FormDestroy(Sender: TObject);
begin
mListInterface.Free;
SaveOptions;
SaveFormSizePos(IniFile,self);
ScanList.Free;
FreeFavListFile;
end;
procedure TFRM_Favoriten.FormCreate(Sender: TObject);
begin
IniFile := ODataBase.PlayerInf;
InitFavListFile(ODataBase.SaveDir + 'favlist.csdat');
ScanList := TList.Create;
if SaveCaptions then SaveAllCaptions(Self,LangFile);
if LoadCaptions then LoadAllCaptions(Self,LangFile);
topmost := false;
StatusBar1.Panels[0].Text := STR_normal;
LoadFormSizePos(IniFile,self);
{//--- erstelle popup für headers ---------------------------------------------
Menu := TVSTPopUpMenu.Create(Self);
menu.VST := VST_ScanList;
VST_ScanList.Header.PopupMenu := menu;
//--- erstelle popup für headers - fertig ------------------------------------}
FilterArea := nil;
LoadOptions; //erst filter laden
LoadFavFileData; //dann liste auffüllen
LoadOldFromIni; //alte laden und löschen
mListInterface := TFRM_Fav_PlanetListInterface.Create(self);
if not FRM_Main.Dir.Visible then
begin
VST_ScanList.Header.Columns.Delete(lpi_col);
VST_ScanList.Header.Columns.Delete(lpa_col);
end;
end;
procedure TFRM_Favoriten.BTN_AddClick(Sender: TObject);
var s: string;
m: integer;
ma: TDateTime;
begin
if InputQuery(STR_Hinzufuegen,STR_Maximales_Alter,s) then
begin
try
m := ReadInt(s,1);
except
m := high(m);
end;
ma := m/(24*60);
AddByTime(ma);
end;
//Belegung anzeigen:
StatusBar1.Panels[1].Text := IntToStr(VST_ScanList.RootNodeCount) + ' / ' +
IntToStr(ScanList.Count) + ' Filter: ' + getfilterinfo();
end;
procedure TFRM_Favoriten.AddByTime(alter: TDateTime);
var g,s,p,i: integer;
m: Boolean;
pl: TPlanetPosition;
pos: single;
begin
VST_ScanList.BeginUpdate;
try
for g := 1 to max_Galaxy do
for s := 1 to max_Systems do
begin
for p := 1 to max_Planeten do
for m := false to true do
begin
i := ODataBase.UniTree.UniReport(g,s,p,m);
if (i >= 0)and
(GameNow - UnixToDateTime(ODataBase.Berichte[i].Head.Time_u) <= alter) then
begin
pl.P[0] := g;
pl.P[1] := s;
pl.P[2] := p;
pl.Mond := m;
Add(pl);
end;
end;
pos := (((g-1)*max_Systems) + s)/(max_Galaxy*max_Systems);
StatusBar1.Panels[2].Text := IntToStr(trunc(pos*100)) + '%';
StatusBar1.Refresh;
end;
finally
VST_ScanList.EndUpdate;
end;
end;
procedure TFRM_Favoriten.LoadOptions;
var c,i,j, default: integer;
sg: TScanGroup;
ini: TIniFile;
begin
//-längenberechnung
c := 0;
for sg := sg_Flotten to sg_Verteidigung do
inc(c, ScanFileCounts[sg]);
SetLength(FleetDefRessValues,c);
SetLength(FleetDefValues,c);
//laden
ini := TIniFile.Create(IniFile);
for i := 0 to length(FleetDefRessValues)-1 do
FleetDefRessValues[i] := ini.ReadInteger(FavSection,'FleetDefRessValue'+inttostr(i),10000);
for i := 0 to length(FleetDefValues)-1 do
begin
if i < ScanFileCounts[sg_Flotten] then
begin
// (Metall+Kristall)/100
default := (fleet_resources[i][0] + fleet_resources[i][1]) div 100;
end
else
begin
j := i-ScanFileCounts[sg_Flotten];
// (Metall+Kristall)/100
if not def_ignoreFight[j] then
default := (def_resources[j][0] + def_resources[j][1]) div 100
else
default := 0;
end;
if default < 0 then
default := 1;
FleetDefValues[i] := ini.ReadInteger(FavSection,'FleetDefValue'+inttostr(i),default);
end;
//Filter:
FRM_Filter.LoadFilter(ini);
Set_CB_Koords;
FilterOptions := FRM_Filter.Filter;
// Liste:
if ini.ReadString(FavSection, 'list_type', 'auto') = 'auto' then
begin
ListType := flt_all_auto_list;
end
else
begin
ListType := flt_list;
end;
// Header
LoadVSTHeaders(VST_ScanList,ini,FavSection);
VST_ScanList.Header.SortColumn := ini.ReadInteger(FavSection, 'sort_column', VST_ScanList.Header.SortColumn);
VST_ScanList.Header.SortDirection := TSortDirection(ini.ReadInteger(FavSection, 'sort_direction', Integer(VST_ScanList.Header.SortDirection)));
ini.free;
end;
procedure TFRM_Favoriten.SaveOptions;
var i: integer;
ini: TIniFile;
begin
ini := TIniFile.Create(IniFile);
for i := 0 to length(FleetDefRessValues)-1 do
ini.WriteInteger(FavSection,'FleetDefRessValue'+inttostr(i),FleetDefRessValues[i]);
for i := 0 to length(FleetDefValues)-1 do
ini.WriteInteger(FavSection,'FleetDefValue'+inttostr(i),FleetDefValues[i]);
// Liste:
if ListType = flt_all_auto_list then
begin
ini.WriteString(FavSection, 'list_type', 'auto');
end
else
begin
ini.WriteString(FavSection, 'list_type', 'custom');
end;
SaveVSTHeaders(VST_ScanList,ini,FavSection);
FRM_Filter.SaveFilter(ini);
ini.WriteInteger(FavSection, 'sort_column', VST_ScanList.Header.SortColumn);
ini.WriteInteger(FavSection, 'sort_direction', Integer(VST_ScanList.Header.SortDirection));
ini.UpdateFile;
ini.free;
end;
procedure TFRM_Favoriten.Notiz1Click(Sender: TObject);
var node: PVirtualNode;
begin
node := VST_ScanList.GetFirstSelected;
if node <> nil then
FRM_Notizen.ShowAddDialog(Self,
TFav(VST_ScanList.GetNodeData(node)^).Position,nPlanet);
end;
procedure TFRM_Favoriten.BTN_RefreshClick(Sender: TObject);
begin
if ListType = flt_all_auto_list then
AddByTime(9999999999999999);
//lbl_filterinfo.Caption := 'aktive Filter: "' + getfilterinfo() + '"';
Refresh_and_delMissing;
//Belegung anzeigen:
StatusBar1.Panels[1].Text := IntToStr(VST_ScanList.RootNodeCount) + ' / ' +
IntToStr(ScanList.Count) + ' Filter: ' + getfilterinfo();
end;
function TFRM_Favoriten.Add(pos: TPlanetPosition;
Sterne: integer = 0; load: boolean = False): integer;
var i: integer;
// add wird auch von load verwendet
item: TPlanetItem;
begin
//Suche nach vorhandenem Eintrag: TODO: suchbaum!? (oder einfach ein array[1..9,1..499,1..15] of pointer)
Result := -1;
item := nil;
for i := 0 to ScanList.Count-1 do
begin
item := ScanList[i];
if SamePlanet(item.Pos,Pos) then
begin
Result := i;
break;
end;
end;
//Wenn kein Eintrag gefunden -> neuen erstellen:
if Result < 0 then
begin
item := TPlanetItem.Create(pos, Sterne, VST_ScanList);
Result := ScanList.Add(item);
end;
//Auf Filter testen und aus der VST-Liste entfernen/hinzufügen
i := ODataBase.UniTree.UniReport(pos);
if (item <> nil) and
(i >= 0) and
Filter(ODataBase.Berichte[i]) then
begin
item.showNode();
//start sort timer (so wird nicht ständig sortiert, wenn mehrere Scans hinzukommen:
tim_startsort.Enabled := True;
end
else
begin
item.hideNode;
end;
if not load then SavePosition_Count(Result); //sofort speichern!
end;
function TFRM_Favoriten.getfilterinfo: string;
var res: string;
rc, i: integer;
procedure add(s: string);
begin
if (rc > 0) then
res := res + ', ';
res := res + s;
inc(rc);
end;
begin
rc := 0;
res := '';
if FilterArea <> nil then
add('Koordinaten');
with FilterOptions do
begin
if Alter.Aktiv then
add('Alter/Datum');
if Ress_Ges.Aktive then
add('Ressourcen');
for i := 0 to 3 do
begin
if MKDE[i].Aktive then
add('ress_' + IntToStr(i));
end;
if Fleet.Aktive then
add('Flotte');
if Def.Aktive then
add('Verteidigung');
if Status_filter <> [] then
begin
if Status_negativ then
add('!Status')
else
add('Status');
end;
end;
if res = '' then
res := 'n/a';
result := res;
end;
function TFRM_Favoriten.Filter(Scan: TScanbericht): Boolean;
var GRess,i : integer;
//30.09.08 UHO OK
begin
Result := True;
if FilterArea <> nil then
begin
Result := Result and (not FilterArea.isElement(Scan.Head.Position));
end;
if Result then
with FilterOptions do
begin
//Alter:
Result := (not Alter.Aktiv)or(GameNow - UnixToDateTime(Scan.Head.Time_u) < FilterOptions.Alter.Alter);
//Gesammt Resourcen:
GRess := 0;
for i := 0 to 2 do
GRess := GRess + Scan.Bericht[sg_Rohstoffe,i];
Result := Result and ((not Ress_Ges.Aktive)or(GRess > Ress_Ges.Value));
//einzelne Resourcen:
for i := 0 to 3 do
begin
Result := Result and ((not MKDE[i].Aktive)or(Scan.Bericht[sg_Rohstoffe,i] > MKDE[i].Value));
end;
//Flotten/Defence Punkte: Multi == 1 wenn größer, Multi = -1 wenn kleiner
Result := Result and ((not Fleet.Aktive)or(FleetPoints(Scan)*Fleet.Multi > Fleet.Value*Fleet.Multi));
Result := Result and ((not Def.Aktive)or(DefPoints(Scan)*Def.Multi > Def.Value*Def.Multi));
//StatusFilter:
i := ODataBase.GetSystemCopyNR(Scan.Head.Position);
if i >= 0 then
with ODataBase.Systeme[i], Planeten[Scan.Head.Position.P[2]] do
begin
if Status_negativ then
Result := Result and ((Status * Status_filter) <> [])
else
Result := Result and ((Status * Status_filter) = []);
end;
end;
end;
function TFRM_Favoriten.FleetPoints(Scan: TScanbericht): Int64;
var j: integer;
//27.12.08 UHO OK
begin
if Scan.Bericht[sg_Flotten,0] < 0 then
Result := -1
else
begin
Result := 0;
for j := 0 to ScanFileCounts[sg_Flotten]-1 do
begin
Result := Result + (Scan.Bericht[sg_Flotten,j]*FleetDefValues[j]);
end;
end;
end;
function TFRM_Favoriten.DefPoints(Scan: TScanbericht): Int64;
var j: integer;
//27.12.08 UHO OK
begin
if Scan.Bericht[sg_Verteidigung,0] < 0 then
Result := -1
else
begin
Result := 0;
for j := 0 to ScanFileCounts[sg_Verteidigung]-1 do
begin
Result := Result + (Scan.Bericht[sg_Verteidigung,j]*
FleetDefValues[ScanFileCounts[sg_Flotten]+j]);
end;
end;
end;
procedure TFRM_Favoriten.VST_ScanListGetNodeDataSize(
Sender: TBaseVirtualTree; var NodeDataSize: Integer);
begin
NodeDataSize := sizeof(TFav);
end;
procedure TFRM_Favoriten.VST_ScanListGetPopupMenu(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; const P: TPoint;
var AskParent: Boolean; var PopupMenu: TPopupMenu);
var mi: TMenuItem;
notes: TNotizArray;
i: integer;
begin
SetLength(Notes,0);
if Column = fcol_Notizen then
begin
PopupMenu := PM_Notizen;
PM_Notizen.Items.Clear;
PM_Notizen.Images := FRM_Notizen.ImageList1;
notes := TFav(VST_ScanList.GetNodeData(Node)^).notes;
for i := 0 to length(Notes)-1 do
begin
mi := TMenuItem.Create(Self);
mi.Caption := notes[i].Note;
mi.ImageIndex := notes[i].Image;
mi.Tag := Integer(notes[i].SNode);
mi.OnClick := musternotiz1Click;
PM_Notizen.Items.Add(mi);
end;
end
else PopupMenu := PopupMenu1;
end;
procedure TFRM_Favoriten.VST_ScanListHeaderClickX(Sender: TVTHeader;
Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
if Button = mbLeft then
begin
if Sender.SortColumn = Column then
begin
if Sender.SortDirection = sdDescending then
Sender.SortDirection := sdAscending
else Sender.SortDirection := sdDescending;
end
else
Sender.SortColumn := Column;
end
else
begin
end;
end;
procedure TFRM_Favoriten.VST_ScanListFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
begin
if node <> nil then
with TFav(VST_ScanList.GetNodeData(node)^) do
begin
FRM_Main.ShowScan(Position, mListInterface);
end;
end;
procedure TFRM_Favoriten.FormShow(Sender: TObject);
begin
BTN_RefreshClick(self);
end;
procedure TFRM_Favoriten.VST_ScanListGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var i: Integer;
// scan: TScanBericht;
fav: TFav;
begin
// WARNING: When adding here a new Column, don't forget adding it to
// VST_ScanListCompareNodes as well!
CellText := '-';
updateNode(node);
fav := TFav(VST_ScanList.GetNodeData(Node)^);
with fav do
begin
//Immer:
case Column of
0: CellText := PositionToStrMond(Position);
6: if Raid_dt > 0 then CellText := CountdownTimeToStr(Raid_dt - GameNow);
7: if Last24h > 0 then CellText := IntToStr(Last24h);
end;
//Solsys:
if ODataBase.GetSystemCopyNR(Position) >= 0 then
with ODataBase.Systeme[ODataBase.GetSystemCopyNR(Position)], Planeten[Position.P[2]] do
case Column of
1: if not Position.Mond then CellText := PlanetName else CellText := STR_Mond;
2: CellText := Player;
3: CellText := ODataBase.LanguagePlugIn.StatusToStr(Status);
4: CellText := Ally;
15: if PlayerPunkte > 0 then CellText := FloatToStrF(PlayerPunkte,ffNumber,60000000,0);
16: if FleetPunkte > 0 then CellText := FloatToStrF(FleetPunkte,ffNumber,60000000,0);
17: if Stars > 0 then CellText := '';
19: if Platz > 0 then CellText := IntToStr(Platz);
20: if FleetPlatz > 0 then CellText := IntToStr(FleetPlatz);
21: if Allyplatz > 0 then CellText := IntToStr(Allyplatz);
22: if Allypunkte > 0 then CellText := FloatToStrF(Allypunkte,ffNumber,60000000,0);
end;
//Scan:
i := ODataBase.UniTree.UniReport(Position);
if i >= 0 then
begin
// Scan := ODataBase.Berichte[i];
// with Scan do
case Column of
5: CellText := ODataBase.Time_To_AgeStr(ScanTime);
8..12: CellText := FloatToStrF(Ress[Column-8],ffNumber,60000000,0);
13: CellText := FloatToStrF(Fleet,ffNumber,60000000,0);
14: CellText := FloatToStrF(Def,ffNumber,60000000,0);
18: CellText := IntToStrKP(Ress_div_Def);
23: CellText := FloatToStrF(MProductionAll,ffNumber,60000000,0);
//TF (Flotte)
24: CellText := IntToStrKP(tf[0] + tf[1] + tf[2]);
//Berechnete Rohstoffe (Produktion mit einberechnet!)
25..29,31,32,lpa_col,lpi_col: CellText := IntToStrKP(getIntValColumn(Column, fav));
33: if (anomalie > 0) then CellText := IntToStrKP(anomalie) else CellText := ' > 1h';
end;
end;
end;
end;
procedure TFRM_Favoriten.VST_ScanListClick(Sender: TObject);
var menu: TPopupMenu;
b: Boolean;
HitInfo: THitInfo;
begin
VST_ScanList.GetHitTestInfoAt(VST_clickpos.X, VST_clickpos.Y, true, HitInfo);
if (HitInfo.HitColumn = fcol_Notizen) and
(HitInfo.HitNode <> nil) then
begin
VST_ScanList.OnGetPopupMenu(VST_ScanList,HitInfo.HitNode,
fcol_Notizen,Mouse.CursorPos,B,menu);
menu.Popup(Mouse.CursorPos.X,Mouse.CursorPos.Y);
end;
end;
procedure TFRM_Favoriten.VST_ScanListCompareNodes(Sender: TBaseVirtualTree;
Node1, Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var Fav1, Fav2: TFav;
s1,s2: WideString;
begin
// WARNING: When adding here a new Column, don't forget adding it to
// VST_ScanListGetText as well!
updateNode(node1);
updateNode(node2);
Fav1 := TFav(Sender.GetNodeData(node1)^);
Fav2 := TFav(Sender.GetNodeData(node2)^);
case Column of
0: if PosBigger(Fav1.Position,Fav2.Position) then Result := 1 else Result := -1;
5: if Fav1.ScanTime > Fav2.ScanTime then Result := 1 else Result := -1;
8..12: if Fav1.Ress[Column-8] > Fav2.Ress[Column-8] then Result := 1 else Result := -1;
13: if Fav1.Fleet > Fav2.Fleet then Result := 1 else Result := -1;
15, 19: if Fav1.PlayerPunkte > Fav2.PlayerPunkte then Result := 1 else Result := -1;
16, 20: if Fav1.FleetPunkte > Fav2.FleetPunkte then Result := 1 else Result := -1;
14: if Fav1.Def > Fav2.Def then Result := 1 else Result := -1;
17: if Fav1.Stars > Fav2.Stars then Result := 1 else Result := -1;
18: if Fav1.Ress_div_Def > Fav2.Ress_div_Def then
Result := 1 else Result := -1;
21, 22: if Fav1.Allypunkte > Fav2.Allypunkte then Result := 1 else Result := -1;
23: if Fav1.MProductionAll > Fav2.MProductionAll then Result := 1 else Result := -1;
24: Result := IfThen(
Fav1.TF[0]+Fav1.TF[1]+Fav1.TF[2] > Fav2.TF[0]+Fav2.TF[1]+Fav2.TF[2],
1,-1);
//Berechnete Rohstoffe (Produktion mit einberechnet!)
25..29,31,32,33,lpa_col,lpi_col: if getIntValColumn(Column, Fav1) > getIntValColumn(Column, Fav2) then
Result := 1 else Result := -1;
// 30: if Fav1.notes then, ka wie des genau mit den notizen klappen soll (nach welcher regel?)
else
VST_ScanListGetText(Sender,Node1,Column,ttNormal,s1);
VST_ScanListGetText(Sender,Node2,Column,ttNormal,s2);
if LowerCase(s1) > LowerCase(s2) then Result := 1 else Result := -1;
end;
end;
procedure TFRM_Favoriten.updateNode(nd: PVirtualNode);
var fav: ^TFav;
i, sb: integer;
report: TScanBericht;
m: TRessType;
item: TPlanetItem;
gpi: PPlayerInformation;
p: TPlanetPosition;
begin
if nd <> nil then
begin
fav := VST_ScanList.GetNodeData(nd);
with fav^ do
if (Now - LastUpdate > 1/24/60/20) then // Hier wird die Systemzeit Verwendet!!
begin
// alles nullen! (InitPointer sichern)
item := InitPointer;
FillChar(fav^,sizeof(fav^),0);
InitPointer := item;
Position := item.pos;
p := item.pos;
LastUpdate := Now; // Hier wird die Systemzeit Verwendet!!
lpa := -1;
lpi := lpa;
Stars := item.Sterne;
notes := FRM_Notizen.GetPlanetInfo(p);
i := ODataBase.FleetBoard.FindNextArrivingFleet(Position, fet_attack);
if i >= 0 then
Raid_dt := UnixToDateTime(ODataBase.FleetBoard.Fleets.Fleets[i].head.arrival_time_u)
else Raid_dt := -1;
Last24h := ODataBase.FleetBoard.GetLast24HoursRaidCount(Position);
RaidCount := ODataBase.FleetBoard.GetRaidCount(Position);
// Sind scans vorhanden?
sb := ODataBase.UniTree.UniReport(Position);
if sb >= 0 then
begin
// aktuellen Scan holen
report := ODataBase.Berichte[sb];
// ScanGroupCount trotzdem vom letzten scan holen
ScanGrpCount := GetScanGrpCount(report);
report := TScanBericht.Create;
try
// UHO: 17.04.09 jetzt verwenden wir den generic Scan
// UHO: 28.10.2010: added research for solsysEnergy!
ODataBase.UniTree.genericReport_withResearch(Position, report);
ScanTime := UnixToDateTime(report.Head.Time_u);
Fleet := FleetPoints(report);
Def := DefPoints(report);
anomalie := report.Head.Activity;
for i := 0 to 3 do
Ress[i] := report.Bericht[sg_Rohstoffe,i];
Ress[4] := report.Bericht[sg_Rohstoffe,0]+
report.Bericht[sg_Rohstoffe,1]+
report.Bericht[sg_Rohstoffe,2]; // m+k+d!
// calc estimated ressources
try
ODataBase.calcScanRess_NowScan(report, MProduction,
prod_faktor, needed_energy, solsatEnergy, calcMaxTemp, v_Ress);
except
ShowMessage('Error on Update: ' + PositionToStrMond(Position));
end;
// sum all produktion
MProductionAll := 0;
for m := low(m) to high(m) do
MProductionAll := MProductionAll + MProduction[m];
// sum estimated resources
v_Ress_all := 0;
for m := rtMetal to rtDeuterium do
v_Ress_all := v_Ress_all + v_Ress[m];
if Def >= 0 then
begin
Ress_div_Def := trunc(Ress[4]/(1+(Def/1000)));
v_Ress_div_Def := trunc(v_Ress_all/(1+(Def/1000)));
end
else
begin
Ress_div_Def := trunc(Ress[4]/(1));
v_Ress_div_Def := trunc(v_Ress_all/(1));
// Ress_div_Def := -1;
// v_Ress_div_Def := -1;
end;
TF := CalcTF(report);
finally
report.Free;
end;
end;
if ODataBase.GetSystemCopyNR(Position) >= 0 then
with ODataBase.Systeme[ODataBase.GetSystemCopyNR(Position)], Planeten[Position.P[2]] do
begin
thePlayerID := PlayerId;
theAllyID := AllyId;
with ODataBase.Stats do
begin
if Statistik[Platz].Name <> Player then // zur rechenersparnis! (weil platz ändert sich ja eher selten, sodass sich das nicht alle paar sekunden ändert!)
Platz := StatPlace(Player,thePlayerID);
PlayerPunkte := Statistik[Platz].Punkte;
end;
with ODataBase.FleetStats do
begin
if Statistik[FleetPlatz].Name <> Player then
FleetPlatz := StatPlace(Player,thePlayerID);
FleetPunkte := Statistik[FleetPlatz].Punkte;
end;
with ODataBase.AllyStats do
begin
if Statistik[AllyPlatz].Name <> Ally then
AllyPlatz := StatPlace(Ally,theAllyID);
AllyPunkte := Statistik[Allyplatz].Punkte;
end;
gpi := ODataBase.UniTree.Player.GetPlayerInfo(Player, thePlayerID);
if gpi <> nil then
begin
lpa := gpi^.lpa;
lpi := gpi^.lpi;
end;
end;
end;
end;
end;
procedure TFRM_Favoriten.VST_ScanListPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType);
begin
with TFav(Sender.GetNodeData(Node)^) do
begin