Subversion Repositories spacemission

Rev

Rev 73 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73 Rev 79
Line 57... Line 57...
57
{$R *.DFM}
57
{$R *.DFM}
58
 
58
 
59
resourcestring
59
resourcestring
60
  SLevelListBox = 'Level %d';
60
  SLevelListBox = 'Level %d';
61
  SSelbsterstellt = 'Selbsterstellt';
61
  SSelbsterstellt = 'Selbsterstellt';
-
 
62
  SLevelFileNotFound = 'Leveldatei nicht gefunden';
62
 
63
 
63
procedure TSpeicherungForm.SearchLevels;
64
procedure TSpeicherungForm.SearchLevels;
64
var
65
var
65
  i: integer;
66
  i: integer;
66
  fil: TLevelFile;
67
  fil: TLevelFile;
Line 90... Line 91...
90
    end;
91
    end;
91
  end;
92
  end;
92
end;
93
end;
93
 
94
 
94
procedure TSpeicherungForm.LoeschenBtnClick(Sender: TObject);
95
procedure TSpeicherungForm.LoeschenBtnClick(Sender: TObject);
-
 
96
resourcestring
-
 
97
  SReallyDeleteLevel = 'Dieses Level wirklich löschen?';
95
var
98
var
96
  fil: TLevelFile;
99
  fil: TLevelFile;
97
begin
100
begin
98
  if LevelListBox.ItemIndex = -1 then exit;
101
  if LevelListBox.ItemIndex = -1 then exit;
99
 
102
 
100
  if MessageDlg('Dieses Level wirklich löschen?', mtConfirmation, mbYesNoCancel, 0) = mrYes then
103
  if MessageDlg(SReallyDeleteLevel, mtConfirmation, mbYesNoCancel, 0) = mrYes then
101
  begin
104
  begin
102
    li1a.visible := false;
105
    li1a.visible := false;
103
    li2a.visible := false;
106
    li2a.visible := false;
104
    li3a.visible := false;
107
    li3a.visible := false;
105
    li1b.visible := false;
108
    li1b.visible := false;
Line 109... Line 112...
109
    liu.visible := false;
112
    liu.visible := false;
110
    liw.visible := true;
113
    liw.visible := true;
111
    LadenBtn.enabled := false;
114
    LadenBtn.enabled := false;
112
    LoeschenBtn.enabled := false;
115
    LoeschenBtn.enabled := false;
113
    fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
116
    fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
114
    if not fil.found then raise Exception.Create('Leveldatei nicht gefunden');
117
    if not fil.found then raise Exception.Create(SLevelFileNotFound);
115
    deletefile(fil.fileLocation);
118
    deletefile(fil.fileLocation);
116
    SearchLevels;
119
    SearchLevels;
117
  end;
120
  end;
118
end;
121
end;
119
 
122
 
120
procedure TSpeicherungForm.LadenBtnClick(Sender: TObject);
123
procedure TSpeicherungForm.LadenBtnClick(Sender: TObject);
-
 
124
resourcestring
-
 
125
  SLoadNewLevelAndDiscardChanges = 'Neues Level laden und Änderungen verwerfen?';
121
var
126
var
122
  fil: TLevelFile;
127
  fil: TLevelFile;
123
begin
128
begin
124
  if LevelListBox.ItemIndex = -1 then exit;
129
  if LevelListBox.ItemIndex = -1 then exit;
125
 
130
 
126
  if MainForm.LevChanged and (MainForm.LevData.CountEnemies>0) then
131
  if MainForm.LevChanged and (MainForm.LevData.CountEnemies>0) then
127
  begin
132
  begin
