X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-editor.git;a=blobdiff_plain;f=src%2Feditor%2Ff_main.pas;h=481f597163599fabe72c50eba1127988af2abb0e;hp=99ddcd9b1a25a3ed1d3c035816546506779ed9b1;hb=e2cdd62f67c91ec8ce236bdfe24232c427efcbf6;hpb=efad5c8ee1b2bcdd58b2b7a4a990daa5cf793a59 diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 99ddcd9..481f597 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -8,7 +8,7 @@ uses 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 @@ -313,7 +313,7 @@ var TestOptionsAllowExit: Boolean; TestOptionsWeaponStay: Boolean; TestOptionsMonstersDM: Boolean; - TestD2dExe: String; + TestD2dExe, TestD2DArgs: String; TestMapOnce: Boolean; LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean = @@ -6626,11 +6626,47 @@ begin 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; + args: SSArray; opt: LongWord; - time: Integer; + time, i: Integer; proc: TProcessUTF8; res: Boolean; begin @@ -6688,6 +6724,10 @@ begin 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();