summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce2fbca)
raw | patch | inline | side by side (parent: ce2fbca)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 29 Mar 2023 10:23:27 +0000 (13:23 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 29 Mar 2023 10:23:27 +0000 (13:23 +0300) |
src/editor/Editor.lpr | patch | blob | history | |
src/editor/f_main.pas | patch | blob | history |
diff --git a/src/editor/Editor.lpr b/src/editor/Editor.lpr
index 3889b5109fd514598830302435c888ccfe509be8..421a095601225ce80cbc610fc7e1f90fd9b0f996 100644 (file)
--- a/src/editor/Editor.lpr
+++ b/src/editor/Editor.lpr
end;
var
- H: THandlerObject;
+ LogFileName: AnsiString = '';
+ ParamFileIndex: Integer = 1;
procedure THandlerObject.ExceptionHandler (Sender: TObject; e: Exception);
begin
MessageDlg('Unhandled exception: ' + e.message + ' (see Editor.log for more information)', mtError, [mbOK], 0);
end;
+ procedure CheckParamOptions;
+ var i: Integer; p: AnsiString;
+ begin
+ i := 1;
+ while (i <= ParamCount) and (Length(ParamStr(i)) > 0) and (ParamStr(i)[1] = '-') do
+ begin
+ p := ParamStr(i);
+ if p = '--log-file' then
+ begin
+ if i + 1 <= ParamCount then
+ begin
+ Inc(i);
+ LogFileName := ParamStr(i);
+ end;
+ end;
+ Inc(i);
+ end;
+ ParamFileIndex := i;
+ end;
+
+ procedure CheckParamFiles;
+ var i: Integer; path: AnsiString;
+ begin
+ i := ParamFileIndex;
+ if i <= ParamCount then
+ begin
+ path := ParamStr(i);
+ if path <> '' then
+ OpenMap(path, '');
+ end;
+ end;
+
+ procedure InitLogs;
+ begin
+ if LogFileName = '' then
+ LogFileName := 'Editor.log';
+
+ if LogFileName <> '' then
+ e_InitLog(LogFileName, WM_NEWFILE);
+
+ {$IF DECLARED(UseHeapTrace)}
+ (* http://wiki.freepascal.org/heaptrc *)
+ GlobalSkipIfNoLeaks := True;
+ //SetHeapTraceOutput('EditorLeaks.log');
+ //HaltOnError := False;
+ {$ENDIF}
+ end;
+
begin
Application.ExceptionDialog := aedOkMessageBox;
- Application.AddOnExceptionHandler(H.ExceptionHandler, True);
+ Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True);
Application.Initialize();
-{$IF DECLARED(UseHeapTrace)}
- (* http://wiki.freepascal.org/heaptrc *)
- GlobalSkipIfNoLeaks := True;
- //SetHeapTraceOutput('EditorLeaks.log');
- //HaltOnError := False;
-{$ENDIF}
+ CheckParamOptions;
+ InitLogs;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TOptionsForm, OptionsForm);
Application.CreateForm(TChooseTypeForm, ChooseTypeForm);
Application.CreateForm(TSelectLanguageForm, SelectLanguageForm);
- if ParamStr(1) <> '' then OpenMap(ParamStr(1), '');
+ CheckParamFiles;
+
Application.Run();
end.
diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index 1d1d2ce5da316808b4db68c1e3fb168ed1ac12f8..b7e3dd36a663217c2c78d8166f2e32f606aae8cd 100644 (file)
--- a/src/editor/f_main.pas
+++ b/src/editor/f_main.pas
EditorDir := ExtractFilePath(Application.ExeName);
- e_InitLog(EditorDir+'Editor.log', WM_NEWFILE);
e_WriteLog('Doom 2D: Forever Editor version ' + EDITOR_VERSION, MSG_NOTIFY);
e_WriteLog('Build date: ' + EDITOR_BUILDDATE + ' ' + EDITOR_BUILDTIME, MSG_NOTIFY);
e_WriteLog('Build hash: ' + g_GetBuildHash(), MSG_NOTIFY);