source: oup/rewrite/Main.pas@ 101

Last change on this file since 101 was 97, checked in by alloc, 18 years ago
File size: 22.3 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 Preview;
14// BinEdit, Extractor, RawEdit, TxmpReplace;
15
16type
17 TForm_Main = class(TForm)
18 saved: TSaveDialog;
19 opend: TOpenDialog;
20 statbar: TStatusBar;
21 MenuImages: TImageList;
22 DockTop: TTBDock;
23 MainMenu: TTBToolbar;
24 menu_main: TTBSubmenuItem;
25 menu_loadfile: TTBItem;
26 menu_sep1: TTBSeparatorItem;
27 menu_settings: TTBItem;
28 menu_sep4: TTBSeparatorItem;
29 menu_exit: TTBItem;
30 menu_convert: TTBSubmenuItem;
31 menu_createdb: TTBItem;
32 menu_createlvl: TTBItem;
33 menu_tools: TTBSubmenuItem;
34 menu_preview: TTBItem;
35 menu_binedit: TTBItem;
36 menu_rawedit: TTBItem;
37 menu_txmpreplace: TTBItem;
38 menu_extractor: TTBItem;
39 menu_filecompare: TTBItem;
40 menu_levelstructedit: TTBItem;
41 menu_view: TTBSubmenuItem;
42 menu_windows_cascade: TTBItem;
43 menu_windows_tile: TTBItem;
44 menu_windows_closeall: TTBItem;
45 menu_sep3: TTBSeparatorItem;
46 menu_windows_next: TTBItem;
47 menu_windows_previous: TTBItem;
48 menu_sep2: TTBSeparatorItem;
49 menu_About: TTBItem;
50 Toolbar: TTBToolbar;
51 tbOpen: TTBItem;
52 DockLeft: TTBDock;
53 DockRight: TTBDock;
54 DockBottom: TTBDock;
55 MDIToolbar: TTBToolbar;
56 TBControlItem1: TTBControlItem;
57 MDITab: TMDITab;
58 menu_toolbars: TTBSubmenuItem;
59 menu_view_mdibar: TTBItem;
60 menu_view_statusbar: TTBItem;
61 menu_view_toolbar: TTBItem;
62 tb_separator1: TTBSeparatorItem;
63 tb_preview: TTBItem;
64 tb_structure: TTBItem;
65 tb_compare: TTBItem;
66 tb_extractor: TTBItem;
67 tb_txmpreplacer: TTBItem;
68 tb_rawedit: TTBItem;
69 tb_datedit: TTBItem;
70 menu_windows_tilevert: TTBItem;
71 tb_meta: TTBItem;
72 menu_meta: TTBItem;
73 TBSeparatorItem1: TTBSeparatorItem;
74 tb_db2dat: TTBItem;
75 tb_dat2db: TTBItem;
76 menu_loaddb: TTBItem;
77 tb_opendb: TTBItem;
78 Images_Close: TImageList;
79 menu_conns: TTBSubmenuItem;
80 menu_windows: TTBSubmenuItem;
81 procedure FormClose(Sender: TObject; var Action: TCloseAction);
82 procedure FormResize(Sender: TObject);
83 procedure FormCreate(Sender: TObject);
84 procedure ActivateTools(active: Boolean);
85 procedure UpdateStatBar;
86 procedure UpdateConLists;
87 procedure LoadFile(typedb: Boolean);
88 function TryCloseAll: Boolean;
89 procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
90 const Rect: TRect; Active: Boolean);
91 procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
92 Shift: TShiftState; X, Y: Integer);
93 procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
94 Y: Integer);
95 procedure ToolbarDockChanged(Sender: TObject);
96 procedure CreateConnection(filename: String);
97 function CheckConnectionCloseable(index: Integer): Boolean;
98
99 procedure menu_loadfileClick(Sender: TObject);
100 procedure menu_loaddbClick(Sender: TObject);
101 procedure menu_settingsClick(Sender: TObject);
102 procedure menu_exitClick(Sender: TObject);
103
104 procedure menu_createlvlClick(Sender: TObject);
105 procedure menu_createdbClick(Sender: TObject);
106
107 procedure menu_bineditClick(Sender: TObject);
108 procedure menu_filecompareClick(Sender: TObject);
109 procedure menu_raweditClick(Sender: TObject);
110 procedure menu_extractorClick(Sender: TObject);
111 procedure menu_txmpreplaceClick(Sender: TObject);
112 procedure menu_previewClick(Sender: TObject);
113 procedure menu_metaClick(Sender: TObject);
114 function open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
115
116 procedure menu_windows_cascadeClick(Sender: TObject);
117 procedure menu_windows_tilevertClick(Sender: TObject);
118 procedure menu_windows_tileClick(Sender: TObject);
119 procedure menu_windows_closeallClick(Sender: TObject);
120 procedure menu_windows_previousClick(Sender: TObject);
121 procedure menu_windows_nextClick(Sender: TObject);
122 procedure menu_conns_itemClick(Sender: TObject);
123 procedure menu_windows_itemClick(Sender: TObject);
124 procedure menu_view_mdibarClick(Sender: TObject);
125 procedure menu_view_statusbarClick(Sender: TObject);
126 procedure menu_view_toolbarClick(Sender: TObject);
127
128 procedure menu_AboutClick(Sender: TObject);
129
130 procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
131 private
132 public
133 procedure DefaultHandler(var Message); override;
134 end;
135
136var
137 Form_Main: TForm_Main;
138
139implementation
140
141{$R *.dfm}
142
143
144procedure ShowOpenMsg(msg: TStatusMessages);
145begin
146 case msg of
147 SM_AlreadyOpened: ShowMessage('File already opened.');
148 SM_FileNotFound: ShowMessage('File not found.');
149 SM_UnknownExtension: ShowMessage('Unknown extension.');
150 SM_IncompatibleFile: ShowMessage('Incompatible file format.');
151 SM_UnknownError: ShowMessage('Unknown error.');
152 end;
153end;
154
155procedure TForm_Main.CreateConnection(filename: String);
156var
157 RepMsg: TStatusMessages;
158begin
159 ConManager.OpenConnection(filename, RepMsg);
160 ShowOpenMsg(RepMsg);
161 if RepMsg = SM_OK then
162 begin
163 UpdateStatBar;
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 ext: String;
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 ext := ExtractFileExt(opend.FileName);
510 if ext = '.dat' then
511 begin
512 CreateConnection(opend.FileName);
513 end else if ext = '.oldb' then
514 begin
515 CreateConnection(opend.FileName);
516 end else
517 ShowMessage('Incompatible file');
518 AppSettings.DatPath := ExtractFilepath(opend.FileName);
519 end;
520 UpdateStatBar;
521end;
522
523
524 {#################################}
525 {##### Main-Menu-Handlers #####}
526 {#################################}
527procedure TForm_Main.menu_loaddbClick(Sender: TObject);
528begin
529 LoadFile(True);
530end;
531
532procedure TForm_Main.menu_loadfileClick(Sender: TObject);
533begin
534 LoadFile(False);
535end;
536
537
538procedure TForm_Main.menu_settingsClick(Sender: TObject);
539begin
540 Form_Settings.Visible := True;
541 Self.Enabled := False;
542end;
543
544
545procedure TForm_Main.menu_exitClick(Sender: TObject);
546begin
547 Self.Close;
548end;
549
550
551 {####################################}
552 {##### Converters-Menu-Handlers #####}
553 {####################################}
554procedure TForm_Main.menu_createdbClick(Sender: TObject);
555begin
556 ShowMessage('Not yet usable');
557{
558 opend.Filter := 'Oni-Dat-Files|*.dat';
559 saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
560 saved.DefaultExt := 'oldb';
561 if opend.Execute then
562 if saved.Execute then
563 Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
564}
565end;
566
567
568procedure TForm_Main.menu_createlvlClick(Sender: TObject);
569begin
570 ShowMessage('Not yet usable');
571{
572 opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
573 saved.Filter := 'Oni-Dat-Files|*.dat';
574 saved.DefaultExt := 'dat';
575 if opend.Execute then
576 if saved.Execute then
577 Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
578}
579end;
580
581
582 {#################################}
583 {##### Tools-Menu-Handlers #####}
584 {#################################}
585procedure TForm_Main.menu_previewClick(Sender: TObject);
586begin
587 open_child('preview', -1, -1);
588end;
589
590procedure TForm_Main.menu_bineditClick(Sender: TObject);
591begin
592 open_child('binedit', -1, -1);
593end;
594
595procedure TForm_Main.menu_raweditClick(Sender: TObject);
596begin
597 open_child('rawedit', -1, -1);
598end;
599
600procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
601begin
602 open_child('txmpreplace', -1, -1);
603end;
604
605procedure TForm_Main.menu_extractorClick(Sender: TObject);
606begin
607 open_child('extractor', -1, -1);
608end;
609
610procedure TForm_Main.menu_metaClick(Sender: TObject);
611begin
612 ShowMessage('TBD');
613end;
614
615procedure TForm_Main.menu_filecompareClick(Sender: TObject);
616begin
617 open_child('compare', -1, -1);
618end;
619
620
621 {#################################}
622 {##### View-Menu-Handlers #####}
623 {#################################}
624procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
625begin
626 Self.Cascade;
627end;
628
629procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
630begin
631 Self.TileMode := tbVertical;
632 Self.Tile;
633end;
634
635procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
636begin
637 Self.TileMode := tbHorizontal;
638 Self.Tile;
639end;
640
641procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
642begin
643 MDITab.CloseAll;
644end;
645
646procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
647begin
648 if MDIChildCount > 1 then
649 if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
650 MDITab.MDIChildren[0].BringToFront
651 else
652 MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
653end;
654
655procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
656begin
657 if MDIChildCount > 1 then
658 if MDITab.TabIndex = 0 then
659 MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
660 else
661 MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
662end;
663
664
665 {##################################}
666 {##### Windows-Menu-Handlers #####}
667 {##################################}
668procedure TForm_Main.menu_windows_itemClick(Sender: TObject);
669var
670 name: String;
671begin
672 name := TTBItem(Sender).Name;
673end;
674
675
676
677 {######################################}
678 {##### Connections-Menu-Handlers #####}
679 {######################################}
680procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
681var
682 name: String;
683 i: Integer;
684 index: Integer;
685 RepMsg: TStatusMessages;
686begin
687// name := TTBItem(Sender).Caption;
688 index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender));
689 name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName);
690 if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
691 name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
692 begin
693 CheckConnectionCloseable(index);
694 ConManager.CloseConnectionByIndex(index, RepMsg);
695 end;
696 UpdateStatBar;
697end;
698
699
700 {###################################}
701 {##### Toolbars-Menu-Handlers #####}
702 {###################################}
703procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
704begin
705 menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
706 Toolbar.Visible := menu_view_toolbar.Checked;
707end;
708
709procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
710begin
711 menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
712 statbar.Visible := menu_view_statusbar.Checked;
713end;
714
715procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
716begin
717 menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
718 mditoolbar.Visible := menu_view_mdibar.Checked;
719end;
720
721
722
723procedure TForm_Main.menu_AboutClick(Sender: TObject);
724begin
725 ShowMessage('Will be implemented later ;)');
726end;
727
728
729
730
731
732function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
733var
734 toolform: TForm_ToolTemplate;
735 i: Integer;
736 tag: Integer;
737 caption_end: String;
738 iconindex: Integer;
739begin
740 Result := nil;
741
742 tag := 1;
743 if MDIChildCount > 0 then
744 for i := 0 to MDIChildCount - 1 do
745 if MDIChildren[i].Tag >= tag then
746 tag := MDIChildren[i].Tag + 1;
747
748 iconindex := -1;
749 caption_end := IntToStr(tag) + ' ';
750
751 if window_context = 'binedit' then
752 begin
753// toolform := TForm_BinEdit.Create(Self);
754 toolform.Caption := 'Binary .dat-Editor ' + caption_end;
755 iconindex := 5;
756 end;
757 if window_context = 'extractor' then
758 begin
759// toolform := TForm_Extractor.Create(Self);
760 toolform.Caption := 'Extractor ' + caption_end;
761 iconindex := 8;
762 end;
763 if window_context = 'preview' then
764 begin
765 toolform := TForm_Preview.Create(Self);
766 toolform.Caption := 'Preview-Window ' + caption_end;
767 iconindex := 4;
768 end;
769 if window_context = 'rawedit' then
770 begin
771// toolform := TForm_RawEdit.Create(Self);
772 toolform.Caption := 'Binary .raw-Editor ' + caption_end;
773 iconindex := 6;
774 end;
775 if window_context = 'txmpreplace' then
776 begin
777// toolform := TForm_TxmpReplace.Create(Application);
778 toolform.Caption := 'TXMP Replacer ' + caption_end;
779 iconindex := 7;
780 end;
781
782 if Assigned(toolform) then
783 begin
784 toolform.Name := window_context + IntToStr(tag);
785 toolform.Tag := tag;
786 MDITab.AddTab(TForm(toolform), iconindex);
787 toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', '');
788 if connection > -1 then
789 begin
790 toolform.SelectConnection(connection);
791 if fileid > -1 then
792 toolform.SelectFileID(connection, fileid);
793 end;
794 Result := toolform;
795 end;
796end;
797
798end.
Note: See TracBrowser for help on using the repository browser.