source: oup/current/Main.pas@ 110

Last change on this file since 110 was 105, checked in by alloc, 18 years ago
File size: 22.2 KB
Line 
1unit Main;
2interface
3uses
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
6 MPHexEditor, ToolWin, ImgList, Tabs,
7 MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst,
8 Data, TypeDefs, ConnectionManager,
9// Functions, Exporters, DataStructures,
10 Functions,
11 Settings, {Helper_LevelDB, }
12 Template,
13 RawEdit, BinEdit, Extractor, Preview, TxmpReplace;
14
15type
16 TForm_Main = class(TForm)
17 saved: TSaveDialog;
18 opend: TOpenDialog;
19 statbar: TStatusBar;
20 MenuImages: TImageList;
21 DockTop: TTBDock;
22 MainMenu: TTBToolbar;
23 menu_main: TTBSubmenuItem;
24 menu_loadfile: TTBItem;
25 menu_sep1: TTBSeparatorItem;
26 menu_settings: TTBItem;
27 menu_sep4: TTBSeparatorItem;
28 menu_exit: TTBItem;
29 menu_convert: TTBSubmenuItem;
30 menu_createdb: TTBItem;
31 menu_createlvl: TTBItem;
32 menu_tools: TTBSubmenuItem;
33 menu_preview: TTBItem;
34 menu_binedit: TTBItem;
35 menu_rawedit: TTBItem;
36 menu_txmpreplace: TTBItem;
37 menu_extractor: TTBItem;
38 menu_filecompare: TTBItem;
39 menu_levelstructedit: TTBItem;
40 menu_view: TTBSubmenuItem;
41 menu_windows_cascade: TTBItem;
42 menu_windows_tile: TTBItem;
43 menu_windows_closeall: TTBItem;
44 menu_sep3: TTBSeparatorItem;
45 menu_windows_next: TTBItem;
46 menu_windows_previous: TTBItem;
47 menu_sep2: TTBSeparatorItem;
48 menu_About: TTBItem;
49 Toolbar: TTBToolbar;
50 tbOpen: TTBItem;
51 DockLeft: TTBDock;
52 DockRight: TTBDock;
53 DockBottom: TTBDock;
54 MDIToolbar: TTBToolbar;
55 TBControlItem1: TTBControlItem;
56 MDITab: TMDITab;
57 menu_toolbars: TTBSubmenuItem;
58 menu_view_mdibar: TTBItem;
59 menu_view_statusbar: TTBItem;
60 menu_view_toolbar: TTBItem;
61 tb_separator1: TTBSeparatorItem;
62 tb_preview: TTBItem;
63 tb_structure: TTBItem;
64 tb_compare: TTBItem;
65 tb_extractor: TTBItem;
66 tb_txmpreplacer: TTBItem;
67 tb_rawedit: TTBItem;
68 tb_datedit: TTBItem;
69 menu_windows_tilevert: TTBItem;
70 tb_meta: TTBItem;
71 menu_meta: TTBItem;
72 TBSeparatorItem1: TTBSeparatorItem;
73 tb_db2dat: TTBItem;
74 tb_dat2db: TTBItem;
75 menu_loaddb: TTBItem;
76 tb_opendb: TTBItem;
77 Images_Close: TImageList;
78 menu_conns: TTBSubmenuItem;
79 menu_windows: TTBSubmenuItem;
80 procedure FormClose(Sender: TObject; var Action: TCloseAction);
81 procedure FormResize(Sender: TObject);
82 procedure FormCreate(Sender: TObject);
83 procedure ActivateTools(active: Boolean);
84 procedure UpdateStatBar;
85 procedure UpdateConLists;
86 procedure LoadFile(typedb: Boolean);
87 function TryCloseAll: Boolean;
88 procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
89 const Rect: TRect; Active: Boolean);
90 procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
91 Shift: TShiftState; X, Y: Integer);
92 procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
93 Y: Integer);
94 procedure ToolbarDockChanged(Sender: TObject);
95 procedure CreateConnection(filename: String);
96 function CheckConnectionCloseable(index: Integer): Boolean;
97
98 procedure menu_loadfileClick(Sender: TObject);
99 procedure menu_loaddbClick(Sender: TObject);
100 procedure menu_settingsClick(Sender: TObject);
101 procedure menu_exitClick(Sender: TObject);
102
103 procedure menu_createlvlClick(Sender: TObject);
104 procedure menu_createdbClick(Sender: TObject);
105
106 procedure menu_bineditClick(Sender: TObject);
107 procedure menu_filecompareClick(Sender: TObject);
108 procedure menu_raweditClick(Sender: TObject);
109 procedure menu_extractorClick(Sender: TObject);
110 procedure menu_txmpreplaceClick(Sender: TObject);
111 procedure menu_previewClick(Sender: TObject);
112 procedure menu_metaClick(Sender: TObject);
113 function open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
114
115 procedure menu_windows_cascadeClick(Sender: TObject);
116 procedure menu_windows_tilevertClick(Sender: TObject);
117 procedure menu_windows_tileClick(Sender: TObject);
118 procedure menu_windows_closeallClick(Sender: TObject);
119 procedure menu_windows_previousClick(Sender: TObject);
120 procedure menu_windows_nextClick(Sender: TObject);
121 procedure menu_conns_itemClick(Sender: TObject);
122 procedure menu_windows_itemClick(Sender: TObject);
123 procedure menu_view_mdibarClick(Sender: TObject);
124 procedure menu_view_statusbarClick(Sender: TObject);
125 procedure menu_view_toolbarClick(Sender: TObject);
126
127 procedure menu_AboutClick(Sender: TObject);
128
129 procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
130 private
131 public
132 procedure DefaultHandler(var Message); override;
133 end;
134
135var
136 Form_Main: TForm_Main;
137
138implementation
139
140{$R *.dfm}
141
142
143procedure ShowOpenMsg(msg: TStatusMessages);
144begin
145 case msg of
146 SM_AlreadyOpened: ShowMessage('File already opened.');
147 SM_FileNotFound: ShowMessage('File not found.');
148 SM_UnknownExtension: ShowMessage('Unknown extension.');
149 SM_IncompatibleFile: ShowMessage('Incompatible file format.');
150 SM_UnknownError: ShowMessage('Unknown error.');
151 end;
152end;
153
154procedure TForm_Main.CreateConnection(filename: String);
155var
156 RepMsg: TStatusMessages;
157begin
158 ConManager.OpenConnection(filename, RepMsg);
159 ShowOpenMsg(RepMsg);
160 if RepMsg = SM_OK then
161 begin
162 UpdateStatBar;
163 UpdateConLists;
164 end;
165end;
166
167function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean;
168var
169 i: Integer;
170 toolform: TForm_ToolTemplate;
171begin
172 if MDITab.MDIChildCount > 0 then
173 begin
174 for i := 0 to MDITab.MDIChildCount - 1 do
175 begin
176 if MDITab.MDIChildren[i] is TForm_ToolTemplate then
177 begin
178 toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]);
179 if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
180 begin
181 if not toolform.Closeable then
182 ShowMessage('Can not close toolwindow: ' + toolform.Caption);
183 end;
184 end;
185 end;
186 end;
187end;
188
189
190{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt }
191procedure TForm_Main.WMCopyData(var Msg: TWMCopyData);
192var
193 strings: TStringList;
194begin
195 if (Msg.CopyDataStruct.dwData = SecondInstMsgId) and (SecondInstMsgId <> 0) then
196 begin
197 Application.BringToFront;
198
199 strings := TStringList.Create;
200 strings.Text := ParamBlobToStr(Msg.CopyDataStruct.lpData);
201 if strings.Count = 2 then
202 begin
203 if strings.Strings[0] = 'opf' then
204 begin
205 ShowMessage('Load OPF-File: ' + ParamStr(2));
206 end
207 else if (strings.Strings[0] = 'oldb') or (strings.Strings[0] = 'dat') then
208 begin
209 CreateConnection(strings.Strings[1]);
210 end;
211 end;
212 end
213 else
214 inherited;
215end;
216
217{----------------------------------------------------------------------------}
218{ Wir überschreiben den DefaultHandler, der alle Nachrichten zuerst bekommt, }
219{ damit wir auf die Nachricht mit der ID SecondInstMsgId reagieren können. }
220{ (Dies ist notwendig, da wir jetzt noch nicht wissen welchen Wert }
221{ die ID haben wird, weswegen wir keine statische Message-Prozedure, }
222{ so wie bei WM_COPYDATA, schreiben können.) }
223{----------------------------------------------------------------------------}
224procedure TForm_Main.DefaultHandler(var Message);
225begin
226 if TMessage(Message).Msg = SecondInstMsgId then
227 { Eine zweite Instanz hat uns nach dem Handle gefragt }
228 { Es wird in die Message-Queue des Threads gepostet. }
229 PostThreadMessage(TMessage(Message).WParam, SecondInstMsgId, Handle, 0)
230 else
231 inherited;
232end;
233
234
235
236procedure TForm_Main.FormCreate(Sender: TObject);
237var
238 RepMsg: TStatusMessages;
239begin
240 Self.Caption := 'Oni Un/Packer ' + version;
241 Self.FormResize(Self);
242
243 ConManager.OnCoonnectionListChanged := UpdateConLists;
244
245 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
246 begin
247 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
248 '\oniunpacker.ini');
249 Reset(AppSettingsFile);
250 Read(AppSettingsFile, AppSettings);
251 CloseFile(AppSettingsFile);
252 end
253 else
254 begin
255 AppSettings.DatPath := ExtractFilepath(Application.EXEname);
256 AppSettings.ExtractPath := ExtractFilepath(Application.EXEname) + '\extract';
257 AppSettings.FilenumbersAsHex := False;
258 AppSettings.CharSet := DEFAULT_CHARSET;
259 AppSettings.HideUnusedData := False;
260 end;
261
262 if MidStr(ParamStr(1), 1, 3) = 'opf' then
263 begin
264 ShowMessage('Load OPF-File: ' + ParamStr(2));
265 end
266 else if (MidStr(ParamStr(1), 1, 4) = 'oldb') or (MidStr(ParamStr(1), 1, 3) = 'dat') then
267 begin
268 CreateConnection(ParamStr(2));
269 end;
270 UpdateStatBar;
271end;
272
273
274
275
276procedure TForm_Main.FormResize(Sender: TObject);
277begin
278 statbar.Panels.Items[0].Width := Self.Width - 200;
279 MDITab.Width := Self.Width - 20;
280end;
281
282
283
284
285procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
286 TabIndex: Integer; const Rect: TRect; Active: Boolean);
287var
288 x, y: Integer;
289 iconindex: Integer;
290 caption: String;
291begin
292 iconindex := TMDITab(Control).Glyphs[TabIndex];
293 caption := TMDITab(Control).Captions[TabIndex];
294 if active then
295 begin
296 Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
297 y := Rect.Top + 1;
298 end else
299 y := Rect.Top;
300 if iconindex >= 0 then
301 begin
302 TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
303 x := Rect.Left + 26;
304 end else
305 x := Rect.Left + 4;
306 Control.Canvas.TextOut(x, y + 2, caption);
307 if active then
308 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 0)
309 else
310 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 1);
311end;
312
313
314procedure TForm_Main.MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
315 Y: Integer);
316var
317 pt: TPoint;
318 tabIndex: Integer;
319 hint: String;
320 tool: TForm_ToolTemplate;
321begin
322 pt.X := X;
323 pt.Y := Y;
324 tabIndex := MDITab.GetTabAtPos(pt);
325 hint := '';
326
327 if tabIndex >= 0 then
328 begin
329 if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
330 begin
331 tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]);
332 if tool.ConnectionID > -1 then
333 hint := 'Connection: ' +
334 ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10
335 else
336 hint := 'Connection: none' + #13+#10;
337 if tool.SelectedFile.ID > -1 then
338 hint := hint + 'Selected File: ' +
339 FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' +
340 tool.SelectedFile.Name + '.' +
341 tool.SelectedFile.Extension
342 else
343 hint := hint + 'Selected File: none';
344 end
345 else
346 hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption;
347 if hint <> MDITab.Hint then
348 begin
349 MDITab.Hint := hint;
350 MDITab.ShowHint := True;
351 end;
352 end
353 else
354 begin
355 MDITab.ShowHint := False;
356 MDITab.Hint := '';
357 end;
358end;
359
360procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
361 Shift: TShiftState; X, Y: Integer);
362var
363 pt: TPoint;
364 tabIndex: Integer;
365 tabRect: TRect;
366 tabX, tabY, tabWidth: Integer;
367begin
368 pt.X := X;
369 pt.Y := Y;
370 tabIndex := MDITab.GetTabAtPos(pt);
371
372// if (Button = mbRight) and (tabIndex >= 0) then
373// MDITab.MDIChildren[tabIndex].Close;
374
375 if (Button = mbLeft) and (tabIndex >= 0) then
376 begin
377 tabrect := MDITab.TabRect(tabIndex);
378 tabX := X - tabrect.Left;
379 tabY := Y - tabrect.Top;
380 tabwidth := tabrect.Right - tabrect.Left;
381 if (tabY >= 4) and (tabY <= 17) then
382 if (tabX >= tabwidth - 19) and (tabX <= tabwidth - 7) then
383 MDITab.MDIChildren[tabIndex].Close;
384 end;
385end;
386
387
388
389
390procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
391begin
392 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
393 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
394 Reset(AppSettingsFile)
395 else
396 Rewrite(AppSettingsFile);
397 Write(AppSettingsFile, AppSettings);
398 CloseFile(AppSettingsFile);
399 Action := caFree;
400end;
401
402
403
404procedure TForm_Main.ActivateTools(active: Boolean);
405begin
406 menu_tools.Enabled := active;
407 tb_preview.Enabled := active;
408 tb_datedit.Enabled := active;
409 tb_rawedit.Enabled := active;
410 tb_txmpreplacer.Enabled := active;
411 tb_extractor.Enabled := active;
412// tb_compare.Enabled := active;
413// tb_structure.Enabled := active;
414end;
415
416procedure TForm_Main.UpdateStatBar;
417begin
418 if ConManager.Count > 0 then
419 begin
420 Self.Caption := 'Oni Un/Packer ' + version;
421 ActivateTools(True);
422 statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count);
423 end
424 else
425 begin
426 Self.Caption := 'Oni Un/Packer ' + version;
427 statbar.Panels.Items[0].Text := '';
428 statbar.Panels.Items[1].Text := 'Connections: -';
429 statbar.Panels.Items[2].Text := '';
430 ActivateTools(False);
431 end;
432 menu_conns.Enabled := ConManager.Count > 0;
433end;
434
435
436
437
438procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
439var
440 toolbar: TTBToolbar;
441 position: TTBDockPosition;
442 mode: TTBItemDisplayMode;
443 i: Integer;
444 isEnabled: Boolean;
445begin
446 toolbar := TTBToolbar(Sender);
447 if toolbar.Floating then
448 mode := nbdmImageAndText
449 else begin
450 position := toolbar.CurrentDock.Position;
451 if position in [dpLeft, dpRight] then
452 mode := nbdmDefault
453 else
454 mode := nbdmImageAndText;
455 end;
456 for i := 0 to toolbar.Items.Count - 1 do
457 toolbar.Items.Items[i].DisplayMode := mode;
458end;
459
460function TForm_Main.TryCloseAll: Boolean;
461begin
462 menu_windows_closeallClick(Self);
463 Application.ProcessMessages;
464 if MDITab.MDIChildCount = 0 then
465 Result := True
466 else
467 Result := False;
468end;
469
470
471procedure TForm_Main.UpdateConLists;
472var
473 i: Integer;
474 entry: TTBItem;
475begin
476 if MDITab.MDIChildCount > 0 then
477 for i := 0 to MDITab.MDIChildCount - 1 do
478 if MDITab.MDIChildren[i] is TForm_ToolTemplate then
479 TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateConList;
480
481 menu_conns.Clear;
482 if ConManager.Count > 0 then
483 begin
484 for i := 0 to ConManager.Count - 1 do
485 begin
486 entry := TTBItem.Create(menu_conns);
487 entry.Caption := ExtractFileName(ConManager.ConnectionByIndex[i].FileName);
488 entry.Name := 'menu_conn_' + IntToStr(i);
489 entry.OnClick := menu_conns_itemClick;
490 menu_conns.Add(entry);
491 entry := nil;
492 end;
493 end;
494end;
495
496
497procedure TForm_Main.LoadFile(typedb: Boolean);
498var
499 i: Integer;
500begin
501 opend.InitialDir := AppSettings.DatPath;
502 opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
503 if typedb then
504 opend.FilterIndex := 3
505 else
506 opend.FilterIndex := 2;
507 if opend.Execute then
508 begin
509 if opend.Files.Count > 0 then
510 for i := 0 to opend.Files.Count - 1 do
511 CreateConnection(opend.Files.Strings[i]);
512 AppSettings.DatPath := ExtractFilepath(opend.FileName);
513 end;
514 UpdateStatBar;
515end;
516
517
518 {#################################}
519 {##### Main-Menu-Handlers #####}
520 {#################################}
521procedure TForm_Main.menu_loaddbClick(Sender: TObject);
522begin
523 LoadFile(True);
524end;
525
526procedure TForm_Main.menu_loadfileClick(Sender: TObject);
527begin
528 LoadFile(False);
529end;
530
531
532procedure TForm_Main.menu_settingsClick(Sender: TObject);
533begin
534 Form_Settings.Visible := True;
535 Self.Enabled := False;
536end;
537
538
539procedure TForm_Main.menu_exitClick(Sender: TObject);
540begin
541 Self.Close;
542end;
543
544
545 {####################################}
546 {##### Converters-Menu-Handlers #####}
547 {####################################}
548procedure TForm_Main.menu_createdbClick(Sender: TObject);
549begin
550 ShowMessage('Not yet usable');
551{
552 opend.Filter := 'Oni-Dat-Files|*.dat';
553 saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
554 saved.DefaultExt := 'oldb';
555 if opend.Execute then
556 if saved.Execute then
557 Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
558}
559end;
560
561
562procedure TForm_Main.menu_createlvlClick(Sender: TObject);
563begin
564 ShowMessage('Not yet usable');
565{
566 opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
567 saved.Filter := 'Oni-Dat-Files|*.dat';
568 saved.DefaultExt := 'dat';
569 if opend.Execute then
570 if saved.Execute then
571 Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
572}
573end;
574
575
576 {#################################}
577 {##### Tools-Menu-Handlers #####}
578 {#################################}
579procedure TForm_Main.menu_previewClick(Sender: TObject);
580begin
581 open_child('preview', -1, -1);
582end;
583
584procedure TForm_Main.menu_bineditClick(Sender: TObject);
585begin
586 open_child('binedit', -1, -1);
587end;
588
589procedure TForm_Main.menu_raweditClick(Sender: TObject);
590begin
591 open_child('rawedit', -1, -1);
592end;
593
594procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
595begin
596 open_child('txmpreplace', -1, -1);
597end;
598
599procedure TForm_Main.menu_extractorClick(Sender: TObject);
600begin
601 open_child('extractor', -1, -1);
602end;
603
604procedure TForm_Main.menu_metaClick(Sender: TObject);
605begin
606 ShowMessage('TBD');
607end;
608
609procedure TForm_Main.menu_filecompareClick(Sender: TObject);
610begin
611 open_child('compare', -1, -1);
612end;
613
614
615 {#################################}
616 {##### View-Menu-Handlers #####}
617 {#################################}
618procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
619begin
620 Self.Cascade;
621end;
622
623procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
624begin
625 Self.TileMode := tbVertical;
626 Self.Tile;
627end;
628
629procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
630begin
631 Self.TileMode := tbHorizontal;
632 Self.Tile;
633end;
634
635procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
636begin
637 MDITab.CloseAll;
638end;
639
640procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
641begin
642 if MDIChildCount > 1 then
643 if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
644 MDITab.MDIChildren[0].BringToFront
645 else
646 MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
647end;
648
649procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
650begin
651 if MDIChildCount > 1 then
652 if MDITab.TabIndex = 0 then
653 MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
654 else
655 MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
656end;
657
658
659 {##################################}
660 {##### Windows-Menu-Handlers #####}
661 {##################################}
662procedure TForm_Main.menu_windows_itemClick(Sender: TObject);
663var
664 name: String;
665begin
666 name := TTBItem(Sender).Name;
667end;
668
669
670
671 {######################################}
672 {##### Connections-Menu-Handlers #####}
673 {######################################}
674procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
675var
676 name: String;
677 i: Integer;
678 index: Integer;
679 RepMsg: TStatusMessages;
680begin
681// name := TTBItem(Sender).Caption;
682 index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender));
683 name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName);
684 if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
685 name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
686 begin
687 CheckConnectionCloseable(index);
688 ConManager.CloseConnectionByIndex(index, RepMsg);
689 ShowOpenMsg(RepMsg);
690 UpdateConLists;
691 end;
692 UpdateStatBar;
693end;
694
695
696 {###################################}
697 {##### Toolbars-Menu-Handlers #####}
698 {###################################}
699procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
700begin
701 menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
702 Toolbar.Visible := menu_view_toolbar.Checked;
703end;
704
705procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
706begin
707 menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
708 statbar.Visible := menu_view_statusbar.Checked;
709end;
710
711procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
712begin
713 menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
714 mditoolbar.Visible := menu_view_mdibar.Checked;
715end;
716
717
718
719procedure TForm_Main.menu_AboutClick(Sender: TObject);
720begin
721 ShowMessage('Will be implemented later ;)');
722end;
723
724
725
726
727
728function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
729var
730 toolform: TForm_ToolTemplate;
731 i: Integer;
732 tag: Integer;
733 caption_end: String;
734 iconindex: Integer;
735begin
736 Result := nil;
737
738 tag := 1;
739 if MDIChildCount > 0 then
740 for i := 0 to MDIChildCount - 1 do
741 if MDIChildren[i].Tag >= tag then
742 tag := MDIChildren[i].Tag + 1;
743
744 iconindex := -1;
745 caption_end := IntToStr(tag) + ' ';
746
747 if window_context = 'binedit' then
748 begin
749 toolform := TForm_BinEdit.Create(Self);
750 toolform.Caption := 'Binary .dat-Editor ' + caption_end;
751 iconindex := 5;
752 end;
753 if window_context = 'extractor' then
754 begin
755 toolform := TForm_Extractor.Create(Self);
756 toolform.Caption := 'Extractor ' + caption_end;
757 iconindex := 8;
758 end;
759 if window_context = 'preview' then
760 begin
761 toolform := TForm_Preview.Create(Self);
762 toolform.Caption := 'Preview-Window ' + caption_end;
763 iconindex := 4;
764 end;
765 if window_context = 'rawedit' then
766 begin
767 toolform := TForm_RawEdit.Create(Self);
768 toolform.Caption := 'Binary .raw-Editor ' + caption_end;
769 iconindex := 6;
770 end;
771 if window_context = 'txmpreplace' then
772 begin
773 toolform := TForm_TxmpReplace.Create(Self);
774 toolform.Caption := 'TXMP Replacer ' + caption_end;
775 iconindex := 7;
776 end;
777
778 if Assigned(toolform) then
779 begin
780 toolform.Name := window_context + IntToStr(tag);
781 toolform.Tag := tag;
782 MDITab.AddTab(TForm(toolform), iconindex);
783 toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', '');
784 if connection > -1 then
785 begin
786 toolform.SelectConnection(connection);
787 if fileid > -1 then
788 toolform.SelectFileID(connection, fileid);
789 end;
790 Result := toolform;
791 end;
792end;
793
794end.
Note: See TracBrowser for help on using the repository browser.