2 |
|
interface |
3 |
|
uses |
4 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
5 |
< |
Dialogs, VirtualTrees, _FileManager; |
5 |
> |
Dialogs, VirtualTrees, _MetaManager, StdCtrls; |
6 |
|
|
7 |
|
type |
8 |
|
TForm_Meta = class(TForm) |
9 |
|
VST: TVirtualStringTree; |
10 |
+ |
Button1: TButton; |
11 |
+ |
Label3: TLabel; |
12 |
+ |
combo_connection: TComboBox; |
13 |
|
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
14 |
|
procedure FormCreate(Sender: TObject); |
15 |
|
procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; |
16 |
|
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); |
17 |
+ |
procedure Button1Click(Sender: TObject); |
18 |
+ |
procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; |
19 |
+ |
var ChildCount: Cardinal); |
20 |
+ |
procedure VSTPaintText(Sender: TBaseVirtualTree; |
21 |
+ |
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
22 |
+ |
TextType: TVSTTextType); |
23 |
|
private |
24 |
|
public |
25 |
< |
FileManager: TFileManager; |
25 |
> |
MetaManager: TMetaManager; |
26 |
|
end; |
27 |
|
|
28 |
|
var |
30 |
|
|
31 |
|
implementation |
32 |
|
uses |
33 |
< |
Data, _DataTypes, _FileTypes; |
33 |
> |
Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils; |
34 |
|
{$R *.dfm} |
35 |
|
|
36 |
|
type |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
< |
procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); |
56 |
> |
procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree; |
57 |
> |
Node: PVirtualNode; var ChildCount: Cardinal); |
58 |
> |
var |
59 |
> |
data: PNodeData; |
60 |
> |
newdata: TNodeData; |
61 |
> |
newnode: PVirtualNode; |
62 |
> |
i: Integer; |
63 |
> |
id: Integer; |
64 |
|
begin |
65 |
< |
FileManager.Free; |
66 |
< |
Action := caFree; |
65 |
> |
data := VST.GetNodeData(node); |
66 |
> |
for i := 0 to MetaManager.FileById[TFile(data.Field).FileID].ChildCount - 1 do |
67 |
> |
begin |
68 |
> |
id := MetaManager.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID; |
69 |
> |
MetaManager.InitFile(id); |
70 |
> |
newdata.Field := MetaManager.FileById[id]; |
71 |
> |
newnode := AddVSTEntry(VST, Node, newdata); |
72 |
> |
if MetaManager.FileById[id].ChildCount > 0 then |
73 |
> |
VST.HasChildren[newnode] := True; |
74 |
> |
end; |
75 |
> |
ChildCount := MetaManager.FileById[TFile(data.Field).FileID].ChildCount; |
76 |
|
end; |
77 |
|
|
78 |
|
|
79 |
< |
procedure TForm_Meta.FormCreate(Sender: TObject); |
79 |
> |
procedure TForm_Meta.Button1Click(Sender: TObject); |
80 |
|
var |
81 |
+ |
name: String; |
82 |
+ |
conid: Integer; |
83 |
+ |
|
84 |
|
a,b,c: Int64; |
85 |
|
i: Integer; |
86 |
|
data: TNodeData; |
87 |
+ |
node: PVirtualNode; |
88 |
|
begin |
89 |
< |
VST.NodeDataSize := SizeOf(TNodeData); |
90 |
< |
VST.Font.Charset := AppSettings.CharSet; |
91 |
< |
VST.Clear; |
89 |
> |
if combo_connection.ItemIndex >= 0 then |
90 |
> |
begin |
91 |
> |
name := combo_connection.Items.Strings[combo_connection.ItemIndex]; |
92 |
> |
conid := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name) - 1)); |
93 |
|
|
94 |
< |
QueryPerformanceFrequency(c); |
95 |
< |
QueryPerformanceCounter(a); |
96 |
< |
FileManager := TFileManager.Create(1); |
97 |
< |
QueryPerformanceCounter(b); |
98 |
< |
ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); |
94 |
> |
QueryPerformanceFrequency(c); |
95 |
> |
QueryPerformanceCounter(a); |
96 |
> |
MetaManager := TMetaManager.Create(conid); |
97 |
> |
QueryPerformanceCounter(b); |
98 |
> |
ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); |
99 |
> |
|
100 |
> |
VST.Clear; |
101 |
> |
VST.BeginUpdate; |
102 |
> |
for i := 0 to MetaManager.FileCount - 1 do |
103 |
> |
begin |
104 |
> |
if Assigned(MetaManager.FileById[i]) then |
105 |
> |
begin |
106 |
> |
data.Field := MetaManager.FileById[i]; |
107 |
> |
node := AddVSTEntry(VST, nil, data); |
108 |
> |
if MetaManager.FileById[i].ChildCount > 0 then |
109 |
> |
VST.HasChildren[node] := True; |
110 |
> |
end; |
111 |
> |
end; |
112 |
> |
VST.EndUpdate; |
113 |
> |
end; |
114 |
> |
end; |
115 |
> |
|
116 |
> |
procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); |
117 |
> |
begin |
118 |
> |
MetaManager.Free; |
119 |
> |
Action := caFree; |
120 |
> |
end; |
121 |
> |
|
122 |
> |
|
123 |
> |
procedure TForm_Meta.FormCreate(Sender: TObject); |
124 |
> |
var |
125 |
> |
i: Integer; |
126 |
|
|
127 |
< |
for i := 0 to FileManager.FileCount - 1 do |
127 |
> |
fn, datatype, boxstring: String; |
128 |
> |
level: Integer; |
129 |
> |
begin |
130 |
> |
combo_connection.ItemIndex := -1; |
131 |
> |
combo_connection.Items.Clear; |
132 |
> |
if ConManager.Count > 0 then |
133 |
|
begin |
134 |
< |
data.Field := FileManager.FileById[i]; |
135 |
< |
AddVSTEntry(VST, nil, data); |
134 |
> |
for i := 0 to ConManager.Count - 1 do |
135 |
> |
begin |
136 |
> |
level := ConManager.ConnectionByIndex[i].LevelNumber; |
137 |
> |
fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); |
138 |
> |
if ConManager.ConnectionByIndex[i].Backend = DB_ONI then |
139 |
> |
datatype := 'ONI-.dat: ' |
140 |
> |
else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then |
141 |
> |
datatype := 'OUP-DB: ' |
142 |
> |
else |
143 |
> |
datatype := 'Unknown: '; |
144 |
> |
boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']'; |
145 |
> |
combo_connection.Items.Add(boxstring); |
146 |
> |
end; |
147 |
> |
if combo_connection.ItemIndex = -1 then |
148 |
> |
begin |
149 |
> |
combo_connection.ItemIndex := 0; |
150 |
> |
end; |
151 |
|
end; |
152 |
+ |
|
153 |
+ |
|
154 |
+ |
VST.NodeDataSize := SizeOf(TNodeData); |
155 |
+ |
VST.Font.Charset := AppSettings.CharSet; |
156 |
+ |
VST.Clear; |
157 |
|
end; |
158 |
|
|
159 |
|
|
168 |
|
if TextType = ttNormal then |
169 |
|
begin |
170 |
|
case Column of |
171 |
< |
0: begin |
90 |
< |
if Data.Field is TFile then |
171 |
> |
0: |
172 |
|
begin |
173 |
< |
CellText := TFile(Data.Field).FileName; |
173 |
> |
if Data.Field is TFile then |
174 |
> |
begin |
175 |
> |
CellText := TFile(Data.Field).FileName; |
176 |
> |
if CellText = '' then |
177 |
> |
CellText := 'Unnamed'; |
178 |
> |
end; |
179 |
|
end; |
94 |
– |
end; |
95 |
– |
{ 0: |
96 |
– |
CellText := Data.Caption; |
180 |
|
1: |
181 |
< |
if Data.DataType > 0 then |
182 |
< |
CellText := '0x' + IntToHex(Data.Offset, 8) |
183 |
< |
else if Data.Offset > 0 then |
184 |
< |
CellText := '0x' + IntToHex(Data.Offset, 8); |
181 |
> |
begin |
182 |
> |
if Data.Field is TFile then |
183 |
> |
CellText := TFile(Data.Field).FileExt; |
184 |
> |
end; |
185 |
|
2: |
186 |
< |
if Data.DataType > 0 then |
187 |
< |
CellText := GetDataType(Data.DataType); |
188 |
< |
3: |
189 |
< |
if Data.DataType > 0 then |
190 |
< |
CellText := Data.Value //GetValue(data.DataType, data.Offset) |
191 |
< |
else if Length(Data.Value) > 0 then |
192 |
< |
CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes'; |
193 |
< |
4: |
194 |
< |
CellText := Data.Description; |
195 |
< |
} end; |
186 |
> |
begin |
187 |
> |
if Data.Field is TFile then |
188 |
> |
CellText := IntToStr(TFile(Data.Field).FileID); |
189 |
> |
end; |
190 |
> |
end; |
191 |
> |
end; |
192 |
> |
end; |
193 |
> |
|
194 |
> |
procedure TForm_Meta.VSTPaintText(Sender: TBaseVirtualTree; |
195 |
> |
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
196 |
> |
TextType: TVSTTextType); |
197 |
> |
var |
198 |
> |
Data: PNodeData; |
199 |
> |
begin |
200 |
> |
Data := Sender.GetNodeData(Node); |
201 |
> |
if TextType = ttNormal then |
202 |
> |
begin |
203 |
> |
case Column of |
204 |
> |
0: |
205 |
> |
begin |
206 |
> |
if Data.Field is TFile then |
207 |
> |
if Length(TFile(Data.Field).FileName) = 0 then |
208 |
> |
TargetCanvas.Font.Color := $000060; |
209 |
> |
end; |
210 |
> |
end; |
211 |
|
end; |
212 |
|
end; |
213 |
|
|