| 4 |
|
|
| 5 |
|
uses |
| 6 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 |
< |
Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls; |
| 7 |
> |
Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls, ComCtrls, Grids, |
| 8 |
> |
MPHexEditor, Wrapgrid, VTHeaderPopup, Menus, _TreeElement; |
| 9 |
|
|
| 10 |
|
type |
| 11 |
|
TForm_Meta = class(TForm_BaseTemplate) |
| 12 |
|
VST: TVirtualStringTree; |
| 12 |
– |
Panel2: TPanel; |
| 13 |
|
splitter: TSplitter; |
| 14 |
+ |
rightPages: TPageControl; |
| 15 |
+ |
tab_hex: TTabSheet; |
| 16 |
+ |
tab_meta: TTabSheet; |
| 17 |
+ |
panel_hex_actions: TPanel; |
| 18 |
+ |
hex: TMPHexEditor; |
| 19 |
+ |
splitter_hex_1: TSplitter; |
| 20 |
+ |
value_viewer: TWrapGrid; |
| 21 |
+ |
splitter_hex_2: TSplitter; |
| 22 |
+ |
structviewer: TVirtualStringTree; |
| 23 |
+ |
value_viewer_context: TPopupMenu; |
| 24 |
+ |
value_viewer_context_copy: TMenuItem; |
| 25 |
+ |
value_viewer_context_copyasdec: TMenuItem; |
| 26 |
+ |
value_viewer_context_copyasfloat: TMenuItem; |
| 27 |
+ |
value_viewer_context_copyasbitset: TMenuItem; |
| 28 |
+ |
value_viewer_context_copyasstring: TMenuItem; |
| 29 |
+ |
value_viewer_context_copyashex: TMenuItem; |
| 30 |
+ |
VTHPopup: TVTHeaderPopupMenu; |
| 31 |
+ |
btn_export: TButton; |
| 32 |
+ |
btn_import: TButton; |
| 33 |
|
procedure FormCreate(Sender: TObject); |
| 34 |
|
procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; |
| 35 |
|
var ChildCount: Cardinal); |
| 45 |
|
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
| 46 |
|
TextType: TVSTTextType); |
| 47 |
|
private |
| 48 |
+ |
root: TTreeElement; |
| 49 |
|
procedure NewCon(ID: Integer); |
| 50 |
|
public |
| 51 |
|
end; |
| 52 |
|
|
| 33 |
– |
var |
| 34 |
– |
Form_Meta: TForm_Meta; |
| 53 |
|
|
| 54 |
|
implementation |
| 55 |
|
{$R *.dfm} |
| 56 |
< |
uses _MetaManager, _FileTypes, Data; |
| 56 |
> |
uses _MetaManager, _MetaTypes, ConnectionManager, Data, _FileTypes; |
| 57 |
|
|
| 58 |
|
type |
| 59 |
|
PNodeData = ^TNodeData; |
| 60 |
|
|
| 61 |
|
TNodeData = record |
| 62 |
< |
Field: TObject; |
| 62 |
> |
Field: TTreeElement; |
| 63 |
|
end; |
| 64 |
|
|
| 65 |
|
function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode; |
| 76 |
|
|
| 77 |
|
procedure TForm_Meta.NewCon(ID: Integer); |
| 78 |
|
var |
| 61 |
– |
a,b,c: Int64; |
| 79 |
|
i: Integer; |
| 80 |
|
data: TNodeData; |
| 81 |
|
node: PVirtualNode; |
| 82 |
+ |
Meta: TMetaManager; |
| 83 |
+ |
root: TTreeElement; |
| 84 |
|
begin |
| 85 |
|
if ID >= 0 then |
| 86 |
|
begin |
| 87 |
< |
QueryPerformanceFrequency(c); |
| 69 |
< |
QueryPerformanceCounter(a); |
| 70 |
< |
if not Assigned(Meta) then |
| 71 |
< |
Meta := TMetaManager.Create(ID); |
| 72 |
< |
QueryPerformanceCounter(b); |
| 73 |
< |
ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); |
| 74 |
< |
|
| 87 |
> |
//VST |
| 88 |
|
VST.Clear; |
| 89 |
|
VST.BeginUpdate; |
| 90 |
< |
for i := 0 to Meta.FileCount - 1 do |
| 90 |
> |
// root := ConManager.Connection[FConnectionID].MetaData.Root; |
| 91 |
> |
root := ConManager.Connection[FConnectionID].MetaData.FileById[454]; |
| 92 |
> |
for i := 0 to root.ChildCount - 1 do |
| 93 |
|
begin |
| 94 |
< |
if Assigned(Meta.FileById[i]) then |
| 95 |
< |
begin |
| 96 |
< |
data.Field := Meta.FileById[i]; |
| 82 |
< |
node := AddVSTEntry(VST, nil, data); |
| 83 |
< |
if Meta.FileById[i].ChildCount > 0 then |
| 84 |
< |
VST.HasChildren[node] := True; |
| 85 |
< |
end; |
| 94 |
> |
data.Field := root.Child[i]; |
| 95 |
> |
node := AddVSTEntry(VST, nil, data); |
| 96 |
> |
VST.HasChildren[node] := True; |
| 97 |
|
end; |
| 98 |
|
VST.EndUpdate; |
| 99 |
|
end; |
| 107 |
|
newdata: TNodeData; |
| 108 |
|
newnode: PVirtualNode; |
| 109 |
|
i: Integer; |
| 110 |
< |
id: Integer; |
| 110 |
> |
Meta: TMetaManager; |
| 111 |
|
begin |
| 112 |
< |
data := VST.GetNodeData(node); |
| 113 |
< |
for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do |
| 112 |
> |
data := Sender.GetNodeData(node); |
| 113 |
> |
Meta := ConManager.Connection[ConnectionID].MetaData; |
| 114 |
> |
|
| 115 |
> |
if data.Field.ChildCount > 0 then |
| 116 |
|
begin |
| 117 |
< |
id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID; |
| 118 |
< |
Meta.InitFile(id); |
| 119 |
< |
newdata.Field := Meta.FileById[id]; |
| 120 |
< |
newnode := AddVSTEntry(VST, Node, newdata); |
| 121 |
< |
if Meta.FileById[id].ChildCount > 0 then |
| 122 |
< |
VST.HasChildren[newnode] := True; |
| 117 |
> |
for i := 0 to data.Field.ChildCount - 1 do |
| 118 |
> |
begin |
| 119 |
> |
newdata.Field := data.Field.Child[i]; |
| 120 |
> |
newnode := AddVSTEntry(TCustomVirtualStringTree(Sender), Node, newdata); |
| 121 |
> |
if newdata.Field.ChildCount > 0 then |
| 122 |
> |
Sender.HasChildren[newnode] := True; |
| 123 |
> |
end; |
| 124 |
|
end; |
| 125 |
< |
ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount; |
| 125 |
> |
ChildCount := Sender.ChildCount[Node]; |
| 126 |
|
end; |
| 127 |
|
|
| 128 |
|
|
| 137 |
|
TFile(data.Field).InitEditor; |
| 138 |
|
if Assigned(TFile(data.Field).Editor) then |
| 139 |
|
begin |
| 140 |
< |
panel2.InsertControl(TFile(data.Field).Editor); |
| 140 |
> |
TFile(data.Field).Editor.Align := alClient; |
| 141 |
> |
tab_meta.InsertControl(TFile(data.Field).Editor); |
| 142 |
|
TFile(data.Field).Opened := True; |
| 143 |
|
end; |
| 144 |
|
end; |
| 168 |
|
begin |
| 169 |
|
if TFile(data.Field).Opened then |
| 170 |
|
begin |
| 171 |
< |
if panel2.ControlCount > 0 then |
| 172 |
< |
for i := 0 to panel2.ControlCount - 1 do |
| 173 |
< |
panel2.RemoveControl(panel2.Controls[i]); |
| 171 |
> |
if tab_meta.ControlCount > 0 then |
| 172 |
> |
for i := 0 to tab_meta.ControlCount - 1 do |
| 173 |
> |
tab_meta.RemoveControl(tab_meta.Controls[i]); |
| 174 |
|
TFile(data.Field).Opened := False; |
| 175 |
|
end; |
| 176 |
|
end; |
| 190 |
|
case Column of |
| 191 |
|
0: |
| 192 |
|
begin |
| 193 |
< |
if Data.Field is TFile then |
| 179 |
< |
begin |
| 180 |
< |
CellText := TFile(Data.Field).FileName; |
| 181 |
< |
if CellText = '' then |
| 182 |
< |
CellText := 'Unnamed'; |
| 183 |
< |
end; |
| 193 |
> |
CellText := Data.Field.GetCaption; |
| 194 |
|
end; |
| 195 |
|
1: |
| 196 |
|
begin |
| 197 |
|
if Data.Field is TFile then |
| 198 |
< |
CellText := TFile(Data.Field).FileExt; |
| 198 |
> |
CellText := TFile(Data.Field).FileInfo.Extension; |
| 199 |
|
end; |
| 200 |
|
2: |
| 201 |
|
begin |
| 202 |
|
if Data.Field is TFile then |
| 203 |
< |
CellText := IntToStr(TFile(Data.Field).FileID); |
| 203 |
> |
CellText := IntToStr(TFile(Data.Field).FileInfo.ID); |
| 204 |
> |
end; |
| 205 |
> |
3: |
| 206 |
> |
begin |
| 207 |
> |
if Data.Field is TDataField then |
| 208 |
> |
CellText := TDataField(Data.Field).ValueAsString; |
| 209 |
|
end; |
| 210 |
|
end; |
| 211 |
|
end; |
| 226 |
|
begin |
| 227 |
|
if Data.Field is TFile then |
| 228 |
|
begin |
| 229 |
< |
if Length(TFile(Data.Field).FileName) = 0 then |
| 229 |
> |
if Length(TFile(Data.Field).FileInfo.Name) = 0 then |
| 230 |
|
TargetCanvas.Font.Color := $C06060; |
| 231 |
< |
if TFile(Data.Field).FileSize = 0 then |
| 231 |
> |
if TFile(Data.Field).FileInfo.Size = 0 then |
| 232 |
|
TargetCanvas.Font.Color := $2020A0; |
| 233 |
|
end; |
| 234 |
|
end; |
| 240 |
|
|
| 241 |
|
procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); |
| 242 |
|
begin |
| 243 |
< |
Meta.Free; |
| 243 |
> |
// Meta.Free; |
| 244 |
|
inherited; |
| 245 |
|
end; |
| 246 |
|
|
| 248 |
|
begin |
| 249 |
|
inherited; |
| 250 |
|
OnNewConnection := NewCon; |
| 236 |
– |
FConnectionID := -1; |
| 251 |
|
|
| 252 |
|
VST.NodeDataSize := SizeOf(TNodeData); |
| 253 |
|
VST.Font.Charset := AppSettings.CharSet; |