3 {$INCLUDE ../shared/a_modes.inc}
6 Forms, Interfaces, Dialogs,
8 e_graphics in '../engine/e_graphics.pas',
9 e_log in '../engine/e_log.pas',
10 e_textures in '../engine/e_textures.pas',
11 MAPSTRUCT in '../shared/MAPSTRUCT.pas',
12 MAPREADER in '../shared/MAPREADER.pas',
13 MAPWRITER in '../shared/MAPWRITER.pas',
14 MAPDEF in '../shared/MAPDEF.pas',
15 WADEDITOR in '../shared/WADEDITOR.pas',
16 WADSTRUCT in '../shared/WADSTRUCT.pas',
17 CONFIG in '../shared/CONFIG.pas',
18 xstreams in '../shared/xstreams.pas',
19 dfzip in '../shared/dfzip.pas',
20 sfs in '../sfs/sfs.pas',
21 sfsPlainFS in '../sfs/sfsPlainFS.pas',
22 sfsZipFS in '../sfs/sfsZipFS.pas',
24 f_about in 'f_about.pas' {AboutForm},
25 f_options in 'f_options.pas' {OptionsForm},
26 f_main in 'f_main.pas' {MainForm},
28 f_mapoptions in 'f_mapoptions.pas' {MapOptionsForm},
29 f_activationtype in 'f_activationtype.pas' {ActivationTypeForm},
30 f_addresource in 'f_addresource.pas' {AddResourceForm},
31 f_keys in 'f_keys.pas' {KeysForm},
32 f_mapcheck in 'f_mapcheck.pas' {MapCheckForm},
33 f_mapoptimization in 'f_mapoptimization.pas' {MapOptimizationForm},
34 g_basic in 'g_basic.pas',
35 g_textures in 'g_textures.pas',
36 f_addresource_texture in 'f_addresource_texture.pas' {AddTextureForm},
37 f_savemap in 'f_savemap.pas' {SaveMapForm},
38 f_selectmap in 'f_selectmap.pas' {SelectMapForm},
39 f_addresource_sky in 'f_addresource_sky.pas' {AddSkyForm},
40 f_addresource_sound in 'f_addresource_sound.pas' {AddSoundForm},
41 spectrum in 'spectrum.pas',
42 f_saveminimap in 'f_saveminimap.pas' {SaveMiniMapForm},
43 f_packmap in 'f_packmap.pas' {PackMapForm},
44 f_maptest in 'f_maptest.pas' {MapTestForm},
45 f_choosetype in 'f_choosetype.pas' {ChooseTypeForm},
55 g_options in 'g_options.pas',
56 g_language in 'g_language.pas',
57 f_selectlang in 'f_selectlang.pas' {SelectLanguageForm};
64 THandlerObject = class (TObject)
65 procedure ExceptionHandler (Sender: TObject; e: Exception);
69 LogFileName: AnsiString = '';
70 ParamFileIndex: Integer = 1;
72 procedure THandlerObject.ExceptionHandler (Sender: TObject; e: Exception);
74 e_WriteStackTrace(e.message);
75 MessageDlg('Unhandled exception: ' + e.message + ' (see Editor.log for more information)', mtError, [mbOK], 0);
78 procedure CheckParamOptions;
79 var i: Integer; p: AnsiString;
82 while (i <= ParamCount) and (Length(ParamStr(i)) > 0) and (ParamStr(i)[1] = '-') do
85 if p = '--log-file' then
87 if i + 1 <= ParamCount then
90 LogFileName := ParamStr(i);
93 else if p = '--config' then
95 if i + 1 <= ParamCount then
98 CfgFileName := ParamStr(i);
106 procedure CheckParamFiles;
107 var i: Integer; path: AnsiString;
110 if i <= ParamCount then
120 if LogFileName = '' then
121 LogFileName := 'Editor.log';
123 if LogFileName <> '' then
124 e_InitLog(LogFileName, WM_NEWFILE);
126 {$IF DECLARED(UseHeapTrace)}
127 (* http://wiki.freepascal.org/heaptrc *)
128 GlobalSkipIfNoLeaks := True;
129 //SetHeapTraceOutput('EditorLeaks.log');
130 //HaltOnError := False;
135 Application.ExceptionDialog := aedOkMessageBox;
136 Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True);
137 Application.Initialize();
139 EditorDir := ExtractFilePath(Application.ExeName);
140 CfgFileName := EditorDir + DirectorySeparator + 'Editor.cfg';
145 Application.CreateForm(TMainForm, MainForm);
146 Application.CreateForm(TOptionsForm, OptionsForm);
147 Application.CreateForm(TAboutForm, AboutForm);
148 Application.CreateForm(TMapOptionsForm, MapOptionsForm);
149 Application.CreateForm(TActivationTypeForm, ActivationTypeForm);
150 Application.CreateForm(TAddResourceForm, AddResourceForm);
151 Application.CreateForm(TKeysForm, KeysForm);
152 Application.CreateForm(TMapCheckForm, MapCheckForm);
153 Application.CreateForm(TMapOptimizationForm, MapOptimizationForm);
154 Application.CreateForm(TAddTextureForm, AddTextureForm);
155 Application.CreateForm(TSaveMapForm, SaveMapForm);
156 Application.CreateForm(TSelectMapForm, SelectMapForm);
157 Application.CreateForm(TAddSkyForm, AddSkyForm);
158 Application.CreateForm(TAddSoundForm, AddSoundForm);
159 Application.CreateForm(TSaveMiniMapForm, SaveMiniMapForm);
160 Application.CreateForm(TPackMapForm, PackMapForm);
161 Application.CreateForm(TMapTestForm, MapTestForm);
162 Application.CreateForm(TChooseTypeForm, ChooseTypeForm);
163 Application.CreateForm(TSelectLanguageForm, SelectLanguageForm);