-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditScan.pas
136 lines (121 loc) · 3.42 KB
/
EditScan.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
unit EditScan;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OGame_Types, StdCtrls, Prog_Unit;
type
TFRM_EditScan = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
TXT_Planet: TEdit;
TXT_Position: TEdit;
TXT_Player: TEdit;
procedure FormCreate(Sender: TObject);
procedure TXT_KeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
public
Edits: array[TScanGroup] of array of TEdit;
Labels: array[TScanGroup] of array of TLabel;
procedure LoadScan(Scan: TScanBericht);
procedure GetScan(result: TScanbericht);
{ Public-Deklarationen }
end;
var
FRM_EditScan: TFRM_EditScan;
implementation
uses Math, DateUtils;
{$R *.dfm}
procedure TFRM_EditScan.FormCreate(Sender: TObject);
var j,k: integer;
y,x: integer;
sg: TScanGroup;
begin
x := Label1.Left;
k := 4;
y := TXT_Player.Top + TXT_Player.Height + 15;
for sg := low(sg) to high(sg) do
begin
SetLength(Edits[sg],ScanFileCounts[sg]);
SetLength(Labels[sg],ScanFileCounts[sg]);
for j := 0 to ScanFileCounts[sg]-1 do
begin
if k > 17 then
begin
k := 0;
x := x + 155;
y := TXT_Planet.Top;
end;
Edits[sg,j] := TEdit.Create(Self);
Edits[sg,j].Parent := Self;
Edits[sg,j].Left := x + 100;
Edits[sg,j].Width := 50;
Edits[sg,j].OnKeyPress := TXT_KeyPress;
Labels[sg,j] := TLabel.Create(self);
Labels[sg,j].Parent := Self;
Labels[sg,j].Left := x;
Edits[sg,j].Top := y;
Labels[sg,j].Top := y;
Edits[sg,j].Text := '0';
Labels[sg,j].Caption := ODataBase.LanguagePlugIn.SBItems[sg][j+1];
inc(y,Edits[sg,j].Height);
inc(k);
with Edits[sg,j] do
begin
If Top + Height + 5 > Self.ClientHeight then Self.ClientHeight := Top + Height + 5;
If Left + Width + 5 > Self.ClientWidth then Self.ClientWidth := Left + Width + 5;
end;
end;
y := y + 15;
inc(k);
end;
end;
procedure TFRM_EditScan.GetScan(result: TScanbericht);
var j: integer;
sg: TScanGroup;
begin
FillChar(Result.Head,Sizeof(Result.Head),0);
Result.Head.Planet := TXT_Planet.Text;
Result.Head.Position := StrToPosition(TXT_Position.Text);
Result.Head.Spieler := TXT_Player.Text;
Result.Head.Spionageabwehr := -2;
Result.Head.Activity := -1;
Result.Head.Time_u := DateTimeToUnix(now);
for sg := low(sg) to high(sg) do
begin
for j := 0 to ScanFileCounts[sg]-1 do
begin
Result.Bericht[sg,j] := StrToInt(Edits[sg,j].Text);
end;
end;
end;
procedure TFRM_EditScan.LoadScan(Scan: TScanBericht);
var j: integer;
sg: TScanGroup;
begin
TXT_Planet.Text := Scan.Head.Planet;
TXT_Position.Text := PositionToStrMond(Scan.Head.Position);
TXT_Player.Text := Scan.Head.Spieler;
for sg := low(sg) to high(sg) do
begin
for j := 0 to ScanFileCounts[sg]-1 do
begin
Edits[sg,j].Text := IntToStr(Scan.Bericht[sg,j]);
end;
end;
end;
procedure TFRM_EditScan.TXT_KeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in ['0'..'9','-',#8]) then
Key := #0;
end;
procedure TFRM_EditScan.FormShow(Sender: TObject);
begin
TXT_Planet.SetFocus;
end;
end.