Index: /oup/current/DataAccess/Access_OniArchive.pas
===================================================================
--- /oup/current/DataAccess/Access_OniArchive.pas	(revision 230)
+++ /oup/current/DataAccess/Access_OniArchive.pas	(revision 231)
@@ -370,19 +370,22 @@
   if fileid < GetFileCount then
   begin
-    if not Assigned(Target) then
-      Target := TMemoryStream.Create;
-    if not FDatOpened then
-      Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
-    Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
-    streampos := Target.Position;
-    Target.CopyFrom(Fdat_file, Fdat_files[fileid].Size);
-    Target.Seek(streampos, soFromBeginning);
-    if UnloadWhenUnused then
-    begin
-      Fdat_file.Free;
-      FDatOpened := False;
-    end
-    else
-      FDatOpened := True;
+    if GetFileInfo(FileID).Size > 0 then
+    begin
+      if not Assigned(Target) then
+        Target := TMemoryStream.Create;
+      if not FDatOpened then
+        Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
+      Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
+      streampos := Target.Position;
+      Target.CopyFrom(Fdat_file, Fdat_files[fileid].Size);
+      Target.Seek(streampos, soFromBeginning);
+      if UnloadWhenUnused then
+      begin
+        Fdat_file.Free;
+        FDatOpened := False;
+      end
+      else
+        FDatOpened := True;
+    end;
   end;
 end;
Index: /oup/current/FileClasses/_Extensions.pas
===================================================================
--- /oup/current/FileClasses/_Extensions.pas	(revision 230)
+++ /oup/current/FileClasses/_Extensions.pas	(revision 231)
@@ -2,4 +2,7 @@
 
 interface
+
+uses
+  _FileTypes;
 
 type
Index: /oup/current/FileClasses/_FileTypes.pas
===================================================================
--- /oup/current/FileClasses/_FileTypes.pas	(revision 230)
+++ /oup/current/FileClasses/_FileTypes.pas	(revision 231)
@@ -11,8 +11,5 @@
     protected
       FConnectionID: Integer;
-      FFileID: Integer;
-      FFileName: String;
-      FFileExt: String;
-      FFileSize: Integer;
+      FFileInfo: TFileInfo;
       FFileStream: TMemoryStream;
 
@@ -45,8 +42,5 @@
 
       property FileStream: TMemoryStream read FFileStream;
-      property FileID: Integer read FFileID;
-      property FileName: String read FFileName;
-      property FileExt: String read FFileExt;
-      property FileSize: Integer read FFileSize;
+      property FileInfo: TFileInfo read FFileInfo;
       property ConnectionID: Integer read FConnectionID;
 
@@ -84,13 +78,7 @@
 
 constructor TFile.Create(ConnectionID, FileID: Integer);
-var
-  fileinfo: TFileInfo;
 begin
   FConnectionID := ConnectionID;
-  FFileID := FileID;
-  fileinfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID);
-  FFileName := fileinfo.Name;
-  FFileExt := fileinfo.Extension;
-  FFileSize := fileinfo.Size;
+  FFileInfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID);
 
   FCached := False;
@@ -235,5 +223,5 @@
 procedure TFile.InitDatLinks;
 begin
-  FDatLinks := ConManager.Connection[FConnectionID].GetDatLinks(FFileID);
+  FDatLinks := ConManager.Connection[FConnectionID].GetDatLinks(FFileInfo.ID);
 end;
 
@@ -245,5 +233,5 @@
 procedure TFile.InitRawList;
 begin
-  FRawParts := ConManager.Connection[FConnectionID].GetRawList(FFileID);
+  FRawParts := ConManager.Connection[FConnectionID].GetRawList(FFileInfo.ID);
 end;
 
Index: /oup/current/Tools/BinEdit.dfm
===================================================================
--- /oup/current/Tools/BinEdit.dfm	(revision 230)
+++ /oup/current/Tools/BinEdit.dfm	(revision 231)
@@ -4,6 +4,4 @@
   OnCreate = FormCreate
   OnKeyUp = FormKeyUp
