source: oup/current/Main.pas@ 94

Last change on this file since 94 was 92, checked in by alloc, 18 years ago

Rev86 was first after multi-cons

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