Index: /oup/current/Code/DataStructures.pas
===================================================================
--- /oup/current/Code/DataStructures.pas	(revision 91)
+++ /oup/current/Code/DataStructures.pas	(revision 92)
@@ -136,5 +136,5 @@
       connection.LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
       Result[i].raw_addr := link;
-      Result[i].raw_size := 0{????????????????????????????????};
+      Result[i].raw_size := 32;
       Result[i].loc_sep  := False;
     end;
@@ -198,5 +198,5 @@
   Result[0].raw_addr   := link;
   Result[0].raw_size   := datasize;
-  Result[0].loc_sep    := OniDataConnection.OSisMac;
+  Result[0].loc_sep    := connection.OSisMac;
 end;
 
@@ -245,5 +245,5 @@
     TOniDataDat(connection).LoadRawOffset(False,
       baselink, lastlink + 1024, Data);
-    //      OniDataConnection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
+    //      connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
     k := 0;
     for j := 0 to 1024 do
@@ -595,5 +595,5 @@
 begin
   Raws := '';
-  //  InsertRawListHandler('AGDB',True,AGDB);
+  InsertRawListHandler('AGDB',False,AGDB);
   InsertRawListHandler('AKVA', True, AKVA);
   InsertRawListHandler('BINA', True, BINA);
Index: /oup/current/Code/OniDataClass.pas
===================================================================
--- /oup/current/Code/OniDataClass.pas	(revision 91)
+++ /oup/current/Code/OniDataClass.pas	(revision 92)
@@ -136,12 +136,5 @@
   end;
 
-  TOniDataEmpty = class(TOniData)
-  private
-  protected
-  public
-    constructor Create(OLDBFilename: String; var Result: Boolean); override;
-    procedure Close; override;
-  published
-  end;
+
 
 const
@@ -151,9 +144,8 @@
 
 var
-//  OniDataConnection: TOniData;
   DataConnections: array of TOniData;
-  OniDataConnection: TOniData;
 
 function CreateDataConnection(filename: String; backend: Integer): TOniData;
+function ConnectionExists(filename: String): TOniData;
 procedure CloseDataConnection(connection: TOniData);
 function GetEmptyFileInfo: TFileInfo;
@@ -213,14 +205,17 @@
   Result.raw_addr := 0;
   Result.raw_size := 0;
-  for i := 0 to High(raw_list) do
-  begin
-    if raw_list[i].src_offset = dat_offset then
-    begin
-      Result.src_id     := fileid;
-      Result.src_offset := raw_list[i].src_offset;
-      Result.raw_addr   := raw_list[i].raw_addr;
-      Result.raw_size   := raw_list[i].raw_size;
-      Result.loc_sep    := raw_list[i].loc_sep;
-      Break;
+  if Length(raw_list) > 0 then
+  begin
+    for i := 0 to High(raw_list) do
+    begin
+      if raw_list[i].src_offset = dat_offset then
+      begin
+        Result.src_id     := fileid;
+        Result.src_offset := raw_list[i].src_offset;
+        Result.raw_addr   := raw_list[i].raw_addr;
+        Result.raw_size   := raw_list[i].raw_size;
+        Result.loc_sep    := raw_list[i].loc_sep;
+        Break;
+      end;
     end;
   end;
@@ -1466,4 +1461,17 @@
 
 
+function ConnectionExists(filename: String): TOniData;
+var
+  i: Integer;
+begin
+  Result := nil;
+  if Length(DataConnections) > 0 then
+    for i := 0 to High(DataConnections) do
+      if DataConnections[i].FFileName = filename then
+      begin
+        Result := DataConnections[i];
+        Exit;
+      end;
+end;
 
 
@@ -1513,18 +1521,3 @@
 
 
-
-
-constructor TOniDataEmpty.Create(OLDBFilename: String; var Result: Boolean);
-var
-  i, j:  Byte;
-  temps: String;
-begin
-  ShowMessage('OLD');
-end;
-
-procedure TOniDataEmpty.Close;
-begin
-  ShowMessage('OLD');
-end;
-
 end.
Index: /oup/current/Code/OniImgClass.pas
===================================================================
--- /oup/current/Code/OniImgClass.pas	(revision 91)
+++ /oup/current/Code/OniImgClass.pas	(revision 92)
@@ -439,5 +439,5 @@
       txmpimg.DataType  := [DT_Decoded32];
       txmpimg.Depth     := 32;
