DEADSOFTWARE

Fix error file not open on win32; Added stacktrace logging
[d2df-editor.git] / src / editor / Editor.lpr
index a0da9cee345627e9a57ab9fcbcab4aab587b794d..e5d615625dc332d9094a59823bba66049db33924 100644 (file)
@@ -1,10 +1,10 @@
 program Editor;
 
-{$MODE Delphi}
+{$INCLUDE ../shared/a_modes.inc}
 
 uses
-  Forms, Interfaces,
-  dglOpenGL in '../lib/dgl/dglOpenGL.pas',
+  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,17 +43,41 @@ uses
   f_packmap in 'f_packmap.pas' {PackMapForm},
   f_maptest in 'f_maptest.pas' {MapTestForm},
   f_choosetype in 'f_choosetype.pas' {ChooseTypeForm},
-  fmod in '../lib/fmod/fmod.pas',
-  fmoderrors in '../lib/fmod/fmoderrors.pas',
-  fmodpresets in '../lib/fmod/fmodpresets.pas',
-  fmodtypes in '../lib/fmod/fmodtypes.pas',
+{$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
+    H: THandlerObject;
+
+  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;
 
 begin
-  Application.Initialize;
+  Application.ExceptionDialog := aedOkMessageBox;
+  Application.AddOnExceptionHandler(H.ExceptionHandler, True);
+  Application.Initialize();
+
   Application.CreateForm(TMainForm, MainForm);
   Application.CreateForm(TOptionsForm, OptionsForm);
   Application.CreateForm(TAboutForm, AboutForm);
@@ -67,7 +97,7 @@ begin
   Application.CreateForm(TMapTestForm, MapTestForm);
   Application.CreateForm(TChooseTypeForm, ChooseTypeForm);
   Application.CreateForm(TSelectLanguageForm, SelectLanguageForm);
-  if ParamStr(1) <> '' then OpenMap(ParamStr(1), '');
 
-  Application.Run;
+  if ParamStr(1) <> '' then OpenMap(ParamStr(1), '');
+  Application.Run();
 end.