| 726 |
|
|
| 727 |
|
|
| 728 |
|
function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; |
| 729 |
+ |
type |
| 730 |
+ |
TTemplate = class of TForm_ToolTemplate; |
| 731 |
+ |
TTool = record |
| 732 |
+ |
name: String; |
| 733 |
+ |
icon: Integer; |
| 734 |
+ |
caption: String; |
| 735 |
+ |
classt: TTemplate; |
| 736 |
+ |
end; |
| 737 |
+ |
const |
| 738 |
+ |
Tools: array[0..4] of TTool = ( |
| 739 |
+ |
(name: 'binedit'; icon: 5; caption: 'Binary .dat-Editor'; classt: TForm_BinEdit), |
| 740 |
+ |
(name: 'extractor'; icon: 8; caption: 'Extractor'; classt: TForm_Extractor), |
| 741 |
+ |
(name: 'preview'; icon: 4; caption: 'Preview-Window'; classt: TForm_Preview), |
| 742 |
+ |
(name: 'rawedit'; icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit), |
| 743 |
+ |
(name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer'; classt: TForm_TxmpReplace) |
| 744 |
+ |
); |
| 745 |
|
var |
| 746 |
|
toolform: TForm_ToolTemplate; |
| 747 |
|
i: Integer; |
| 748 |
|
tag: Integer; |
| 733 |
– |
caption_end: String; |
| 749 |
|
iconindex: Integer; |
| 750 |
|
begin |
| 751 |
|
Result := nil; |
| 757 |
|
tag := MDIChildren[i].Tag + 1; |
| 758 |
|
|
| 759 |
|
iconindex := -1; |
| 745 |
– |
caption_end := IntToStr(tag) + ' '; |
| 760 |
|
|
| 761 |
|
toolform := nil; |
| 762 |
|
|
| 763 |
< |
if window_context = 'binedit' then |
| 764 |
< |
begin |
| 765 |
< |
toolform := TForm_BinEdit.Create(Self); |
| 766 |
< |
toolform.Caption := 'Binary .dat-Editor ' + caption_end; |
| 753 |
< |
iconindex := 5; |
| 754 |
< |
end; |
| 755 |
< |
if window_context = 'extractor' then |
| 756 |
< |
begin |
| 757 |
< |
toolform := TForm_Extractor.Create(Self); |
| 758 |
< |
toolform.Caption := 'Extractor ' + caption_end; |
| 759 |
< |
iconindex := 8; |
| 760 |
< |
end; |
| 761 |
< |
if window_context = 'preview' then |
| 762 |
< |
begin |
| 763 |
< |
toolform := TForm_Preview.Create(Self); |
| 764 |
< |
toolform.Caption := 'Preview-Window ' + caption_end; |
| 765 |
< |
iconindex := 4; |
| 766 |
< |
end; |
| 767 |
< |
if window_context = 'rawedit' then |
| 768 |
< |
begin |
| 769 |
< |
toolform := TForm_RawEdit.Create(Self); |
| 770 |
< |
toolform.Caption := 'Binary .raw-Editor ' + caption_end; |
| 771 |
< |
iconindex := 6; |
| 772 |
< |
end; |
| 773 |
< |
if window_context = 'txmpreplace' then |
| 763 |
> |
for i := 0 to High(Tools) do |
| 764 |
> |
if Tools[i].name = window_context then |
| 765 |
> |
Break; |
| 766 |
> |
if i < Length(Tools) then |
| 767 |
|
begin |
| 768 |
< |
toolform := TForm_TxmpReplace.Create(Self); |
| 769 |
< |
toolform.Caption := 'TXMP Replacer ' + caption_end; |
| 770 |
< |
iconindex := 7; |
| 768 |
> |
toolform := TTemplate(Tools[i].classt).Create(Self); |
| 769 |
> |
toolform.Caption := Tools[i].caption + ' ' + IntToStr(tag) + ' '; |
| 770 |
> |
iconindex := Tools[i].icon; |
| 771 |
> |
end else begin |
| 772 |
> |
ShowMessage('WindowContext not found!'); |
| 773 |
|
end; |
| 774 |
|
|
| 775 |
|
if Assigned(toolform) then |