-      txmpimg.WriteToBMP('D:\' + IntToStr(i) + '.bmp');
+      txmpimg.WriteToBMP('M:\' + IntToStr(i) + '.bmp');
     end;
   end;
Index: /oup/current/Helper_LevelDB.pas
===================================================================
--- /oup/current/Helper_LevelDB.pas	(revision 91)
+++ /oup/current/Helper_LevelDB.pas	(revision 92)
@@ -59,4 +59,5 @@
   Stream_Body, Stream_Names: TMemoryStream;
   Stream_Dat, Stream_Raw, Stream_Sep: TFileStream;
+  OniDataConnection: TOniData;
 
 
@@ -107,4 +108,19 @@
   timeformat.LongTimeFormat := 'hh:nn:ss';
   timeformat.TimeSeparator := ':';
+
+  connection := ConnectionExists(target);
+  if connection <> nil then
+  begin
+    ShowMessage('Destination-file is opened, close it in order to proceed conversion?');
+    Exit;
+  end;
+
+  connection := ConnectionExists(source);
+  if connection <> nil then
+  begin
+    ShowMessage('Source-file is opened, close it in order to proceed conversion?');
+    Exit;
+  end;
+
 
   if CreateDataConnection(Source, ODB_ADB) = nil then
Index: /oup/current/ImportedStuff/OneInst.pas
===================================================================
--- /oup/current/ImportedStuff/OneInst.pas	(revision 91)
+++ /oup/current/ImportedStuff/OneInst.pas	(revision 92)
@@ -1,6 +1,6 @@
+{ Downloaded from: http://www.michael-puff.de/Developer/Delphi/Importe/Nico/oneinst.zip  }
+
 unit OneInst;
-
 interface
-
 uses
   Windows, Messages;
@@ -22,5 +22,5 @@
   { Der Text den diese Variable hat sollte bei jedem neuen Programm geändert }
   { werden und möglichst eindeutig (und nicht zu kurz) sein.                 }
-  UniqueName: array [0..MAX_PATH] of Char = 'EindeutigerNameFuerDasProgramm'#0;
+  UniqueName: array [0..MAX_PATH] of Char = 'Oni Un/Packer'#0;
   MutexHandle: THandle = 0;
 
Index: /oup/current/Main.pas
===================================================================
--- /oup/current/Main.pas	(revision 91)
+++ /oup/current/Main.pas	(revision 92)
@@ -7,5 +7,5 @@
   Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
   MPHexEditor, ToolWin, ImgList, Tabs,
-  MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI,
+  MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI, OneInst,
   Data, Functions, DataStructures, OniDataClass, Exporters,
   Helper_LevelDB, Settings, Template,
@@ -89,5 +89,5 @@
     procedure menu_windows_nextClick(Sender: TObject);
     procedure menu_windows_tileClick(Sender: TObject);
-    function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
+    function open_child(window_context: String; connection: TOniData; fileid: Integer): TForm_ToolTemplate;
     procedure menu_windows_closeallClick(Sender: TObject);
     procedure menu_windows_cascadeClick(Sender: TObject);
@@ -116,6 +116,9 @@
     procedure MDITabMouseMove(Sender: TObject; Shift: TShiftState; X,
       Y: Integer);
-  private
+
+    procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
   public
+    procedure DefaultHandler(var Message); override;
+  public
   end;
 
@@ -126,4 +129,60 @@
 
 {$R *.dfm}
+
+
+
+{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt }
+procedure TForm_Main.WMCopyData(var Msg: TWMCopyData);
+var
+  strings: TStringList;
+begin
+  if (Msg.CopyDataStruct.dwData = SecondInstMsgId) and (SecondInstMsgId <> 0) then
+  begin
+    Application.BringToFront;
+    
+    strings := TStringList.Create;
+    strings.Text := ParamBlobToStr(Msg.CopyDataStruct.lpData);
+    if strings.Count = 2 then
+    begin
+      if strings.Strings[0] = 'opf' then
+      begin
+        ShowMessage('Load OPF-File: ' + ParamStr(2));
+      end
+      else if strings.Strings[0] = 'oldb' then
+      begin
+        if CreateDataConnection(strings.Strings[1], ODB_ADB) = nil then
+          ShowMessage('Error while loading the file:' + CrLf +
+                strings.Strings[1] + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
+      end
+      else if strings.Strings[0] = 'dat' then
+      begin
+        if CreateDataConnection(strings.Strings[1], ODB_Dat) = nil then
+          ShowMessage('Error while loading the file:' + CrLf +
+                strings.Strings[1] + CrLf + 'Perhaps not an Oni-.dat-file?');
+      end;
+      UpdateStatBar;
+      UpdateConLists;
+    end;
+  end
+  else
+    inherited;
+end;
+
+{----------------------------------------------------------------------------}
+{ Wir überschreiben den DefaultHandler, der alle Nachrichten zuerst bekommt, }
+{ damit wir auf die Nachricht mit der ID SecondInstMsgId reagieren können.   }
+{ (Dies ist notwendig, da wir jetzt noch nicht wissen welchen Wert           }
+{  die ID haben wird, weswegen wir keine statische Message-Prozedure,        }
+{  so wie bei WM_COPYDATA, schreiben können.)                                }
+{----------------------------------------------------------------------------}
+procedure TForm_Main.DefaultHandler(var Message);
+begin
+  if TMessage(Message).Msg = SecondInstMsgId then
+    { Eine zweite Instanz hat uns nach dem Handle gefragt }
+    { Es wird in die Message-Queue des Threads gepostet.  }
+    PostThreadMessage(TMessage(Message).WParam, SecondInstMsgId, Handle, 0)
+  else
+    inherited;
+end;
 
 
@@ -388,4 +447,5 @@
       end;
   end;
+  UpdateStatBar;
   UpdateConLists;
 end;
@@ -482,17 +542,6 @@
 procedure TForm_Main.menu_createdbClick(Sender: TObject);
 begin
-{  if Assigned(OniDataConnection) then
-    if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
-          'Do you want to close it to continue?'), PChar('Close file?'),
-          MB_YESNO + MB_ICONQUESTION) = ID_NO then
-      Exit
-    else begin
-      if TryCloseAll then
-      begin
-        CloseDataConnection;
-        UpdateStatBar;
-      end else
-        Exit;
-    end;
+  ShowMessage('Not yet usable');
+{
   opend.Filter     := 'Oni-Dat-Files|*.dat';
   saved.Filter     := 'OUP-Level-DB (*.oldb)|*.oldb';
@@ -501,5 +550,6 @@
     if saved.Execute then
       Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
-}end;
+}
+end;
 
 
@@ -508,17 +558,6 @@
 procedure TForm_Main.menu_createlvlClick(Sender: TObject);
 begin
-{  if Assigned(OniDataConnection) then
-    if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
-          'Do you want to close it to continue?'), PChar('Close file?'),
-          MB_YESNO + MB_ICONQUESTION) = ID_NO then
-      Exit
-    else begin
-      if TryCloseAll then
-      begin
-        CloseDataConnection;
-        UpdateStatBar;
-      end else
-        Exit;
-    end;
+  ShowMessage('Not yet usable');
+{
   opend.Filter     := 'OUP-Level-DB (*.oldb)|*.oldb';
   saved.Filter     := 'Oni-Dat-Files|*.dat';
@@ -527,5 +566,6 @@
     if saved.Execute then
       Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
-}end;
+}
+end;
 
  {#################################}
@@ -534,5 +574,5 @@
 procedure TForm_Main.menu_previewClick(Sender: TObject);
 begin
-  open_child('preview', -1);
+  open_child('preview', nil, -1);
 end;
 
@@ -540,5 +580,5 @@
 procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
 begin
-  open_child('txmpreplace', -1);
+  open_child('txmpreplace', nil, -1);
 end;
 
@@ -546,5 +586,5 @@
 procedure TForm_Main.menu_bineditClick(Sender: TObject);
 begin
-  open_child('binedit', -1);
+  open_child('binedit', nil, -1);
 end;
 
@@ -552,5 +592,5 @@
 procedure TForm_Main.menu_raweditClick(Sender: TObject);
 begin
-  open_child('rawedit', -1);
+  open_child('rawedit', nil, -1);
 end;
 
@@ -558,5 +598,5 @@
 procedure TForm_Main.menu_extractorClick(Sender: TObject);
 begin
-  open_child('extractor', -1);
+  open_child('extractor', nil, -1);
 end;
 
@@ -570,5 +610,5 @@
 procedure TForm_Main.menu_filecompareClick(Sender: TObject);
 begin
-  open_child('compare', -1);
+  open_child('compare', nil, -1);
 end;
 
@@ -666,5 +706,5 @@
 
 
-function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
+function TForm_Main.open_child(window_context: String; connection: TOniData; fileid: Integer): TForm_ToolTemplate;
 var
   toolform:    TForm_ToolTemplate;
@@ -722,6 +762,8 @@
     MDITab.AddTab(TForm(toolform), iconindex);
     toolform.Caption := AnsiReplaceStr(toolform.Caption, '       ', '');
-    if fileid > -1 then
-      toolform.SelectFileID(fileid);
+    if (fileid > -1) and (connection <> nil) then
+    begin
+      toolform.SelectFileID(connection, fileid);
+    end;
     Result := toolform;
   end;
Index: /oup/current/OniUnPacker.bdsproj
===================================================================
--- /oup/current/OniUnPacker.bdsproj	(revision 91)
+++ /oup/current/OniUnPacker.bdsproj	(revision 92)
@@ -178,6 +178,4 @@
 		</Language>  
     
-    
-    
     <Excluded_Packages>
       <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages>
Index: /oup/current/OniUnPacker.dpr
===================================================================
--- /oup/current/OniUnPacker.dpr	(revision 91)
+++ /oup/current/OniUnPacker.dpr	(revision 92)
@@ -2,5 +2,5 @@
 
 uses
-  Forms, Windows,
+  Forms,
   Main in 'Main.pas' {Form_Main},
   Data in 'Data.pas',
@@ -8,5 +8,4 @@
   Helper_ValueEdit in 'Helper_ValueEdit.pas' {Form_ValueEdit},
   Settings in 'Settings.pas' {Form_Settings},
-  FTypeReg in 'FTypeReg.pas',
   Functions in 'Code\Functions.pas',
   Exporters in 'Code\Exporters.pas',
@@ -20,29 +19,18 @@
   RawEdit in 'Tools\RawEdit.pas' {Form_ToolTemplate4},
   TxmpReplace in 'Tools\TxmpReplace.pas' {Form_ToolTemplate5},
-  FolderBrowser in 'Code\FolderBrowser.pas';
+  FTypeReg in 'ImportedStuff\FTypeReg.pas',
+  FolderBrowser in 'ImportedStuff\FolderBrowser.pas',
+  OneInst in 'ImportedStuff\OneInst.pas';
 
 {$R *.res}
 {$R ExtraIcos.res}
-const
-  MutexName = 'Oni Un/Packer';
-var
-  hMutex: THandle;
 
 begin
-  hMutex := CreateMutex(nil, True, MutexName);
-  if (hMutex = 0) or (GetLastError = ERROR_ALREADY_EXISTS) then
-  begin
-    PostMessage(HWND_BROADCAST, 0, 0, 0);
-  end
-  else
-  begin
-    Application.Initialize;
-    Application.Title := 'Oni Un/Packer';
-    Application.CreateForm(TForm_Main, Form_Main);
-    Application.CreateForm(TForm_LevelDB, Form_LevelDB);
-    Application.CreateForm(TForm_ValueEdit, Form_ValueEdit);
-    Application.CreateForm(TForm_Settings, Form_Settings);
-    Application.Run;
-  end;
-  CloseHandle(hMutex);
+  Application.Initialize;
+  Application.Title := 'Oni Un/Packer';
+  Application.CreateForm(TForm_Main, Form_Main);
+  Application.CreateForm(TForm_LevelDB, Form_LevelDB);
+  Application.CreateForm(TForm_ValueEdit, Form_ValueEdit);
+  Application.CreateForm(TForm_Settings, Form_Settings);
+  Application.Run;
 end.
Index: /oup/current/Tools/BinEdit.dfm
===================================================================
--- /oup/current/Tools/BinEdit.dfm	(revision 91)
+++ /oup/current/Tools/BinEdit.dfm	(revision 92)
@@ -4,12 +4,8 @@
   OnCloseQuery = FormCloseQuery
   OnKeyUp = FormKeyUp
+  ExplicitWidth = 500
+  ExplicitHeight = 450
   PixelsPerInch = 96
   TextHeight = 13
-  inherited panel_files: TPanel
-    inherited filelist: TListBox
-      ExplicitTop = 153
-      ExplicitHeight = 270
-    end
-  end
   inherited content: TPanel
     object Splitter2: TSplitter
@@ -93,4 +89,5 @@
       Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing]
       PopupMenu = value_viewer_context
