Index: oup/current/Tools/MetaEditor.dfm
===================================================================
--- oup/current/Tools/MetaEditor.dfm	(revision 209)
+++ oup/current/Tools/MetaEditor.dfm	(revision 209)
@@ -0,0 +1,53 @@
+object Form_Meta: TForm_Meta
+  Left = 0
+  Top = 0
+  Caption = 'Form_Meta'
+  ClientHeight = 293
+  ClientWidth = 426
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'Tahoma'
+  Font.Style = []
+  FormStyle = fsMDIChild
+  OldCreateOrder = False
+  Visible = True
+  WindowState = wsMaximized
+  OnClose = FormClose
+  OnCreate = FormCreate
+  DesignSize = (
+    426
+    293)
+  PixelsPerInch = 96
+  TextHeight = 13
+  object VST: TVirtualStringTree
+    Left = 8
+    Top = 8
+    Width = 389
+    Height = 265
+    Anchors = [akLeft, akTop, akRight, akBottom]
+    AnimationDuration = 0
+    Header.AutoSizeIndex = 0
+    Header.Font.Charset = DEFAULT_CHARSET
+    Header.Font.Color = clWindowText
+    Header.Font.Height = -11
+    Header.Font.Name = 'Tahoma'
+    Header.Font.Style = []
+    Header.Options = [hoColumnResize, hoDrag, hoVisible]
+    TabOrder = 0
+    TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
+    TreeOptions.PaintOptions = [toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages]
+    OnGetText = VSTGetText
+    Columns = <
+      item
+        Position = 0
+        Width = 150
+        WideText = 'Main'
+      end
+      item
+        Position = 1
+        WideText = 'Data'
+      end>
+  end
+end
Index: oup/current/Tools/MetaEditor.pas
===================================================================
--- oup/current/Tools/MetaEditor.pas	(revision 209)
+++ oup/current/Tools/MetaEditor.pas	(revision 209)
@@ -0,0 +1,200 @@
+unit MetaEditor;
+interface
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, VirtualTrees, _FileManager;
+
+type
+  TForm_Meta = class(TForm)
+    VST: TVirtualStringTree;
+    procedure FormClose(Sender: TObject; var Action: TCloseAction);
+    procedure FormCreate(Sender: TObject);
+    procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
+      Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
+  private
+  public
+    FileManager: TFileManager;
+  end;
+
+var
+  Form_Meta: TForm_Meta;
+
+implementation
+uses
+  Data, _DataTypes, _FileTypes;
+{$R *.dfm}
+
+type
+  PNodeData = ^TNodeData;
+
+  TNodeData = record
+    Field: TObject;
+  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_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+  FileManager.Free;
+  Action := caFree;
+end;
+
+
+procedure TForm_Meta.FormCreate(Sender: TObject);
+var
+  a,b,c: Int64;
+  i: Integer;
+  data: TNodeData;
+begin
+  VST.NodeDataSize := SizeOf(TNodeData);
+  VST.Font.Charset := AppSettings.CharSet;
+  VST.Clear;
+
+  QueryPerformanceFrequency(c);
+  QueryPerformanceCounter(a);
+  FileManager := TFileManager.Create(1);
+  QueryPerformanceCounter(b);
+  ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');
+
+  for i := 0 to FileManager.FileCount - 1 do
+  begin
+    data.Field := FileManager.FileById[i];
+    AddVSTEntry(VST, nil, data);
+  end;
+end;
+
+
+
+procedure TForm_Meta.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
+  Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
+var
+  Data: PNodeData;
+begin
+  Data     := Sender.GetNodeData(Node);
+  CellText := '';
+  if TextType = ttNormal then
+  begin
+    case Column of
+      0: begin
+        if Data.Field is TFile then
+        begin
+          CellText := TFile(Data.Field).FileName;
+        end;
+      end;
+{      0:
+        CellText := Data.Caption;
+      1:
+        if Data.DataType > 0 then
+          CellText := '0x' + IntToHex(Data.Offset, 8)
+        else if Data.Offset > 0 then
+          CellText := '0x' + IntToHex(Data.Offset, 8);
+      2:
+        if Data.DataType > 0 then
+          CellText := GetDataType(Data.DataType);
+      3:
+        if Data.DataType > 0 then
+          CellText := Data.Value //GetValue(data.DataType, data.Offset)
+        else if Length(Data.Value) > 0 then
+          CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes';
+      4:
+        CellText := Data.Description;
+}    end;
+  end;
+end;
+
+{
+
+procedure WriteStructureInfos;
+var
+  i, j:    Integer;
+  pdata:   PNodeData;
+  Data:    TNodeData;
+  node:    PVirtualNode;
+begin
+  VST.BeginUpdate;
+  if VST.RootNodeCount = 0 then
+  begin
+    structs := LoadStructureDefinition(ConID, fileid);
+    if structs.Data then
+    begin
+      if Length(structs.Global) > 0 then
+      begin
+        for i := 0 to High(structs.Global) do
+        begin
+          Data.Caption  := structs.Global[i].Name;
+          Data.Offset   := structs.Global[i].offset;
+          Data.DataType := structs.Global[i].datatype;
+          Data.Value    := GetValue(structs.Global[i].datatype, structs.Global[i].offset);
+          Data.Description := structs.Global[i].description;
+          AddVSTEntry(VST, nil, Data);
+        end;
+      end;
+      if Length(structs.Subs) > 0 then
+      begin
+        for i := 0 to High(structs.Subs) do
+        begin
+          with structs.Subs[i] do
+          begin
+            if Length(Entries) > 0 then
+            begin
+              if Pos('#', SubName) > 0 then
+              begin
+                Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
+                Data.Value   := '$' +
+                  MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
+                Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
+                Data.Description := SubDesc;
+              end
+              else
+              begin
+                Data.Caption := SubName;
+                Data.Description := SubDesc;
+                Data.Offset := 0;
+                Data.Value := '';
+              end;
+              Data.DataType := 0;
+              node := AddVSTEntry(VST, nil, Data);
+              Data.Description := '';
+              for j := 0 to High(Entries) do
+              begin
+                Data.Caption  := Entries[j].Name;
+                Data.Offset   := Entries[j].offset;
+                Data.DataType := Entries[j].datatype;
+                Data.Value    := GetValue(Entries[j].datatype, Entries[j].offset);
+                Data.Description := Entries[j].description;
+                AddVSTEntry(VST, node, Data);
+              end;
+            end;
+          end;
+        end;
+      end;
+    end;
+    if VST.RootNodeCount > 0 then
+      VST.FocusedNode := VST.GetFirst;
+  end
+  else
+  begin
+    Node := VST.GetFirst;
+    while Assigned(Node) do
+    begin
+      pdata := VST.GetNodeData(Node);
+      if pdata.DataType > 0 then
+        pdata.Value := GetValue(pdata.Datatype, pdata.Offset);
+      Node := VST.GetNext(Node);
+    end;
+  end;
+  VST.EndUpdate;
+end;
+}
+end.
Index: oup/current/Tools/Preview.dfm
===================================================================
--- oup/current/Tools/Preview.dfm	(revision 206)
+++ oup/current/Tools/Preview.dfm	(revision 209)
@@ -27,9 +27,12 @@
     end
     object img: TImage
