Subversion Repositories spacemission

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

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