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