Rev 2 | Rev 6 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 4 | ||
---|---|---|---|
1 | unit LevSpeicherung; |
1 | unit LevSpeicherung; |
2 | 2 | ||
3 | interface |
3 | interface |
4 | 4 | ||
5 | uses |
5 | uses |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
7 | StdCtrls, ExtCtrls, Spin, ComCtrls; |
7 | StdCtrls, ExtCtrls, Spin, ComCtrls, System.UITypes; |
8 | 8 | ||
9 | type |
9 | type |
10 | TSpeicherungForm = class(TForm) |
10 | TSpeicherungForm = class(TForm) |
11 | Bevel1: TBevel; |
11 | Bevel1: TBevel; |
12 | LadenBtn: TButton; |
12 | LadenBtn: TButton; |
13 | LoeschenBtn: TButton; |
13 | LoeschenBtn: TButton; |
14 | AktualisierenBtn: TButton; |
14 | AktualisierenBtn: TButton; |
15 | SpeichernBtn: TButton; |
15 | SpeichernBtn: TButton; |
16 | AbbrechenBtn: TButton; |
16 | AbbrechenBtn: TButton; |
17 | LevelListBox: TListBox; |
17 | LevelListBox: TListBox; |
18 | Label2: TLabel; |
18 | Label2: TLabel; |
19 | Label3: TLabel; |
19 | Label3: TLabel; |
20 | Label1: TLabel; |
20 | Label1: TLabel; |
21 | ElPanel1: TPanel; |
21 | ElPanel1: TPanel; |
22 | li3a: TLabel; |
22 | li3a: TLabel; |
23 | li1b: TLabel; |
23 | li1b: TLabel; |
24 | li1a: TLabel; |
24 | li1a: TLabel; |
25 | li2b: TLabel; |
25 | li2b: TLabel; |
26 | li2a: TLabel; |
26 | li2a: TLabel; |
27 | li3b: TLabel; |
27 | li3b: TLabel; |
28 | liu: TLabel; |
28 | liu: TLabel; |
29 | liw: TLabel; |
29 | liw: TLabel; |
30 | SpinEditEdt: TEdit; |
30 | SpinEditEdt: TEdit; |
31 | SpinEdit: TUpDown; |
31 | SpinEdit: TUpDown; |
32 | procedure LoeschenBtnClick(Sender: TObject); |
32 | procedure LoeschenBtnClick(Sender: TObject); |
33 | procedure LadenBtnClick(Sender: TObject); |
33 | procedure LadenBtnClick(Sender: TObject); |
34 | procedure SpeichernBtnClick(Sender: TObject); |
34 | procedure SpeichernBtnClick(Sender: TObject); |
35 | procedure LevelListBoxClick(Sender: TObject); |
35 | procedure LevelListBoxClick(Sender: TObject); |
36 | procedure Button4Click(Sender: TObject); |
36 | procedure Button4Click(Sender: TObject); |
37 | procedure FormShow(Sender: TObject); |
37 | procedure FormShow(Sender: TObject); |
38 | procedure DsFancyButton2Click(Sender: TObject); |
38 | procedure DsFancyButton2Click(Sender: TObject); |
39 | procedure AbbrechenBtnClick(Sender: TObject); |
39 | procedure AbbrechenBtnClick(Sender: TObject); |
40 | procedure LevelNameChange(Sender: TObject); |
40 | procedure LevelNameChange(Sender: TObject); |
41 | procedure LevelListBoxDblClick(Sender: TObject); |
41 | procedure LevelListBoxDblClick(Sender: TObject); |
42 | procedure FormHide(Sender: TObject); |
42 | procedure FormHide(Sender: TObject); |
43 | procedure SpinEditClick(Sender: TObject; Button: TUDBtnType); |
43 | procedure SpinEditClick(Sender: TObject; Button: TUDBtnType); |
44 | procedure SpinEditEdtKeyPress(Sender: TObject; var Key: Char); |
44 | procedure SpinEditEdtKeyPress(Sender: TObject; var Key: Char); |
45 | procedure SpinEditEdtChange(Sender: TObject); |
45 | procedure SpinEditEdtChange(Sender: TObject); |
46 | public |
46 | public |
47 | procedure SearchLevels; |
47 | procedure SearchLevels; |
48 | function RightStr(str: string; count: integer): string; |
48 | function RightStr(str: string; count: integer): string; |
49 | function Filter(n: integer; s: string): string; |
49 | function Filter(n: integer; s: string): string; |
50 | end; |
50 | end; |
51 | 51 | ||
52 | var |
52 | var |
53 | SpeicherungForm: TSpeicherungForm; |
53 | SpeicherungForm: TSpeicherungForm; |
54 | 54 | ||
55 | implementation |
55 | implementation |
56 | 56 | ||
57 | uses |
57 | uses |
58 | Global, LevMain; |
58 | Global, LevMain; |
59 | 59 | ||
60 | {$R *.DFM} |
60 | {$R *.DFM} |
61 | 61 | ||
62 | procedure TSpeicherungForm.SearchLevels; |
62 | procedure TSpeicherungForm.SearchLevels; |
63 | var |
63 | var |
64 | {sr: TSearchRec; |
64 | {sr: TSearchRec; |
65 | res: integer;} |
65 | res: integer;} |
66 | i: integer; |
66 | i: integer; |
67 | begin |
67 | begin |
68 | //SpinEdit.Value := 1; |
68 | //SpinEdit.Value := 1; |
69 | LevelListBox.items.clear; |
69 | LevelListBox.items.clear; |
70 | li1a.visible := false; |
70 | li1a.visible := false; |
71 | li2a.visible := false; |
71 | li2a.visible := false; |
72 | li3a.visible := false; |
72 | li3a.visible := false; |
73 | li1b.visible := false; |
73 | li1b.visible := false; |
74 | li2b.visible := false; |
74 | li2b.visible := false; |
75 | li3b.visible := false; |
75 | li3b.visible := false; |
76 | liw.visible := true; |
76 | liw.visible := true; |
77 | LadenBtn.enabled := false; |
77 | LadenBtn.enabled := false; |
78 | LoeschenBtn.enabled := false; |
78 | LoeschenBtn.enabled := false; |
79 | {res := FindFirst(mainform.fdirectory+'Levels\*.lev', 0, sr); |
79 | {res := FindFirst(mainform.fdirectory+'Levels\*.lev', 0, sr); |
80 | try |
80 | try |
81 | while (res = 0) do |
81 | while (res = 0) do |
82 | begin |
82 | begin |
83 | if (sr.name <> '.') and (sr.name <> '..') then |
83 | if (sr.name <> '.') and (sr.name <> '..') then |
84 | LevelListBox.items.Add(copy(sr.Name, 0, length(sr.name)-4)); |
84 | LevelListBox.items.Add(copy(sr.Name, 0, length(sr.name)-4)); |
85 | res := FindNext(sr); |
85 | res := FindNext(sr); |
86 | end; |
86 | end; |
87 | finally |
87 | finally |
88 | FindClose(sr); |
88 | FindClose(sr); |
89 | end;} |
89 | end;} |
90 | for i := 1 to 9999 do |
90 | for i := 1 to 9999 do |
91 | begin |
91 | begin |
92 | if fileexists(fdirectory+'Levels\Level '+inttostr(i)+'.lev') then |
92 | if fileexists(fdirectory+'Levels\Level '+inttostr(i)+'.lev') then |
93 | LevelListBox.items.Add('Level ' + inttostr(i)); |
93 | LevelListBox.items.Add('Level ' + inttostr(i)); |
94 | end; |
94 | end; |
95 | end; |
95 | end; |
96 | 96 | ||
97 | procedure TSpeicherungForm.LoeschenBtnClick(Sender: TObject); |
97 | procedure TSpeicherungForm.LoeschenBtnClick(Sender: TObject); |
98 | var |
98 | var |
99 | Markiert: boolean; |
99 | Markiert: boolean; |
100 | i: integer; |
100 | i: integer; |
101 | begin |
101 | begin |
102 | Markiert := false; |
102 | Markiert := false; |
103 | for i := 0 to LevelListBox.items.Count-1 do |
103 | for i := 0 to LevelListBox.items.Count-1 do |
104 | begin |
104 | begin |
105 | if LevelListBox.Selected[i] then Markiert := true; |
105 | if LevelListBox.Selected[i] then Markiert := true; |
106 | end; |
106 | end; |
107 | if not Markiert then exit; |
107 | if not Markiert then exit; |
108 | if MessageDlg('Dieses Level wirklich löschen?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then |
108 | if MessageDlg('Dieses Level wirklich löschen?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then |
109 | begin |
109 | begin |
110 | li1a.visible := false; |
110 | li1a.visible := false; |
111 | li2a.visible := false; |
111 | li2a.visible := false; |
112 | li3a.visible := false; |
112 | li3a.visible := false; |
113 | li1b.visible := false; |
113 | li1b.visible := false; |
114 | li2b.visible := false; |
114 | li2b.visible := false; |
115 | li3b.visible := false; |
115 | li3b.visible := false; |
116 | liu.visible := false; |
116 | liu.visible := false; |
117 | liw.visible := true; |
117 | liw.visible := true; |
118 | LadenBtn.enabled := false; |
118 | LadenBtn.enabled := false; |
119 | LoeschenBtn.enabled := false; |
119 | LoeschenBtn.enabled := false; |
120 | deletefile(FDirectory+'Levels\'+ |
120 | deletefile(FDirectory+'Levels\'+ |
121 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
121 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
122 | SearchLevels; |
122 | SearchLevels; |
123 | end; |
123 | end; |
124 | end; |
124 | end; |
125 | 125 | ||
126 | procedure TSpeicherungForm.LadenBtnClick(Sender: TObject); |
126 | procedure TSpeicherungForm.LadenBtnClick(Sender: TObject); |
127 | var |
127 | var |
128 | Markiert: boolean; |
128 | Markiert: boolean; |
129 | i, TempArtMain, TempLiveMain: integer; |
129 | i, TempArtMain, TempLiveMain: integer; |
130 | SavGame: textfile; |
130 | SavGame: textfile; |
131 | Ergebnis: array[1..5] of string; |
131 | Ergebnis: array[1..5] of string; |
132 | begin |
132 | begin |
133 | Markiert := false; |
133 | Markiert := false; |
134 | for i := 0 to LevelListBox.items.Count-1 do |
134 | for i := 0 to LevelListBox.items.Count-1 do |
135 | begin |
135 | begin |
136 | if LevelListBox.Selected[i] then Markiert := true; |
136 | if LevelListBox.Selected[i] then Markiert := true; |
137 | end; |
137 | end; |
138 | if not Markiert then exit; |
138 | if not Markiert then exit; |
139 | if LevelListBox.items.count = 0 then |
139 | if LevelListBox.items.count = 0 then |
140 | begin |
140 | begin |
141 | li1a.visible := false; |
141 | li1a.visible := false; |
142 | li2a.visible := false; |
142 | li2a.visible := false; |
143 | li3a.visible := false; |
143 | li3a.visible := false; |
144 | li1b.visible := false; |
144 | li1b.visible := false; |
145 | li2b.visible := false; |
145 | li2b.visible := false; |
146 | li3b.visible := false; |
146 | li3b.visible := false; |
147 | liw.visible := true; |
147 | liw.visible := true; |
148 | LadenBtn.enabled := false; |
148 | LadenBtn.enabled := false; |
149 | LoeschenBtn.enabled := false; |
149 | LoeschenBtn.enabled := false; |
150 | end; |
150 | end; |
151 | // Da Button bei ungültigen Level deaktiviert wird, ist das nicht mehr nötig. |
151 | // Da Button bei ungültigen Level deaktiviert wird, ist das nicht mehr nötig. |
152 | {if liu.visible or (LevelListBox.items.count=0) then |
152 | {if liu.visible or (LevelListBox.items.count=0) then |
153 | exit;} |
153 | exit;} |
154 | // Vorbereiten |
154 | // Vorbereiten |
155 | MainForm.DestroyLevel; |
155 | MainForm.DestroyLevel; |
156 | MainForm.LevChanged := false; |
156 | MainForm.LevChanged := false; |
157 | // Öffnen |
157 | // Öffnen |
158 | AssignFile(SavGame, FDirectory+'Levels\'+ |
158 | AssignFile(SavGame, FDirectory+'Levels\'+ |
159 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
159 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
160 | Reset(SavGame); |
160 | Reset(SavGame); |
161 | // Laden |
161 | // Laden |
162 | ReadLN(SavGame); // --> Copyrightinfo |
162 | ReadLN(SavGame); // --> Copyrightinfo |
163 | ReadLN(SavGame); // --> Copyrightinfo |
163 | ReadLN(SavGame); // --> Copyrightinfo |
164 | ReadLN(SavGame, Ergebnis[5]); // --> Länge der Karte |
164 | ReadLN(SavGame, Ergebnis[5]); // --> Länge der Karte |
165 | MainForm.ScrollBar.Max := strtoint(Ergebnis[5]); |
165 | MainForm.ScrollBar.Max := strtoint(Ergebnis[5]); |
166 | MainForm.Enemys.Clear; |
166 | MainForm.Enemys.Clear; |
167 | TempArtMain := MainForm.ArtChecked; |
167 | TempArtMain := MainForm.ArtChecked; |
168 | TempLiveMain := MainForm.LiveEdit; |
168 | TempLiveMain := MainForm.LiveEdit; |
169 | while not seekEoF(SavGame) do |
169 | while not seekEoF(SavGame) do |
170 | begin |
170 | begin |
171 | ReadLN(SavGame, Ergebnis[3]); |
171 | ReadLN(SavGame, Ergebnis[3]); |
172 | ReadLN(SavGame, Ergebnis[1]); |
172 | ReadLN(SavGame, Ergebnis[1]); |
173 | ReadLN(SavGame, Ergebnis[2]); |
173 | ReadLN(SavGame, Ergebnis[2]); |
174 | ReadLN(SavGame, Ergebnis[4]); |
174 | ReadLN(SavGame, Ergebnis[4]); |
175 | MainForm.EnemyAdd(strtoint(Ergebnis[1]), strtoint(Ergebnis[2]), strtoint(Ergebnis[3]), strtoint(Ergebnis[4])); |
175 | MainForm.EnemyAdd(strtoint(Ergebnis[1]), strtoint(Ergebnis[2]), strtoint(Ergebnis[3]), strtoint(Ergebnis[4])); |
176 | MainForm.ArtChecked := strtoint(Ergebnis[3]); |
176 | MainForm.ArtChecked := strtoint(Ergebnis[3]); |
177 | MainForm.LiveEdit := strtoint(Ergebnis[4]); |
177 | MainForm.LiveEdit := strtoint(Ergebnis[4]); |
178 | MainForm.EnemyCreate(strtoint(Ergebnis[1]), strtoint(Ergebnis[2])); |
178 | MainForm.EnemyCreate(strtoint(Ergebnis[1]), strtoint(Ergebnis[2])); |
179 | inc(MainForm.NumEnemys); |
179 | inc(MainForm.NumEnemys); |
180 | if Ergebnis[3] = '7' then MainForm.Boss := true; |
180 | if Ergebnis[3] = '7' then MainForm.Boss := true; |
181 | end; |
181 | end; |
182 | MainForm.LiveEdit := TempLiveMain; |
182 | MainForm.LiveEdit := TempLiveMain; |
183 | MainForm.ArtChecked := TempArtMain; |
183 | MainForm.ArtChecked := TempArtMain; |
184 | // Schließen |
184 | // Schließen |
185 | CloseFile(SavGame); |
185 | CloseFile(SavGame); |
186 | // Nacharbeiten |
186 | // Nacharbeiten |
187 | MainForm.AnzeigeAct; |
187 | MainForm.AnzeigeAct; |
188 | close; |
188 | close; |
189 | end; |
189 | end; |
190 | 190 | ||
191 | function TSpeicherungForm.RightStr(str: string; count: integer): string; |
191 | function TSpeicherungForm.RightStr(str: string; count: integer): string; |
192 | begin |
192 | begin |
193 | result := copy(str, length(str)-(count-1), count); |
193 | result := copy(str, length(str)-(count-1), count); |
194 | end; |
194 | end; |
195 | 195 | ||
196 | function TSpeicherungForm.Filter(n: integer; s: string): string; |
196 | function TSpeicherungForm.Filter(n: integer; s: string): string; |
197 | var |
197 | var |
198 | i, last: integer; |
198 | i, last: integer; |
199 | start, start2: boolean; |
199 | start, start2: boolean; |
200 | temp: string; |
200 | temp: string; |
201 | begin |
201 | begin |
202 | last := 0; |
202 | last := 0; |
203 | start := false; |
203 | start := false; |
204 | start2 := false; |
204 | start2 := false; |
205 | temp := ''; |
205 | temp := ''; |
206 | if n = 1 then |
206 | if n = 1 then |
207 | begin |
207 | begin |
208 | for i := 1 to length(s)+1 do |
208 | for i := 1 to length(s)+1 do |
209 | begin |
209 | begin |
210 | if copy(s, i, 1) = '-' then |
210 | if copy(s, i, 1) = '-' then |
211 | begin |
211 | begin |
212 | last := i; |
212 | last := i; |
213 | break; |
213 | break; |
214 | end; |
214 | end; |
215 | end; |
215 | end; |
216 | temp := copy(s, 1, last-1); |
216 | temp := copy(s, 1, last-1); |
217 | end; |
217 | end; |
218 | if n = 2 then |
218 | if n = 2 then |
219 | begin |
219 | begin |
220 | for i := 1 to length(s)+1 do |
220 | for i := 1 to length(s)+1 do |
221 | begin |
221 | begin |
222 | if start2 then start := true; |
222 | if start2 then start := true; |
223 | if copy(s, i, 1) = '-' then start2 := true; |
223 | if copy(s, i, 1) = '-' then start2 := true; |
224 | if (copy(s, i, 1) = ':') and start then break; |
224 | if (copy(s, i, 1) = ':') and start then break; |
225 | if start then temp := temp + copy(s, i, 1) |
225 | if start then temp := temp + copy(s, i, 1) |
226 | end; |
226 | end; |
227 | end; |
227 | end; |
228 | if n = 3 then |
228 | if n = 3 then |
229 | begin |
229 | begin |
230 | for i := 1 to length(s)+1 do |
230 | for i := 1 to length(s)+1 do |
231 | begin |
231 | begin |
232 | if start2 then start := true; |
232 | if start2 then start := true; |
233 | if copy(s, i, 1) = ':' then start2 := true; |
233 | if copy(s, i, 1) = ':' then start2 := true; |
234 | if (copy(s, i, 1) = '(') and start then break; |
234 | if (copy(s, i, 1) = '(') and start then break; |
235 | if start then temp := temp + copy(s, i, 1) |
235 | if start then temp := temp + copy(s, i, 1) |
236 | end; |
236 | end; |
237 | end; |
237 | end; |
238 | if n = 4 then |
238 | if n = 4 then |
239 | begin |
239 | begin |
240 | for i := 1 to length(s)+1 do |
240 | for i := 1 to length(s)+1 do |
241 | begin |
241 | begin |
242 | if start2 then start := true; |
242 | if start2 then start := true; |
243 | if copy(s, i, 1) = '(' then start2 := true; |
243 | if copy(s, i, 1) = '(' then start2 := true; |
244 | if (copy(s, i, 1) = ')') and start then break; |
244 | if (copy(s, i, 1) = ')') and start then break; |
245 | if start then temp := temp + copy(s, i, 1) |
245 | if start then temp := temp + copy(s, i, 1) |
246 | end; |
246 | end; |
247 | end; |
247 | end; |
248 | result := temp; |
248 | result := temp; |
249 | end; |
249 | end; |
250 | 250 | ||
251 | procedure TSpeicherungForm.SpeichernBtnClick(Sender: TObject); |
251 | procedure TSpeicherungForm.SpeichernBtnClick(Sender: TObject); |
252 | var |
252 | var |
253 | SavGame: textfile; |
253 | SavGame: textfile; |
254 | i, j: integer; |
254 | i, j: integer; |
255 | puffer: string; |
255 | puffer: string; |
256 | begin |
256 | begin |
257 | if mainform.Enemys.count = 0 then |
257 | if mainform.Enemys.count = 0 then |
258 | begin |
258 | begin |
259 | MessageDlg('Das Level ist leer!', mtError, [mbOK], 0); |
259 | MessageDlg('Das Level ist leer!', mtError, [mbOK], 0); |
260 | SpinEdit.SetFocus; |
260 | SpinEdit.SetFocus; |
261 | exit; |
261 | exit; |
262 | end; |
262 | end; |
263 | {for i := 0 to length(LevelName.text) do |
263 | {for i := 0 to length(LevelName.text) do |
264 | begin |
264 | begin |
265 | if (copy(LevelName.text, i, 1) = '\') or |
265 | if (copy(LevelName.text, i, 1) = '\') or |
266 | (copy(LevelName.text, i, 1) = '/') or |
266 | (copy(LevelName.text, i, 1) = '/') or |
267 | (copy(LevelName.text, i, 1) = ':') or |
267 | (copy(LevelName.text, i, 1) = ':') or |
268 | (copy(LevelName.text, i, 1) = '*') or |
268 | (copy(LevelName.text, i, 1) = '*') or |
269 | (copy(LevelName.text, i, 1) = '?') or |
269 | (copy(LevelName.text, i, 1) = '?') or |
270 | (copy(LevelName.text, i, 1) = '"') or |
270 | (copy(LevelName.text, i, 1) = '"') or |
271 | (copy(LevelName.text, i, 1) = '<') or |
271 | (copy(LevelName.text, i, 1) = '<') or |
272 | (copy(LevelName.text, i, 1) = '>') or |
272 | (copy(LevelName.text, i, 1) = '>') or |
273 | (copy(LevelName.text, i, 1) = '|') then |
273 | (copy(LevelName.text, i, 1) = '|') then |
274 | begin |
274 | begin |
275 | MessageDlg('Dies ist kein gültiger Levelname!', mtError, [mbOK], 0); |
275 | MessageDlg('Dies ist kein gültiger Levelname!', mtError, [mbOK], 0); |
276 | LevelName.SetFocus; |
276 | LevelName.SetFocus; |
277 | exit; |
277 | exit; |
278 | end; |
278 | end; |
279 | end;} |
279 | end;} |
280 | if LevelListBox.items.IndexOf('Level ' + inttostr(SpinEdit.Position)) > -1 then |
280 | if LevelListBox.items.IndexOf('Level ' + inttostr(SpinEdit.Position)) > -1 then |
281 | begin |
281 | begin |
282 | if MessageDlg('Level ist bereits vorhanden. Ersetzen?', mtConfirmation, [mbYes, mbNo], 0) = mrNo then |
282 | if MessageDlg('Level ist bereits vorhanden. Ersetzen?', mtConfirmation, [mbYes, mbNo], 0) = mrNo then |
283 | exit; |
283 | exit; |
284 | end; |
284 | end; |
285 | // Öffnen oder erstellen |
285 | // Öffnen oder erstellen |
286 | AssignFile(SavGame, FDirectory+'Levels\Level '+inttostr(SpinEdit.Position)+'.lev'); |
286 | AssignFile(SavGame, FDirectory+'Levels\Level '+inttostr(SpinEdit.Position)+'.lev'); |
287 | Rewrite(SavGame); |
287 | Rewrite(SavGame); |
288 | // Sortierung |
288 | // Sortierung |
289 | for j := 0 to mainform.enemys.Count - 2 do |
289 | for j := 0 to mainform.enemys.Count - 2 do |
290 | begin |
290 | begin |
291 | for i := 0 to mainform.enemys.Count - 2 do |
291 | for i := 0 to mainform.enemys.Count - 2 do |
292 | begin |
292 | begin |
293 | if strtoint(filter(1, mainform.enemys.Strings[i])) > strtoint(filter(1, mainform.enemys.Strings[i + 1])) then |
293 | if strtoint(filter(1, mainform.enemys.Strings[i])) > strtoint(filter(1, mainform.enemys.Strings[i + 1])) then |
294 | begin |
294 | begin |
295 | puffer := mainform.enemys.Strings[i]; |
295 | puffer := mainform.enemys.Strings[i]; |
296 | mainform.enemys.Strings[i] := mainform.enemys.Strings[i + 1]; |
296 | mainform.enemys.Strings[i] := mainform.enemys.Strings[i + 1]; |
297 | mainform.enemys.Strings[i + 1] := puffer; |
297 | mainform.enemys.Strings[i + 1] := puffer; |
298 | end; |
298 | end; |
299 | end; |
299 | end; |
300 | end; |
300 | end; |
301 | // Speichern |
301 | // Speichern |
302 | WriteLN(SavGame, '; SpaceMission ' + FCompVersion); |
302 | WriteLN(SavGame, '; SpaceMission ' + FCompVersion); |
303 | WriteLN(SavGame, '; LEV-File'); |
303 | WriteLN(SavGame, '; LEV-File'); |
304 | WriteLN(SavGame, inttostr(MainForm.ScrollBar.Max)); // --> Länge der Karte |
304 | WriteLN(SavGame, inttostr(MainForm.ScrollBar.Max)); // --> Länge der Karte |
305 | for i := 0 to mainform.enemys.count-1 do |
305 | for i := 0 to mainform.enemys.count-1 do |
306 | begin |
306 | begin |
307 | WriteLN(SavGame, filter(3, mainform.enemys.Strings[i])); |
307 | WriteLN(SavGame, filter(3, mainform.enemys.Strings[i])); |
308 | WriteLN(SavGame, filter(1, mainform.enemys.Strings[i])); |
308 | WriteLN(SavGame, filter(1, mainform.enemys.Strings[i])); |
309 | WriteLN(SavGame, filter(2, mainform.enemys.Strings[i])); |
309 | WriteLN(SavGame, filter(2, mainform.enemys.Strings[i])); |
310 | WriteLN(SavGame, filter(4, mainform.enemys.Strings[i])); |
310 | WriteLN(SavGame, filter(4, mainform.enemys.Strings[i])); |
311 | end; |
311 | end; |
312 | // Schließen |
312 | // Schließen |
313 | CloseFile(SavGame); |
313 | CloseFile(SavGame); |
314 | // Nacharbeiten |
314 | // Nacharbeiten |
315 | MainForm.LevChanged := false; |
315 | MainForm.LevChanged := false; |
316 | MainForm.AnzeigeAct; |
316 | MainForm.AnzeigeAct; |
317 | SearchLevels; |
317 | SearchLevels; |
318 | end; |
318 | end; |
319 | 319 | ||
320 | procedure TSpeicherungForm.LevelListBoxClick(Sender: TObject); |
320 | procedure TSpeicherungForm.LevelListBoxClick(Sender: TObject); |
321 | var |
321 | var |
322 | Ergebnis, boss, l, temp: string; |
322 | Ergebnis, boss, l, temp: string; |
323 | SavGame: textfile; |
323 | SavGame: textfile; |
324 | x, a: integer; |
324 | x, a: integer; |
325 | begin |
325 | begin |
326 | li1a.visible := false; |
326 | li1a.visible := false; |
327 | li2a.visible := false; |
327 | li2a.visible := false; |
328 | li3a.visible := false; |
328 | li3a.visible := false; |
329 | li1b.visible := false; |
329 | li1b.visible := false; |
330 | li2b.visible := false; |
330 | li2b.visible := false; |
331 | li3b.visible := false; |
331 | li3b.visible := false; |
332 | liu.visible := false; |
332 | liu.visible := false; |
333 | liw.visible := false; |
333 | liw.visible := false; |
334 | if (LevelListBox.items.count=0) or (LevelListBox.itemindex = -1) then |
334 | if (LevelListBox.items.count=0) or (LevelListBox.itemindex = -1) then |
335 | begin |
335 | begin |
336 | ladenbtn.enabled := false; |
336 | ladenbtn.enabled := false; |
337 | loeschenbtn.enabled := false; |
337 | loeschenbtn.enabled := false; |
338 | liw.visible := true; |
338 | liw.visible := true; |
339 | exit; |
339 | exit; |
340 | end; |
340 | end; |
341 | temp := LevelListBox.Items.strings[LevelListBox.itemindex]; |
341 | temp := LevelListBox.Items.strings[LevelListBox.itemindex]; |
342 | SpinEdit.Position := strtoint(RightStr(temp, length(temp)-6)); |
342 | SpinEdit.Position := strtoint(RightStr(temp, length(temp)-6)); |
343 | AssignFile(SavGame, FDirectory+'Levels\'+ |
343 | AssignFile(SavGame, FDirectory+'Levels\'+ |
344 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
344 | LevelListBox.Items.strings[LevelListBox.itemindex]+'.lev'); |
345 | Reset(SavGame); |
345 | Reset(SavGame); |
346 | ReadLN(SavGame, Ergebnis); |
346 | ReadLN(SavGame, Ergebnis); |
347 | if Ergebnis <> '; SpaceMission '+FCompVersion then |
347 | if Ergebnis <> '; SpaceMission '+FCompVersion then |
348 | begin |
348 | begin |
349 | liu.visible := true; |
349 | liu.visible := true; |
350 | LadenBtn.enabled := false; |
350 | LadenBtn.enabled := false; |
351 | CloseFile(SavGame); |
351 | CloseFile(SavGame); |
352 | exit; |
352 | exit; |
353 | end; |
353 | end; |
354 | ReadLN(SavGame, Ergebnis); |
354 | ReadLN(SavGame, Ergebnis); |
355 | if Ergebnis <> '; LEV-File' then |
355 | if Ergebnis <> '; LEV-File' then |
356 | begin |
356 | begin |
357 | liu.visible := true; |
357 | liu.visible := true; |
358 | LadenBtn.enabled := false; |
358 | LadenBtn.enabled := false; |
359 | CloseFile(SavGame); |
359 | CloseFile(SavGame); |
360 | exit; |
360 | exit; |
361 | end; |
361 | end; |
362 | ReadLN(SavGame, l); |
362 | ReadLN(SavGame, l); |
363 | x := 0; |
363 | x := 0; |
364 | a := 0; |
364 | a := 0; |
365 | boss := 'Nein'; |
365 | boss := 'Nein'; |
366 | while not SeekEOF(SavGame) do |
366 | while not SeekEOF(SavGame) do |
367 | begin |
367 | begin |
368 | ReadLN(SavGame, Ergebnis); |
368 | ReadLN(SavGame, Ergebnis); |
369 | inc(a); |
369 | inc(a); |
370 | if a = 5 then a := 1; |
370 | if a = 5 then a := 1; |
371 | if (a = 1) and (Ergebnis = '7') then boss := 'Ja'; |
371 | if (a = 1) and (Ergebnis = '7') then boss := 'Ja'; |
372 | inc(x); |
372 | inc(x); |
373 | end; |
373 | end; |
374 | CloseFile(SavGame); |
374 | CloseFile(SavGame); |
375 | if a <> 4 then |
375 | if a <> 4 then |
376 | begin |
376 | begin |
377 | liu.visible := true; |
377 | liu.visible := true; |
378 | LadenBtn.enabled := false; |
378 | LadenBtn.enabled := false; |
379 | end |
379 | end |
380 | else |
380 | else |
381 | begin |
381 | begin |
382 | li1a.visible := true; |
382 | li1a.visible := true; |
383 | li2a.visible := true; |
383 | li2a.visible := true; |
384 | li3a.visible := true; |
384 | li3a.visible := true; |
385 | li1b.visible := true; |
385 | li1b.visible := true; |
386 | li2b.visible := true; |
386 | li2b.visible := true; |
387 | li3b.visible := true; |
387 | li3b.visible := true; |
388 | LadenBtn.enabled := true; |
388 | LadenBtn.enabled := true; |
389 | LoeschenBtn.enabled := true; |
389 | LoeschenBtn.enabled := true; |
390 | li1b.caption := inttostr(trunc(x / 4)); |
390 | li1b.caption := inttostr(trunc(x / 4)); |
391 | li2b.caption := boss; |
391 | li2b.caption := boss; |
392 | li3b.caption := l + ' Felder'; |
392 | li3b.caption := l + ' Felder'; |
393 | end; |
393 | end; |
394 | end; |
394 | end; |
395 | 395 | ||
396 | procedure TSpeicherungForm.Button4Click(Sender: TObject); |
396 | procedure TSpeicherungForm.Button4Click(Sender: TObject); |
397 | begin |
397 | begin |
398 | close; |
398 | close; |
399 | end; |
399 | end; |
400 | 400 | ||
401 | procedure TSpeicherungForm.FormShow(Sender: TObject); |
401 | procedure TSpeicherungForm.FormShow(Sender: TObject); |
402 | begin |
402 | begin |
403 | mainform.dxtimer.enabled := false; |
403 | mainform.dxtimer.enabled := false; |
404 | SearchLevels; |
404 | SearchLevels; |
405 | end; |
405 | end; |
406 | 406 | ||
407 | procedure TSpeicherungForm.DsFancyButton2Click(Sender: TObject); |
407 | procedure TSpeicherungForm.DsFancyButton2Click(Sender: TObject); |
408 | begin |
408 | begin |
409 | SearchLevels; |
409 | SearchLevels; |
410 | end; |
410 | end; |
411 | 411 | ||
412 | procedure TSpeicherungForm.AbbrechenBtnClick(Sender: TObject); |
412 | procedure TSpeicherungForm.AbbrechenBtnClick(Sender: TObject); |
413 | begin |
413 | begin |
414 | close; |
414 | close; |
415 | end; |
415 | end; |
416 | 416 | ||
417 | procedure TSpeicherungForm.LevelNameChange(Sender: TObject); |
417 | procedure TSpeicherungForm.LevelNameChange(Sender: TObject); |
418 | begin |
418 | begin |
419 | {...} |
419 | {...} |
420 | end; |
420 | end; |
421 | 421 | ||
422 | procedure TSpeicherungForm.LevelListBoxDblClick(Sender: TObject); |
422 | procedure TSpeicherungForm.LevelListBoxDblClick(Sender: TObject); |
423 | begin |
423 | begin |
424 | LadenBtn.click; |
424 | LadenBtn.click; |
425 | end; |
425 | end; |
426 | 426 | ||
427 | procedure TSpeicherungForm.FormHide(Sender: TObject); |
427 | procedure TSpeicherungForm.FormHide(Sender: TObject); |
428 | begin |
428 | begin |
429 | mainform.dxtimer.enabled := true; |
429 | mainform.dxtimer.enabled := true; |
430 | end; |
430 | end; |
431 | 431 | ||
432 | procedure TSpeicherungForm.SpinEditClick(Sender: TObject; |
432 | procedure TSpeicherungForm.SpinEditClick(Sender: TObject; |
433 | Button: TUDBtnType); |
433 | Button: TUDBtnType); |
434 | begin |
434 | begin |
435 | SpinEditEdt.Text := inttostr(SpinEdit.position); |
435 | SpinEditEdt.Text := inttostr(SpinEdit.position); |
436 | end; |
436 | end; |
437 | 437 | ||
438 | procedure TSpeicherungForm.SpinEditEdtKeyPress(Sender: TObject; |
438 | procedure TSpeicherungForm.SpinEditEdtKeyPress(Sender: TObject; |
439 | var Key: Char); |
439 | var Key: Char); |
440 | begin |
440 | begin |
441 | if not (Key in [#13, #08, '0'..'9']) then |
441 | if not (Key in [#13, #08, '0'..'9']) then |
442 | Key := #0; |
442 | Key := #0; |
443 | end; |
443 | end; |
444 | 444 | ||
445 | procedure TSpeicherungForm.SpinEditEdtChange(Sender: TObject); |
445 | procedure TSpeicherungForm.SpinEditEdtChange(Sender: TObject); |
446 | begin |
446 | begin |
447 | SpinEdit.Position := strtoint(SpinEditEdt.text); |
447 | SpinEdit.Position := strtoint(SpinEditEdt.text); |
448 | end; |
448 | end; |
449 | 449 | ||
450 | end. |
450 | end. |
451 | 451 | ||
452 | 452 |