From: DeaDDooMER Date: Wed, 29 Mar 2023 14:24:23 +0000 (+0300) Subject: system: add option --config X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9d717c612a7756b30839103d1d6e8d89e2596393;p=d2df-editor.git system: add option --config --- diff --git a/src/editor/Editor.lpr b/src/editor/Editor.lpr index 421a095..052fbb8 100644 --- a/src/editor/Editor.lpr +++ b/src/editor/Editor.lpr @@ -52,6 +52,7 @@ uses ImagingTypes, Imaging, ImagingUtility, + g_options in 'g_options.pas', g_language in 'g_language.pas', f_selectlang in 'f_selectlang.pas' {SelectLanguageForm}; @@ -88,6 +89,14 @@ uses Inc(i); LogFileName := ParamStr(i); end; + end + else if p = '--config' then + begin + if i + 1 <= ParamCount then + begin + Inc(i); + CfgFileName := ParamStr(i); + end; end; Inc(i); end; @@ -127,6 +136,9 @@ begin Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True); Application.Initialize(); + EditorDir := ExtractFilePath(Application.ExeName); + CfgFileName := EditorDir + DirectorySeparator + 'Editor.cfg'; + CheckParamOptions; InitLogs; diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index b7e3dd3..34a7287 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -341,7 +341,7 @@ uses MAPREADER, f_selectmap, f_savemap, WADEDITOR, MAPDEF, g_map, f_saveminimap, f_addresource, CONFIG, f_packmap, f_addresource_sound, f_maptest, f_choosetype, - g_language, f_selectlang, ClipBrd, g_resources; + g_language, f_selectlang, ClipBrd, g_resources, g_options; const UNDO_DELETE_PANEL = 1; @@ -2673,7 +2673,7 @@ begin OpenedMap := ''; OpenedWAD := ''; - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); if config.ReadInt('Editor', 'XPos', -1) = -1 then Position := poDesktopCenter @@ -4238,7 +4238,7 @@ var config: TConfig; i: Integer; begin - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); if WindowState <> wsMaximized then begin @@ -4277,7 +4277,7 @@ begin config.WriteStr('RecentFiles', IntToStr(i+1), ''); RecentFiles.Free(); - config.SaveFile(EditorDir+'Editor.cfg'); + config.SaveFile(CfgFileName); config.Free(); slInvalidTextures.Free; @@ -6235,9 +6235,9 @@ begin else gLanguage := LANGUAGE_RUSSIAN; end; - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); config.WriteStr('Editor', 'Language', gLanguage); - config.SaveFile(EditorDir+'Editor.cfg'); + config.SaveFile(CfgFileName); config.Free(); end; diff --git a/src/editor/f_maptest.pas b/src/editor/f_maptest.pas index ed08dc7..f22f5fd 100644 --- a/src/editor/f_maptest.pas +++ b/src/editor/f_maptest.pas @@ -64,7 +64,7 @@ var implementation uses - f_main, CONFIG; + f_main, g_options, CONFIG; {$R *.lfm} @@ -75,7 +75,7 @@ var n: Integer; begin - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); if rbTDM.Checked then s := 'TDM' @@ -121,7 +121,7 @@ begin config.WriteStr('TestRun', 'Args', edD2DArgs.Text); TestD2DArgs := edD2DArgs.Text; - config.SaveFile(EditorDir+'Editor.cfg'); + config.SaveFile(CfgFileName); config.Free(); Close(); end; @@ -161,7 +161,7 @@ var config: TConfig; begin - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); TestGameMode := config.ReadStr('TestRun', 'GameMode', 'DM'); TestLimTime := config.ReadStr('TestRun', 'LimTime', '0'); diff --git a/src/editor/f_options.pas b/src/editor/f_options.pas index 91cc695..feffc4b 100644 --- a/src/editor/f_options.pas +++ b/src/editor/f_options.pas @@ -77,7 +77,7 @@ procedure RegisterFileType(ext: String; FileName: String); implementation uses - f_main, StdConvs, CONFIG, g_language, g_resources; + f_main, StdConvs, CONFIG, g_language, g_resources, g_options; {$R *.lfm} @@ -207,7 +207,7 @@ begin else DotSize := 1; - config := TConfig.CreateFile(EditorDir+'Editor.cfg'); + config := TConfig.CreateFile(CfgFileName); config.WriteInt('Editor', 'DotColor', DotColor); config.WriteBool('Editor', 'DotEnable', DotEnable); @@ -232,7 +232,7 @@ begin MainForm.RefreshRecentMenu(); end; - config.SaveFile(EditorDir+'Editor.cfg'); + config.SaveFile(CfgFileName); config.Free(); Close(); end;