--- oup/current/Tools/MetaEditor.pas 2007/06/28 09:24:08 232 +++ oup/current/Tools/MetaEditor.pas 2007/07/13 23:15:47 236 @@ -5,7 +5,7 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls, ComCtrls, Grids, - MPHexEditor, Wrapgrid; + MPHexEditor, Wrapgrid, VTHeaderPopup, Menus, _TreeElement; type TForm_Meta = class(TForm_BaseTemplate) @@ -20,6 +20,16 @@ type value_viewer: TWrapGrid; splitter_hex_2: TSplitter; structviewer: TVirtualStringTree; + value_viewer_context: TPopupMenu; + value_viewer_context_copy: TMenuItem; + value_viewer_context_copyasdec: TMenuItem; + value_viewer_context_copyasfloat: TMenuItem; + value_viewer_context_copyasbitset: TMenuItem; + value_viewer_context_copyasstring: TMenuItem; + value_viewer_context_copyashex: TMenuItem; + VTHPopup: TVTHeaderPopupMenu; + btn_export: TButton; + btn_import: TButton; procedure FormCreate(Sender: TObject); procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); @@ -35,6 +45,7 @@ type const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType); private + root: TTreeElement; procedure NewCon(ID: Integer); public end; @@ -48,7 +59,7 @@ type PNodeData = ^TNodeData; TNodeData = record - Field: TObject; + Field: TTreeElement; end; function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode; @@ -69,7 +80,7 @@ var data: TNodeData; node: PVirtualNode; Meta: TMetaManager; - root: TExtensions; + root: TTreeElement; begin if ID >= 0 then begin @@ -77,9 +88,9 @@ begin VST.Clear; VST.BeginUpdate; root := ConManager.Connection[FConnectionID].MetaData.Root; - for i := 0 to High(root) do + for i := 0 to root.ChildCount - 1 do begin - data.Field := root[i]; + data.Field := root.Child[i]; node := AddVSTEntry(VST, nil, data); VST.HasChildren[node] := True; end; @@ -95,44 +106,21 @@ var newdata: TNodeData; newnode: PVirtualNode; i: Integer; - id: Integer; Meta: TMetaManager; begin data := Sender.GetNodeData(node); Meta := ConManager.Connection[ConnectionID].MetaData; - if data.Field is TFile then - begin - if TFile(data.Field).ChildCount > 0 then - begin - 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(TCustomVirtualStringTree(Sender), Node, newdata); - if Meta.FileById[id].ChildCount > 0 then - Sender.HasChildren[newnode] := True; - end; - end; - if TFile(data.Field).RawCount > 0 then - begin - for i := 0 to TFile(data.Field).RawCount - 1 do - begin -// Exit; - end; - end; - end; if data.Field is TExtension then - begin - if TExtension(data.Field).FileCount = 0 then + if TExtension(data.Field).ChildCount = 0 then TExtension(data.Field).InitList; - for i := 0 to TExtension(data.Field).FileCount - 1 do + + if data.Field.ChildCount > 0 then + begin + for i := 0 to data.Field.ChildCount - 1 do begin - id := TExtension(data.Field).Files[i]; - Meta.InitFile(id); - newdata.Field := Meta.FileById[id]; + newdata.Field := data.Field.Child[i]; newnode := AddVSTEntry(TCustomVirtualStringTree(Sender), Node, newdata); - if Meta.FileById[id].ChildCount > 0 then + if newdata.Field.ChildCount > 0 then Sender.HasChildren[newnode] := True; end; end; @@ -204,14 +192,7 @@ begin case Column of 0: begin - if Data.Field is TFile then - begin - CellText := TFile(Data.Field).FileInfo.Name; - if CellText = '' then - CellText := 'Unnamed'; - end; - if Data.Field is TExtension then - CellText := TExtension(Data.Field).Ext; + CellText := Data.Field.GetCaption; end; 1: begin @@ -223,6 +204,11 @@ begin if Data.Field is TFile then CellText := IntToStr(TFile(Data.Field).FileInfo.ID); end; + 3: + begin + if Data.Field is TDataField then + CellText := TDataField(Data.Field).ValueAsString; + end; end; end; end;