Subversion Repositories spacemission

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 daniel-mar 1
unit CnvMain;
2
 
3
interface
4
 
5
uses
6
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
4 daniel-mar 7
  StdCtrls, Gauges, ShellAPI, ExtCtrls, ComCtrls, System.UITypes;
3 daniel-mar 8
 
9
type
10
  TMainForm = class(TForm)
11
    Run: TButton;
12
    Button1: TButton;
13
    Button2: TButton;
14
    Button3: TButton;
15
    Bevel1: TBevel;
16
    Label1: TLabel;
17
    Label2: TLabel;
18
    comb: TComboBox;
19
    gauge: TProgressBar;
20
    procedure RunClick(Sender: TObject);
21
    procedure FormCreate(Sender: TObject);
22
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
23
    procedure Button1Click(Sender: TObject);
24
    procedure Button2Click(Sender: TObject);
25
    procedure Button3Click(Sender: TObject);
26
  public
27
    FDirectory: string;
28
    procedure c02t03(von, an: string);
29
    procedure c03t04(von, an: string);
30
    procedure c04t10(von, an: string);
31
  end;
32
 
33
var
34
  MainForm: TMainForm;
35
  m: array[1..5] of tstrings;
36
 
37
implementation
38
 
39
{$R *.DFM}
40
 
41
procedure TMainForm.RunClick(Sender: TObject);
42
var
43
  i: integer;
44
begin
45
  if comb.ItemIndex = -1 then
46
  begin
47
    MessageDLG('Bitte Umwandlungsmethode whlen!', mtError, [mbOK], 0);
48
    exit;
49
  end;
50
  if not DirectoryExists(FDirectory+'Temp') then CreateDir(FDirectory+'Temp');
51
  if not DirectoryExists(FDirectory+'Temp\1') then CreateDir(FDirectory+'Temp\1');
52
  if not DirectoryExists(FDirectory+'Temp\2') then CreateDir(FDirectory+'Temp\2');
53
  if not DirectoryExists(FDirectory+'Eingabe') then CreateDir(FDirectory+'Eingabe');
54
  if not DirectoryExists(FDirectory+'Ausgabe') then CreateDir(FDirectory+'Ausgabe');
55
  for i := 1 to 999 do
56
  begin
57
    if fileexists(FDirectory+'Temp\1\Lev'+inttostr(i)+'A1.sav') then DeleteFile(FDirectory+'Temp\1\Lev'+inttostr(i)+'A1.sav');
58
    if fileexists(FDirectory+'Temp\2\Lev'+inttostr(i)+'A1.sav') then DeleteFile(FDirectory+'Temp\2\Lev'+inttostr(i)+'A1.sav');
59
    if fileexists(FDirectory+'Temp\1\Lev'+inttostr(i)+'A2.sav') then DeleteFile(FDirectory+'Temp\1\Lev'+inttostr(i)+'A2.sav');
60
    if fileexists(FDirectory+'Temp\2\Lev'+inttostr(i)+'A2.sav') then DeleteFile(FDirectory+'Temp\2\Lev'+inttostr(i)+'A2.sav');
61
    if fileexists(FDirectory+'Temp\1\Lev'+inttostr(i)+'A3.sav') then DeleteFile(FDirectory+'Temp\1\Lev'+inttostr(i)+'A3.sav');
62
    if fileexists(FDirectory+'Temp\2\Lev'+inttostr(i)+'A3.sav') then DeleteFile(FDirectory+'Temp\2\Lev'+inttostr(i)+'A3.sav');
63
    if fileexists(FDirectory+'Temp\1\Lev'+inttostr(i)+'A4.sav') then DeleteFile(FDirectory+'Temp\1\Lev'+inttostr(i)+'A4.sav');
64
    if fileexists(FDirectory+'Temp\2\Lev'+inttostr(i)+'A4.sav') then DeleteFile(FDirectory+'Temp\2\Lev'+inttostr(i)+'A4.sav');
65
    if fileexists(FDirectory+'Temp\1\Lev'+inttostr(i)+'A5.sav') then DeleteFile(FDirectory+'Temp\1\Lev'+inttostr(i)+'A5.sav');
66
    if fileexists(FDirectory+'Temp\2\Lev'+inttostr(i)+'A5.sav') then DeleteFile(FDirectory+'Temp\2\Lev'+inttostr(i)+'A5.sav');