+      ScrollBars = ssVertical
       TabOrder = 1
       OnDblClick = value_viewerDblClick
@@ -194,4 +191,5 @@
   object value_viewer_context: TPopupMenu [3]
     AutoHotkeys = maManual
+    AutoLineReduction = maManual
     OnPopup = value_viewer_contextPopup
     Left = 280
Index: /oup/current/Tools/BinEdit.pas
===================================================================
--- /oup/current/Tools/BinEdit.pas	(revision 91)
+++ /oup/current/Tools/BinEdit.pas	(revision 92)
@@ -32,5 +32,5 @@
     procedure hexChange(Sender: TObject);
 
-    procedure LoadDat(_fileid: LongWord);
+    procedure LoadDat(_fileid: Integer);
     function Save: Boolean;
     function GetValue(datatype: Word; offset: LongWord): String;
@@ -57,4 +57,5 @@
     procedure value_viewer_contextPopup(Sender: TObject);
   private
+    con: TOniData;
     fileid: Integer;
   public
@@ -93,4 +94,5 @@
   value_viewer.RowCount := 8;
   value_viewer.FixedRows := 1;
+  value_viewer.FixedCols := 1;
   value_viewer.Cells[0, 0] := 'Type';
   value_viewer.Cells[1, 0] := 'Value';
