source: oup/current/Main.pas@ 125

Last change on this file since 125 was 113, 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 Result := True;
173 if MDITab.MDIChildCount > 0 then
174 begin
175 for i := 0 to MDITab.MDIChildCount - 1 do
176 begin
177 if MDITab.MDIChildren[i] is TForm_ToolTemplate then
178 begin
179 toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]);
180 if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
181 begin
182 if not toolform.Closeable then
183 begin
184 ShowMessage('Can not close toolwindow: ' + toolform.Caption);
185 Result := False;
186 end;
187 end;
188 end;
189 end;
190 end;
191end;
192
193
194{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt }
195procedure TForm_Main.WMCopyData(var Msg: TWMCopyData);
196var
197 strings: TStringList;
198begin
199 if (Msg.CopyDataStruct.dwData = SecondInstMsgId) and (SecondInstMsgId <> 0) then
200 begin
201 Application.BringToFront;
202
203 strings := TStringList.Create;
204 strings.Text := ParamBlobToStr(Msg.CopyDataStruct.lpData);
205 if strings.Count = 2 then
206 begin
207 if strings.Strings[0] = 'opf' then
208 begin
209 ShowMessage('Load OPF-File: ' + ParamStr(2));
210 end
211 else if (strings.Strings[0] = 'oldb') or (strings.Strings[0] = 'dat') then
212 begin
213 CreateConnection(strings.Strings[1]);
214 end;
215 end;
216 end
217 else
218 inherited;
219end;
220
221{----------------------------------------------------------------------------}
222{ Wir überschreiben den DefaultHandler, der alle Nachrichten zuerst bekommt, }
223{ damit wir auf die Nachricht mit der ID SecondInstMsgId reagieren können. }
224{ (Dies ist notwendig, da wir jetzt noch nicht wissen welchen Wert }
225{ die ID haben wird, weswegen wir keine statische Message-Prozedure, }
226{ so wie bei WM_COPYDATA, schreiben können.) }
227{----------------------------------------------------------------------------}
228procedure TForm_Main.DefaultHandler(var Message);
229begin
230 if TMessage(Message).Msg = SecondInstMsgId then
231 { Eine zweite Instanz hat uns nach dem Handle gefragt }
232 { Es wird in die Message-Queue des Threads gepostet. }
233 PostThreadMessage(TMessage(Message).WParam, SecondInstMsgId, Handle, 0)
234 else
235 inherited;
236end;
237
238
239
240procedure TForm_Main.FormCreate(Sender: TObject);
241begin
242 Self.Caption := 'Oni Un/Packer ' + version;
243 Self.FormResize(Self);
244
245 ConManager.OnCoonnectionListChanged := UpdateConLists;
246
247 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
248 begin
249 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
250 '\oniunpacker.ini');
251 Reset(AppSettingsFile);
252 Read(AppSettingsFile, AppSettings);
253 CloseFile(AppSettingsFile);
254 end
255 else
256 begin
257 AppSettings.DatPath := ExtractFilepath(Application.EXEname);
258 AppSettings.ExtractPath := ExtractFilepath(Application.EXEname) + '\extract';
259 AppSettings.CharSet := DEFAULT_CHARSET;
260 AppSettings.HideUnusedData := False;
261 end;
262
263 if MidStr(ParamStr(1), 1, 3) = 'opf' then
264 begin
265 ShowMessage('Load OPF-File: ' + ParamStr(2));
266 end
267 else if (MidStr(ParamStr(1), 1, 4) = 'oldb') or (MidStr(ParamStr(1), 1, 3) = 'dat') then
268 begin
269 CreateConnection(ParamStr(2));
270 end;
271 UpdateStatBar;
272end;
273
274
275
276
277procedure TForm_Main.FormResize(Sender: TObject);
278begin
279 statbar.Panels.Items[0].Width := Self.Width - 200;
280 MDITab.Width := Self.Width - 20;
281end;
282
283
284
285
286procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
287 TabIndex: Integer; const Rect: TRect; Active: Boolean);
288var
289 x, y: Integer;
290 iconindex: Integer;
291 caption: String;
292begin
293 iconindex := TMDITab(Control).Glyphs[TabIndex];
294 caption := TMDITab(Control).Captions[TabIndex];
295 if active then
296 begin
297 Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
298 y := Rect.Top + 1;
299 end else
300 y := Rect.Top;
301 if iconindex >= 0 then
302 begin
303 TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
304 x := Rect.Left + 26;
305 end else
306 x := Rect.Left + 4;
307 Control.Canvas.TextOut(x, y + 2, caption);
308 if active then
309 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 0)
310 else
311 Images_Close.Draw(Control.Canvas, Rect.Right - 18, y, 1);
312end;
313
314
315procedure TForm_Main.MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
316 Y: Integer);
317var
318 pt: TPoint;
319 tabIndex: Integer;
320 hint: String;
321 tool: TForm_ToolTemplate;
322begin
323 pt.X := X;
324 pt.Y := Y;
325 tabIndex := MDITab.GetTabAtPos(pt);
326 hint := '';
327
328 if tabIndex >= 0 then
329 begin
330 if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
331 begin
332 tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]);
333 if tool.ConnectionID > -1 then
334 hint := 'Connection: ' +
335 ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10
336 else
337 hint := 'Connection: none' + #13+#10;
338 if tool.SelectedFile.ID > -1 then
339 hint := hint + 'Selected File: ' +
340 FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' +
341 tool.SelectedFile.Name + '.' +
342 tool.SelectedFile.Extension
343 else
344 hint := hint + 'Selected File: none';
345 end
346 else
347 hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption;
348 if hint <> MDITab.Hint then
349 begin
350 MDITab.Hint := hint;
351 MDITab.ShowHint := True;
352 end;
353 end
354 else
355 begin
356 MDITab.ShowHint := False;
357 MDITab.Hint := '';
358 end;
359end;
360
361procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
362 Shift: TShiftState; X, Y: Integer);
363var
364 pt: TPoint;
365 tabIndex: Integer;
366 tabRect: TRect;
367 tabX, tabY, tabWidth: Integer;
368begin
369 pt.X := X;
370 pt.Y := Y;
371 tabIndex := MDITab.GetTabAtPos(pt);
372
373// if (Button = mbRight) and (tabIndex >= 0) then
374// MDITab.MDIChildren[tabIndex].Close;
375
376 if (Button = mbLeft) and (tabIndex >= 0) then
377 begin
378 tabrect := MDITab.TabRect(tabIndex);
379 tabX := X - tabrect.Left;
380 tabY := Y - tabrect.Top;
381 tabwidth := tabrect.Right - tabrect.Left;
382 if (tabY >= 4) and (tabY <= 17) then
383 if (tabX >= tabwidth - 19) and (tabX <= tabwidth - 7) then
384 MDITab.MDIChildren[tabIndex].Close;
385 end;
386end;
387
388
389
390
391procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
392begin
393 AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
394 if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
395 Reset(AppSettingsFile)
396 else
397 Rewrite(AppSettingsFile);
398 Write(AppSettingsFile, AppSettings);
399 CloseFile(AppSettingsFile);
400 Action := caFree;
401end;
402
403
404
405procedure TForm_Main.ActivateTools(active: Boolean);
406begin
407 menu_tools.Enabled := active;
408 tb_preview.Enabled := active;
409 tb_datedit.Enabled := active;
410 tb_rawedit.Enabled := active;
411 tb_txmpreplacer.Enabled := active;
412 tb_extractor.Enabled := active;
413// tb_compare.Enabled := active;
414// tb_structure.Enabled := active;
415end;
416
417procedure TForm_Main.UpdateStatBar;
418begin
419 if ConManager.Count > 0 then
420 begin
421 Self.Caption := 'Oni Un/Packer ' + version;
422 ActivateTools(True);
423 statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count);
424 end
425 else
426 begin
427 Self.Caption := 'Oni Un/Packer ' + version;
428 statbar.Panels.Items[0].Text := '';
429 statbar.Panels.Items[1].Text := 'Connections: -';
430 statbar.Panels.Items[2].Text := '';
431 ActivateTools(False);
432 end;
433 menu_conns.Enabled := ConManager.Count > 0;
434end;
435
436
437
438
439procedure TForm_Main.ToolbarDockChanged(Sender: TObject);
440var
441 toolbar: TTBToolbar;
442 position: TTBDockPosition;
443 mode: TTBItemDisplayMode;
444 i: Integer;
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 index: Integer;
678 RepMsg: TStatusMessages;
679begin
680// name := TTBItem(Sender).Caption;
681 index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender));
682 name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName);
683 if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
684 name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
685 begin
686 CheckConnectionCloseable(index);
687 ConManager.CloseConnectionByIndex(index, RepMsg);
688 ShowOpenMsg(RepMsg);
689 UpdateConLists;
690 end;
691 UpdateStatBar;
692end;
693
694
695 {###################################}
696 {##### Toolbars-Menu-Handlers #####}
697 {###################################}
698procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
699begin
700 menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
701 Toolbar.Visible := menu_view_toolbar.Checked;
702end;
703
704procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
705begin
706 menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
707 statbar.Visible := menu_view_statusbar.Checked;
708end;
709
710procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
711begin
712 menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
713 mditoolbar.Visible := menu_view_mdibar.Checked;
714end;
715
716
717
718procedure TForm_Main.menu_AboutClick(Sender: TObject);
719begin
720 ShowMessage('Will be implemented later ;)');
721end;
722
723
724
725
726
727function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate;
728var
729 toolform: TForm_ToolTemplate;
730 i: Integer;
731 tag: Integer;
732 caption_end: String;
733 iconindex: Integer;
734begin
735 Result := nil;
736
737 tag := 1;
738 if MDIChildCount > 0 then
739 for i := 0 to MDIChildCount - 1 do
740 if MDIChildren[i].Tag >= tag then
741 tag := MDIChildren[i].Tag + 1;
742
743 iconindex := -1;
744 caption_end := IntToStr(tag) + ' ';
745
746 toolform := nil;
747
748 if window_context = 'binedit' then
749 begin
750 toolform := TForm_BinEdit.Create(Self);
751 toolform.Caption := 'Binary .dat-Editor ' + caption_end;
752 iconindex := 5;
753 end;
754 if window_context = 'extractor' then
755 begin
756 toolform := TForm_Extractor.Create(Self);
757 toolform.Caption := 'Extractor ' + caption_end;
758 iconindex := 8;
759 end;
760 if window_context = 'preview' then
761 begin
762 toolform := TForm_Preview.Create(Self);
763 toolform.Caption := 'Preview-Window ' + caption_end;
764 iconindex := 4;
765 end;
766 if window_context = 'rawedit' then
767 begin
768 toolform := TForm_RawEdit.Create(Self);
769 toolform.Caption := 'Binary .raw-Editor ' + caption_end;
770 iconindex := 6;
771 end;
772 if window_context = 'txmpreplace' then
773 begin
774 toolform := TForm_TxmpReplace.Create(Self);
775 toolform.Caption := 'TXMP Replacer ' + caption_end;
776 iconindex := 7;
777 end;
778
779 if Assigned(toolform) then
780 begin
781 toolform.Name := window_context + IntToStr(tag);
782 toolform.Tag := tag;
783 MDITab.AddTab(TForm(toolform), iconindex);
784 toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', '');
785 if connection > -1 then
786 begin
787 toolform.SelectConnection(connection);
788 if fileid > -1 then
789 toolform.SelectFileID(connection, fileid);
790 end;
791 Result := toolform;
792 end;
793end;
794
795end.
Note: See TracBrowser for help on using the repository browser.