-      Left = 0
-      Top = 20
-      Width = 283
-      Height = 403
+      AlignWithMargins = True
+      Left = 3
+      Top = 23
+      Width = 277
+      Height = 397
       Align = alClient
+      ExplicitLeft = 0
+      ExplicitTop = 20
       ExplicitWidth = 313
       ExplicitHeight = 453
Index: oup/current/Tools/TxmpReplace.dfm
===================================================================
--- oup/current/Tools/TxmpReplace.dfm	(revision 206)
+++ oup/current/Tools/TxmpReplace.dfm	(revision 209)
@@ -84,9 +84,12 @@
       TabOrder = 0
       object image_bmppreview: TImage
-        Left = 2
-        Top = 45
-        Width = 279
-        Height = 297
+        AlignWithMargins = True
+        Left = 5
+        Top = 48
+        Width = 273
+        Height = 291
         Align = alClient
+        ExplicitLeft = 2
+        ExplicitTop = 45
         ExplicitWidth = 182
         ExplicitHeight = 302
Index: oup/current/Tools/TxmpReplace.pas
===================================================================
--- oup/current/Tools/TxmpReplace.pas	(revision 206)
+++ oup/current/Tools/TxmpReplace.pas	(revision 209)
@@ -234,7 +234,4 @@
   Self.OnNewFileSelected := SelectFile;
   opend.Filter := saved.Filter;
-
-  TXMP := TFile_TXMP.Create(ConnectionID, 8552);
-  TXMP.Free;
 end;
 
