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 | function TryCloseAll: Boolean;
|
---|
75 | procedure menu_AboutClick(Sender: TObject);
|
---|
76 | procedure menu_settingsClick(Sender: TObject);
|
---|
77 | procedure menu_filecompareClick(Sender: TObject);
|
---|
78 | procedure menu_raweditClick(Sender: TObject);
|
---|
79 | procedure menu_createlvlClick(Sender: TObject);
|
---|
80 | procedure menu_extractorClick(Sender: TObject);
|
---|
81 | procedure menu_createdbClick(Sender: TObject);
|
---|
82 | procedure menu_windows_previousClick(Sender: TObject);
|
---|
83 | procedure menu_windows_nextClick(Sender: TObject);
|
---|
84 | procedure menu_windows_tileClick(Sender: TObject);
|
---|
85 | function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
86 | procedure menu_windows_closeallClick(Sender: TObject);
|
---|
87 | procedure menu_windows_cascadeClick(Sender: TObject);
|
---|
88 | procedure menu_bineditClick(Sender: TObject);
|
---|
89 | procedure menu_loadfileClick(Sender: TObject);
|
---|
90 | procedure menu_txmpreplaceClick(Sender: TObject);
|
---|
91 | procedure menu_exitClick(Sender: TObject);
|
---|
92 | procedure menu_previewClick(Sender: TObject);
|
---|
93 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
94 | procedure FormResize(Sender: TObject);
|
---|
95 | procedure FormCreate(Sender: TObject);
|
---|
96 | procedure UpdateStatBar;
|
---|
97 | procedure menu_view_mdibarClick(Sender: TObject);
|
---|
98 | procedure menu_view_statusbarClick(Sender: TObject);
|
---|
99 | procedure menu_view_toolbarClick(Sender: TObject);
|
---|
100 | procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
|
---|
101 | const Rect: TRect; Active: Boolean);
|
---|
102 | procedure ActivateTools(active: Boolean);
|
---|
103 | procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
104 | Shift: TShiftState; X, Y: Integer);
|
---|
105 | procedure menu_windows_tilevertClick(Sender: TObject);
|
---|
106 | procedure menu_metaClick(Sender: TObject);
|
---|
107 | procedure ToolbarDockChanged(Sender: TObject);
|
---|
108 | private
|
---|
109 | public
|
---|
110 | end;
|
---|
111 |
|
---|
112 | var
|
---|
113 | Form_Main: TForm_Main;
|
---|
114 |
|
---|
115 | implementation
|
---|
116 |
|
---|
117 | {$R *.dfm}
|
---|
118 |
|
---|
119 |
|
---|
120 |
|
---|
121 | procedure TForm_Main.FormCreate(Sender: TObject);
|
---|
122 | begin
|
---|
123 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
124 | Self.FormResize(Self);
|
---|
125 |
|
---|
126 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
127 | begin
|
---|
128 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
|
---|
129 | '\oniunpacker.ini');
|
---|
130 | Reset(AppSettingsFile);
|
---|
131 | Read(AppSettingsFile, AppSettings);
|
---|
132 | CloseFile(AppSettingsFile);
|
---|
133 | end
|
---|
134 | else
|
---|
135 | begin
|
---|
136 | AppSettings.DatPath := 'D:\Spiele\Oni\GameDataFolder';
|
---|
137 | AppSettings.ExtractPath := 'C:\Dokumente und Einstellungen\Administrator\Desktop';
|
---|
138 | AppSettings.FilenumbersAsHex := False;
|
---|
139 | AppSettings.CharSet := DEFAULT_CHARSET;
|
---|
140 | AppSettings.HideUnusedData := False;
|
---|
141 | end;
|
---|
142 |
|
---|
143 | if MidStr(ParamStr(1), 1, 3) = 'opf' then
|
---|
144 | begin
|
---|
145 | ShowMessage('Load OPF-File: ' + ParamStr(2));
|
---|
146 | end
|
---|
147 | else if MidStr(ParamStr(1), 1, 4) = 'oldb' then
|
---|
148 | begin
|
---|
149 | if not CreateDataConnection(ParamStr(2), ODB_ADB) then
|
---|
150 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
151 | 2) + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
152 | end
|
---|
153 | else if MidStr(ParamStr(1), 1, 3) = 'dat' then
|
---|
154 | begin
|
---|
155 | if not CreateDataConnection(ParamStr(2), ODB_Dat) then
|
---|
156 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
157 | 2) + CrLf + 'Perhaps not an Oni-.dat-file?');
|
---|
158 | end;
|
---|
159 | UpdateStatBar;
|
---|
160 | end;
|
---|
161 |
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | procedure TForm_Main.FormResize(Sender: TObject);
|
---|
166 | const
|
---|
167 | MinWidth: Integer = 750;
|
---|
168 | MinHeight: Integer = 500;
|
---|
169 | begin
|
---|
170 | if Self.Width < MinWidth then
|
---|
171 | Self.Width := MinWidth;
|
---|
172 | if Self.Height < MinHeight then
|
---|
173 | Self.Height := MinHeight;
|
---|
174 | statbar.Panels.Items[0].Width := Self.Width - 200;
|
---|
175 | MDITab.Width := Self.Width - 20;
|
---|
176 | end;
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 | procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
|
---|
182 | TabIndex: Integer; const Rect: TRect; Active: Boolean);
|
---|
183 | var
|
---|
184 | x, y: Integer;
|
---|
185 | iconindex: Integer;
|
---|
186 | caption: String;
|
---|
187 | begin
|
---|
188 | iconindex := TMDITab(Control).Glyphs[TabIndex];
|
---|
189 | caption := TMDITab(Control).Captions[TabIndex];
|
---|
190 | if active then
|
---|
191 | begin
|
---|
192 | Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
|
---|
193 | y := Rect.Top + 1;
|
---|
194 | end else
|
---|
195 | y := Rect.Top;
|
---|
196 | if iconindex >= 0 then
|
---|
197 | begin
|
---|
198 | TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
|
---|
199 | x := Rect.Left + 26;
|
---|
200 | end else
|
---|
201 | x := Rect.Left + 4;
|
---|
202 | Control.Canvas.TextOut(x, y + 2, caption);
|
---|
203 | end;
|
---|
204 |
|
---|
205 |
|
---|
206 |
|
---|
207 |
|
---|
208 |
|
---|
209 |
|
---|
210 | procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
211 | Shift: TShiftState; X, Y: Integer);
|
---|
212 | var
|
---|
213 | pt: TPoint;
|
---|
214 | index: Integer;
|
---|
215 | begin
|
---|
216 | pt.X := X;
|
---|
217 | pt.Y := Y;
|
---|
218 | index := MDITab.GetTabAtPos(pt);
|
---|
219 | if (Button = mbRight) and (index >= 0) then
|
---|
220 | MDITab.MDIChildren[index].Close;
|
---|
221 | end;
|
---|
222 |
|
---|
223 | procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
224 | begin
|
---|
225 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
|
---|
226 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
227 | Reset(AppSettingsFile)
|
---|
228 | else
|
---|
229 | Rewrite(AppSettingsFile);
|
---|
230 | Write(AppSettingsFile, AppSettings);
|
---|
231 | CloseFile(AppSettingsFile);
|
---|
232 | Action := caFree;
|
---|
233 | end;
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 | procedure TForm_Main.ActivateTools(active: Boolean);
|
---|
238 | begin
|
---|
239 | menu_tools.Enabled := active;
|
---|
240 | tb_preview.Enabled := active;
|
---|
241 | tb_datedit.Enabled := active;
|
---|
242 | tb_rawedit.Enabled := active;
|
---|
243 | tb_txmpreplacer.Enabled := active;
|
---|
244 | tb_extractor.Enabled := active;
|
---|
245 | // tb_compare.Enabled := active;
|
---|
246 | // tb_structure.Enabled := active;
|
---|
247 | end;
|
---|
248 |
|
---|
249 | procedure TForm_Main.UpdateStatBar;
|
---|
250 | begin
|
---|
251 | if Assigned(OniDataConnection) then
|
---|
252 | begin
|
---|
253 | Self.Caption := 'Oni Un/Packer ' + version + ' (' + ExtractFileName(
|
---|
254 | OniDataConnection.FileName) + ')';
|
---|
255 | ActivateTools(True);
|
---|
256 | statbar.Panels.Items[1].Text := 'Files: ' + IntToStr(OniDataConnection.GetFilesCount);
|
---|
257 | statbar.Panels.Items[2].Text :=
|
---|
258 | 'Extensions: ' + IntToStr(Length(OniDataConnection.GetExtensionsList));
|
---|
259 | case OniDataConnection.Backend of
|
---|
260 | ODB_Dat:
|
---|
261 | begin
|
---|
262 | statbar.Panels.Items[0].Text := '.dat loaded: ' + OniDataConnection.FileName;
|
---|
263 | end;
|
---|
264 | ODB_ADB:
|
---|
265 | begin
|
---|
266 | statbar.Panels.Items[0].Text := 'OLDB loaded: ' + OniDataConnection.FileName;
|
---|
267 | end;
|
---|
268 | else
|
---|
269 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
270 | statbar.Panels.Items[0].Text := 'Nothing loaded';
|
---|
271 | statbar.Panels.Items[1].Text := 'Files: -';
|
---|
272 | statbar.Panels.Items[2].Text := 'Extensions: -';
|
---|
273 | ActivateTools(False);
|
---|
274 | end;
|
---|
275 | end
|
---|
276 | else
|
---|
277 | begin
|
---|
278 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
279 | statbar.Panels.Items[0].Text := 'Nothing loaded';
|
---|
280 | statbar.Panels.Items[1].Text := 'Files: -';
|
---|
281 | statbar.Panels.Items[2].Text := 'Extensions: -';
|
---|
282 | ActivateTools(False);
|
---|
283 | end;
|
---|
284 | end;
|
---|
285 |
|
---|
286 |
|
---|
287 |
|
---|
288 |
|
---|
289 | procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
|
---|
290 | var
|
---|
291 | toolbar: TTBToolbar;
|
---|
292 | position: TTBDockPosition;
|
---|
293 | mode: TTBItemDisplayMode;
|
---|
294 | i: Integer;
|
---|
295 | isEnabled: Boolean;
|
---|
296 | begin
|
---|
297 | toolbar := TTBToolbar(Sender);
|
---|
298 | if toolbar.Floating then
|
---|
299 | mode := nbdmImageAndText
|
---|
300 | else begin
|
---|
301 | position := toolbar.CurrentDock.Position;
|
---|
302 | if position in [dpLeft, dpRight] then
|
---|
303 | mode := nbdmDefault
|
---|
304 | else
|
---|
305 | mode := nbdmImageAndText;
|
---|
306 | end;
|
---|
307 | for i := 0 to toolbar.Items.Count - 1 do
|
---|
308 | toolbar.Items.Items[i].DisplayMode := mode;
|
---|
309 | end;
|
---|
310 |
|
---|
311 | function TForm_Main.TryCloseAll: Boolean;
|
---|
312 | begin
|
---|
313 | menu_windows_closeallClick(Self);
|
---|
314 | Application.ProcessMessages;
|
---|
315 | if MDITab.MDIChildCount = 0 then
|
---|
316 | Result := True
|
---|
317 | else
|
---|
318 | Result := False;
|
---|
319 | end;
|
---|
320 |
|
---|
321 |
|
---|
322 | {#################################}
|
---|
323 | {##### Main-Menu-Handlers #####}
|
---|
324 | {#################################}
|
---|
325 | procedure TForm_Main.menu_loadfileClick(Sender: TObject);
|
---|
326 | var
|
---|
327 | ext: String;
|
---|
328 | begin
|
---|
329 | if TryCloseAll then
|
---|
330 | begin
|
---|
331 | CloseDataConnection;
|
---|
332 | opend.InitialDir := AppSettings.DatPath;
|
---|
333 | opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
|
---|
334 | if opend.Execute then
|
---|
335 | begin
|
---|
336 | ext := ExtractFileExt(opend.FileName);
|
---|
337 | if ext = '.dat' then
|
---|
338 | begin
|
---|
339 | if not CreateDataConnection(opend.FileName, ODB_Dat) then
|
---|
340 | ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
|
---|
341 | CrLf + 'Perhaps not an Oni-.dat-file?');
|
---|
342 | end else if ext = '.oldb' then
|
---|
343 | begin
|
---|
344 | if not CreateDataConnection(opend.FileName, ODB_ADB) then
|
---|
345 | ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
|
---|
346 | CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
347 | end else
|
---|
348 | ShowMessage('Incompatible file');
|
---|
349 | AppSettings.DatPath := ExtractFilepath(opend.FileName);
|
---|
350 | end;
|
---|
351 | end;
|
---|
352 | UpdateStatBar;
|
---|
353 | end;
|
---|
354 |
|
---|
355 |
|
---|
356 |
|
---|
357 |
|
---|
358 | procedure TForm_Main.menu_settingsClick(Sender: TObject);
|
---|
359 | begin
|
---|
360 | Form_Settings.Visible := True;
|
---|
361 | Self.Enabled := False;
|
---|
362 | end;
|
---|
363 |
|
---|
364 |
|
---|
365 |
|
---|
366 |
|
---|
367 | procedure TForm_Main.menu_exitClick(Sender: TObject);
|
---|
368 | begin
|
---|
369 | Self.Close;
|
---|
370 | end;
|
---|
371 |
|
---|
372 | {####################################}
|
---|
373 | {##### Converters-Menu-Handlers #####}
|
---|
374 | {####################################}
|
---|
375 | procedure TForm_Main.menu_createdbClick(Sender: TObject);
|
---|
376 | begin
|
---|
377 | if Assigned(OniDataConnection) then
|
---|
378 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
379 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
380 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
381 | Exit
|
---|
382 | else begin
|
---|
383 | if TryCloseAll then
|
---|
384 | begin
|
---|
385 | CloseDataConnection;
|
---|
386 | UpdateStatBar;
|
---|
387 | end else
|
---|
388 | Exit;
|
---|
389 | end;
|
---|
390 | opend.Filter := 'Oni-Dat-Files|*.dat';
|
---|
391 | saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
392 | saved.DefaultExt := 'oldb';
|
---|
393 | if opend.Execute then
|
---|
394 | if saved.Execute then
|
---|
395 | Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
|
---|
396 | end;
|
---|
397 |
|
---|
398 |
|
---|
399 |
|
---|
400 |
|
---|
401 | procedure TForm_Main.menu_createlvlClick(Sender: TObject);
|
---|
402 | begin
|
---|
403 | if Assigned(OniDataConnection) then
|
---|
404 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
405 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
406 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
407 | Exit
|
---|
408 | else begin
|
---|
409 | if TryCloseAll then
|
---|
410 | begin
|
---|
411 | CloseDataConnection;
|
---|
412 | UpdateStatBar;
|
---|
413 | end else
|
---|
414 | Exit;
|
---|
415 | end;
|
---|
416 | opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
417 | saved.Filter := 'Oni-Dat-Files|*.dat';
|
---|
418 | saved.DefaultExt := 'dat';
|
---|
419 | if opend.Execute then
|
---|
420 | if saved.Execute then
|
---|
421 | Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
|
---|
422 | end;
|
---|
423 |
|
---|
424 | {#################################}
|
---|
425 | {##### Tools-Menu-Handlers #####}
|
---|
426 | {#################################}
|
---|
427 | procedure TForm_Main.menu_previewClick(Sender: TObject);
|
---|
428 | begin
|
---|
429 | open_child('preview', -1);
|
---|
430 | end;
|
---|
431 |
|
---|
432 |
|
---|
433 | procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
|
---|
434 | begin
|
---|
435 | open_child('txmpreplace', -1);
|
---|
436 | end;
|
---|
437 |
|
---|
438 |
|
---|
439 | procedure TForm_Main.menu_bineditClick(Sender: TObject);
|
---|
440 | begin
|
---|
441 | open_child('binedit', -1);
|
---|
442 | end;
|
---|
443 |
|
---|
444 |
|
---|
445 | procedure TForm_Main.menu_raweditClick(Sender: TObject);
|
---|
446 | begin
|
---|
447 | open_child('rawedit', -1);
|
---|
448 | end;
|
---|
449 |
|
---|
450 |
|
---|
451 | procedure TForm_Main.menu_extractorClick(Sender: TObject);
|
---|
452 | begin
|
---|
453 | open_child('extractor', -1);
|
---|
454 | end;
|
---|
455 |
|
---|
456 |
|
---|
457 | procedure TForm_Main.menu_metaClick(Sender: TObject);
|
---|
458 | begin
|
---|
459 | ShowMessage('TBD');
|
---|
460 | end;
|
---|
461 |
|
---|
462 |
|
---|
463 | procedure TForm_Main.menu_filecompareClick(Sender: TObject);
|
---|
464 | begin
|
---|
465 | open_child('compare', -1);
|
---|
466 | end;
|
---|
467 |
|
---|
468 |
|
---|
469 | {#################################}
|
---|
470 | {##### View-Menu-Handlers #####}
|
---|
471 | {#################################}
|
---|
472 | procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
|
---|
473 | begin
|
---|
474 | menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
|
---|
475 | mditoolbar.Visible := menu_view_mdibar.Checked;
|
---|
476 | end;
|
---|
477 |
|
---|
478 |
|
---|
479 |
|
---|
480 |
|
---|
481 | procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
|
---|
482 | begin
|
---|
483 | menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
|
---|
484 | statbar.Visible := menu_view_statusbar.Checked;
|
---|
485 | end;
|
---|
486 |
|
---|
487 |
|
---|
488 |
|
---|
489 |
|
---|
490 | procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
|
---|
491 | begin
|
---|
492 | menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
|
---|
493 | Toolbar.Visible := menu_view_toolbar.Checked;
|
---|
494 | end;
|
---|
495 |
|
---|
496 |
|
---|
497 |
|
---|
498 | {#################################}
|
---|
499 | {##### Window-Menu-Handlers #####}
|
---|
500 | {#################################}
|
---|
501 | procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
|
---|
502 | begin
|
---|
503 | Self.Cascade;
|
---|
504 | end;
|
---|
505 |
|
---|
506 |
|
---|
507 |
|
---|
508 | procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
|
---|
509 | begin
|
---|
510 | Self.TileMode := tbHorizontal;
|
---|
511 | Self.Tile;
|
---|
512 | end;
|
---|
513 |
|
---|
514 | procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
|
---|
515 | begin
|
---|
516 | Self.TileMode := tbVertical;
|
---|
517 | Self.Tile;
|
---|
518 | end;
|
---|
519 |
|
---|
520 |
|
---|
521 | procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
|
---|
522 | begin
|
---|
523 | MDITab.CloseAll;
|
---|
524 | end;
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 | procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
|
---|
529 | begin
|
---|
530 | if MDIChildCount > 1 then
|
---|
531 | if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
|
---|
532 | MDITab.MDIChildren[0].BringToFront
|
---|
533 | else
|
---|
534 | MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
|
---|
535 | end;
|
---|
536 |
|
---|
537 |
|
---|
538 |
|
---|
539 | procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
|
---|
540 | begin
|
---|
541 | if MDIChildCount > 1 then
|
---|
542 | if MDITab.TabIndex = 0 then
|
---|
543 | MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
|
---|
544 | else
|
---|
545 | MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
|
---|
546 | end;
|
---|
547 |
|
---|
548 |
|
---|
549 |
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 | procedure TForm_Main.menu_AboutClick(Sender: TObject);
|
---|
554 | begin
|
---|
555 | ShowMessage('Will be implemented later ;)');
|
---|
556 | end;
|
---|
557 |
|
---|
558 |
|
---|
559 |
|
---|
560 |
|
---|
561 | function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
562 | var
|
---|
563 | toolform: TForm_ToolTemplate;
|
---|
564 | i: Integer;
|
---|
565 | tag: Integer;
|
---|
566 | iconindex: Integer;
|
---|
567 | begin
|
---|
568 | Result := nil;
|
---|
569 |
|
---|
570 | tag := 1;
|
---|
571 | if MDIChildCount > 0 then
|
---|
572 | for i := 0 to MDIChildCount - 1 do
|
---|
573 | if MDIChildren[i].Tag >= tag then
|
---|
574 | tag := MDIChildren[i].Tag + 1;
|
---|
575 |
|
---|
576 | iconindex := -1;
|
---|
577 |
|
---|
578 | if window_context = 'binedit' then
|
---|
579 | begin
|
---|
580 | toolform := TForm_BinEdit.Create(Self);
|
---|
581 | toolform.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
|
---|
582 | iconindex := 4;
|
---|
583 | end;
|
---|
584 | if window_context = 'extractor' then
|
---|
585 | begin
|
---|
586 | toolform := TForm_Extractor.Create(Self);
|
---|
587 | toolform.Caption := 'Extractor ' + IntToStr(tag);
|
---|
588 | iconindex := 7;
|
---|
589 | end;
|
---|
590 | if window_context = 'preview' then
|
---|
591 | begin
|
---|
592 | toolform := TForm_Preview.Create(Self);
|
---|
593 | toolform.Caption := 'Preview-Window ' + IntToStr(tag);
|
---|
594 | iconindex := 3;
|
---|
595 | end;
|
---|
596 | if window_context = 'rawedit' then
|
---|
597 | begin
|
---|
598 | toolform := TForm_RawEdit.Create(Self);
|
---|
599 | toolform.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
|
---|
600 | iconindex := 5;
|
---|
601 | end;
|
---|
602 | if window_context = 'txmpreplace' then
|
---|
603 | begin
|
---|
604 | toolform := TForm_TxmpReplace.Create(Application);
|
---|
605 | toolform.Caption := 'TXMP Replacer ' + IntToStr(tag);
|
---|
606 | iconindex := 6;
|
---|
607 | end;
|
---|
608 |
|
---|
609 | if Assigned(toolform) then
|
---|
610 | begin
|
---|
611 | toolform.Name := window_context + IntToStr(tag);
|
---|
612 | toolform.Tag := tag;
|
---|
613 | MDITab.AddTab(TForm(toolform), iconindex);
|
---|
614 | if fileid > -1 then
|
---|
615 | toolform.SelectFileID(fileid);
|
---|
616 | Result := toolform;
|
---|
617 | end;
|
---|
618 | end;
|
---|
619 |
|
---|
620 | end.
|
---|