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 |
begin |
232 |
hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption + #13+#10 + |
233 |
'Selected File: '; |
234 |
if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then |
235 |
hint := hint + TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName |
236 |
else |
237 |
hint := hint + 'None'; |
238 |
end |
239 |
else |
240 |
hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption; |
241 |
if hint <> MDITab.Hint then |
242 |
begin |
243 |
MDITab.Hint := hint; |
244 |
MDITab.ShowHint := True; |
245 |
end; |
246 |
end |
247 |
else |
248 |
begin |
249 |
MDITab.ShowHint := False; |
250 |
MDITab.Hint := ''; |
251 |
end; |
252 |
end; |
253 |
|
254 |
procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton; |
255 |
Shift: TShiftState; X, Y: Integer); |
256 |
var |
257 |
pt: TPoint; |
258 |
tabIndex: Integer; |
259 |
tabRect: TRect; |
260 |
tabX, tabY, tabWidth: Integer; |
261 |
begin |
262 |
pt.X := X; |
263 |
pt.Y := Y; |
264 |
tabIndex := MDITab.GetTabAtPos(pt); |
265 |
if (Button = mbRight) and (tabIndex >= 0) then |
266 |
MDITab.MDIChildren[tabIndex].Close; |
267 |
|
268 |
if (Button = mbLeft) and (tabIndex >= 0) then |
269 |
begin |
270 |
tabrect := MDITab.TabRect(tabIndex); |
271 |
tabX := X - tabrect.Left; |
272 |
tabY := Y - tabrect.Top; |
273 |
tabwidth := tabrect.Right - tabrect.Left; |
274 |
if (tabY >= 4) and (tabY <= 17) then |
275 |
if (tabX >= tabwidth - 19) and (tabX <= tabwidth - 7) then |
276 |
MDITab.MDIChildren[tabIndex].Close; |
277 |
end; |
278 |
end; |
279 |
|
280 |
|
281 |
|
282 |
|
283 |
procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction); |
284 |
begin |
285 |
AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini'); |
286 |
if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then |
287 |
Reset(AppSettingsFile) |
288 |
else |
289 |
Rewrite(AppSettingsFile); |
290 |
Write(AppSettingsFile, AppSettings); |
291 |
CloseFile(AppSettingsFile); |
292 |
Action := caFree; |
293 |
end; |
294 |
|
295 |
|
296 |
|
297 |
procedure TForm_Main.ActivateTools(active: Boolean); |
298 |
begin |
299 |
menu_tools.Enabled := active; |
300 |
tb_preview.Enabled := active; |
301 |
tb_datedit.Enabled := active; |
302 |
tb_rawedit.Enabled := active; |
303 |
tb_txmpreplacer.Enabled := active; |
304 |
tb_extractor.Enabled := active; |
305 |
// tb_compare.Enabled := active; |
306 |
// tb_structure.Enabled := active; |
307 |
end; |
308 |
|
309 |
procedure TForm_Main.UpdateStatBar; |
310 |
begin |
311 |
if Assigned(OniDataConnection) then |
312 |
begin |
313 |
Self.Caption := 'Oni Un/Packer ' + version + ' (' + ExtractFileName( |
314 |
OniDataConnection.FileName) + ')'; |
315 |
ActivateTools(True); |
316 |
statbar.Panels.Items[1].Text := 'Files: ' + IntToStr(OniDataConnection.GetFilesCount); |
317 |
statbar.Panels.Items[2].Text := |
318 |
'Extensions: ' + IntToStr(Length(OniDataConnection.GetExtensionsList)); |
319 |
case OniDataConnection.Backend of |
320 |
ODB_Dat: |
321 |
begin |
322 |
statbar.Panels.Items[0].Text := '.dat loaded: ' + OniDataConnection.FileName; |
323 |
end; |
324 |
ODB_ADB: |
325 |
begin |
326 |
statbar.Panels.Items[0].Text := 'OLDB loaded: ' + OniDataConnection.FileName; |
327 |
end; |
328 |
else |
329 |
Self.Caption := 'Oni Un/Packer ' + version; |
330 |
statbar.Panels.Items[0].Text := 'Nothing loaded'; |
331 |
statbar.Panels.Items[1].Text := 'Files: -'; |
332 |
statbar.Panels.Items[2].Text := 'Extensions: -'; |
333 |
ActivateTools(False); |
334 |
end; |
335 |
end |
336 |
else |
337 |
begin |
338 |
Self.Caption := 'Oni Un/Packer ' + version; |
339 |
statbar.Panels.Items[0].Text := 'Nothing loaded'; |
340 |
statbar.Panels.Items[1].Text := 'Files: -'; |
341 |
statbar.Panels.Items[2].Text := 'Extensions: -'; |
342 |
ActivateTools(False); |
343 |
end; |
344 |
end; |
345 |
|
346 |
|
347 |
|
348 |
|
349 |
procedure TForm_Main.ToolbarDockChanged(Sender: TObject); |
350 |
var |
351 |
toolbar: TTBToolbar; |
352 |
position: TTBDockPosition; |
353 |
mode: TTBItemDisplayMode; |
354 |
i: Integer; |
355 |
isEnabled: Boolean; |
356 |
begin |
357 |
toolbar := TTBToolbar(Sender); |
358 |
if toolbar.Floating then |
359 |
mode := nbdmImageAndText |
360 |
else begin |
361 |
position := toolbar.CurrentDock.Position; |
362 |
if position in [dpLeft, dpRight] then |
363 |
mode := nbdmDefault |
364 |
else |
365 |
mode := nbdmImageAndText; |
366 |
end; |
367 |
for i := 0 to toolbar.Items.Count - 1 do |
368 |
toolbar.Items.Items[i].DisplayMode := mode; |
369 |
end; |
370 |
|
371 |
function TForm_Main.TryCloseAll: Boolean; |
372 |
begin |
373 |
menu_windows_closeallClick(Self); |
374 |
Application.ProcessMessages; |
375 |
if MDITab.MDIChildCount = 0 then |
376 |
Result := True |
377 |
else |
378 |
Result := False; |
379 |
end; |
380 |
|
381 |
|
382 |
|
383 |
procedure TForm_Main.LoadFile(typedb: Boolean); |
384 |
var |
385 |
ext: String; |
386 |
begin |
387 |
if TryCloseAll then |
388 |
begin |
389 |
CloseDataConnection; |
390 |
opend.InitialDir := AppSettings.DatPath; |
391 |
opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*'; |
392 |
if typedb then |
393 |
opend.FilterIndex := 3 |
394 |
else |
395 |
opend.FilterIndex := 2; |
396 |
if opend.Execute then |
397 |
begin |
398 |
ext := ExtractFileExt(opend.FileName); |
399 |
if ext = '.dat' then |
400 |
begin |
401 |
if not CreateDataConnection(opend.FileName, ODB_Dat) then |
402 |
ShowMessage('Error while loading the file:' + CrLf + opend.FileName + |
403 |
CrLf + 'Perhaps not an Oni-.dat-file?'); |
404 |
end else if ext = '.oldb' then |
405 |
begin |
406 |
if not CreateDataConnection(opend.FileName, ODB_ADB) then |
407 |
ShowMessage('Error while loading the file:' + CrLf + opend.FileName + |
408 |
CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?'); |
409 |
end else |
410 |
ShowMessage('Incompatible file'); |
411 |
AppSettings.DatPath := ExtractFilepath(opend.FileName); |
412 |
end; |
413 |
end; |
414 |
UpdateStatBar; |
415 |
end; |
416 |
|
417 |
|
418 |
{#################################} |
419 |
{##### Main-Menu-Handlers #####} |
420 |
{#################################} |
421 |
procedure TForm_Main.menu_loaddbClick(Sender: TObject); |
422 |
begin |
423 |
LoadFile(True); |
424 |
end; |
425 |
|
426 |
procedure TForm_Main.menu_loadfileClick(Sender: TObject); |
427 |
begin |
428 |
LoadFile(False); |
429 |
end; |
430 |
|
431 |
|
432 |
|
433 |
|
434 |
procedure TForm_Main.menu_settingsClick(Sender: TObject); |
435 |
begin |
436 |
Form_Settings.Visible := True; |
437 |
Self.Enabled := False; |
438 |
end; |
439 |
|
440 |
|
441 |
|
442 |
|
443 |
procedure TForm_Main.menu_exitClick(Sender: TObject); |
444 |
begin |
445 |
Self.Close; |
446 |
end; |
447 |
|
448 |
{####################################} |
449 |
{##### Converters-Menu-Handlers #####} |
450 |
{####################################} |
451 |
procedure TForm_Main.menu_createdbClick(Sender: TObject); |
452 |
begin |
453 |
if Assigned(OniDataConnection) then |
454 |
if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' + |
455 |
'Do you want to close it to continue?'), PChar('Close file?'), |
456 |
MB_YESNO + MB_ICONQUESTION) = ID_NO then |
457 |
Exit |
458 |
else begin |
459 |
if TryCloseAll then |
460 |
begin |
461 |
CloseDataConnection; |
462 |
UpdateStatBar; |
463 |
end else |
464 |
Exit; |
465 |
end; |
466 |
opend.Filter := 'Oni-Dat-Files|*.dat'; |
467 |
saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
468 |
saved.DefaultExt := 'oldb'; |
469 |
if opend.Execute then |
470 |
if saved.Execute then |
471 |
Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName); |
472 |
end; |
473 |
|
474 |
|
475 |
|
476 |
|
477 |
procedure TForm_Main.menu_createlvlClick(Sender: TObject); |
478 |
begin |
479 |
if Assigned(OniDataConnection) then |
480 |
if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' + |
481 |
'Do you want to close it to continue?'), PChar('Close file?'), |
482 |
MB_YESNO + MB_ICONQUESTION) = ID_NO then |
483 |
Exit |
484 |
else begin |
485 |
if TryCloseAll then |
486 |
begin |
487 |
CloseDataConnection; |
488 |
UpdateStatBar; |
489 |
end else |
490 |
Exit; |
491 |
end; |
492 |
opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; |
493 |
saved.Filter := 'Oni-Dat-Files|*.dat'; |
494 |
saved.DefaultExt := 'dat'; |
495 |
if opend.Execute then |
496 |
if saved.Execute then |
497 |
Form_LevelDB.CreateLevel(opend.FileName, saved.FileName); |
498 |
end; |
499 |
|
500 |
{#################################} |
501 |
{##### Tools-Menu-Handlers #####} |
502 |
{#################################} |
503 |
procedure TForm_Main.menu_previewClick(Sender: TObject); |
504 |
begin |
505 |
open_child('preview', -1); |
506 |
end; |
507 |
|
508 |
|
509 |
procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); |
510 |
begin |
511 |
open_child('txmpreplace', -1); |
512 |
end; |
513 |
|
514 |
|
515 |
procedure TForm_Main.menu_bineditClick(Sender: TObject); |
516 |
begin |
517 |
open_child('binedit', -1); |
518 |
end; |
519 |
|
520 |
|
521 |
procedure TForm_Main.menu_raweditClick(Sender: TObject); |
522 |
begin |
523 |
open_child('rawedit', -1); |
524 |
end; |
525 |
|
526 |
|
527 |
procedure TForm_Main.menu_extractorClick(Sender: TObject); |
528 |
begin |
529 |
open_child('extractor', -1); |
530 |
end; |
531 |
|
532 |
|
533 |
procedure TForm_Main.menu_metaClick(Sender: TObject); |
534 |
begin |
535 |
ShowMessage('TBD'); |
536 |
end; |
537 |
|
538 |
|
539 |
procedure TForm_Main.menu_filecompareClick(Sender: TObject); |
540 |
begin |
541 |
open_child('compare', -1); |
542 |
end; |
543 |
|
544 |
|
545 |
{#################################} |
546 |
{##### View-Menu-Handlers #####} |
547 |
{#################################} |
548 |
procedure TForm_Main.menu_view_mdibarClick(Sender: TObject); |
549 |
begin |
550 |
menu_view_mdibar.Checked := not menu_view_mdibar.Checked; |
551 |
mditoolbar.Visible := menu_view_mdibar.Checked; |
552 |
end; |
553 |
|
554 |
|
555 |
|
556 |
|
557 |
procedure TForm_Main.menu_view_statusbarClick(Sender: TObject); |
558 |
begin |
559 |
menu_view_statusbar.Checked := not menu_view_statusbar.Checked; |
560 |
statbar.Visible := menu_view_statusbar.Checked; |
561 |
end; |
562 |
|
563 |
|
564 |
|
565 |
|
566 |
procedure TForm_Main.menu_view_toolbarClick(Sender: TObject); |
567 |
begin |
568 |
menu_view_toolbar.Checked := not menu_view_toolbar.Checked; |
569 |
Toolbar.Visible := menu_view_toolbar.Checked; |
570 |
end; |
571 |
|
572 |
|
573 |
|
574 |
{#################################} |
575 |
{##### Window-Menu-Handlers #####} |
576 |
{#################################} |
577 |
procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject); |
578 |
begin |
579 |
Self.Cascade; |
580 |
end; |
581 |
|
582 |
|
583 |
|
584 |
procedure TForm_Main.menu_windows_tileClick(Sender: TObject); |
585 |
begin |
586 |
Self.TileMode := tbHorizontal; |
587 |
Self.Tile; |
588 |
end; |
589 |
|
590 |
procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject); |
591 |
begin |
592 |
Self.TileMode := tbVertical; |
593 |
Self.Tile; |
594 |
end; |
595 |
|
596 |
|
597 |
procedure TForm_Main.menu_windows_closeallClick(Sender: TObject); |
598 |
begin |
599 |
MDITab.CloseAll; |
600 |
end; |
601 |
|
602 |
|
603 |
|
604 |
procedure TForm_Main.menu_windows_nextClick(Sender: TObject); |
605 |
begin |
606 |
if MDIChildCount > 1 then |
607 |
if MDITab.TabIndex = MDITab.MDIChildCount - 1 then |
608 |
MDITab.MDIChildren[0].BringToFront |
609 |
else |
610 |
MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront; |
611 |
end; |
612 |
|
613 |
|
614 |
|
615 |
procedure TForm_Main.menu_windows_previousClick(Sender: TObject); |
616 |
begin |
617 |
if MDIChildCount > 1 then |
618 |
if MDITab.TabIndex = 0 then |
619 |
MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront |
620 |
else |
621 |
MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront; |
622 |
end; |
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
procedure TForm_Main.menu_AboutClick(Sender: TObject); |
630 |
begin |
631 |
ShowMessage('Will be implemented later ;)'); |
632 |
end; |
633 |
|
634 |
|
635 |
|
636 |
|
637 |
function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate; |
638 |
var |
639 |
toolform: TForm_ToolTemplate; |
640 |
i: Integer; |
641 |
tag: Integer; |
642 |
caption_end: String; |
643 |
iconindex: Integer; |
644 |
begin |
645 |
Result := nil; |
646 |
|
647 |
tag := 1; |
648 |
if MDIChildCount > 0 then |
649 |
for i := 0 to MDIChildCount - 1 do |
650 |
if MDIChildren[i].Tag >= tag then |
651 |
tag := MDIChildren[i].Tag + 1; |
652 |
|
653 |
iconindex := -1; |
654 |
caption_end := IntToStr(tag) + ' '; |
655 |
|
656 |
if window_context = 'binedit' then |
657 |
begin |
658 |
toolform := TForm_BinEdit.Create(Self); |
659 |
toolform.Caption := 'Binary .dat-Editor ' + caption_end; |
660 |
iconindex := 5; |
661 |
end; |
662 |
if window_context = 'extractor' then |
663 |
begin |
664 |
toolform := TForm_Extractor.Create(Self); |
665 |
toolform.Caption := 'Extractor ' + caption_end; |
666 |
iconindex := 8; |
667 |
end; |
668 |
if window_context = 'preview' then |
669 |
begin |
670 |
toolform := TForm_Preview.Create(Self); |
671 |
toolform.Caption := 'Preview-Window ' + caption_end; |
672 |
iconindex := 4; |
673 |
end; |
674 |
if window_context = 'rawedit' then |
675 |
begin |
676 |
toolform := TForm_RawEdit.Create(Self); |
677 |
toolform.Caption := 'Binary .raw-Editor ' + caption_end; |
678 |
iconindex := 6; |
679 |
end; |
680 |
if window_context = 'txmpreplace' then |
681 |
begin |
682 |
toolform := TForm_TxmpReplace.Create(Application); |
683 |
toolform.Caption := 'TXMP Replacer ' + caption_end; |
684 |
iconindex := 7; |
685 |
end; |
686 |
|
687 |
if Assigned(toolform) then |
688 |
begin |
689 |
toolform.Name := window_context + IntToStr(tag); |
690 |
toolform.Tag := tag; |
691 |
MDITab.AddTab(TForm(toolform), iconindex); |
692 |
toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); |
693 |
if fileid > -1 then |
694 |
toolform.SelectFileID(fileid); |
695 |
Result := toolform; |
696 |
end; |
697 |
end; |
698 |
|
699 |
end. |