@@ -102,6 +104,6 @@
   value_viewer.Cells[0, 6] := 'String';
   value_viewer.Cells[0, 7] := 'Selected length';
-//  value_viewer.ColWidths[0] := 100;
-//  value_viewer.ColWidths[1] := value_viewer.Width - 150;
+  value_viewer.ColWidths[0] := 120;
+  value_viewer.ColWidths[1] := 1000;
 //  hex.Height := content.Height - 215;
   //
@@ -135,34 +137,48 @@
 
 
-procedure TForm_BinEdit.LoadDat(_fileid: LongWord);
+procedure TForm_BinEdit.LoadDat(_fileid: Integer);
 var
   mem:  TMemoryStream;
   Data: Tdata;
 begin
-  if hex.Modified then
-  begin
-    if not Save then
-    begin
-      Self.SelectFileID(fileid);
-      Exit;
-    end;
-  end;
-  fileid := _fileid;
-  if OniDataConnection.ExtractFileID(
-        filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
-    Self.SelectFileID(fileid);
-  Self.ClearStructViewer;
-  Data := OniDataConnection.LoadDatFile(fileid);
-  if Length(Data) > 0 then
-  begin
-    mem := TMemoryStream.Create;
-    mem.Write(Data[0], Length(Data));
-    mem.Seek(0, soFromBeginning);
-    hex.LoadFromStream(mem);
-    mem.Free;
-    WriteStructureInfos;
+  if con <> nil then
+  begin
+    if hex.Modified then
+    begin
+      if not Save then
+      begin
+        Self.SelectFileID(Connection, fileid);
+        Exit;
+      end;
+    end;
+  end;
+  if _fileid >= 0 then
+  begin
+    fileid := _fileid;
+    con := Connection;
+    if con.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
+      Self.SelectFileID(Connection, fileid);
+    Self.ClearStructViewer;
+    Data := con.LoadDatFile(fileid);
+    if Length(Data) > 0 then
+    begin
+      mem := TMemoryStream.Create;
+      mem.Write(Data[0], Length(Data));
+      mem.Seek(0, soFromBeginning);
+      hex.LoadFromStream(mem);
+      mem.Free;
+      WriteStructureInfos;
+    end
+    else
+    begin
+      ClearValues;
+      hex.DataSize := 0;
+    end;
   end
   else
   begin
+    fileid := _fileid;
+    con := nil;
+    Self.ClearStructViewer;
     ClearValues;
     hex.DataSize := 0;
@@ -226,5 +242,5 @@
       Result := IntToBin(hex.Data[offset]);
     11:
-      Result := '0x' + IntToHex(OniDataConnection.GetRawInfo(fileid, offset).raw_addr, 8);
+      Result := '0x' + IntToHex(con.GetRawInfo(fileid, offset).raw_addr, 8);
     12:
       Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
@@ -291,5 +307,5 @@
   if VST.RootNodeCount = 0 then
   begin
-    structs := LoadStructureDefinition(Connection, fileid);
+    structs := LoadStructureDefinition(con, fileid);
     if structs.Data then
     begin
@@ -501,5 +517,5 @@
 begin
   case MessageBox(Self.Handle, PChar('Save changes to file ' +
-      OniDataConnection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
+      con.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
       MB_YESNOCANCEL) of
     idYes:
@@ -511,5 +527,5 @@
       mem.Read(Data[0], mem.Size);
       mem.Free;
-      OniDataConnection.UpdateDatFile(fileid, Data);
+      con.UpdateDatFile(fileid, Data);
       hex.Modified := False;
       for i := 0 to hex.Datasize - 1 do
@@ -762,15 +778,15 @@
       if nodedata.DataType = 11 then
       begin
-        if OniDataConnection.GetRawInfo(fileid, nodedata.offset).raw_size > 0 then
-          Form_Main.open_child('rawedit', fileid);
+        if con.GetRawInfo(fileid, nodedata.offset).raw_size > 0 then
+          Form_Main.open_child('rawedit', Connection, fileid);
       end;
       if nodedata.DataType = 12 then
       begin
-        if (StrToInt(nodedata.Value) < OniDataConnection.GetFilesCount) and
+        if (StrToInt(nodedata.Value) < con.GetFilesCount) and
           (StrToInt(nodedata.Value) > 0) and
           (StrToInt(nodedata.Value) <> fileid) then
         begin
-          if OniDataConnection.GetFileInfo(StrToInt(nodedata.Value)).Size > 0 then
-            Form_Main.open_child('binedit', StrToInt(nodedata.Value))
+          if con.GetFileInfo(StrToInt(nodedata.Value)).Size > 0 then
+            Form_Main.open_child('binedit', Connection, StrToInt(nodedata.Value))
           else
             ShowMessage('Linked filed is a zero-byte-file');
@@ -779,5 +795,5 @@
       if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then
       begin
-        form := Form_Main.open_child('binedit', -1);
+        form := Form_Main.open_child('binedit', Connection, -1);
         if Assigned(form) then
           form.SetFileFilters(nodedata.Value, '', False);
Index: /oup/current/Tools/Extractor.dfm
===================================================================
--- /oup/current/Tools/Extractor.dfm	(revision 91)
+++ /oup/current/Tools/Extractor.dfm	(revision 92)
@@ -22,5 +22,4 @@
       Width = 333
       Height = 338
-      ExplicitTop = 153
       ExplicitWidth = 333
       ExplicitHeight = 338
@@ -29,4 +28,8 @@
       Width = 333
       ExplicitWidth = 333
+      inherited Bevel1: TBevel
+        Width = 327
+        ExplicitWidth = 327
+      end
       inherited combo_extension: TComboBox
         Width = 325
@@ -39,4 +42,8 @@
         Width = 325
         ExplicitWidth = 325
+      end
+      inherited combo_connection: TComboBox
+        Width = 263
+        ExplicitWidth = 263
       end
     end
Index: /oup/current/Tools/Extractor.pas
===================================================================
--- /oup/current/Tools/Extractor.pas	(revision 91)
+++ /oup/current/Tools/Extractor.pas	(revision 92)
@@ -105,5 +105,5 @@
     if (selonly and filelist.Selected[i]) or not selonly then
     begin
-      fileid := OniDataConnection.ExtractFileID(filelist.Items.Strings[i]);
+      fileid := Connection.ExtractFileID(filelist.Items.Strings[i]);
       filename := GetWinFilename(filelist.Items.Strings[i]);
       if check_dat.Checked then
Index: /oup/current/Tools/RawEdit.dfm
===================================================================
--- /oup/current/Tools/RawEdit.dfm	(revision 91)
+++ /oup/current/Tools/RawEdit.dfm	(revision 92)
@@ -23,6 +23,6 @@
     end
     inherited filelist: TListBox
-      Height = 76
-      ExplicitHeight = 76
+      Height = 52
+      ExplicitHeight = 52
     end
     object panel_imexport: TPanel
@@ -79,5 +79,4 @@
   end
   inherited content: TPanel
-    OnResize = panel_contentResize
     object Splitter2: TSplitter
       Left = 0
@@ -152,4 +151,5 @@
       ParentFont = False
       PopupMenu = value_viewer_context
+      ScrollBars = ssVertical
       TabOrder = 1
       OnDblClick = value_viewerDblClick
Index: /oup/current/Tools/RawEdit.pas
===================================================================
--- /oup/current/Tools/RawEdit.pas	(revision 91)
+++ /oup/current/Tools/RawEdit.pas	(revision 92)
@@ -39,6 +39,4 @@
     procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
 
-    procedure panel_contentResize(Sender: TObject);
-
     function GetValue(datatype: Word; offset: LongWord): String;
     procedure ClearValues;
@@ -58,5 +56,5 @@
     fileid:     Integer;
     dat_offset: LongWord;
-    fileid_opened, dat_offset_opened: LongWord;
+    fileid_opened, dat_offset_opened: Integer;
   public
   end;
@@ -74,20 +72,30 @@
   i: Integer;
 begin
-  if hex.Modified then
-    if not Save then
-      Exit;
-  ClearValues;
-  hex.DataSize := 0;
-  fileid := fileinfo.ID;
-  list_offset.Enabled := False;
-  if fileinfo.size > 0 then
-  begin
-    offsets := OniDataConnection.GetRawList(fileid);
+  if fileinfo.ID >= 0 then
+  begin
+    if hex.Modified then
+      if not Save then
+        Exit;
+    ClearValues;
+    hex.DataSize := 0;
+    fileid := fileinfo.ID;
+    list_offset.Enabled := False;
+    if fileinfo.size > 0 then
+    begin
+      offsets := Connection.GetRawList(fileid);
+      list_offset.Items.Clear;
+      if Length(offsets) > 0 then
+        for i := 0 to High(offsets) do
+          list_offset.Items.Add('0x' + IntToHex(offsets[i].src_offset, 8) +
+                ', ' + IntToStr(offsets[i].raw_size) + ' bytes');
+      list_offset.Enabled := True;
+    end;
+  end
+  else
+  begin
+    ClearValues;
+    hex.DataSize := 0;
+    fileid := -1;
     list_offset.Items.Clear;
-    if Length(offsets) > 0 then
-      for i := 0 to High(offsets) do
-        list_offset.Items.Add('0x' + IntToHex(offsets[i].src_offset, 8) +
-              ', ' + IntToStr(offsets[i].raw_size) + ' bytes');
-    list_offset.Enabled := True;
   end;
 end;
@@ -109,5 +117,5 @@
     for i := 0 to filelist.Count - 1 do
     begin
-      if OniDataConnection.ExtractFileID(filelist.Items.Strings[i]) = raw_info.src_id then
+      if Connection.ExtractFileID(filelist.Items.Strings[i]) = raw_info.src_id then
       begin
         filelist.ItemIndex := i;
@@ -126,5 +134,5 @@
   end;
   SetLength(Data, raw_info.raw_size);
-  OniDataConnection.LoadRawFile(raw_info.src_id, raw_info.src_offset, @Data[0]);
+  Connection.LoadRawFile(raw_info.src_id, raw_info.src_offset, @Data[0]);
   if Length(Data) > 0 then
   begin
@@ -158,5 +166,5 @@
   dat_offset := StrToInt('$' + MidStr(
     list_offset.Items.Strings[list_offset.ItemIndex], 3, 8));
-  LoadRaw(OniDataConnection.GetRawInfo(fileid, dat_offset));
+  LoadRaw(Connection.GetRawInfo(fileid, dat_offset));
 end;
 
@@ -391,4 +399,5 @@
 }
   value_viewer.FixedRows := 1;
+  value_viewer.FixedCols := 1;
   value_viewer.Cells[0, 0] := 'Type';
   value_viewer.Cells[1, 0] := 'Value';
@@ -400,5 +409,6 @@
   value_viewer.Cells[0, 6] := 'String';
   value_viewer.Cells[0, 7] := 'Selected length';
-  value_viewer.ColWidths[0] := 100;
+  value_viewer.ColWidths[0] := 125;
+  value_viewer.ColWidths[1] := 1000;
   //
   value_viewer.Font.Charset := AppSettings.CharSet;
@@ -416,5 +426,5 @@
 begin
   case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' +
-      OniDataConnection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
+      Connection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
       MB_YESNOCANCEL) of
     idYes:
@@ -426,5 +436,5 @@
       mem.Read(Data[0], mem.Size);
       mem.Free;
-      OniDataConnection.UpdateRawFile(fileid_opened, dat_offset_opened,
+      Connection.UpdateRawFile(fileid_opened, dat_offset_opened,
         Length(Data), @Data[0]);
       hex.Modified := False;
@@ -452,13 +462,4 @@
       CanClose := False;
   end;
-end;
-
-
-
-
-procedure TForm_RawEdit.panel_contentResize(Sender: TObject);
-begin
-  if fileid >= 0 then
-    value_viewer.ColWidths[1] := value_viewer.Width - value_viewer.ColWidths[0] - 50;
 end;
 
@@ -546,8 +547,8 @@
   fs: TFileStream;
 begin
-  saved.Filter     := 'Files of matching extension (*.' + OniDataConnection.GetFileInfo(
-    fileid).Extension + ')|*.' + OniDataConnection.GetFileInfo(fileid).Extension +
+  saved.Filter     := 'Files of matching extension (*.' + Connection.GetFileInfo(
+    fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension +
     '|All files|*.*';
-  saved.DefaultExt := OniDataConnection.GetFileInfo(fileid).Extension;
+  saved.DefaultExt := Connection.GetFileInfo(fileid).Extension;
   if saved.Execute then
   begin
@@ -566,6 +567,6 @@
   fs:   TFileStream;
 begin
-  opend.Filter := 'Files of matching extension (*.' + OniDataConnection.GetFileInfo(
-    fileid).Extension + ')|*.' + OniDataConnection.GetFileInfo(fileid).Extension +
+  opend.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo(
+    fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension +
     '|All files|*.*';
   if opend.Execute then
Index: /oup/current/Tools/Template.dfm
===================================================================
--- /oup/current/Tools/Template.dfm	(revision 91)
+++ /oup/current/Tools/Template.dfm	(revision 92)
@@ -52,6 +52,4 @@
       OnClick = listClick
       OnMouseDown = listMouseDown
-      ExplicitTop = 129
-      ExplicitHeight = 294
     end
     object panel_extension: TPanel
Index: /oup/current/Tools/Template.pas
===================================================================
--- /oup/current/Tools/Template.pas	(revision 91)
+++ /oup/current/Tools/Template.pas	(revision 92)
@@ -44,6 +44,6 @@
     procedure RecreateExtList;
     procedure LoadFileNames;
-    procedure SelectFileName(filename: String);
-    procedure SelectFileID(id: Integer);
+    procedure SelectFileName(connection: TOniData; filename: String);
+    procedure SelectFileID(connection: TOniData; id: Integer);
     procedure check_filternameClick(Sender: TObject);
     procedure check_zerobyteClick(Sender: TObject);
@@ -285,5 +285,5 @@
   id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);
   context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name));