67
    if fileexists(FDirectory+'Temp\1\Level '+inttostr(i)+'.lev') then DeleteFile(FDirectory+'Temp\1\Level '+inttostr(i)+'.lev');
68
    if fileexists(FDirectory+'Temp\2\Level '+inttostr(i)+'.lev') then DeleteFile(FDirectory+'Temp\2\Level '+inttostr(i)+'.lev');
69
  end;
70
  if comb.ItemIndex = 0 then c02t03(FDirectory+'Eingabe', FDirectory+'Ausgabe');
71
  if comb.ItemIndex = 1 then
72
  begin
73
    c02t03(FDirectory+'Eingabe', FDirectory+'Temp\1');
74
    c03t04(FDirectory+'Temp\1', FDirectory+'Ausgabe');
75
  end;
76
  if comb.ItemIndex = 2 then c03t04(FDirectory+'Eingabe', FDirectory+'Ausgabe');
77
  if comb.ItemIndex = 3 then c04t10(FDirectory+'Eingabe', FDirectory+'Ausgabe');
78
  if comb.ItemIndex = 4 then
79
  begin
80
    c02t03(FDirectory+'Eingabe', FDirectory+'Temp\1');
81
    c03t04(FDirectory+'Temp\1', FDirectory+'Test\2');
82
    c04t10(FDirectory+'Temp\2', FDirectory+'Ausgabe');
83
  end;
84
  if comb.ItemIndex = 5 then
85
  begin
86
    c03t04(FDirectory+'Eingabe', FDirectory+'Temp\1');
87
    c04t10(FDirectory+'Temp\1', FDirectory+'Ausgabe');
88
  end;
89
end;
90
 
91
procedure TMainForm.c02t03(von, an: string);
92
var
93
  daten: textfile;
94
  lev, i, j: integer;
95
  ergebnis, temp: string;
96
begin
97
  for lev := 1 to 999 do
98
  begin
99
    gauge.Position := gauge.Position + 1;
100
    if fileexists(von+'\Lev'+inttostr(lev)+'A1.sav') then
101
    begin
102
      m[1].loadfromfile(von+'\Lev'+inttostr(lev)+'A1.sav');
103
      m[2].loadfromfile(von+'\Lev'+inttostr(lev)+'A2.sav');
104
      m[3].loadfromfile(von+'\Lev'+inttostr(lev)+'A3.sav');
105
      m[4].loadfromfile(von+'\Lev'+inttostr(lev)+'A4.sav');
106
      m[5].loadfromfile(von+'\Lev'+inttostr(lev)+'A5.sav');
107
      m[1].strings[0]:='-624';
108
      if fileexists(an+'\Lev'+inttostr(lev)+'A6.sav') then
109
      begin
110
        assignfile(daten, an+'\Lev'+inttostr(lev)+'A6.sav');
111
        reset(daten);
112
        readln(daten, ergebnis);
113
        temp:=ergebnis;
114
        closefile(daten);
115
      end
116
      else
117
      begin
118
        temp:='30000';
119
      end;
120
      assignfile(daten, an+'\Level '+inttostr(lev)+'.lev');
121
      rewrite(daten);
122
      append(daten);
123
      writeln(daten, '; SpaceMission 0.3');
124
      writeln(daten, temp);
125
      for j := 0 to m[1].count-2 do
126
      begin
127
        for i := 0 to m[1].count-2 do
128
        begin
129
          if strtoint(m[1].strings[i]) > strtoint(m[1].strings[i+1]) then
130
          begin
131
            m[1].exchange(i, i+1);
132
            m[2].exchange(i, i+1);
133
            m[3].exchange(i, i+1);
134
            m[4].exchange(i, i+1);
135
            m[5].exchange(i, i+1);
136
          end;
137
        end;
138
      end;
139
      for i := 0 to m[3].count-1 do
140
      begin
141
        for j := 1 to 4 do
142
        begin
143
          if j = 1 then writeln(daten, m[3].strings[i]);
144
          if j = 2 then writeln(daten, m[1].strings[i]);
145
          if j = 3 then writeln(daten, m[2].strings[i]);
146
          if j = 4 then writeln(daten, m[4].strings[i]);
147
        end;
148
      end;
149
      closefile(daten);