-  ExplicitWidth = 320
-  ExplicitHeight = 240
   PixelsPerInch = 96
   TextHeight = 13
@@ -19,4 +17,10 @@
             ExplicitHeight = 318
           end
+        end
+        inherited tab_meta: TTabSheet
+          ExplicitLeft = 0
+          ExplicitTop = 0
+          ExplicitWidth = 0
+          ExplicitHeight = 0
         end
       end
@@ -133,5 +137,4 @@
         OnDblClick = value_viewerDblClick
         OnMouseDown = value_viewerMouseDown
-        ExplicitHeight = 218
       end
       object VST: TVirtualStringTree
Index: /oup/current/Tools/BinEdit.pas
===================================================================
--- /oup/current/Tools/BinEdit.pas	(revision 230)
+++ /oup/current/Tools/BinEdit.pas	(revision 231)
@@ -30,5 +30,4 @@
     procedure NewFile(fileinfo: TFileInfo);
 
-    procedure LoadDat(_fileid: Integer);
     function Save: Boolean;
     function GetValue(datatype: Word; offset: Integer): String;
@@ -121,26 +120,4 @@
 
 procedure TForm_BinEdit.NewFile(fileinfo: TFileInfo);
-begin
-  LoadDat(fileinfo.ID);
-end;
-
-
-
-
-function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
-  ARecord: TNodeData): PVirtualNode;
-var
-  Data: PNodeData;
-begin
-  Result := AVST.AddChild(ANode);
-  Data   := AVST.GetNodeData(Result);
-  AVST.ValidateNode(Result, False);
-  Data^ := ARecord;
-end;
-
-
-
-
-procedure TForm_BinEdit.LoadDat(_fileid: Integer);
 var
   mem:  TMemoryStream;
@@ -157,10 +134,10 @@
     end;
   end;
-  if _fileid >= 0 then
-  begin
-    fileid := _fileid;
+  if fileinfo.ID >= 0 then
+  begin
+    fileid := fileinfo.ID;
     ConID := ConnectionID;
-    if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
-      Self.SelectFileID(ConnectionID, fileid);
+//    if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
+//      Self.SelectFileID(ConnectionID, fileid);
     Self.ClearStructViewer;
     mem := nil;
@@ -174,5 +151,5 @@
   else
   begin
-    fileid := _fileid;
+    fileid := -1;
     ConID := -1;
     Self.ClearStructViewer;
@@ -182,4 +159,20 @@
   end;
 end;
+
+
+
+
+function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
+  ARecord: TNodeData): PVirtualNode;
+var
+  Data: PNodeData;
+begin
+  Result := AVST.AddChild(ANode);
+  Data   := AVST.GetNodeData(Result);
+  AVST.ValidateNode(Result, False);
+  Data^ := ARecord;
+end;
+
+
 
 
Index: /oup/current/Tools/FileManager.dfm
===================================================================
--- /oup/current/Tools/FileManager.dfm	(revision 230)
+++ /oup/current/Tools/FileManager.dfm	(revision 231)
@@ -3,3 +3,12 @@
   PixelsPerInch = 96
   TextHeight = 13
+  inherited panel_basecontent: TPanel
+    inherited panel_files: TPanel
+      inherited FilePages: TPageControl
+        inherited tab_files: TTabSheet
+          Caption = 'File list'
+        end
+      end
+    end
+  end
 end
Index: /oup/current/Tools/MetaEditor.pas
===================================================================
--- /oup/current/Tools/MetaEditor.pas	(revision 230)
+++ /oup/current/Tools/MetaEditor.pas	(revision 231)
@@ -34,5 +34,5 @@
 implementation
 {$R *.dfm}