-  Form_Main.open_child(context, id);
+  Form_Main.open_child(context, FConnection, id);
 end;
 
@@ -415,8 +415,24 @@
 
 
-procedure TForm_ToolTemplate.SelectFileID(id: Integer);
-var
-  i: Integer;
-begin
+procedure TForm_ToolTemplate.SelectFileID(connection: TOniData; id: Integer);
+var
+  i: Integer;
+  name: String;
+  nstart, nend: Integer;
+begin
+  for i := 0 to combo_connection.Items.Count - 1 do
+  begin
+    name := combo_connection.Items.Strings[i];
+    nstart := Pos(' ', name) + 1;
+    nend := Pos('(', name) - 1;
+    name := MidStr(name, nstart, nend - nstart);
+
+    if ExtractFileName(connection.FileName) = name then
+    begin
+      combo_connection.ItemIndex := i;
+      combo_connectionChange(Self);
+    end;
+  end;
+
   filelist.ItemIndex := -1;
   if filelist.Items.Count > 0 then
@@ -430,8 +446,24 @@
 end;
 
-procedure TForm_ToolTemplate.SelectFileName(filename: String);
-var
-  i: Integer;
-begin
+procedure TForm_ToolTemplate.SelectFileName(connection: TOniData; filename: String);
+var
+  i: Integer;
+  name: String;
+  nstart, nend: Integer;
+begin
+  for i := 0 to combo_connection.Items.Count - 1 do
+  begin
+    name := combo_connection.Items.Strings[i];
+    nstart := Pos(' ', name) + 1;
+    nend := Pos('(', name) - 1;
+    name := MidStr(name, nstart, nend - nstart);
+
+    if ExtractFileName(connection.FileName) = name then
+    begin
+      combo_connection.ItemIndex := i;
+      combo_connectionChange(Self);
+    end;
+  end;
+
   filelist.ItemIndex := -1;
   if filelist.Items.Count > 0 then
