DEADSOFTWARE

add command line passing for map test
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 21 Jul 2019 15:08:43 +0000 (18:08 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 21 Jul 2019 15:08:43 +0000 (18:08 +0300)
src/editor/f_main.pas
src/editor/f_maptest.lfm
src/editor/f_maptest.pas

index 99ddcd9b1a25a3ed1d3c035816546506779ed9b1..481f597163599fabe72c50eba1127988af2abb0e 100644 (file)
@@ -8,7 +8,7 @@ uses
   LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics,
   Controls, Forms, Dialogs, StdCtrls, Buttons,
   ComCtrls, ValEdit, Types, Menus, ExtCtrls,
   LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics,
   Controls, Forms, Dialogs, StdCtrls, Buttons,
   ComCtrls, ValEdit, Types, Menus, ExtCtrls,
-  CheckLst, Grids, OpenGLContext, utils, UTF8Process;
+  CheckLst, Grids, OpenGLContext, Utils, UTF8Process;
 
 type
 
 
 type
 
@@ -313,7 +313,7 @@ var
   TestOptionsAllowExit: Boolean;
   TestOptionsWeaponStay: Boolean;
   TestOptionsMonstersDM: Boolean;
   TestOptionsAllowExit: Boolean;
   TestOptionsWeaponStay: Boolean;
   TestOptionsMonstersDM: Boolean;
-  TestD2dExe: String;
+  TestD2dExe, TestD2DArgs: String;
   TestMapOnce: Boolean;
 
   LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean =
   TestMapOnce: Boolean;
 
   LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean =
@@ -6626,11 +6626,47 @@ begin
   MapTestForm.ShowModal();
 end;
 
   MapTestForm.ShowModal();
 end;
 
+type SSArray = array of String;
+
+function ParseString (Str: AnsiString): SSArray;
+  function GetStr (var Str: AnsiString): AnsiString;
+    var a, b: Integer;
+  begin
+    Result := '';
+    if Str[1] = '"' then
+      for b := 1 to Length(Str) do
+        if (b = Length(Str)) or (Str[b + 1] = '"') then
+        begin
+          Result := Copy(Str, 2, b - 1);
+          Delete(Str, 1, b + 1);
+          Str := Trim(Str);
+          Exit;
+        end;
+    for a := 1 to Length(Str) do
+      if (a = Length(Str)) or (Str[a + 1] = ' ') then
+      begin
+        Result := Copy(Str, 1, a);
+        Delete(Str, 1, a + 1);
+        Str := Trim(Str);
+        Exit;
+      end;
+  end;
+begin
+  Result := nil;
+  Str := Trim(Str);
+  while Str <> '' do
+  begin
+    SetLength(Result, Length(Result)+1);
+    Result[High(Result)] := GetStr(Str);
+  end;
+end;
+
 procedure TMainForm.miTestMapClick(Sender: TObject);
 var
   mapWAD, mapToRun, tempWAD: String;
 procedure TMainForm.miTestMapClick(Sender: TObject);
 var
   mapWAD, mapToRun, tempWAD: String;
+  args: SSArray;
   opt: LongWord;
   opt: LongWord;
-  time: Integer;
+  time, i: Integer;
   proc: TProcessUTF8;
   res: Boolean;
 begin
   proc: TProcessUTF8;
   res: Boolean;
 begin
@@ -6688,6 +6724,10 @@ begin
   if TestMapOnce then
     proc.Parameters.Add('--close');
 
   if TestMapOnce then
     proc.Parameters.Add('--close');
 
+  args := ParseString(TestD2DArgs);
+  for i := 0 to High(args) do
+    proc.Parameters.Add(args[i]);
+
   res := True;
   try
     proc.Execute();
   res := True;
   try
     proc.Execute();
index 6e5fa1edc98d0e12b43f971ae89e1ebe6615c35c..c3cc7d1e31faa8451cff83781e3a21dd38d948ee 100644 (file)
@@ -214,6 +214,14 @@ object MapTestForm: TMapTestForm
       ParentFont = False
       TabOrder = 15
     end
       ParentFont = False
       TabOrder = 15
     end
+    object edD2DArgs: TEdit
+      Left = 14
+      Height = 21
+      Top = 200
+      Width = 297
+      TabOrder = 16
+      Text = ''
+    end
     object cbMapOnce: TCheckBox
       Left = 14
       Height = 17
     object cbMapOnce: TCheckBox
       Left = 14
       Height = 17
@@ -226,7 +234,7 @@ object MapTestForm: TMapTestForm
   object FindD2dDialog: TOpenDialog
     Title = 'Выберите файл игры Doom 2D: Forever'
     DefaultExt = '.exe'
   object FindD2dDialog: TOpenDialog
     Title = 'Выберите файл игры Doom 2D: Forever'
     DefaultExt = '.exe'
-    Filter = 'Doom2DF.exe|Doom2DF.exe'
+    Filter = 'Doom2DF.exe|Doom2DF.exe;Doom2DF'
     Options = [ofHideReadOnly, ofNoChangeDir, ofEnableSizing]
     left = 320
     top = 144
     Options = [ofHideReadOnly, ofNoChangeDir, ofEnableSizing]
     left = 320
     top = 144
index 69f7f40f0568c338ddfee771a442719314fac0e8..b35dc4688d0d695c5d20f7696d5ab6a9c6ed274e 100644 (file)
@@ -38,6 +38,7 @@ type
   // Путь:
     LabelPath: TLabel;
     edD2dexe: TEdit;
   // Путь:
     LabelPath: TLabel;
     edD2dexe: TEdit;
+    edD2DArgs: TEdit;
     bChooseD2d: TButton;
     FindD2dDialog: TOpenDialog;
 
     bChooseD2d: TButton;
     FindD2dDialog: TOpenDialog;
 
@@ -113,6 +114,8 @@ begin
   
   config.WriteStr('TestRun', 'Exe', edD2dExe.Text);
   TestD2dExe := edD2dExe.Text;
   
   config.WriteStr('TestRun', 'Exe', edD2dExe.Text);
   TestD2dExe := edD2dExe.Text;
+  config.WriteStr('TestRun', 'Args', edD2DArgs.Text);
+  TestD2DArgs := edD2DArgs.Text;
 
   config.SaveFile(EditorDir+'Editor.cfg');
   config.Free();
 
   config.SaveFile(EditorDir+'Editor.cfg');
   config.Free();
@@ -146,6 +149,7 @@ begin
   cbMonstersDM.Checked := TestOptionsMonstersDM;
   cbMapOnce.Checked := TestMapOnce;
   edD2dExe.Text := TestD2dExe;
   cbMonstersDM.Checked := TestOptionsMonstersDM;
   cbMapOnce.Checked := TestMapOnce;
   edD2dExe.Text := TestD2dExe;
+  edD2DArgs.Text := TestD2DArgs;
 end;
 
 procedure TMapTestForm.FormCreate(Sender: TObject);
 end;
 
 procedure TMapTestForm.FormCreate(Sender: TObject);
@@ -165,6 +169,7 @@ begin
   TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False);
   TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False);
   TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe');
   TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False);
   TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False);
   TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe');
+  TestD2DArgs := config.ReadStr('TestRun', 'Args', '');
 
   config.Free();
 
 
   config.Free();