-uses _MetaManager, _FileTypes, Data;
+uses _MetaManager, _MetaTypes, ConnectionManager, Data;
 
 type
@@ -57,21 +57,14 @@
 procedure TForm_Meta.NewCon(ID: Integer);
 var
-  a,b,c: Int64;
   i: Integer;
   data: TNodeData;
   node: PVirtualNode;
-begin
-{
+  Meta: TMetaManager;
+begin
   if ID >= 0 then
   begin
-    QueryPerformanceFrequency(c);
-    QueryPerformanceCounter(a);
-    if not Assigned(Meta) then
-      Meta := TMetaManager.Create(ID, Self);
-    QueryPerformanceCounter(b);
-    ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');
-
     VST.Clear;
     VST.BeginUpdate;
+    Meta := ConManager.Connection[ID].MetaData;
     for i := 0 to Meta.FileCount - 1 do
     begin
@@ -86,5 +79,4 @@
     VST.EndUpdate;
   end;
-}
 end;
 
@@ -98,18 +90,18 @@
   i: Integer;
   id: Integer;
-begin
-{
-  data := VST.GetNodeData(node);
-  for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do
-  begin
-    id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID;
+  Meta: TMetaManager;
+begin
+  data := Sender.GetNodeData(node);
+  Meta := ConManager.Connection[ID].MetaData;
+  for i := 0 to TFile(data.Field).ChildCount - 1 do
+  begin
+    id := TFile(data.Field).LinkByIndex[i].DestID;
     Meta.InitFile(id);
     newdata.Field := Meta.FileById[id];
-    newnode := AddVSTEntry(VST, Node, newdata);
+    newnode := AddVSTEntry(TCustomVirtualStringTree(Sender), Node, newdata);
     if Meta.FileById[id].ChildCount > 0 then
-      VST.HasChildren[newnode] := True;
-  end;
-  ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount;
-}
+      Sender.HasChildren[newnode] := True;
+  end;
+  ChildCount := Sender.ChildCount[Node];
 end;
 
@@ -180,5 +172,5 @@
           if Data.Field is TFile then
           begin
-            CellText := TFile(Data.Field).FileName;
+            CellText := TFile(Data.Field).FileInfo.Name;
             if CellText = '' then
               CellText := 'Unnamed';
@@ -188,10 +180,10 @@
         begin
           if Data.Field is TFile then
-            CellText := TFile(Data.Field).FileExt;
+            CellText := TFile(Data.Field).FileInfo.Extension;
         end;
       2:
         begin
           if Data.Field is TFile then
-            CellText := IntToStr(TFile(Data.Field).FileID);
+            CellText := IntToStr(TFile(Data.Field).FileInfo.ID);
         end;
     end;
@@ -214,7 +206,7 @@
           if Data.Field is TFile then
           begin
-            if Length(TFile(Data.Field).FileName) = 0 then
+            if Length(TFile(Data.Field).FileInfo.Name) = 0 then
               TargetCanvas.Font.Color := $C06060;
-            if TFile(Data.Field).FileSize = 0 then
+            if TFile(Data.Field).FileInfo.Size = 0 then
               TargetCanvas.Font.Color := $2020A0;
           end;
Index: /oup/current/Tools/_TemplateFileList.dfm
===================================================================
--- /oup/current/Tools/_TemplateFileList.dfm	(revision 230)
+++ /oup/current/Tools/_TemplateFileList.dfm	(revision 231)
@@ -37,5 +37,5 @@
         TabOrder = 0
         object tab_files: TTabSheet
-          Caption = 'Files'
+          Caption = 'Filelist'
           object panel_extension: TPanel
             Left = 0
@@ -267,5 +267,5 @@
         end
         object tab_meta: TTabSheet
-          Caption = 'Meta'
+          Caption = 'Tree'
           ImageIndex = 1
           object filelist_meta: TVirtualStringTree
@@ -284,4 +284,6 @@
             Header.Options = [hoColumnResize, hoDrag]
             TabOrder = 0
