-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.pas
173 lines (159 loc) · 4.77 KB
/
load.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
unit load;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm5 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure initializeButton(Button: Integer; filename : String);
end;
var
Form5: TForm5;
Save1: TextFile;
SaveStats1 : tstringlist;
SaveExist1: boolean;
Save2 : TextFile;
SaveStats2 : tstringlist;
SaveExist2: boolean;
Save3 : TextFile;
SaveStats3 : tstringlist;
SaveExist3: boolean;
implementation
{$R *.dfm}
uses Unit1, Objects;
procedure TForm5.initializeButton(Button: Integer; filename : String); //Knöpfe werden initialisiert (s. save.pas)
begin
case Button of
1:Begin
SaveStats1:= Form1.getText(filename);
AssignFile(Save1, filename);
Reset(Save1);
Button1.Caption := SaveStats1[0];
CloseFile(Save1);
End;
2:Begin
SaveStats2:= Form1.getText(filename);
AssignFile(Save2, filename);
Reset(Save2);
Button2.Caption := SaveStats1[0];
CloseFile(Save2);
End;
3:Begin
SaveStats1:= Form1.getText(filename);
AssignFile(Save1, filename);
Reset(Save3);
Button1.Caption := SaveStats1[0];
CloseFile(Save3);
End;
end;
end;
procedure TForm5.Button1Click(Sender: TObject); //Save 1
var player : Tplayer;
items : TStringList;
i : integer;
begin
if(SaveExist1) then //wenn dieser Save existiert
Begin
items := TStringList.Create;
Form1.setData(SaveStats1[1]); //URL wird in Hauptroutine auf gespeicherte URL gesetzt
player := Tplayer.create(strtoint(SaveStats1[2]), strtoint(SaveStats1[3]), strtoint(SaveStats1[4]), strtoint(SaveStats1[5])); // neuer Player wird erstelt
if StrToInt(SaveStats1[6]) <> 0 then
for i := 0 to strtoint(SaveStats1[6]) - 1 do
Begin
items.Append(SaveStats1[7 + i]); // items werden dem neuem player hinzugefügt
End;
player.setItems(items);
Form1.setPlayer(player); //player zur Hauptroutine hinzugefügt
Form1.Enabled := true;
Form1.StoryClear;
ShowMessage('Profil geladen!');
Form5.Hide
End;
end;
//Save 2
procedure TForm5.Button2Click(Sender: TObject);
var player : Tplayer;
items : TStringList;
i : integer;
begin
if(SaveExist2) then
Begin
items := TStringList.Create;
Form1.setData(SaveStats2[1]);
player := Tplayer.create(strtoint(SaveStats2[2]), strtoint(SaveStats2[3]), strtoint(SaveStats2[4]), strtoint(SaveStats2[5]));
for i := 0 to strtoint(SaveStats2[6]) do
Begin
items.Append(SaveStats2[7 + i]);
End;
Form1.setPlayer(player);
Form1.Enabled := true;
Form1.StoryClear;
ShowMessage('Profil geladen!');
Form5.Hide
End;
end;
procedure TForm5.Button3Click(Sender: TObject); //Save 3
var player : Tplayer;
items : TStringList;
i : integer;
begin
if(SaveExist3) then
Begin
items := TStringList.Create;
Form1.setData(SaveStats3[1]);
player := Tplayer.create(strtoint(SaveStats3[2]), strtoint(SaveStats3[3]), strtoint(SaveStats3[4]), strtoint(SaveStats3[5]));
for i := 0 to strtoint(SaveStats3[6]) do
Begin
items.Append(SaveStats3[7 + i]);
End;
Form1.setPlayer(player);
Form1.Enabled := true;
Form1.StoryClear;
ShowMessage('Profil geladen!');
Form5.Hide
End;
end;
procedure TForm5.Button4Click(Sender: TObject); // Cancel
begin
Form1.Enabled := true;
Form5.Hide;
end;
// bei jedem Start ded Fensters wird das ausgeführt (s. save.pas)
procedure TForm5.FormCreate(Sender: TObject);
begin
SaveStats1 := tstringlist.create;
SaveStats2 := tstringlist.create;
SaveStats3 := tstringlist.create;
if FileExists(GetCurrentDir() + '\Saves\save1.zrk') then
Begin
initializeButton(1, GetCurrentDir() + '\Saves\save1.zrk');
SaveExist1 := true;
End
else SaveExist1 := false;
if FileExists(GetCurrentDir() + '\Saves\save2.zrk') then
Begin
initializeButton(2, GetCurrentDir() + '\Saves\save2.zrk');
SaveExist2 := true;
End
else SaveExist2 := false;
if FileExists(GetCurrentDir() + '\Saves\save3.zrk') then
Begin
initializeButton(3, GetCurrentDir() + '\Saves\save3.zrk');
SaveExist3 := true;
End
else SaveExist3 := false;
end;
end.