X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2FEditor.lpr;h=421a095601225ce80cbc610fc7e1f90fd9b0f996;hb=7bc9ae2fc0204a6412aa1cb5f05f0ffa8d1870ac;hp=647bfae8129308cbab1781174315cc8acacfec16;hpb=c3be56f2a3849cd22be39ce594498c7990e05606;p=d2df-editor.git diff --git a/src/editor/Editor.lpr b/src/editor/Editor.lpr index 647bfae..421a095 100644 --- a/src/editor/Editor.lpr +++ b/src/editor/Editor.lpr @@ -1,10 +1,10 @@ program Editor; -{$MODE Delphi} +{$INCLUDE ../shared/a_modes.inc} uses - Forms, Interfaces, - GL, GLExt, + Forms, Interfaces, Dialogs, + GL, GLExt, SysUtils, e_graphics in '../engine/e_graphics.pas', e_log in '../engine/e_log.pas', e_textures in '../engine/e_textures.pas', @@ -15,6 +15,12 @@ uses WADEDITOR in '../shared/WADEDITOR.pas', WADSTRUCT in '../shared/WADSTRUCT.pas', CONFIG in '../shared/CONFIG.pas', + xstreams in '../shared/xstreams.pas', + dfzip in '../shared/dfzip.pas', + sfs in '../sfs/sfs.pas', + sfsPlainFS in '../sfs/sfsPlainFS.pas', + sfsZipFS in '../sfs/sfsZipFS.pas', + f_about in 'f_about.pas' {AboutForm}, f_options in 'f_options.pas' {OptionsForm}, f_main in 'f_main.pas' {MainForm}, @@ -37,20 +43,93 @@ uses f_packmap in 'f_packmap.pas' {PackMapForm}, f_maptest in 'f_maptest.pas' {MapTestForm}, f_choosetype in 'f_choosetype.pas' {ChooseTypeForm}, +{$IFNDEF NOSOUND} fmod, fmoderrors, fmodpresets, fmodtypes, +{$ENDIF} ImagingTypes, Imaging, ImagingUtility, g_language in 'g_language.pas', f_selectlang in 'f_selectlang.pas' {SelectLanguageForm}; -{$R *.res} +{$IFDEF WINDOWS} + {$R *.res} +{$ENDIF} + + type + THandlerObject = class (TObject) + procedure ExceptionHandler (Sender: TObject; e: Exception); + end; + + var + LogFileName: AnsiString = ''; + ParamFileIndex: Integer = 1; + + procedure THandlerObject.ExceptionHandler (Sender: TObject; e: Exception); + begin + e_WriteStackTrace(e.message); + 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.Initialize; + Application.ExceptionDialog := aedOkMessageBox; + Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True); + Application.Initialize(); + + CheckParamOptions; + InitLogs; + Application.CreateForm(TMainForm, MainForm); Application.CreateForm(TOptionsForm, OptionsForm); Application.CreateForm(TAboutForm, AboutForm); @@ -70,7 +149,8 @@ begin Application.CreateForm(TMapTestForm, MapTestForm); Application.CreateForm(TChooseTypeForm, ChooseTypeForm); Application.CreateForm(TSelectLanguageForm, SelectLanguageForm); - if ParamStr(1) <> '' then OpenMap(ParamStr(1), ''); - Application.Run; + CheckParamFiles; + + Application.Run(); end.