Changeset 217 for oup/current/Tools/MetaEditor.pas
- Timestamp:
- Jun 15, 2007, 5:12:11 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tools/MetaEditor.pas
r214 r217 1 1 unit MetaEditor; 2 2 3 interface 4 3 5 uses 4 6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 5 Dialogs, VirtualTrees, _MetaManager, StdCtrls, ExtCtrls;7 Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls; 6 8 7 9 type 8 TForm_Meta = class(TForm )10 TForm_Meta = class(TForm_BaseTemplate) 9 11 VST: TVirtualStringTree; 10 Panel1: TPanel;11 Button1: TButton;12 combo_connection: TComboBox;13 Label3: TLabel;14 Splitter1: TSplitter;15 12 Panel2: TPanel; 16 procedure FormClose(Sender: TObject; var Action: TCloseAction);13 splitter: TSplitter; 17 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);21 15 procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; 22 16 var ChildCount: Cardinal); 23 procedure VSTPaintText(Sender: TBaseVirtualTree; 24 const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; 25 TextType: TVSTTextType); 17 procedure FormClose(Sender: TObject; var Action: TCloseAction); 26 18 procedure VSTFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; 27 19 Column: TColumnIndex); … … 29 21 NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; 30 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); 31 28 private 29 procedure NewCon(ID: Integer); 32 30 public 33 31 end; … … 37 35 38 36 implementation 39 uses40 Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils;41 37 {$R *.dfm} 38 uses _MetaManager, _FileTypes, Data; 42 39 43 40 type … … 60 57 61 58 62 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); 87 var 88 name: String; 89 conid: Integer; 90 59 procedure TForm_Meta.NewCon(ID: Integer); 60 var 91 61 a,b,c: Int64; 92 62 i: Integer; … … 94 64 node: PVirtualNode; 95 65 begin 96 if combo_connection.ItemIndex >= 0 then 97 begin 98 name := combo_connection.Items.Strings[combo_connection.ItemIndex]; 99 conid := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name) - 1)); 100 66 if ID >= 0 then 67 begin 101 68 QueryPerformanceFrequency(c); 102 69 QueryPerformanceCounter(a); 103 70 if not Assigned(Meta) then 104 Meta := TMetaManager.Create( conid);71 Meta := TMetaManager.Create(ID); 105 72 QueryPerformanceCounter(b); 106 73 ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); … … 122 89 end; 123 90 124 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); 125 begin 126 Meta.Free; 127 Action := caFree; 128 end; 129 130 131 procedure TForm_Meta.FormCreate(Sender: TObject); 132 var 91 92 procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree; 93 Node: PVirtualNode; var ChildCount: Cardinal); 94 var 95 data: PNodeData; 96 newdata: TNodeData; 97 newnode: PVirtualNode; 133 98 i: Integer; 134 135 fn, datatype, boxstring: String; 136 level: Integer; 137 begin 138 combo_connection.ItemIndex := -1; 139 combo_connection.Items.Clear; 140 if ConManager.Count > 0 then 141 begin 142 for i := 0 to ConManager.Count - 1 do 143 begin 144 level := ConManager.ConnectionByIndex[i].LevelNumber; 145 fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); 146 if ConManager.ConnectionByIndex[i].Backend = DB_ONI then 147 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; 159 end; 160 161 162 VST.NodeDataSize := SizeOf(TNodeData); 163 VST.Font.Charset := AppSettings.CharSet; 164 VST.Clear; 165 end; 166 99 id: Integer; 100 begin 101 data := VST.GetNodeData(node); 102 for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do 103 begin 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 ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount; 112 end; 167 113 168 114 … … 183 129 end; 184 130 end; 131 185 132 186 133 procedure TForm_Meta.VSTFocusChanging(Sender: TBaseVirtualTree; OldNode, … … 216 163 end; 217 164 165 218 166 procedure TForm_Meta.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; 219 167 Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); … … 248 196 end; 249 197 end; 198 250 199 251 200 procedure TForm_Meta.VSTPaintText(Sender: TBaseVirtualTree; … … 273 222 end; 274 223 275 { 276 277 procedure WriteStructureInfos; 278 var 279 i, j: Integer; 280 pdata: PNodeData; 281 Data: TNodeData; 282 node: PVirtualNode; 283 begin 284 VST.BeginUpdate; 285 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; 357 end; 358 } 224 225 226 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); 227 begin 228 Meta.Free; 229 inherited; 230 end; 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 359 245 end.
Note:
See TracChangeset
for help on using the changeset viewer.