Index: /oup/current/Tools/TxmpReplace.dfm
===================================================================
--- /oup/current/Tools/TxmpReplace.dfm	(revision 91)
+++ /oup/current/Tools/TxmpReplace.dfm	(revision 92)
@@ -1,6 +1,4 @@
 inherited Form_TxmpReplace: TForm_TxmpReplace
   Caption = 'TxmpReplace'
-  ExplicitWidth = 320
-  ExplicitHeight = 240
   PixelsPerInch = 96
   TextHeight = 13
@@ -37,5 +35,4 @@
       Height = 146
       Align = alTop
-      ExplicitTop = 153
       ExplicitHeight = 146
     end
Index: /oup/current/Tools/TxmpReplace.pas
===================================================================
--- /oup/current/Tools/TxmpReplace.pas	(revision 91)
+++ /oup/current/Tools/TxmpReplace.pas	(revision 92)
@@ -52,7 +52,7 @@
 begin
   fileid := fileinfo.ID;
-  OniDataConnection.LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte);
-  OniDataConnection.LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);
-  OniDataConnection.LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte);
+  Connection.LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte);
+  Connection.LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);
+  Connection.LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte);
   check_fading.Checked := (fadingbyte and $01) > 0;
   check_transparency.Checked := (depthbyte and $04) > 0;
