1 |
|
unit MetaEditor; |
2 |
+ |
|
3 |
|
interface |
4 |
+ |
|
5 |
|
uses |
6 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
< |
Dialogs, VirtualTrees, _MetaManager, StdCtrls, ExtCtrls; |
7 |
> |
Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls; |
8 |
|
|
9 |
|
type |
10 |
< |
TForm_Meta = class(TForm) |
10 |
> |
TForm_Meta = class(TForm_BaseTemplate) |
11 |
|
VST: TVirtualStringTree; |
10 |
– |
Panel1: TPanel; |
11 |
– |
Button1: TButton; |
12 |
– |
combo_connection: TComboBox; |
13 |
– |
Label3: TLabel; |
14 |
– |
Splitter1: TSplitter; |
12 |
|
Panel2: TPanel; |
13 |
< |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
13 |
> |
splitter: TSplitter; |
14 |
|
procedure FormCreate(Sender: TObject); |
18 |
– |
procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; |
19 |
– |
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); |
20 |
– |
procedure Button1Click(Sender: TObject); |
15 |
|
procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; |
16 |
|
var ChildCount: Cardinal); |
17 |
< |
procedure VSTPaintText(Sender: TBaseVirtualTree; |
24 |
< |
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
25 |
< |
TextType: TVSTTextType); |
17 |
> |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
18 |
|
procedure VSTFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; |
19 |
|
Column: TColumnIndex); |
20 |
|
procedure VSTFocusChanging(Sender: TBaseVirtualTree; OldNode, |
21 |
|
NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; |
22 |
|
var Allowed: Boolean); |
23 |
+ |
procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; |
24 |
+ |
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); |
25 |
+ |
procedure VSTPaintText(Sender: TBaseVirtualTree; |
26 |
+ |
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
27 |
+ |
TextType: TVSTTextType); |
28 |
|
private |
29 |
+ |
procedure NewCon(ID: Integer); |
30 |
|
public |
31 |
|
end; |
32 |
|
|
34 |
|
Form_Meta: TForm_Meta; |
35 |
|
|
36 |
|
implementation |
39 |
– |
uses |
40 |
– |
Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils; |
37 |
|
{$R *.dfm} |
38 |
+ |
uses _MetaManager, _FileTypes, Data; |
39 |
|
|
40 |
|
type |
41 |
|
PNodeData = ^TNodeData; |
56 |
|
end; |
57 |
|
|
58 |
|
|
59 |
< |
|
63 |
< |
procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree; |
64 |
< |
Node: PVirtualNode; var ChildCount: Cardinal); |
65 |
< |
var |
66 |
< |
data: PNodeData; |
67 |
< |
newdata: TNodeData; |
68 |
< |
newnode: PVirtualNode; |
69 |
< |
i: Integer; |
70 |
< |
id: Integer; |
71 |
< |
begin |
72 |
< |
data := VST.GetNodeData(node); |
73 |
< |
for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do |
74 |
< |
begin |
75 |
< |
id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID; |
76 |
< |
Meta.InitFile(id); |
77 |
< |
newdata.Field := Meta.FileById[id]; |
78 |
< |
newnode := AddVSTEntry(VST, Node, newdata); |
79 |
< |
if Meta.FileById[id].ChildCount > 0 then |
80 |
< |
VST.HasChildren[newnode] := True; |
81 |
< |
end; |
82 |
< |
ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount; |
83 |
< |
end; |
84 |
< |
|
85 |
< |
|
86 |
< |
procedure TForm_Meta.Button1Click(Sender: TObject); |
59 |
> |
procedure TForm_Meta.NewCon(ID: Integer); |
60 |
|
var |
88 |
– |
name: String; |
89 |
– |
conid: Integer; |
90 |
– |
|
61 |
|
a,b,c: Int64; |
62 |
|
i: Integer; |
63 |
|
data: TNodeData; |
64 |
|
node: PVirtualNode; |
65 |
|
begin |
66 |
< |
if combo_connection.ItemIndex >= 0 then |
66 |
> |
if ID >= 0 then |
67 |
|
begin |
98 |
– |
name := combo_connection.Items.Strings[combo_connection.ItemIndex]; |
99 |
– |
conid := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name) - 1)); |
100 |
– |
|
68 |
|
QueryPerformanceFrequency(c); |
69 |
|
QueryPerformanceCounter(a); |
70 |
|
if not Assigned(Meta) then |
71 |
< |
Meta := TMetaManager.Create(conid); |
71 |
> |
Meta := TMetaManager.Create(ID); |
72 |
|
QueryPerformanceCounter(b); |
73 |
|
ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); |
74 |
|
|
88 |
|
end; |
89 |
|
end; |
90 |
|
|
124 |
– |
procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); |
125 |
– |
begin |
126 |
– |
Meta.Free; |
127 |
– |
Action := caFree; |
128 |
– |
end; |
91 |
|
|
92 |
< |
|
93 |
< |
procedure TForm_Meta.FormCreate(Sender: TObject); |
92 |
> |
procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree; |
93 |
> |
Node: PVirtualNode; var ChildCount: Cardinal); |
94 |
|
var |
95 |
+ |
data: PNodeData; |
96 |
+ |
newdata: TNodeData; |
97 |
+ |
newnode: PVirtualNode; |
98 |
|
i: Integer; |
99 |
< |
|
135 |
< |
fn, datatype, boxstring: String; |
136 |
< |
level: Integer; |
99 |
> |
id: Integer; |
100 |
|
begin |
101 |
< |
combo_connection.ItemIndex := -1; |
102 |
< |
combo_connection.Items.Clear; |
140 |
< |
if ConManager.Count > 0 then |
101 |
> |
data := VST.GetNodeData(node); |
102 |
> |
for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do |
103 |
|
begin |
104 |
< |
for i := 0 to ConManager.Count - 1 do |
105 |
< |
begin |
106 |
< |
level := ConManager.ConnectionByIndex[i].LevelNumber; |
107 |
< |
fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); |
108 |
< |
if ConManager.ConnectionByIndex[i].Backend = DB_ONI then |
109 |
< |
datatype := 'ONI-.dat: ' |
148 |
< |
else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then |
149 |
< |
datatype := 'OUP-DB: ' |
150 |
< |
else |
151 |
< |
datatype := 'Unknown: '; |
152 |
< |
boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']'; |
153 |
< |
combo_connection.Items.Add(boxstring); |
154 |
< |
end; |
155 |
< |
if combo_connection.ItemIndex = -1 then |
156 |
< |
begin |
157 |
< |
combo_connection.ItemIndex := 0; |
158 |
< |
end; |
104 |
> |
id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID; |
105 |
> |
Meta.InitFile(id); |
106 |
> |
newdata.Field := Meta.FileById[id]; |
107 |
> |
newnode := AddVSTEntry(VST, Node, newdata); |
108 |
> |
if Meta.FileById[id].ChildCount > 0 then |
109 |
> |
VST.HasChildren[newnode] := True; |
110 |
|
end; |
111 |
< |
|
161 |
< |
|
162 |
< |
VST.NodeDataSize := SizeOf(TNodeData); |
163 |
< |
VST.Font.Charset := AppSettings.CharSet; |
164 |
< |
VST.Clear; |
111 |
> |
ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount; |
112 |
|
end; |
113 |
|
|
114 |
|
|
168 |
– |
|
115 |
|
procedure TForm_Meta.VSTFocusChanged(Sender: TBaseVirtualTree; |
116 |
|
Node: PVirtualNode; Column: TColumnIndex); |
117 |
|
var |
129 |
|
end; |
130 |
|
end; |
131 |
|
|
132 |
+ |
|
133 |
|
procedure TForm_Meta.VSTFocusChanging(Sender: TBaseVirtualTree; OldNode, |
134 |
|
NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; |
135 |
|
var Allowed: Boolean); |
162 |
|
end; |
163 |
|
end; |
164 |
|
|
165 |
+ |
|
166 |
|
procedure TForm_Meta.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; |
167 |
|
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); |
168 |
|
var |
196 |
|
end; |
197 |
|
end; |
198 |
|
|
199 |
+ |
|
200 |
|
procedure TForm_Meta.VSTPaintText(Sender: TBaseVirtualTree; |
201 |
|
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; |
202 |
|
TextType: TVSTTextType); |
221 |
|
end; |
222 |
|
end; |
223 |
|
|
275 |
– |
{ |
224 |
|
|
225 |
< |
procedure WriteStructureInfos; |
226 |
< |
var |
279 |
< |
i, j: Integer; |
280 |
< |
pdata: PNodeData; |
281 |
< |
Data: TNodeData; |
282 |
< |
node: PVirtualNode; |
225 |
> |
|
226 |
> |
procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); |
227 |
|
begin |
228 |
< |
VST.BeginUpdate; |
229 |
< |
if VST.RootNodeCount = 0 then |
286 |
< |
begin |
287 |
< |
structs := LoadStructureDefinition(ConID, fileid); |
288 |
< |
if structs.Data then |
289 |
< |
begin |
290 |
< |
if Length(structs.Global) > 0 then |
291 |
< |
begin |
292 |
< |
for i := 0 to High(structs.Global) do |
293 |
< |
begin |
294 |
< |
Data.Caption := structs.Global[i].Name; |
295 |
< |
Data.Offset := structs.Global[i].offset; |
296 |
< |
Data.DataType := structs.Global[i].datatype; |
297 |
< |
Data.Value := GetValue(structs.Global[i].datatype, structs.Global[i].offset); |
298 |
< |
Data.Description := structs.Global[i].description; |
299 |
< |
AddVSTEntry(VST, nil, Data); |
300 |
< |
end; |
301 |
< |
end; |
302 |
< |
if Length(structs.Subs) > 0 then |
303 |
< |
begin |
304 |
< |
for i := 0 to High(structs.Subs) do |
305 |
< |
begin |
306 |
< |
with structs.Subs[i] do |
307 |
< |
begin |
308 |
< |
if Length(Entries) > 0 then |
309 |
< |
begin |
310 |
< |
if Pos('#', SubName) > 0 then |
311 |
< |
begin |
312 |
< |
Data.Offset := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8)); |
313 |
< |
Data.Value := '$' + |
314 |
< |
MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8); |
315 |
< |
Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1); |
316 |
< |
Data.Description := SubDesc; |
317 |
< |
end |
318 |
< |
else |
319 |
< |
begin |
320 |
< |
Data.Caption := SubName; |
321 |
< |
Data.Description := SubDesc; |
322 |
< |
Data.Offset := 0; |
323 |
< |
Data.Value := ''; |
324 |
< |
end; |
325 |
< |
Data.DataType := 0; |
326 |
< |
node := AddVSTEntry(VST, nil, Data); |
327 |
< |
Data.Description := ''; |
328 |
< |
for j := 0 to High(Entries) do |
329 |
< |
begin |
330 |
< |
Data.Caption := Entries[j].Name; |
331 |
< |
Data.Offset := Entries[j].offset; |
332 |
< |
Data.DataType := Entries[j].datatype; |
333 |
< |
Data.Value := GetValue(Entries[j].datatype, Entries[j].offset); |
334 |
< |
Data.Description := Entries[j].description; |
335 |
< |
AddVSTEntry(VST, node, Data); |
336 |
< |
end; |
337 |
< |
end; |
338 |
< |
end; |
339 |
< |
end; |
340 |
< |
end; |
341 |
< |
end; |
342 |
< |
if VST.RootNodeCount > 0 then |
343 |
< |
VST.FocusedNode := VST.GetFirst; |
344 |
< |
end |
345 |
< |
else |
346 |
< |
begin |
347 |
< |
Node := VST.GetFirst; |
348 |
< |
while Assigned(Node) do |
349 |
< |
begin |
350 |
< |
pdata := VST.GetNodeData(Node); |
351 |
< |
if pdata.DataType > 0 then |
352 |
< |
pdata.Value := GetValue(pdata.Datatype, pdata.Offset); |
353 |
< |
Node := VST.GetNext(Node); |
354 |
< |
end; |
355 |
< |
end; |
356 |
< |
VST.EndUpdate; |
228 |
> |
Meta.Free; |
229 |
> |
inherited; |
230 |
|
end; |
231 |
< |
} |
231 |
> |
|
232 |
> |
procedure TForm_Meta.FormCreate(Sender: TObject); |
233 |
> |
begin |
234 |
> |
inherited; |
235 |
> |
OnNewConnection := NewCon; |
236 |
> |
FConnectionID := -1; |
237 |
> |
|
238 |
> |
VST.NodeDataSize := SizeOf(TNodeData); |
239 |
> |
VST.Font.Charset := AppSettings.CharSet; |
240 |
> |
VST.Clear; |
241 |
> |
|
242 |
> |
UpdateConList; |
243 |
> |
end; |
244 |
> |
|
245 |
|
end. |