128
    if MessageDlg('Neues Level laden und Änderungen verwerfen?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit;
133
    if MessageDlg(SLoadNewLevelAndDiscardChanges, mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit;
129
  end;
134
  end;
130
 
135
 
131
  // Da Button bei ungültigen Level deaktiviert wird, ist das nicht mehr nötig.
136
  // Da Button bei ungültigen Level deaktiviert wird, ist das nicht mehr nötig.
132
  {if liu.visible or (LevelListBox.items.count=0) then
137
  {if liu.visible or (LevelListBox.items.count=0) then
133
    exit;}
138
    exit;}
134
 
139
 
135
  MainForm.DestroyLevel;
140
  MainForm.DestroyLevel;
136
  MainForm.LevData.RasterErzwingen := true;
141
  MainForm.LevData.RasterErzwingen := true;
137
  fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
142
  fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
138
  if not fil.found then raise Exception.Create('Leveldatei nicht gefunden');
143
  if not fil.found then raise Exception.Create(SLevelFileNotFound);
139
  MainForm.LevData.LoadFromFile(fil.fileLocation);
144
  MainForm.LevData.LoadFromFile(fil.fileLocation);
140
  MainForm.RefreshFromLevData;
145
  MainForm.RefreshFromLevData;
141
  MainForm.LevChanged := false;
146
  MainForm.LevChanged := false;
142
  MainForm.AnzeigeAct;
147
  MainForm.AnzeigeAct;
143
  close;
148
  close;
144
end;
149
end;
145
 
150
 
146
procedure TSpeicherungForm.SpeichernBtnClick(Sender: TObject);
151
procedure TSpeicherungForm.SpeichernBtnClick(Sender: TObject);
-
 
152
resourcestring
-
 
153
  SLevelIsEmpty = 'Das Level ist leer!';
-
 
154
  SLevelAlreadyExists = 'Level ist bereits vorhanden. Ersetzen?';
-
 
155
  SNoValidLevelName = 'Dies ist kein gültiger Levelname!';
147
begin
156
begin
148
  if MainForm.LevData.CountEnemies = 0 then
157
  if MainForm.LevData.CountEnemies = 0 then
149
  begin
158
  begin
150
    MessageDlg('Das Level ist leer!', mtError, [mbOK], 0);
159
    MessageDlg(SLevelIsEmpty, mtError, [mbOK], 0);
151
    LevelNumber.SetFocus;
160
    LevelNumber.SetFocus;
152
    exit;
161
    exit;
153
  end;
162
  end;
154
  {for i := 1 to length(LevelName.text) do
163
  {for i := 1 to length(LevelName.text) do
155
  begin
164
  begin
Line 161... Line 170...
161
      (copy(LevelName.text, i, 1) = '"') or
170
      (copy(LevelName.text, i, 1) = '"') or
162
      (copy(LevelName.text, i, 1) = '<') or
171
      (copy(LevelName.text, i, 1) = '<') or
163
      (copy(LevelName.text, i, 1) = '>') or
172
      (copy(LevelName.text, i, 1) = '>') or
164
      (copy(LevelName.text, i, 1) = '|') then
173
      (copy(LevelName.text, i, 1) = '|') then
165
    begin
174
    begin
166
      MessageDlg('Dies ist kein gültiger Levelname!', mtError, [mbOK], 0);
175
      MessageDlg(SNoValidLevelName, mtError, [mbOK], 0);
167
      LevelName.SetFocus;
176
      LevelName.SetFocus;
168
      exit;
177
      exit;
169
    end;
178
    end;
170
  end;}
179
  end;}
171
  if (LevelListBox.items.IndexOf(Format(SLevelListBox, [LevelNumber.Value])) > -1) or
180
  if (LevelListBox.items.IndexOf(Format(SLevelListBox, [LevelNumber.Value])) > -1) or
172
     (LevelListBox.items.IndexOf(Format(SLevelListBox, [LevelNumber.Value])+' ('+SSelbsterstellt+')') > -1) then
181
     (LevelListBox.items.IndexOf(Format(SLevelListBox, [LevelNumber.Value])+' ('+SSelbsterstellt+')') > -1) then
173
  begin
182
  begin
174
    if MessageDlg('Level ist bereits vorhanden. Ersetzen?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then
183
    if MessageDlg(SLevelAlreadyExists, mtConfirmation, mbYesNoCancel, 0) <> mrYes then
175
      exit;
184
      exit;
176
  end;
185
  end;
177
 
186
 
178
  // Speichern
187
  // Speichern
179
  MainForm.LevData.LevelEditorLength := MainForm.ScrollBar.Max;
188
  MainForm.LevData.LevelEditorLength := MainForm.ScrollBar.Max;
Line 184... Line 193...
184
  MainForm.AnzeigeAct;
193
  MainForm.AnzeigeAct;
185
  SearchLevels;
194
  SearchLevels;
186
end;
195
end;
187
 
196
 
188
procedure TSpeicherungForm.LevelListBoxClick(Sender: TObject);
197
procedure TSpeicherungForm.LevelListBoxClick(Sender: TObject);
-
 
198
resourcestring
-
 
199
  SYes = 'Ja';
-
 
200
  SNo = 'Nein';
-
 
201
  SFields = '%d Felder';
-
 
202
  SXbyY = '%s von %s';
189
var
203
var
190
  LevelData: TLevelData;
204
  LevelData: TLevelData;
191
  boss: boolean;
205
  boss: boolean;
192
  i: Integer;
206
  i: Integer;
193
  anzahlEinheiten: integer;
207
  anzahlEinheiten: integer;
Line 215... Line 229...
215
  try
229
  try
216
    try
230
    try
217
      LevelData.RasterErzwingen := true;
231
      LevelData.RasterErzwingen := true;
218
 
232
 
219
      fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
233
      fil := GetLevelFileName(GetListBoxSelectedLevelNumber,false);
220
      if not fil.found then raise Exception.Create('Leveldatei nicht gefunden');
234
      if not fil.found then raise Exception.Create(SLevelFileNotFound);
221
      LevelData.LoadFromFile(fil.fileLocation);
235
      LevelData.LoadFromFile(fil.fileLocation);
222
 
236
 
223
      boss := false;
237
      boss := false;
224
      anzahlEinheiten := Length(LevelData.EnemyAdventTable);
238
      anzahlEinheiten := Length(LevelData.EnemyAdventTable);
225
      for i := 0 to anzahlEinheiten - 1 do
239
      for i := 0 to anzahlEinheiten - 1 do
Line 239... Line 253...
239
      li4.visible := true;
253
      li4.visible := true;
240
      LadenBtn.enabled := true;
254
      LadenBtn.enabled := true;
241
      LoeschenBtn.enabled := true;
255
      LoeschenBtn.enabled := true;
242
      li1b.caption := inttostr(anzahlEinheiten);
256
      li1b.caption := inttostr(anzahlEinheiten);
243
      if boss then
257
      if boss then
244
        li2b.caption := 'Ja'
258
        li2b.caption := SYes
245
      else
259
      else
246
        li2b.caption := 'Nein';
260
        li2b.caption := SNo;
247
      li3b.caption := IntToStr(LevelData.LevelEditorLength) + ' Felder';
261
      li3b.caption := Format(SFields, [LevelData.LevelEditorLength]);
248
      li4.Caption := Trim(LevelData.LevelName + ' von ' + LevelData.LevelAuthor);
262
      li4.Caption := Trim(Format(SXbyY, [LevelData.LevelName, LevelData.LevelAuthor]));
249
    finally
263
    finally
250
      FreeAndNil(LevelData);
264
      FreeAndNil(LevelData);
251
    end;
265
    end;
252
  except
266
  except
253
    liu.visible := true;
267
    liu.visible := true;