150
    end;
151
  end;
152
  gauge.Position := 0;
153
end;
154
 
155
procedure TMainForm.c03t04(von, an: string);
156
var
157
  daten, daten2: textfile;
158
  lev: integer;
159
  ergebniss: string;
160
begin
161
  for lev := 1 to 999 do
162
  begin
163
    gauge.Position := gauge.Position + 1;
164
    if fileexists(von+'\Level '+inttostr(lev)+'.lev') then
165
    begin
166
      assignfile(daten, von+'\Level '+inttostr(lev)+'.lev');
167
      reset(daten);
168
      assignfile(daten2, an+'\Level '+inttostr(lev)+'.lev');
169
      rewrite(daten2);
170
      while not seekeof(daten) do
171
      begin
172
        readln(daten, ergebniss);
173
        if ergebniss = '; SpaceMission 0.3' then
174
        begin
175
          writeln(daten2, '; SpaceMission 0.4');
176
          writeln(daten2, '; LEV-File');
177
        end
178
        else
179
        begin
180
          writeln(daten2, ergebniss);
181
        end;
182
      end;
183
      closefile(daten2);
184
      closefile(daten);
185
    end;
186
  end;
187
  gauge.Position := 0;
188
end;
189
 
190
procedure TMainForm.c04t10(von, an: string);
191
var
192
  daten, daten2: textfile;
193
  lev, z, act: integer;
194
  ergebnis: string;
195
begin
196
  for lev := 1 to 999 do
197
  begin
198
    gauge.Position := gauge.Position + 1;
199
    if fileexists(von+'\Level '+inttostr(lev)+'.lev') then
200
    begin
201
      assignfile(daten, von+'\Level '+inttostr(lev)+'.lev');
202
      reset(daten);
203
      assignfile(daten2, an+'\Level '+inttostr(lev)+'.lev');
204
      rewrite(daten2);
205
      z := 0;
206
      act := 0;
207
      while not seekeof(daten) do
208
      begin
209
        inc(z);
210
        if z > 2 then inc(act);
211
        if act = 5 then act := 1;
212
        readln(daten, ergebnis);
213
        if ergebnis = '; SpaceMission 0.4' then
214
          writeln(daten2, '; SpaceMission 1.0')
215
        else
216
        begin
217
          if (ergebnis = '30000') and (z = 3) then
218
            writeln(daten2, '1200')
219
          else
220
          begin
221
            //if not (((ergebnis = '0') and (z = 4)) or ((ergebnis = '-624') and (z = 5)) or ((ergebnis = '222') and (z = 6)) or ((ergebnis = '3') and (z = 7))) then
222
            if (z < 4) or (z > 7) then
223
            begin
224
              if act = 4 then
225
                writeln(daten2, inttostr(strtoint(ergebnis) + 32 - (5 * (strtoint(ergebnis) div 37))))
226
              else
227
                writeln(daten2, ergebnis);
228
            end;
229
          end;
230
        end;
231
      end;
232
      closefile(daten2);
233
      closefile(daten);
234
    end;
235
  end;
236
  gauge.Position := 0;
237
end;
238
 
239
procedure TMainForm.FormCreate(Sender: TObject);
240
begin
241
  FDirectory := extractfilepath(paramstr(0));
242
  m[1] := TStringList.create;
243
  m[2] := TStringList.create;
244
  m[3] := TStringList.create;
245
  m[4] := TStringList.create;
246
  m[5] := TStringList.create;
247
end;
248
 
249
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
250
begin
251
  m[1].Free;
252
  m[2].Free;
253
  m[3].Free;
254
  m[4].Free;
255
  m[5].Free;
256
end;
257
 
258
procedure TMainForm.Button1Click(Sender: TObject);
259
begin
260
  shellexecute(handle, 'open', pchar(FDirectory+'Eingabe\'), '', '', 1);
261
end;
262
 
263
procedure TMainForm.Button2Click(Sender: TObject);
264
begin
265
  shellexecute(handle, 'open', pchar(FDirectory+'Ausgabe\'), '', '', 1);
266
end;
267
 
268
procedure TMainForm.Button3Click(Sender: TObject);
269
begin
270
  shellexecute(handle, 'open', pchar(FDirectory+'Levels\'), '', '', 1);
271
end;
272
 
273
end.
274