--- oup/current/Main.pas 2007/06/04 22:07:29 209 +++ oup/current/Main.pas 2007/06/18 14:22:53 222 @@ -6,8 +6,9 @@ uses MPHexEditor, ToolWin, ImgList, Tabs, MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst, Data, TypeDefs, ConnectionManager, - Functions, Settings, Template, - RawEdit, BinEdit, Extractor, Preview, TxmpReplace; + Functions, Settings, + RawEdit, BinEdit, Extractor, Preview, TxmpReplace, + _BaseTemplate, _TemplateFile, _TemplateFileList; type TForm_Main = class(TForm) @@ -107,7 +108,6 @@ type procedure menu_txmpreplaceClick(Sender: TObject); procedure menu_previewClick(Sender: TObject); procedure menu_metaClick(Sender: TObject); - function open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; procedure menu_windows_cascadeClick(Sender: TObject); procedure menu_windows_tilevertClick(Sender: TObject); @@ -126,6 +126,9 @@ type procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA; private public + function open_child(window_context: String; Connection, FileID: Integer): TForm_BaseTemplate; overload; + function open_child(window_context: String; Connection: Integer): TForm_BaseTemplate; overload; + function open_child(window_context: String): TForm_BaseTemplate; overload; procedure DefaultHandler(var Message); override; end; @@ -167,16 +170,16 @@ end; function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean; var i: Integer; - toolform: TForm_ToolTemplate; + toolform: TForm_BaseTemplate; begin Result := True; if MDITab.MDIChildCount > 0 then begin for i := 0 to MDITab.MDIChildCount - 1 do begin - if MDITab.MDIChildren[i] is TForm_ToolTemplate then + if MDITab.MDIChildren[i] is TForm_BaseTemplate then begin - toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]); + toolform := TForm_BaseTemplate(MDITab.MDIChildren[i]); if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then begin if not toolform.Closeable then @@ -322,7 +325,7 @@ var pt: TPoint; tabIndex: Integer; hint: String; - tool: TForm_ToolTemplate; + tool: TForm_BaseTemplate; begin pt.X := X; pt.Y := Y; @@ -331,21 +334,24 @@ begin if tabIndex >= 0 then begin - if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then + if MDITab.MDIChildren[tabIndex] is TForm_BaseTemplate then begin - tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]); + tool := TForm_BaseTemplate(MDITab.MDIChildren[tabIndex]); if tool.ConnectionID > -1 then hint := 'Connection: ' + - ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10 + ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) else - hint := 'Connection: none' + #13+#10; - if tool.SelectedFile.ID > -1 then - hint := hint + 'Selected File: ' + - FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' + - tool.SelectedFile.Name + '.' + - tool.SelectedFile.Extension - else - hint := hint + 'Selected File: none'; + hint := 'Connection: none'; + if tool is TForm_TemplateFile then + begin + if TForm_TemplateFile(tool).SelectedFile.ID > -1 then + hint := hint + #13+#10 + 'Selected File: ' + + FormatNumber(TForm_TemplateFile(tool).SelectedFile.ID, 5, '0') + '-' + + TForm_TemplateFile(tool).SelectedFile.Name + '.' + + TForm_TemplateFile(tool).SelectedFile.Extension + else + hint := hint + #13+#10 + 'Selected File: none'; + end; end else hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption; @@ -480,8 +486,8 @@ var begin if MDITab.MDIChildCount > 0 then for i := 0 to MDITab.MDIChildCount - 1 do - if MDITab.MDIChildren[i] is TForm_ToolTemplate then - TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateConList; + if MDITab.MDIChildren[i] is TForm_BaseTemplate then + TForm_BaseTemplate(MDITab.MDIChildren[i]).UpdateConList; menu_conns.Clear; if ConManager.Count > 0 then @@ -552,8 +558,6 @@ end; {####################################} procedure TForm_Main.menu_createdbClick(Sender: TObject); begin -// ShowMessage('Not yet usable'); - opend.Filter := 'Oni-Dat-Files|*.dat'; saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; saved.DefaultExt := 'oldb'; @@ -565,8 +569,6 @@ end; procedure TForm_Main.menu_createlvlClick(Sender: TObject); begin -// ShowMessage('Not yet usable'); - opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb'; saved.Filter := 'Oni-Dat-Files|*.dat'; saved.DefaultExt := 'dat'; @@ -581,62 +583,37 @@ end; {#################################} procedure TForm_Main.menu_previewClick(Sender: TObject); begin - open_child('preview', -1, -1); + open_child('preview'); end; procedure TForm_Main.menu_bineditClick(Sender: TObject); begin - open_child('binedit', -1, -1); + open_child('binedit'); end; procedure TForm_Main.menu_raweditClick(Sender: TObject); begin - open_child('rawedit', -1, -1); + open_child('rawedit'); end; procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); begin - open_child('txmpreplace', -1, -1); + open_child('txmpreplace'); end; procedure TForm_Main.menu_extractorClick(Sender: TObject); begin - open_child('extractor', -1, -1); + open_child('extractor'); end; procedure TForm_Main.menu_metaClick(Sender: TObject); -var - toolform: TForm_Meta; - i: Integer; - tag: Integer; - iconindex: Integer; begin - tag := 1; - if MDIChildCount > 0 then - for i := 0 to MDIChildCount - 1 do - if MDIChildren[i].Tag >= tag then - tag := MDIChildren[i].Tag + 1; - - iconindex := -1; - - toolform := nil; - - toolform := TForm_Meta.Create(Self); - toolform.Caption := 'MetaEditor' + ' ' + IntToStr(tag) + ' '; - iconindex := 11; - - if Assigned(toolform) then - begin - toolform.Name := 'meta' + IntToStr(tag); - toolform.Tag := tag; - MDITab.AddTab(TForm(toolform), iconindex); - toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); - end; + open_child('meta'); end; procedure TForm_Main.menu_filecompareClick(Sender: TObject); begin - open_child('compare', -1, -1); + open_child('compare'); end; @@ -705,7 +682,6 @@ var index: Integer; RepMsg: TStatusMessages; begin -// name := TTBItem(Sender).Caption; index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender)); name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName); if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+ @@ -752,9 +728,9 @@ end; -function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_ToolTemplate; +function TForm_Main.open_child(window_context: String; connection, fileid: Integer): TForm_BaseTemplate; type - TTemplate = class of TForm_ToolTemplate; + TTemplate = class of TForm_BaseTemplate; TTool = record name: String; icon: Integer; @@ -767,10 +743,11 @@ const (name: 'extractor'; icon: 8; caption: 'Extractor'; classt: TForm_Extractor), (name: 'preview'; icon: 4; caption: 'Preview-Window'; classt: TForm_Preview), (name: 'rawedit'; icon: 6; caption: 'Binary .raw-Editor'; classt: TForm_RawEdit), - (name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer'; classt: TForm_TxmpReplace) +// (name: 'txmpreplace'; icon: 7; caption: 'TXMP Replacer'; classt: TForm_TxmpReplace), + (name: 'meta'; icon: 11; caption: 'MetaEditor'; classt: TForm_Meta) ); var - toolform: TForm_ToolTemplate; + toolform: TForm_BaseTemplate; i: Integer; tag: Integer; iconindex: Integer; @@ -805,14 +782,24 @@ begin toolform.Tag := tag; MDITab.AddTab(TForm(toolform), iconindex); toolform.Caption := AnsiReplaceStr(toolform.Caption, ' ', ''); - if connection > -1 then + if Connection > -1 then begin toolform.SelectConnection(connection); - if fileid > -1 then - toolform.SelectFileID(connection, fileid); + if (FileID > -1) and (toolform is TForm_TemplateFile) then + TForm_TemplateFile(toolform).SelectFileID(Connection, FileID); end; Result := toolform; end; end; +function TForm_Main.open_child(window_context: String; Connection: Integer): TForm_BaseTemplate; +begin + open_child(window_context, Connection, -1); +end; + +function TForm_Main.open_child(window_context: String): TForm_BaseTemplate; +begin + open_child(window_context, -1, -1); +end; + end.