1 | unit Main;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
7 | Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
|
---|
8 | MPHexEditor, ToolWin, ImgList, Tabs,
|
---|
9 | MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI,
|
---|
10 | Data, Functions, DataStructures, OniDataClass, Exporters,
|
---|
11 | Helper_LevelDB, Settings, Template,
|
---|
12 | BinEdit, Extractor, Preview, RawEdit, TxmpReplace;
|
---|
13 |
|
---|
14 | type
|
---|
15 | TForm_Main = class(TForm)
|
---|
16 | saved: TSaveDialog;
|
---|
17 | opend: TOpenDialog;
|
---|
18 | statbar: TStatusBar;
|
---|
19 | MenuImages: TImageList;
|
---|
20 | DockTop: TTBDock;
|
---|
21 | MainMenu: TTBToolbar;
|
---|
22 | menu_main: TTBSubmenuItem;
|
---|
23 | menu_loadfile: TTBItem;
|
---|
24 | menu_sep1: TTBSeparatorItem;
|
---|
25 | menu_settings: TTBItem;
|
---|
26 | menu_sep4: TTBSeparatorItem;
|
---|
27 | menu_exit: TTBItem;
|
---|
28 | menu_convert: TTBSubmenuItem;
|
---|
29 | menu_createdb: TTBItem;
|
---|
30 | menu_createlvl: TTBItem;
|
---|
31 | menu_tools: TTBSubmenuItem;
|
---|
32 | menu_preview: TTBItem;
|
---|
33 | menu_binedit: TTBItem;
|
---|
34 | menu_rawedit: TTBItem;
|
---|
35 | menu_txmpreplace: TTBItem;
|
---|
36 | menu_extractor: TTBItem;
|
---|
37 | menu_filecompare: TTBItem;
|
---|
38 | menu_levelstructedit: TTBItem;
|
---|
39 | menu_windows: TTBSubmenuItem;
|
---|
40 | menu_windows_cascade: TTBItem;
|
---|
41 | menu_windows_tile: TTBItem;
|
---|
42 | menu_windows_closeall: TTBItem;
|
---|
43 | menu_sep3: TTBSeparatorItem;
|
---|
44 | menu_windows_next: TTBItem;
|
---|
45 | menu_windows_previous: TTBItem;
|
---|
46 | menu_sep2: TTBSeparatorItem;
|
---|
47 | menu_About: TTBItem;
|
---|
48 | Toolbar: TTBToolbar;
|
---|
49 | tbOpen: TTBItem;
|
---|
50 | DockLeft: TTBDock;
|
---|
51 | DockRight: TTBDock;
|
---|
52 | DockBottom: TTBDock;
|
---|
53 | MDIToolbar: TTBToolbar;
|
---|
54 | TBControlItem1: TTBControlItem;
|
---|
55 | MDITab: TMDITab;
|
---|
56 | menu_view: TTBSubmenuItem;
|
---|
57 | menu_view_mdibar: TTBItem;
|
---|
58 | menu_view_statusbar: TTBItem;
|
---|
59 | menu_view_toolbar: TTBItem;
|
---|
60 | tb_separator1: TTBSeparatorItem;
|
---|
61 | tb_preview: TTBItem;
|
---|
62 | tb_structure: TTBItem;
|
---|
63 | tb_compare: TTBItem;
|
---|
64 | tb_extractor: TTBItem;
|
---|
65 | tb_txmpreplacer: TTBItem;
|
---|
66 | tb_rawedit: TTBItem;
|
---|
67 | tb_datedit: TTBItem;
|
---|
68 | menu_windows_tilevert: TTBItem;
|
---|
69 | tb_meta: TTBItem;
|
---|
70 | menu_meta: TTBItem;
|
---|
71 | TBSeparatorItem1: TTBSeparatorItem;
|
---|
72 | tb_db2dat: TTBItem;
|
---|
73 | tb_dat2db: TTBItem;
|
---|
74 | menu_loaddb: TTBItem;
|
---|
75 | tb_opendb: TTBItem;
|
---|
76 | Images_Close: TImageList;
|
---|
77 | procedure UpdateConLists;
|
---|
78 | procedure LoadFile(typedb: Boolean);
|
---|
79 | function TryCloseAll: Boolean;
|
---|
80 | procedure menu_AboutClick(Sender: TObject);
|
---|
81 | procedure menu_settingsClick(Sender: TObject);
|
---|
82 | procedure menu_filecompareClick(Sender: TObject);
|
---|
83 | procedure menu_raweditClick(Sender: TObject);
|
---|
84 | procedure menu_createlvlClick(Sender: TObject);
|
---|
85 | procedure menu_extractorClick(Sender: TObject);
|
---|
86 | procedure menu_createdbClick(Sender: TObject);
|
---|
87 | procedure menu_windows_previousClick(Sender: TObject);
|
---|
88 | procedure menu_windows_nextClick(Sender: TObject);
|
---|
89 | procedure menu_windows_tileClick(Sender: TObject);
|
---|
90 | function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
91 | procedure menu_windows_closeallClick(Sender: TObject);
|
---|
92 | procedure menu_windows_cascadeClick(Sender: TObject);
|
---|
93 | procedure menu_bineditClick(Sender: TObject);
|
---|
94 | procedure menu_loadfileClick(Sender: TObject);
|
---|
95 | procedure menu_txmpreplaceClick(Sender: TObject);
|
---|
96 | procedure menu_exitClick(Sender: TObject);
|
---|
97 | procedure menu_previewClick(Sender: TObject);
|
---|
98 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
99 | procedure FormResize(Sender: TObject);
|
---|
100 | procedure FormCreate(Sender: TObject);
|
---|
101 | procedure UpdateStatBar;
|
---|
102 | procedure menu_view_mdibarClick(Sender: TObject);
|
---|
103 | procedure menu_view_statusbarClick(Sender: TObject);
|
---|
104 | procedure menu_view_toolbarClick(Sender: TObject);
|
---|
105 | procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
|
---|
106 | const Rect: TRect; Active: Boolean);
|
---|
107 | procedure ActivateTools(active: Boolean);
|
---|
108 | procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
109 | Shift: TShiftState; X, Y: Integer);
|
---|
110 | procedure menu_windows_tilevertClick(Sender: TObject);
|
---|
111 | procedure menu_metaClick(Sender: TObject);
|
---|
112 | procedure ToolbarDockChanged(Sender: TObject);
|
---|
113 | procedure menu_loaddbClick(Sender: TObject);
|
---|
114 | procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
|
---|
115 | Y: Integer);
|
---|
116 | private
|
---|
117 | public
|
---|
118 | end;
|
---|
119 |
|
---|
120 | var
|
---|
121 | Form_Main: TForm_Main;
|
---|
122 |
|
---|
123 | implementation
|
---|
124 |
|
---|
125 | {$R *.dfm}
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 | procedure TForm_Main.FormCreate(Sender: TObject);
|
---|
130 | begin
|
---|
131 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
132 | Self.FormResize(Self);
|
---|
133 |
|
---|
134 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
135 | begin
|
---|
136 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
|
---|
137 | '\oniunpacker.ini');
|
---|
138 | Reset(AppSettingsFile);
|
---|
139 | Read(AppSettingsFile, AppSettings);
|
---|
140 | CloseFile(AppSettingsFile);
|
---|
141 | end
|
---|
142 | else
|
---|
143 | begin
|
---|
144 | AppSettings.DatPath := 'D:\Spiele\Oni\GameDataFolder';
|
---|
145 | AppSettings.ExtractPath := 'C:\Dokumente und Einstellungen\Administrator\Desktop';
|
---|
146 | AppSettings.FilenumbersAsHex := False;
|
---|
147 | AppSettings.CharSet := DEFAULT_CHARSET;
|
---|
148 | AppSettings.HideUnusedData := False;
|
---|
149 | end;
|
---|
150 |
|
---|
151 | if MidStr(ParamStr(1), 1, 3) = 'opf' then
|
---|
152 | begin
|
---|
153 | ShowMessage('Load OPF-File: ' + ParamStr(2));
|
---|
154 | end
|
---|
155 | else if MidStr(ParamStr(1), 1, 4) = 'oldb' then
|
---|
156 | begin
|
---|
157 | if CreateDataConnection(ParamStr(2), ODB_ADB) = nil then
|
---|
158 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
159 | 2) + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
160 | end
|
---|
161 | else if MidStr(ParamStr(1), 1, 3) = 'dat' then
|
---|
162 | begin
|
---|
163 | if CreateDataConnection(ParamStr(2), ODB_Dat) = nil then
|
---|
164 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
165 | 2) + CrLf + 'Perhaps not an Oni-.dat-file?');
|
---|
166 | end;
|
---|
167 | UpdateStatBar;
|
---|
168 | end;
|
---|
169 |
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 | procedure TForm_Main.FormResize(Sender: TObject);
|
---|
174 | const
|
---|
175 | MinWidth: Integer = 750;
|
---|
176 | MinHeight: Integer = 500;
|
---|
177 | begin
|
---|
178 | if Self.Width < MinWidth then
|
---|
179 | Self.Width := MinWidth;
|
---|
180 | if Self.Height < MinHeight then
|
---|
181 | Self.Height := MinHeight;
|
---|
182 | statbar.Panels.Items[0].Width := Self.Width - 200;
|
---|
183 | MDITab.Width := Self.Width - 20;
|
---|
184 | end;
|
---|
185 |
|
---|
186 |
|
---|
187 |
|
---|
188 |
|
---|
189 | procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
|
---|
190 | TabIndex: Integer; const Rect: TRect; Active: Boolean);
|
---|
191 | var
|
---|
192 | x, y: Integer;
|
---|
193 | iconindex: Integer;
|
---|
194 | caption: String;
|
---|
195 | begin
|
---|
196 | iconindex := TMDITab(Control).Glyphs[TabIndex];
|
---|
197 | caption := TMDITab(Control).Captions[TabIndex];
|
---|
198 | if active then
|
---|
199 | begin
|
---|
200 | Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
|
---|
201 | y := Rect.Top + 1;
|
---|
202 | end else
|
---|
203 | y := Rect.Top;
|
---|
204 | if iconindex >= 0 then
|
---|
205 | begin
|
---|
206 | TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
|
---|
207 | x := Rect.Left + 26;
|
---|
208 | end else
|
---|
209 | x := Rect.Left + 4;
|
---|
210 | Control.Canvas.TextOut(x, y + 2, caption);
|
---|
211 | if active then
|
---|
212 | Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 0)
|
---|
213 | else
|
---|
214 | Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 1);
|
---|
215 | end;
|
---|
216 |
|
---|
217 |
|
---|
218 | procedure TForm_Main.MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
|
---|
219 | Y: Integer);
|
---|
220 | var
|
---|
221 | pt: TPoint;
|
---|
222 | tabIndex: Integer;
|
---|
223 | hint: String;
|
---|
224 | begin
|
---|
225 | pt.X := X;
|
---|
226 | pt.Y := Y;
|
---|
227 | tabIndex := MDITab.GetTabAtPos(pt);
|
---|
228 |
|
---|
229 | if tabIndex >= 0 then
|
---|
230 | begin
|
---|
231 | if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
|
---|
232 | begin
|
---|
233 | hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption + #13+#10 +
|
---|
234 | 'Selected File: ';
|
---|
235 | if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then
|
---|
236 | hint := hint + TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName
|
---|
237 | else
|
---|
238 | hint := hint + 'None';
|
---|
239 | end
|
---|
240 | else
|
---|
241 | hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption;
|
---|
242 | if hint <> MDITab.Hint then
|
---|
243 | begin
|
---|
244 | MDITab.Hint := hint;
|
---|
245 | MDITab.ShowHint := True;
|
---|
246 | end;
|
---|
247 | end
|
---|
248 | else
|
---|
249 | begin
|
---|
250 | MDITab.ShowHint := False;
|
---|
251 | MDITab.Hint := '';
|
---|
252 | end;
|
---|
253 | end;
|
---|
254 |
|
---|
255 | procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
256 | Shift: TShiftState; X, Y: Integer);
|
---|
257 | var
|
---|
258 | pt: TPoint;
|
---|
259 | tabIndex: Integer;
|
---|
260 | tabRect: TRect;
|
---|
261 | tabX, tabY, tabWidth: Integer;
|
---|
262 | begin
|
---|
263 | pt.X := X;
|
---|
264 | pt.Y := Y;
|
---|
265 | tabIndex := MDITab.GetTabAtPos(pt);
|
---|
266 |
|
---|
267 | // if (Button = mbRight) and (tabIndex >= 0) then
|
---|
268 | // MDITab.MDIChildren[tabIndex].Close;
|
---|
269 |
|
---|
270 | if (Button = mbLeft) and (tabIndex >= 0) then
|
---|
271 | begin
|
---|
272 | tabrect := MDITab.TabRect(tabIndex);
|
---|
273 | tabX := X - tabrect.Left;
|
---|
274 | tabY := Y - tabrect.Top;
|
---|
275 | tabwidth := tabrect.Right - tabrect.Left;
|
---|
276 | if (tabY >= 4) and (tabY <= 17) then
|
---|
277 | if (tabX >= tabwidth - 19) and (tabX <= tabwidth - 7) then
|
---|
278 | MDITab.MDIChildren[tabIndex].Close;
|
---|
279 | end;
|
---|
280 | end;
|
---|
281 |
|
---|
282 |
|
---|
283 |
|
---|
284 |
|
---|
285 | procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
286 | begin
|
---|
287 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
|
---|
288 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
289 | Reset(AppSettingsFile)
|
---|
290 | else
|
---|
291 | Rewrite(AppSettingsFile);
|
---|
292 | Write(AppSettingsFile, AppSettings);
|
---|
293 | CloseFile(AppSettingsFile);
|
---|
294 | Action := caFree;
|
---|
295 | end;
|
---|
296 |
|
---|
297 |
|
---|
298 |
|
---|
299 | procedure TForm_Main.ActivateTools(active: Boolean);
|
---|
300 | begin
|
---|
301 | menu_tools.Enabled := active;
|
---|
302 | tb_preview.Enabled := active;
|
---|
303 | tb_datedit.Enabled := active;
|
---|
304 | tb_rawedit.Enabled := active;
|
---|
305 | tb_txmpreplacer.Enabled := active;
|
---|
306 | tb_extractor.Enabled := active;
|
---|
307 | // tb_compare.Enabled := active;
|
---|
308 | // tb_structure.Enabled := active;
|
---|
309 | end;
|
---|
310 |
|
---|
311 | procedure TForm_Main.UpdateStatBar;
|
---|
312 | begin
|
---|
313 | if Length(DataConnections) > 0 then
|
---|
314 | begin
|
---|
315 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
316 | ActivateTools(True);
|
---|
317 | statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(Length(DataConnections));
|
---|
318 | end
|
---|
319 | else
|
---|
320 | begin
|
---|
321 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
322 | statbar.Panels.Items[0].Text := 'Nothing loaded';
|
---|
323 | statbar.Panels.Items[1].Text := 'Files: -';
|
---|
324 | statbar.Panels.Items[2].Text := 'Extensions: -';
|
---|
325 | ActivateTools(False);
|
---|
326 | end;
|
---|
327 | end;
|
---|
328 |
|
---|
329 |
|
---|
330 |
|
---|
331 |
|
---|
332 | procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
|
---|
333 | var
|
---|
334 | toolbar: TTBToolbar;
|
---|
335 | position: TTBDockPosition;
|
---|
336 | mode: TTBItemDisplayMode;
|
---|
337 | i: Integer;
|
---|
338 | isEnabled: Boolean;
|
---|
339 | begin
|
---|
340 | toolbar := TTBToolbar(Sender);
|
---|
341 | if toolbar.Floating then
|
---|
342 | mode := nbdmImageAndText
|
---|
343 | else begin
|
---|
344 | position := toolbar.CurrentDock.Position;
|
---|
345 | if position in [dpLeft, dpRight] then
|
---|
346 | mode := nbdmDefault
|
---|
347 | else
|
---|
348 | mode := nbdmImageAndText;
|
---|
349 | end;
|
---|
350 | for i := 0 to toolbar.Items.Count - 1 do
|
---|
351 | toolbar.Items.Items[i].DisplayMode := mode;
|
---|
352 | end;
|
---|
353 |
|
---|
354 | function TForm_Main.TryCloseAll: Boolean;
|
---|
355 | begin
|
---|
356 | menu_windows_closeallClick(Self);
|
---|
357 | Application.ProcessMessages;
|
---|
358 | if MDITab.MDIChildCount = 0 then
|
---|
359 | Result := True
|
---|
360 | else
|
---|
361 | Result := False;
|
---|
362 | end;
|
---|
363 |
|
---|
364 |
|
---|
365 | procedure TForm_Main.UpdateConLists;
|
---|
366 | var
|
---|
367 | i: Integer;
|
---|
368 | begin
|
---|
369 | for i := 0 to MDITab.MDIChildCount - 1 do
|
---|
370 | if MDITab.MDIChildren[i] is TForm_ToolTemplate then
|
---|
371 | TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateList;
|
---|
372 | end;
|
---|
373 |
|
---|
374 |
|
---|
375 | procedure TForm_Main.LoadFile(typedb: Boolean);
|
---|
376 | var
|
---|
377 | ext: String;
|
---|
378 | begin
|
---|
379 | opend.InitialDir := AppSettings.DatPath;
|
---|
380 | opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
|
---|
381 | if typedb then
|
---|
382 | opend.FilterIndex := 3
|
---|
383 | else
|
---|
384 | opend.FilterIndex := 2;
|
---|
385 | if opend.Execute then
|
---|
386 | begin
|
---|
387 | ext := ExtractFileExt(opend.FileName);
|
---|
388 | if ext = '.dat' then
|
---|
389 | begin
|
---|
390 | if CreateDataConnection(opend.FileName, ODB_Dat) <> nil then
|
---|
391 | UpdateConLists;
|
---|
392 | end else if ext = '.oldb' then
|
---|
393 | begin
|
---|
394 | if CreateDataConnection(opend.FileName, ODB_ADB) <> nil then
|
---|
395 | UpdateConLists;
|
---|
396 | end else
|
---|
397 | ShowMessage('Incompatible file');
|
---|
398 | AppSettings.DatPath := ExtractFilepath(opend.FileName);
|
---|
399 | end;
|
---|
400 | UpdateStatBar;
|
---|
401 | end;
|
---|
402 |
|
---|
403 |
|
---|
404 | {#################################}
|
---|
405 | {##### Main-Menu-Handlers #####}
|
---|
406 | {#################################}
|
---|
407 | procedure TForm_Main.menu_loaddbClick(Sender: TObject);
|
---|
408 | begin
|
---|
409 | LoadFile(True);
|
---|
410 | end;
|
---|
411 |
|
---|
412 | procedure TForm_Main.menu_loadfileClick(Sender: TObject);
|
---|
413 | begin
|
---|
414 | LoadFile(False);
|
---|
415 | end;
|
---|
416 |
|
---|
417 |
|
---|
418 |
|
---|
419 |
|
---|
420 | procedure TForm_Main.menu_settingsClick(Sender: TObject);
|
---|
421 | begin
|
---|
422 | Form_Settings.Visible := True;
|
---|
423 | Self.Enabled := False;
|
---|
424 | end;
|
---|
425 |
|
---|
426 |
|
---|
427 |
|
---|
428 |
|
---|
429 | procedure TForm_Main.menu_exitClick(Sender: TObject);
|
---|
430 | begin
|
---|
431 | Self.Close;
|
---|
432 | end;
|
---|
433 |
|
---|
434 | {####################################}
|
---|
435 | {##### Converters-Menu-Handlers #####}
|
---|
436 | {####################################}
|
---|
437 | procedure TForm_Main.menu_createdbClick(Sender: TObject);
|
---|
438 | begin
|
---|
439 | { if Assigned(OniDataConnection) then
|
---|
440 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
441 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
442 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
443 | Exit
|
---|
444 | else begin
|
---|
445 | if TryCloseAll then
|
---|
446 | begin
|
---|
447 | CloseDataConnection;
|
---|
448 | UpdateStatBar;
|
---|
449 | end else
|
---|
450 | Exit;
|
---|
451 | end;
|
---|
452 | opend.Filter := 'Oni-Dat-Files|*.dat';
|
---|
453 | saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
454 | saved.DefaultExt := 'oldb';
|
---|
455 | if opend.Execute then
|
---|
456 | if saved.Execute then
|
---|
457 | Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
|
---|
458 | }end;
|
---|
459 |
|
---|
460 |
|
---|
461 |
|
---|
462 |
|
---|
463 | procedure TForm_Main.menu_createlvlClick(Sender: TObject);
|
---|
464 | begin
|
---|
465 | { if Assigned(OniDataConnection) then
|
---|
466 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
467 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
468 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
469 | Exit
|
---|
470 | else begin
|
---|
471 | if TryCloseAll then
|
---|
472 | begin
|
---|
473 | CloseDataConnection;
|
---|
474 | UpdateStatBar;
|
---|
475 | end else
|
---|
476 | Exit;
|
---|
477 | end;
|
---|
478 | opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
479 | saved.Filter := 'Oni-Dat-Files|*.dat';
|
---|
480 | saved.DefaultExt := 'dat';
|
---|
481 | if opend.Execute then
|
---|
482 | if saved.Execute then
|
---|
483 | Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
|
---|
484 | }end;
|
---|
485 |
|
---|
486 | {#################################}
|
---|
487 | {##### Tools-Menu-Handlers #####}
|
---|
488 | {#################################}
|
---|
489 | procedure TForm_Main.menu_previewClick(Sender: TObject);
|
---|
490 | begin
|
---|
491 | open_child('preview', -1);
|
---|
492 | end;
|
---|
493 |
|
---|
494 |
|
---|
495 | procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
|
---|
496 | begin
|
---|
497 | open_child('txmpreplace', -1);
|
---|
498 | end;
|
---|
499 |
|
---|
500 |
|
---|
501 | procedure TForm_Main.menu_bineditClick(Sender: TObject);
|
---|
502 | begin
|
---|
503 | open_child('binedit', -1);
|
---|
504 | end;
|
---|
505 |
|
---|
506 |
|
---|
507 | procedure TForm_Main.menu_raweditClick(Sender: TObject);
|
---|
508 | begin
|
---|
509 | open_child('rawedit', -1);
|
---|
510 | end;
|
---|
511 |
|
---|
512 |
|
---|
513 | procedure TForm_Main.menu_extractorClick(Sender: TObject);
|
---|
514 | begin
|
---|
515 | open_child('extractor', -1);
|
---|
516 | end;
|
---|
517 |
|
---|
518 |
|
---|
519 | procedure TForm_Main.menu_metaClick(Sender: TObject);
|
---|
520 | begin
|
---|
521 | ShowMessage('TBD');
|
---|
522 | end;
|
---|
523 |
|
---|
524 |
|
---|
525 | procedure TForm_Main.menu_filecompareClick(Sender: TObject);
|
---|
526 | begin
|
---|
527 | open_child('compare', -1);
|
---|
528 | end;
|
---|
529 |
|
---|
530 |
|
---|
531 | {#################################}
|
---|
532 | {##### View-Menu-Handlers #####}
|
---|
533 | {#################################}
|
---|
534 | procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
|
---|
535 | begin
|
---|
536 | menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
|
---|
537 | mditoolbar.Visible := menu_view_mdibar.Checked;
|
---|
538 | end;
|
---|
539 |
|
---|
540 |
|
---|
541 |
|
---|
542 |
|
---|
543 | procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
|
---|
544 | begin
|
---|
545 | menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
|
---|
546 | statbar.Visible := menu_view_statusbar.Checked;
|
---|
547 | end;
|
---|
548 |
|
---|
549 |
|
---|
550 |
|
---|
551 |
|
---|
552 | procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
|
---|
553 | begin
|
---|
554 | menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
|
---|
555 | Toolbar.Visible := menu_view_toolbar.Checked;
|
---|
556 | end;
|
---|
557 |
|
---|
558 |
|
---|
559 |
|
---|
560 | {#################################}
|
---|
561 | {##### Window-Menu-Handlers #####}
|
---|
562 | {#################################}
|
---|
563 | procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
|
---|
564 | begin
|
---|
565 | Self.Cascade;
|
---|
566 | end;
|
---|
567 |
|
---|
568 |
|
---|
569 |
|
---|
570 | procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
|
---|
571 | begin
|
---|
572 | Self.TileMode := tbHorizontal;
|
---|
573 | Self.Tile;
|
---|
574 | end;
|
---|
575 |
|
---|
576 | procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
|
---|
577 | begin
|
---|
578 | Self.TileMode := tbVertical;
|
---|
579 | Self.Tile;
|
---|
580 | end;
|
---|
581 |
|
---|
582 |
|
---|
583 | procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
|
---|
584 | begin
|
---|
585 | MDITab.CloseAll;
|
---|
586 | end;
|
---|
587 |
|
---|
588 |
|
---|
589 |
|
---|
590 | procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
|
---|
591 | begin
|
---|
592 | if MDIChildCount > 1 then
|
---|
593 | if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
|
---|
594 | MDITab.MDIChildren[0].BringToFront
|
---|
595 | else
|
---|
596 | MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
|
---|
597 | end;
|
---|
598 |
|
---|
599 |
|
---|
600 |
|
---|
601 | procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
|
---|
602 | begin
|
---|
603 | if MDIChildCount > 1 then
|
---|
604 | if MDITab.TabIndex = 0 then
|
---|
605 | MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
|
---|
606 | else
|
---|
607 | MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
|
---|
608 | end;
|
---|
609 |
|
---|
610 |
|
---|
611 |
|
---|
612 |
|
---|
613 |
|
---|
614 |
|
---|
615 | procedure TForm_Main.menu_AboutClick(Sender: TObject);
|
---|
616 | begin
|
---|
617 | ShowMessage('Will be implemented later ;)');
|
---|
618 | end;
|
---|
619 |
|
---|
620 |
|
---|
621 |
|
---|
622 |
|
---|
623 | function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
624 | var
|
---|
625 | toolform: TForm_ToolTemplate;
|
---|
626 | i: Integer;
|
---|
627 | tag: Integer;
|
---|
628 | caption_end: String;
|
---|
629 | iconindex: Integer;
|
---|
630 | begin
|
---|
631 | Result := nil;
|
---|
632 |
|
---|
633 | tag := 1;
|
---|
634 | if MDIChildCount > 0 then
|
---|
635 | for i := 0 to MDIChildCount - 1 do
|
---|
636 | if MDIChildren[i].Tag >= tag then
|
---|
637 | tag := MDIChildren[i].Tag + 1;
|
---|
638 |
|
---|
639 | iconindex := -1;
|
---|
640 | caption_end := IntToStr(tag) + ' ';
|
---|
641 |
|
---|
642 | if window_context = 'binedit' then
|
---|
643 | begin
|
---|
644 | toolform := TForm_BinEdit.Create(Self);
|
---|
645 | toolform.Caption := 'Binary .dat-Editor ' + caption_end;
|
---|
646 | iconindex := 5;
|
---|
647 | end;
|
---|
648 | if window_context = 'extractor' then
|
---|
649 | begin
|
---|
650 | toolform := TForm_Extractor.Create(Self);
|
---|
651 | toolform.Caption := 'Extractor ' + caption_end;
|
---|
652 | iconindex := 8;
|
---|
653 | end;
|
---|
654 | if window_context = 'preview' then
|
---|
655 | begin
|
---|
656 | toolform := TForm_Preview.Create(Self);
|
---|
657 | toolform.Caption := 'Preview-Window ' + caption_end;
|
---|
658 | iconindex := 4;
|
---|
659 | end;
|
---|
660 | if window_context = 'rawedit' then
|
---|
661 | begin
|
---|
662 | toolform := TForm_RawEdit.Create(Self);
|
---|
663 | toolform.Caption := 'Binary .raw-Editor ' + caption_end;
|
---|
664 | iconindex := 6;
|
---|
665 | end;
|
---|
666 | if window_context = 'txmpreplace' then
|
---|
667 | begin
|
---|
668 | toolform := TForm_TxmpReplace.Create(Application);
|
---|
669 | toolform.Caption := 'TXMP Replacer ' + caption_end;
|
---|
670 | iconindex := 7;
|
---|
671 | end;
|
---|
672 |
|
---|
673 | if Assigned(toolform) then
|
---|
674 | begin
|
---|
675 | toolform.Name := window_context + IntToStr(tag);
|
---|
676 | toolform.Tag := tag;
|
---|
677 | MDITab.AddTab(TForm(toolform), iconindex);
|
---|
678 | toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', '');
|
---|
679 | if fileid > -1 then
|
---|
680 | toolform.SelectFileID(fileid);
|
---|
681 | Result := toolform;
|
---|
682 | end;
|
---|
683 | end;
|
---|
684 |
|
---|
685 | end.
|
---|