@@ -103,9 +103,9 @@
   if filelist.ItemIndex >= 0 then
   begin
-    OniDataConnection.LoadDatFilePart(fileid, $88, 1, @oldfading);
-    if OniDataConnection.OSisMac then
-      OniDataConnection.UpdateDatFilePart(fileid, $A0, 4, @old_rawaddr)
+    Connection.LoadDatFilePart(fileid, $88, 1, @oldfading);
+    if Connection.OSisMac then
+      Connection.UpdateDatFilePart(fileid, $A0, 4, @old_rawaddr)
     else
-      OniDataConnection.LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);
+      Connection.LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);
 
     if (OniImage_Old.Width <> OniImage_New.Width) or
@@ -138,11 +138,11 @@
     newsize := OniImage_New.GetImageDataSize(check_fading.Checked);
 
-    if (newsize > old_size) and (OniDataConnection.Backend = ODB_Dat) then
-      new_rawaddr := OniDataConnection.AppendRawFile(
-        OniDataConnection.OSisMac, Length(tempd), tempd)
+    if (newsize > old_size) and (Connection.Backend = ODB_Dat) then
+      new_rawaddr := Connection.AppendRawFile(
+        Connection.OSisMac, Length(tempd), tempd)
     else
     begin
       new_rawaddr := old_rawaddr;
-      OniDataConnection.UpdateRawFile(fileid, $9C, Length(tempd), tempd);
+      Connection.UpdateRawFile(fileid, $9C, Length(tempd), tempd);
     end;
 
@@ -150,17 +150,17 @@
     if check_fading.Checked then
       datbyte := datbyte or $01;
-    OniDataConnection.UpdateDatFilePart(fileid, $88, 1, @datbyte);
+    Connection.UpdateDatFilePart(fileid, $88, 1, @datbyte);
     datbyte := $10;
     if check_transparency.Checked then
       datbyte := datbyte or $04;
-    OniDataConnection.UpdateDatFilePart(fileid, $89, 1, @datbyte);
-    OniDataConnection.UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width);
-    OniDataConnection.UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height);
+    Connection.UpdateDatFilePart(fileid, $89, 1, @datbyte);
+    Connection.UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width);
+    Connection.UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height);
     datbyte := $08;
-    OniDataConnection.UpdateDatFilePart(fileid, $90, 1, @datbyte);
-    if OniDataConnection.OSisMac then
-      OniDataConnection.UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr)
+    Connection.UpdateDatFilePart(fileid, $90, 1, @datbyte);
+    if Connection.OSisMac then
+      Connection.UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr)
     else
-      OniDataConnection.UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr);
+      Connection.UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr);
 
     ShowMessage('TXMP-image replaced');
