-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spielerdaten.pas
280 lines (251 loc) · 7.45 KB
/
Spielerdaten.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
unit Spielerdaten;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin, IniFiles, OGame_Types, languages, OGameData, quickupdate;
type
TFRM_Spielerdaten = class(TForm)
LBL_PlayerI1: TLabel;
ed: TGroupBox;
LBL_PlayerI2: TLabel;
CB_OGame_Site: TComboBox;
BTN_OK: TButton;
BTN_Abbrechen: TButton;
LBL_PlayerI3: TLabel;
lbl_Speedfaktor: TLabel;
GroupBox1: TGroupBox;
LBL_PlayerI4: TLabel;
LBL_PlayerI5: TLabel;
Label5: TLabel;
Label6: TLabel;
E_Spielername: TEdit;
E_Gala: TEdit;
E_System: TEdit;
E_Planet: TEdit;
cb_fleet_TF_calc: TComboBox;
Label2: TLabel;
CB_OGame_Universename: TComboBox;
btn_update: TButton;
Label3: TLabel;
cb_def_TF_calc: TComboBox;
cb_redesign: TCheckBox;
Label8: TLabel;
Label9: TLabel;
cb_gala_count: TComboBox;
cb_solsys_count: TComboBox;
Label1: TLabel;
Label7: TLabel;
cb_speed: TComboBox;
procedure CB_OGame_SiteChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure E_GalaKeyPress(Sender: TObject; var Key: Char);
procedure BTN_OKClick(Sender: TObject);
procedure E_UniChange(Sender: TObject);
procedure btn_updateClick(Sender: TObject);
private
ODB: TObject;
procedure updateGameSites;
{ Private-Deklarationen }
public
game_domain: string;
urlName: string;
UniverseName: String;
GalaCount, SysCount: Integer;
IngameName: String;
HomePlanet: TPlanetPosition;
SpeedFaktor: Single;
TF_fact_fleet: Double;
TF_fact_def: Double;
redesign: Boolean;
function Execute: boolean;
constructor Create(AOwner: TComponent; odb: TObject); reintroduce;
{ Public-Deklarationen }
end;
implementation
uses Prog_Unit;
{$R *.DFM}
procedure TFRM_Spielerdaten.CB_OGame_SiteChange(Sender: TObject);
var i: integer;
site: TGameSite;
begin
CB_OGame_Universename.Items.Clear;
CB_OGame_Universename.Text := '';
if CB_OGame_Site.ItemIndex <> -1 then
begin
site := TOgameDataBase(ODB).game_data.GameSites[CB_OGame_Site.ItemIndex];
for i := 0 to site.Count -1 do
CB_OGame_Universename.Items.Add(site.UniverseList[i].name);
end;
end;
constructor TFRM_Spielerdaten.Create(AOwner: TComponent; odb: TObject);
begin
inherited Create(AOwner);
Self.ODB := odb;
end;
function TFRM_Spielerdaten.Execute: boolean;
var i: integer;
begin
CB_OGame_Site.Text := game_domain;
CB_OGame_Universename.Text := UniverseName;
cb_speed.Text := FloatToStr(SpeedFaktor);
cb_gala_count.Text := IntToStr(GalaCount);
cb_solsys_count.Text := IntToStr(SysCount);
E_Spielername.Text := IngameName;
E_Gala.Text := IntToStr(homeplanet.P[0]);
E_System.Text := IntToStr(homeplanet.P[1]);
E_Planet.Text := IntToStr(homeplanet.P[2]);
cb_redesign.Checked := redesign;
i := round(TF_fact_fleet*100);
if (i = 30)or(i = 0) then
cb_fleet_TF_calc.ItemIndex := 0
else
cb_fleet_TF_calc.Text := IntToStr(i);
i := round(TF_fact_def*100);
if (i = 0) then
cb_def_TF_calc.ItemIndex := 0
else
cb_def_TF_calc.Text := IntToStr(i);
Result := (ShowModal = mrOk);
if Result then
begin
game_domain := CB_OGame_Site.Text;
UniverseName := CB_OGame_Universename.Text;
SpeedFaktor := StrToFloat(cb_speed.Text);
i := ReadInt(cb_fleet_TF_calc.Text,1,false);
TF_fact_fleet := i /100;
i := ReadInt(cb_def_TF_calc.Text,1,false);
TF_fact_def := i /100;
IngameName := E_Spielername.Text;
i := ReadInt(cb_gala_count.Text,1,false);
GalaCount := i;
i := ReadInt(cb_solsys_count.Text,1,false);
SysCount := i;
try
HomePlanet.P[0] := StrToInt(E_Gala.Text);
HomePlanet.P[1] := StrToInt(E_System.Text);
HomePlanet.P[2] := StrToInt(E_Planet.Text);
HomePlanet.mond := False;
except
FillChar(HomePlanet,sizeof(HomePlanet),0);
end;
redesign := cb_redesign.Checked;
end;
end;
procedure TFRM_Spielerdaten.FormCreate(Sender: TObject);
begin
if SaveCaptions then SaveAllCaptions(Self,LangFile);
if LoadCaptions then LoadAllCaptions(Self,LangFile);
updateGameSites;
end;
procedure TFRM_Spielerdaten.FormPaint(Sender: TObject);
begin
Application.BringToFront;
end;
procedure TFRM_Spielerdaten.E_GalaKeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',#8]) then
Key := #0;
end;
procedure TFRM_Spielerdaten.BTN_OKClick(Sender: TObject);
var i: integer;
f: single;
begin
try
f := StrToFloat(cb_speed.Text);
if (f <= 0) then
raise Exception.Create('');
except
ShowMessage('Fehlerhaftes Format bei ' + lbl_Speedfaktor.Caption);
exit;
end;
try
i := ReadInt(cb_fleet_TF_calc.Text, 1, false);
if (i < 0) or (i > 100) then
raise Exception.Create('');
except
ShowMessage('Fehlerhaftes Format bei ' + Label7.Caption);
exit;
end;
try
i := ReadInt(cb_def_TF_calc.Text, 1, false);
if (i < 0) or (i > 100) then
raise Exception.Create('');
except
ShowMessage('Fehlerhaftes Format bei ' + Label1.Caption);
exit;
end;
try
i := ReadInt(cb_gala_count.Text, 1, false);
if (i <= 0) then
raise Exception.Create('');
except
ShowMessage('Fehlerhaftes Format bei ' + Label9.Caption);
exit;
end;
try
i := ReadInt(cb_solsys_count.Text, 1, false);
if (i <= 0) then
raise Exception.Create('');
except
ShowMessage('Fehlerhaftes Format bei ' + Label8.Caption);
exit;
end;
if (E_Spielername.Text <> '')and
(E_Gala.Text <> '')and
(E_System.Text <> '')and
(E_Planet.Text <> '')and
(CB_OGame_Universename.Text <> '')and
(CB_OGame_Site.Text <> '') then
ModalResult := mrOk;
end;
procedure TFRM_Spielerdaten.E_UniChange(Sender: TObject);
var site, uni: integer;
universe: TGameUniverse;
begin
site := CB_OGame_Site.ItemIndex;
if site >= 0 then
begin
uni := CB_OGame_Universename.ItemIndex;
if uni >= 0 then
begin
universe := TOgameDataBase(ODB).
game_data.GameSites[site].UniverseList[uni];
urlName := universe.urlName;
cb_gala_count.Text := IntToStr(universe.galaxyCount);
cb_solsys_count.Text := IntToStr(universe.solsysCount);
cb_speed.Text := FloatToStr(universe.gameSpeedFactor);
cb_fleet_TF_calc.Text := IntToStr(round(universe.tfFleetFactor*100));
cb_def_TF_calc.Text := IntToStr(round(universe.tfDefFactor*100));
cb_redesign.Checked := universe.redesign_rules;
end
else
begin
urlName := CB_OGame_Universename.Text;
end;
end;
end;
procedure TFRM_Spielerdaten.btn_updateClick(Sender: TObject);
var frm_quickupdate: Tfrm_quickupdate;
begin
frm_quickupdate := Tfrm_quickupdate.Create(Self, ODB, false);
try
if frm_quickupdate.ShowModal = mrOk then
begin
TOgameDataBase(ODB).updateGameData;
updateGameSites;
end;
finally
frm_quickupdate.Free;
end;
end;
procedure TFRM_Spielerdaten.updateGameSites;
var i: integer;
begin
CB_OGame_Site.Items.Clear;
for i := 0 to TOgameDataBase(ODB).game_data.Count -1 do
CB_OGame_Site.Items.Add(TOgameDataBase(ODB).game_data.GameSites[i].name);
CB_OGame_Site.ItemIndex := 0;
CB_OGame_SiteChange(Self);
end;
end.