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);
101 else if p = '--game-wad' then
103 if i + 1 <= ParamCount then
106 GameWad := ParamStr(i);
109 else if p = '--editor-wad' then
111 if i + 1 <= ParamCount then
114 EditorWad := ParamStr(i);
117 else if p = '--wads-dir' then
119 if i + 1 <= ParamCount then
122 WadsDir := ParamStr(i);
130 procedure CheckParamFiles;
134 if i <= ParamCount then
135 StartMap := ParamStr(i);
140 if LogFileName = '' then
141 LogFileName := 'Editor.log';
143 if LogFileName <> '' then
144 e_InitLog(LogFileName, WM_NEWFILE);
146 {$IF DECLARED(UseHeapTrace)}
147 (* http://wiki.freepascal.org/heaptrc *)
148 GlobalSkipIfNoLeaks := True;
149 //SetHeapTraceOutput('EditorLeaks.log');
150 //HaltOnError := False;
155 Application.ExceptionDialog := aedOkMessageBox;
156 Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True);
157 Application.Initialize();
159 EditorDir := ExtractFilePath(Application.ExeName);
160 CfgFileName := EditorDir + DirectorySeparator + 'Editor.cfg';
161 GameWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'game.wad';
162 EditorWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'editor.wad';
163 WadsDir := EditorDir + DirectorySeparator + 'wads';
168 Application.CreateForm(TMainForm, MainForm);
169 Application.CreateForm(TOptionsForm, OptionsForm);
170 Application.CreateForm(TAboutForm, AboutForm);
171 Application.CreateForm(TMapOptionsForm, MapOptionsForm);
172 Application.CreateForm(TActivationTypeForm, ActivationTypeForm);
173 Application.CreateForm(TAddResourceForm, AddResourceForm);
174 Application.CreateForm(TKeysForm, KeysForm);
175 Application.CreateForm(TMapCheckForm, MapCheckForm);
176 Application.CreateForm(TMapOptimizationForm, MapOptimizationForm);
177 Application.CreateForm(TAddTextureForm, AddTextureForm);
178 Application.CreateForm(TSaveMapForm, SaveMapForm);
179 Application.CreateForm(TSelectMapForm, SelectMapForm);
180 Application.CreateForm(TAddSkyForm, AddSkyForm);
181 Application.CreateForm(TAddSoundForm, AddSoundForm);
182 Application.CreateForm(TSaveMiniMapForm, SaveMiniMapForm);
183 Application.CreateForm(TPackMapForm, PackMapForm);
184 Application.CreateForm(TMapTestForm, MapTestForm);
185 Application.CreateForm(TChooseTypeForm, ChooseTypeForm);
186 Application.CreateForm(TSelectLanguageForm, SelectLanguageForm);