Changeset 212 for oup/current/Tools
- Timestamp:
- Jun 12, 2007, 6:42:53 PM (17 years ago)
- Location:
- oup/current/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tools/MetaEditor.dfm
r209 r212 3 3 Top = 0 4 4 Caption = 'Form_Meta' 5 ClientHeight = 2936 ClientWidth = 4 265 ClientHeight = 365 6 ClientWidth = 446 7 7 Color = clBtnFace 8 8 Font.Charset = DEFAULT_CHARSET … … 18 18 OnCreate = FormCreate 19 19 DesignSize = ( 20 4 2621 293)20 446 21 365) 22 22 PixelsPerInch = 96 23 23 TextHeight = 13 24 object Label3: TLabel 25 Left = 3 26 Top = 6 27 Width = 61 28 Height = 13 29 Caption = 'Connection: ' 30 end 24 31 object VST: TVirtualStringTree 25 Left = 826 Top = 827 Width = 38928 Height = 26532 Left = 4 33 Top = 44 34 Width = 409 35 Height = 321 29 36 Anchors = [akLeft, akTop, akRight, akBottom] 30 37 AnimationDuration = 0 … … 37 44 Header.Options = [hoColumnResize, hoDrag, hoVisible] 38 45 TabOrder = 0 46 TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoDeleteMovedNodes] 39 47 TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning] 40 TreeOptions.PaintOptions = [toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages]41 48 OnGetText = VSTGetText 49 OnPaintText = VSTPaintText 50 OnInitChildren = VSTInitChildren 42 51 Columns = < 43 52 item 44 53 Position = 0 45 54 Width = 150 46 WideText = ' Main'55 WideText = 'FName' 47 56 end 48 57 item 49 58 Position = 1 59 WideText = 'FType' 60 end 61 item 62 Position = 2 63 WideText = 'FID' 64 end 65 item 66 Position = 3 50 67 WideText = 'Data' 51 68 end> 52 69 end 70 object Button1: TButton 71 Left = 204 72 Top = 1 73 Width = 75 74 Height = 25 75 Anchors = [akTop, akRight] 76 Caption = 'Load' 77 Default = True 78 TabOrder = 1 79 OnClick = Button1Click 80 end 81 object combo_connection: TComboBox 82 Left = 64 83 Top = 3 84 Width = 134 85 Height = 21 86 Style = csDropDownList 87 Anchors = [akLeft, akTop, akRight] 88 DropDownCount = 12 89 ItemHeight = 13 90 TabOrder = 2 91 end 53 92 end -
oup/current/Tools/MetaEditor.pas
r209 r212 3 3 uses 4 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 5 Dialogs, VirtualTrees, _ FileManager;5 Dialogs, VirtualTrees, _MetaManager, StdCtrls; 6 6 7 7 type 8 8 TForm_Meta = class(TForm) 9 9 VST: TVirtualStringTree; 10 Button1: TButton; 11 Label3: TLabel; 12 combo_connection: TComboBox; 10 13 procedure FormClose(Sender: TObject; var Action: TCloseAction); 11 14 procedure FormCreate(Sender: TObject); 12 15 procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; 13 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); 14 23 private 15 24 public 16 FileManager: TFileManager;25 MetaManager: TMetaManager; 17 26 end; 18 27 … … 22 31 implementation 23 32 uses 24 Data, _DataTypes, _FileTypes ;33 Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils; 25 34 {$R *.dfm} 26 35 … … 45 54 46 55 47 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); 48 begin 49 FileManager.Free; 50 Action := caFree; 51 end; 52 53 54 procedure TForm_Meta.FormCreate(Sender: TObject); 55 var 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 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.Button1Click(Sender: TObject); 80 var 81 name: String; 82 conid: Integer; 83 56 84 a,b,c: Int64; 57 85 i: Integer; 58 86 data: TNodeData; 59 begin 87 node: PVirtualNode; 88 begin 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 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 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 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 60 154 VST.NodeDataSize := SizeOf(TNodeData); 61 155 VST.Font.Charset := AppSettings.CharSet; 62 156 VST.Clear; 63 64 QueryPerformanceFrequency(c);65 QueryPerformanceCounter(a);66 FileManager := TFileManager.Create(1);67 QueryPerformanceCounter(b);68 ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');69 70 for i := 0 to FileManager.FileCount - 1 do71 begin72 data.Field := FileManager.FileById[i];73 AddVSTEntry(VST, nil, data);74 end;75 157 end; 76 158 … … 87 169 begin 88 170 case Column of 89 0: begin 90 if Data.Field is TFile then 91 begin 92 CellText := TFile(Data.Field).FileName; 93 end; 94 end; 95 { 0: 96 CellText := Data.Caption; 171 0: 172 begin 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; 97 180 1: 98 if Data.DataType > 0 then99 CellText := '0x' + IntToHex(Data.Offset, 8)100 else if Data.Offset > 0 then101 CellText := '0x' + IntToHex(Data.Offset, 8);181 begin 182 if Data.Field is TFile then 183 CellText := TFile(Data.Field).FileExt; 184 end; 102 185 2: 103 if Data.DataType > 0 then 104 CellText := GetDataType(Data.DataType); 105 3: 106 if Data.DataType > 0 then 107 CellText := Data.Value //GetValue(data.DataType, data.Offset) 108 else if Length(Data.Value) > 0 then 109 CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes'; 110 4: 111 CellText := Data.Description; 112 } 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; 113 211 end; 114 212 end;
Note:
See TracChangeset
for help on using the changeset viewer.