--- oup/current/Main.pas 2006/12/18 23:35:30 43 +++ oup/current/Main.pas 2006/12/23 00:03:50 45 @@ -6,10 +6,10 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids, MPHexEditor, ToolWin, ImgList, Tabs, - Code_Functions, Data, Code_DataStructures, - Helper_LevelDB, Code_Exporters, Settings, - Tool_Preview, Tool_TxmpReplace, Tool_BinEdit, Tool_Extractor, Tool_RawEdit, - Code_OniDataClass, MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI; + MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, + Code_Functions, Data, Code_DataStructures, Code_OniDataClass, + Helper_LevelDB, Code_Exporters, Settings, Tool_Template, + Tool_BinEdit, Tool_Extractor, Tool_Preview, Tool_RawEdit, Tool_TxmpReplace; type TForm_Main = class(TForm) @@ -76,7 +76,7 @@ type procedure menu_windows_previousClick(Sender: TObject); procedure menu_windows_nextClick(Sender: TObject); procedure menu_windows_tileClick(Sender: TObject); - function open_child(window_context: String): Boolean; + function open_child(window_context: String; fileid: Integer): Boolean; procedure menu_windows_closeallClick(Sender: TObject); procedure menu_windows_cascadeClick(Sender: TObject); procedure menu_bineditClick(Sender: TObject); @@ -304,14 +304,16 @@ begin begin ext := ExtractFileExt(opend.FileName); if ext = '.dat' then + begin if not CreateDataConnection(opend.FileName, ODB_Dat) then ShowMessage('Error while loading the file:' + CrLf + opend.FileName + - CrLf + 'Perhaps not an Oni-.dat-file?') - else if ext = '.oldb' then + CrLf + 'Perhaps not an Oni-.dat-file?'); + end else if ext = '.oldb' then + begin if not CreateDataConnection(opend.FileName, ODB_ADB) then ShowMessage('Error while loading the file:' + CrLf + opend.FileName + - CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?') - else + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?'); + end else ShowMessage('Incompatible file'); AppSettings.DatPath := ExtractFilepath(opend.FileName); end; @@ -393,37 +395,37 @@ end; {#################################} procedure TForm_Main.menu_previewClick(Sender: TObject); begin - open_child('preview'); + open_child('preview', -1); end; procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject); begin - open_child('txmpreplace'); + open_child('txmpreplace', -1); end; procedure TForm_Main.menu_bineditClick(Sender: TObject); begin - open_child('binedit'); + open_child('binedit', -1); end; procedure TForm_Main.menu_raweditClick(Sender: TObject); begin - open_child('rawedit'); + open_child('rawedit', -1); end; procedure TForm_Main.menu_extractorClick(Sender: TObject); begin - open_child('extractor'); + open_child('extractor', -1); end; procedure TForm_Main.menu_filecompareClick(Sender: TObject); begin - open_child('compare'); + open_child('compare', -1); end; @@ -514,9 +516,9 @@ end; -function TForm_Main.open_child(window_context: String): Boolean; +function TForm_Main.open_child(window_context: String; fileid: Integer): Boolean; var - form: TCustomForm; + toolform: TForm_ToolTemplate; i: Integer; tag: Integer; iconindex: Integer; @@ -533,40 +535,39 @@ begin if window_context = 'binedit' then begin - form := TForm_BinEdit.Create(Application); - TForm_BinEdit(form).Recreatelist; - form.Caption := 'Binary .dat-Editor ' + IntToStr(tag); - iconindex := 0; + toolform := TForm_BinEdit.Create(Self); + toolform.Caption := 'Binary .dat-Editor ' + IntToStr(tag); + iconindex := 0; end; - if window_context = 'rawedit' then + if window_context = 'extractor' then begin - form := TForm_RawEdit.Create(Application); - TForm_RawEdit(form).Recreatelist; - form.Caption := 'Binary .raw-Editor ' + IntToStr(tag); + toolform := TForm_Extractor.Create(Self); + toolform.Caption := 'Extractor ' + IntToStr(tag); end; if window_context = 'preview' then begin - form := TForm_Preview.Create(Application); - TForm_Preview(form).Recreatelist; - form.Caption := 'Preview-Window ' + IntToStr(tag); + toolform := TForm_Preview.Create(Self); + toolform.Caption := 'Preview-Window ' + IntToStr(tag); end; - if window_context = 'txmpreplace' then + if window_context = 'rawedit' then begin - form := TForm_TxmpReplace.Create(Application); - TForm_TxmpReplace(form).Recreatelist; - form.Caption := 'TXMP Replacer ' + IntToStr(tag); + toolform := TForm_RawEdit.Create(Self); + toolform.Caption := 'Binary .raw-Editor ' + IntToStr(tag); end; - if window_context = 'extractor' then + if window_context = 'txmpreplace' then begin - form := TForm_Extractor.Create(Application); - TForm_Extractor(form).Recreatelist; - form.Caption := 'Extractor ' + IntToStr(tag); + toolform := TForm_TxmpReplace.Create(Application); + toolform.Caption := 'TXMP Replacer ' + IntToStr(tag); end; - form.Name := window_context + IntToStr(tag); - form.Tag := tag; - - MDITab.AddTab(TForm(form), iconindex); + if Assigned(toolform) then + begin + toolform.Name := window_context + IntToStr(tag); + toolform.Tag := tag; + MDITab.AddTab(TForm(toolform), iconindex); + if fileid > -1 then + toolform.SelectFileID(fileid); + end; end; end.