+            OnFocusChanged = filelist_metaFocusChanged
+            OnFocusChanging = filelist_metaFocusChanging
             OnGetText = filelist_metaGetText
             OnPaintText = filelist_metaPaintText
Index: /oup/current/Tools/_TemplateFileList.pas
===================================================================
--- /oup/current/Tools/_TemplateFileList.pas	(revision 230)
+++ /oup/current/Tools/_TemplateFileList.pas	(revision 231)
@@ -9,4 +9,6 @@
 
 type
+  TNewFileSelectingEvent = procedure(FileInfo: TFileInfo; var allowed: Boolean) of object;
+
   TForm_TemplateFileList = class(TForm_TemplateFile)
     panel_files: TPanel;
@@ -62,8 +64,14 @@
       const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
       TextType: TVSTTextType);
+    procedure filelist_metaFocusChanging(Sender: TBaseVirtualTree; OldNode,
+      NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
+      var Allowed: Boolean);
+    procedure filelist_metaFocusChanged(Sender: TBaseVirtualTree;
+      Node: PVirtualNode; Column: TColumnIndex);
   private
     FSortBy: TSortType;
     FAllowedExts: String;
     FAllowMultiSelect: Boolean;
+    FOnNewFileSelecting: TNewFileSelectingEvent;
     procedure SetAllowedExts(exts: String);
     procedure SetMultiSelect(allow: Boolean);
@@ -75,4 +83,5 @@
     property AllowedExts: String read FAllowedExts write SetAllowedExts;
     property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect;
+    property OnNewFileSelecting: TNewFileSelectingEvent read FOnNewFileSelecting write FOnNewFileSelecting;
   end;
 
@@ -404,4 +413,37 @@
 
 
+procedure TForm_TemplateFileList.filelist_metaFocusChanged(
+  Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
+var
+  data: PNodeData;
+begin
+  inherited;
+  data := Sender.GetNodeData(Node);
+  if data.Field is TFile then
+  begin
+    if Assigned(FOnNewFileSelected) then
+    begin
+      FOnNewFileSelected(TFile(data.Field).FileInfo);
+    end;
+  end;
+end;
+
+procedure TForm_TemplateFileList.filelist_metaFocusChanging(
+  Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn,
+  NewColumn: TColumnIndex; var Allowed: Boolean);
+var
+  data: PNodeData;
+begin
+  inherited;
+  data := Sender.GetNodeData(NewNode);
+  if data.Field is TFile then
+  begin
+    if Assigned(FOnNewFileSelecting) then
+    begin
+      FOnNewFileSelecting(TFile(data.Field).FileInfo, Allowed);
+    end;
+  end;
+end;
+
 procedure TForm_TemplateFileList.filelist_metaGetText(Sender: TBaseVirtualTree;
   Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
@@ -418,8 +460,8 @@
   if data.Field is TFile then
   begin
-    if TFile(data.Field).FileName = '' then
-      CellText := TFile(data.Field).FileExt + ' (unnamed)'
+    if TFile(data.Field).FileInfo.Name = '' then
+      CellText := TFile(data.Field).FileInfo.Extension + ' (unnamed)'
     else
-      CellText := TFile(data.Field).FileExt + ': ' + TFile(data.Field).FileName;
+      CellText := TFile(data.Field).FileInfo.Extension + ': ' + TFile(data.Field).FileInfo.Name;
   end;
 end;
@@ -479,7 +521,7 @@
   if Data.Field is TFile then
   begin
-    if Length(TFile(Data.Field).FileName) = 0 then
+    if Length(TFile(Data.Field).FileInfo.Name) = 0 then
       TargetCanvas.Font.Color := $C06060;
-    if TFile(Data.Field).FileSize = 0 then
+    if TFile(Data.Field).FileInfo.Size = 0 then
       TargetCanvas.Font.Color := $2020A0;
   end;
