Changeset 212 for oup


Ignore:
Timestamp:
Jun 12, 2007, 6:42:53 PM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
3 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • oup/current/FileClasses/TXMP.pas

    r210 r212  
    2727  templist: TStringList;
    2828begin
    29   FDataFields := TBlock.Create(Self, 0, 'Base', '', nil);
     29  FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
    3030  templist := TStringList.Create;
    3131  with FDataFields do
  • oup/current/FileClasses/_DataTypes.pas

    r207 r212  
    1414      FDataLength: Integer;
    1515      FParentFile: TObject;
     16      FParentField: TDataField;
    1617      FChanged: Boolean;
    1718      function GetValueAsString: String; virtual; abstract;
    1819    public
    19       constructor Create(ParentFile: TObject; Offset: Integer;
    20           Name, Description: String; ExtraArgs: Pointer); virtual;
     20      constructor Create(ParentFile: TObject; ParentField: TDataField;
     21          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); virtual;
    2122
    2223      procedure Update(Offset, Length: Integer); virtual; abstract;
     
    4041    public
    4142      // ExtraArgs: keine
    42       constructor Create(ParentFile: TObject; Offset: Integer;
    43           Name, Description: String; ExtraArgs: Pointer); override;
     43      constructor Create(ParentFile: TObject; ParentField: TDataField;
     44          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    4445      procedure Update(Offset, Length: Integer); override;
    4546      property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset;
     
    4748      property FieldCount: Integer read GetFieldCount;
    4849
    49       procedure AddField(fieldtype: TFieldType; Offset: Integer;
    50           Name, Description: String; ExtraArgs: Pointer);
     50      function AddField(fieldtype: TFieldType; Offset: Integer;
     51          Name, Description: String; ExtraArgs: Pointer): TDataField;
    5152  end;
    5253
     
    5859    public
    5960      // ExtraArgs: Pointer auf Integer: Bytes of TInt
    60       constructor Create(ParentFile: TObject; Offset: Integer;
    61           Name, Description: String; ExtraArgs: Pointer); override;
     61      constructor Create(ParentFile: TObject; ParentField: TDataField;
     62          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    6263      procedure Update(Offset, Length: Integer); override;
    6364  end;
     
    7172    public
    7273      // ExtraArgs: Pointer auf TStringList
    73       constructor Create(ParentFile: TObject; Offset: Integer;
    74           Name, Description: String; ExtraArgs: Pointer); override;
     74      constructor Create(ParentFile: TObject; ParentField: TDataField;
     75          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    7576      procedure Update(Offset, Length: Integer); override;
    7677  end;
     
    8384    public
    8485      // ExtraArgs: keine
    85       constructor Create(ParentFile: TObject; Offset: Integer;
    86           Name, Description: String; ExtraArgs: Pointer); override;
     86      constructor Create(ParentFile: TObject; ParentField: TDataField;
     87          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    8788      procedure Update(Offset, Length: Integer); override;
    8889  end;
     
    9596    public
    9697      // ExtraArgs: keine
    97       constructor Create(ParentFile: TObject; Offset: Integer;
    98           Name, Description: String; ExtraArgs: Pointer); override;
     98      constructor Create(ParentFile: TObject; ParentField: TDataField;
     99          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    99100      procedure Update(Offset, Length: Integer); override;
    100101  end;
     
    108109    public
    109110      // ExtraArgs: Pointer auf String: Possible Exts
    110       constructor Create(ParentFile: TObject; Offset: Integer;
    111           Name, Description: String; ExtraArgs: Pointer); override;
     111      constructor Create(ParentFile: TObject; ParentField: TDataField;
     112          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    112113      procedure Update(Offset, Length: Integer); override;
    113114  end;
     
    120121    public
    121122      // ExtraArgs: Pointer auf Integer: Length
    122       constructor Create(ParentFile: TObject; Offset: Integer;
    123           Name, Description: String; ExtraArgs: Pointer); override;
     123      constructor Create(ParentFile: TObject; ParentField: TDataField;
     124          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    124125      procedure Update(Offset, Length: Integer); override;
    125126  end;
     
    134135    public
    135136      // ExtraArgs: Pointer auf 2 Integer: Length+Count (packed record...)
    136       constructor Create(ParentFile: TObject; Offset: Integer;
    137           Name, Description: String; ExtraArgs: Pointer); override;
     137      constructor Create(ParentFile: TObject; ParentField: TDataField;
     138          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    138139      procedure Update(Offset, Length: Integer); override;
    139140      property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset;
     
    141142      property FieldCount: Integer read GetFieldCount;
    142143
    143       procedure AddField(fieldtype: TFieldType; Offset: Integer;
    144           Name, Description: String; ExtraArgs: Pointer);
     144      function AddField(fieldtype: TFieldType; Offset: Integer;
     145          Name, Description: String; ExtraArgs: Pointer): TDataField;
    145146  end;
    146147
     
    152153    public
    153154      // ExtraArgs: keine
    154       constructor Create(ParentFile: TObject; Offset: Integer;
    155           Name, Description: String; ExtraArgs: Pointer); override;
     155      constructor Create(ParentFile: TObject; ParentField: TDataField;
     156          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    156157      procedure Update(Offset, Length: Integer); override;
    157158  end;
     
    163164    public
    164165      // ExtraArgs: Pointer auf Integer: Length
    165       constructor Create(ParentFile: TObject; Offset: Integer;
    166           Name, Description: String; ExtraArgs: Pointer); override;
     166      constructor Create(ParentFile: TObject; ParentField: TDataField;
     167          Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    167168      procedure Update(Offset, Length: Integer); override;
    168169  end;
     
    181182{ TDataType }
    182183
    183 constructor TDataField.Create(ParentFile: TObject; Offset: Integer;
    184     Name, Description: String; ExtraArgs: Pointer);
     184constructor TDataField.Create(ParentFile: TObject; ParentField: TDataField;
     185    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    185186begin
    186187  FOffset := Offset;
    187188  FName := Name;
    188189  FDescription := Description;
    189   FParentFile := ParentFile;
     190  FParentFile := ParentFile;
     191  FParentField := ParentField;
    190192end;
    191193
     
    194196{ TString }
    195197
    196 constructor TString.Create(ParentFile: TObject; Offset: Integer;
    197     Name, Description: String; ExtraArgs: Pointer);
     198constructor TString.Create(ParentFile: TObject; ParentField: TDataField;
     199    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    198200var
    199201  fstream: TMemoryStream;
    200202  i: Integer;
    201203begin
    202   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     204  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    203205  FDataLength := Integer(ExtraArgs^);
    204206  fstream := TFile(ParentFile).FileStream;
     
    228230{ TInt }
    229231
    230 constructor TInt.Create(ParentFile: TObject; Offset: Integer;
    231     Name, Description: String; ExtraArgs: Pointer);
    232 var
    233   fstream: TMemoryStream;
    234 begin
    235   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     232constructor TInt.Create(ParentFile: TObject; ParentField: TDataField;
     233    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     234var
     235  fstream: TMemoryStream;
     236begin
     237  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    236238  FDataLength := Integer(ExtraArgs^);
    237239  FInt := 0;
     
    255257{ TArray }
    256258
    257 procedure TArray.AddField(fieldtype: TFieldType; Offset: Integer;
    258           Name, Description: String; ExtraArgs: Pointer);
    259 begin
    260   Exit;
    261 end;
    262 
    263 constructor TArray.Create(ParentFile: TObject; Offset: Integer;
    264     Name, Description: String; ExtraArgs: Pointer);
    265 begin
    266   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     259function TArray.AddField(fieldtype: TFieldType; Offset: Integer;
     260    Name, Description: String; ExtraArgs: Pointer): TDataField;
     261begin
     262  Exit;
     263end;
     264
     265constructor TArray.Create(ParentFile: TObject; ParentField: TDataField;
     266    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     267begin
     268  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    267269end;
    268270
     
    305307{ TBlock }
    306308
    307 procedure TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,
    308   Description: String; ExtraArgs: Pointer);
     309function TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,
     310    Description: String; ExtraArgs: Pointer): TDataField;
    309311var
    310312  i: Integer;
     
    323325  SetLength(FDataFields, Length(FDataFields) + 1);
    324326  FDataFields[High(FDataFields)] := TFieldType(fieldtype).Create(
    325       FParentFile, Offset, Name, Description, ExtraArgs);
    326 end;
    327 
    328 constructor TBlock.Create(ParentFile: TObject; Offset: Integer;
    329     Name, Description: String; ExtraArgs: Pointer);
    330 begin
    331   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     327      FParentFile, Self, Offset, Name, Description, ExtraArgs);
     328  Result := FDataFields[High(FDataFields)];
     329end;
     330
     331constructor TBlock.Create(ParentFile: TObject; ParentField: TDataField;
     332    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     333begin
     334  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    332335end;
    333336
     
    356359{ TLevelID }
    357360
    358 constructor TLevelID.Create(ParentFile: TObject; Offset: Integer;
    359     Name, Description: String; ExtraArgs: Pointer);
    360 var
    361   fstream: TMemoryStream;
    362 begin
    363   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     361constructor TLevelID.Create(ParentFile: TObject; ParentField: TDataField;
     362    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     363var
     364  fstream: TMemoryStream;
     365begin
     366  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    364367  FDataLength := 4;
    365368  fstream := TFile(ParentFile).FileStream;
     
    383386{ TFileID }
    384387
    385 constructor TFileID.Create(ParentFile: TObject; Offset: Integer;
    386     Name, Description: String; ExtraArgs: Pointer);
    387 var
    388   fstream: TMemoryStream;
    389 begin
    390   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     388constructor TFileID.Create(ParentFile: TObject; ParentField: TDataField;
     389    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     390var
     391  fstream: TMemoryStream;
     392begin
     393  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    391394  FDataLength := 4;
    392395  fstream := TFile(ParentFile).FileStream;
     
    413416{ TLinkByID }
    414417
    415 constructor TLinkByID.Create(ParentFile: TObject; Offset: Integer; Name,
    416   Description: String; ExtraArgs: Pointer);
    417 var
    418   fstream: TMemoryStream;
    419 begin
    420   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     418constructor TLinkByID.Create(ParentFile: TObject; ParentField: TDataField;
     419    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     420var
     421  fstream: TMemoryStream;
     422begin
     423  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    421424  FDataLength := 4;
    422425  FPosExts := String(ExtraArgs^);
     
    444447{ TRawLink }
    445448
    446 constructor TRawLink.Create(ParentFile: TObject; Offset: Integer; Name,
    447   Description: String; ExtraArgs: Pointer);
    448 var
    449   fstream: TMemoryStream;
    450 begin
    451   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     449constructor TRawLink.Create(ParentFile: TObject; ParentField: TDataField;
     450    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     451var
     452  fstream: TMemoryStream;
     453begin
     454  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    452455  FDataLength := 4;
    453456  fstream := TFile(ParentFile).FileStream;
     
    470473{ TUnused }
    471474
    472 constructor TUnused.Create(ParentFile: TObject; Offset: Integer; Name,
    473   Description: String; ExtraArgs: Pointer);
    474 begin
    475   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     475constructor TUnused.Create(ParentFile: TObject; ParentField: TDataField;
     476    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     477begin
     478  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    476479  FDataLength := Integer(ExtraArgs^);
    477480end;
     
    491494{ TBitSet }
    492495
    493 constructor TBitSet.Create(ParentFile: TObject; Offset: Integer; Name,
    494   Description: String; ExtraArgs: Pointer);
    495 var
    496   fstream: TMemoryStream;
    497 begin
    498   inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);
     496constructor TBitSet.Create(ParentFile: TObject; ParentField: TDataField;
     497    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     498var
     499  fstream: TMemoryStream;
     500begin
     501  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    499502  FNames := TStringList.Create;
    500503  FNames.AddStrings(TStringList(ExtraArgs^));
  • oup/current/FileClasses/_FileTypes.pas

    r210 r212  
    1717      FFileStream: TMemoryStream;
    1818
     19      FCached: Boolean;
     20      FChanged: Boolean;
     21
    1922      FDatLinks: TDatLinkList;
    2023      FDataFields: TBlock;
     
    3134      function GetRawPartByOffset(Offset: Integer): TRawDataInfo;
    3235      function GetRawPartByIndex(ID: Integer): TRawDataInfo;
     36      function GetChildCount: Integer;
    3337    public
    3438      constructor Create(ConnectionID, FileID: Integer); virtual;
     
    4246      property ConnectionID: Integer read FConnectionID;
    4347
     48      property Cached: Boolean read FCached;
     49      property Changed: Boolean read FChanged write FChanged;
     50
     51      property ChildCount: Integer read GetChildCount;
    4452      property LinkByOffset[Offset: Integer]: TDatLink read GetDatLinkByOffset;
    4553      property LinkByIndex[ID: Integer]: TDatLink read GetDatLinkByIndex;
     
    6371
    6472uses
    65   DatLinks, RawList, ConnectionManager, Dialogs;
     73  DatLinks, RawList, ConnectionManager, Dialogs, _EmptyFile;
    6674
    6775{ TFileType }
     
    7987  FFileSize := fileinfo.Size;
    8088
    81   FFileStream := TMemoryStream.Create;
    82   ConManager.Connection[ConnectionID].LoadDatFile(FileID, TStream(FFileStream));
     89  FCached := False;
     90  FChanged := False;
     91
     92  if not (Self is TFile_Empty) then
     93  begin
     94    FFileStream := TMemoryStream.Create;
     95    ConManager.Connection[ConnectionID].LoadDatFile(FileID, TStream(FFileStream));
     96  end;
    8397
    8498  InitDatLinks();
     
    86100  InitRawList();
    87101
    88   FFileStream.Free;
     102  if not (Self is TFile_Empty) then
     103    FFileStream.Free;
    89104  FFileStream := nil;
    90105end;
     
    97112
    98113function TFile.GetDatLinkByIndex(ID: Integer): TDatLink;
    99 begin
    100   if ID < Length(FDatLinks) then
    101     Result := FDatLinks[ID]
     114var
     115  i: Integer;
     116  valids: Integer;
     117begin
     118  if ID < GetChildCount then
     119  begin
     120    valids := 0;
     121    i := 0;
     122    repeat
     123      if FDatLinks[i].DestID >= 0 then
     124      begin
     125        Inc(valids);
     126      end;
     127      Inc(i);
     128    until valids > ID;
     129    Result := FDatLinks[i - 1];
     130  end
    102131  else
    103132    with Result do
     
    140169end;
    141170
     171
     172function TFile.GetChildCount: Integer;
     173var
     174  i: Integer;
     175begin
     176  Result := Length(FDatLinks);
     177  if Result > 0 then
     178  begin
     179    Result := 0;
     180    for i := 0 to High(FDatLinks) do
     181      if FDatLinks[i].DestID >= 0 then
     182        Inc(Result);
     183  end;
     184end;
    142185
    143186function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo;
  • oup/current/OniUnPacker.bdsproj

    r209 r212  
    176176                        <Language Name="ProjectLang">$00000000</Language>
    177177                        <Language Name="RootDir"></Language>
    178                 </Language>  <Excluded_Packages>
     178                </Language> 
     179    <Excluded_Packages>
    179180      <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages>
    180181    </Excluded_Packages>
  • oup/current/OniUnPacker.dpr

    r209 r212  
    3434  TXMP in 'FileClasses\TXMP.pas',
    3535  MetaEditor in 'Tools\MetaEditor.pas' {Form_Meta},
    36   _FileManager in 'FileClasses\_FileManager.pas';
     36  _MetaManager in 'FileClasses\_MetaManager.pas',
     37  _EmptyFile in 'FileClasses\_EmptyFile.pas',
     38  TXAN in 'FileClasses\TXAN.pas';
    3739
    3840{$R *.res}
  • oup/current/Tools/MetaEditor.dfm

    r209 r212  
    33  Top = 0
    44  Caption = 'Form_Meta'
    5   ClientHeight = 293
    6   ClientWidth = 426
     5  ClientHeight = 365
     6  ClientWidth = 446
    77  Color = clBtnFace
    88  Font.Charset = DEFAULT_CHARSET
     
    1818  OnCreate = FormCreate
    1919  DesignSize = (
    20     426
    21     293)
     20    446
     21    365)
    2222  PixelsPerInch = 96
    2323  TextHeight = 13
     24  object Label3: TLabel
     25    Left = 3
     26    Top = 6
     27    Width = 61
     28    Height = 13
     29    Caption = 'Connection: '
     30  end
    2431  object VST: TVirtualStringTree
    25     Left = 8
    26     Top = 8
    27     Width = 389
    28     Height = 265
     32    Left = 4
     33    Top = 44
     34    Width = 409
     35    Height = 321
    2936    Anchors = [akLeft, akTop, akRight, akBottom]
    3037    AnimationDuration = 0
     
    3744    Header.Options = [hoColumnResize, hoDrag, hoVisible]
    3845    TabOrder = 0
     46    TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoDeleteMovedNodes]
    3947    TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
    40     TreeOptions.PaintOptions = [toShowDropmark, toShowRoot, toShowTreeLines, toThemeAware, toUseBlendedImages]
    4148    OnGetText = VSTGetText
     49    OnPaintText = VSTPaintText
     50    OnInitChildren = VSTInitChildren
    4251    Columns = <
    4352      item
    4453        Position = 0
    4554        Width = 150
    46         WideText = 'Main'
     55        WideText = 'FName'
    4756      end
    4857      item
    4958        Position = 1
     59        WideText = 'FType'
     60      end
     61      item
     62        Position = 2
     63        WideText = 'FID'
     64      end
     65      item
     66        Position = 3
    5067        WideText = 'Data'
    5168      end>
    5269  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
    5392end
  • oup/current/Tools/MetaEditor.pas

    r209 r212  
    33uses
    44  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    5   Dialogs, VirtualTrees, _FileManager;
     5  Dialogs, VirtualTrees, _MetaManager, StdCtrls;
    66
    77type
    88  TForm_Meta = class(TForm)
    99    VST: TVirtualStringTree;
     10    Button1: TButton;
     11    Label3: TLabel;
     12    combo_connection: TComboBox;
    1013    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    1114    procedure FormCreate(Sender: TObject);
    1215    procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
    1316      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);
    1423  private
    1524  public
    16     FileManager: TFileManager;
     25    MetaManager: TMetaManager;
    1726  end;
    1827
     
    2231implementation
    2332uses
    24   Data, _DataTypes, _FileTypes;
     33  Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils;
    2534{$R *.dfm}
    2635
     
    4554
    4655
    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
     56procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree;
     57  Node: PVirtualNode; var ChildCount: Cardinal);
     58var
     59  data: PNodeData;
     60  newdata: TNodeData;
     61  newnode: PVirtualNode;
     62  i: Integer;
     63  id: Integer;
     64begin
     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;
     76end;
     77
     78
     79procedure TForm_Meta.Button1Click(Sender: TObject);
     80var
     81  name: String;
     82  conid: Integer;
     83
    5684  a,b,c: Int64;
    5785  i: Integer;
    5886  data: TNodeData;
    59 begin
     87  node: PVirtualNode;
     88begin
     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;
     114end;
     115
     116procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
     117begin
     118  MetaManager.Free;
     119  Action := caFree;
     120end;
     121
     122
     123procedure TForm_Meta.FormCreate(Sender: TObject);
     124var
     125  i: Integer;
     126
     127  fn, datatype, boxstring: String;
     128  level: Integer;
     129begin
     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
    60154  VST.NodeDataSize := SizeOf(TNodeData);
    61155  VST.Font.Charset := AppSettings.CharSet;
    62156  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 do
    71   begin
    72     data.Field := FileManager.FileById[i];
    73     AddVSTEntry(VST, nil, data);
    74   end;
    75157end;
    76158
     
    87169  begin
    88170    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;
    97180      1:
    98         if Data.DataType > 0 then
    99           CellText := '0x' + IntToHex(Data.Offset, 8)
    100         else if Data.Offset > 0 then
    101           CellText := '0x' + IntToHex(Data.Offset, 8);
     181        begin
     182          if Data.Field is TFile then
     183            CellText := TFile(Data.Field).FileExt;
     184        end;
    102185      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;
     192end;
     193
     194procedure TForm_Meta.VSTPaintText(Sender: TBaseVirtualTree;
     195  const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
     196  TextType: TVSTTextType);
     197var
     198  Data: PNodeData;
     199begin
     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;
    113211  end;
    114212end;
Note: See TracChangeset for help on using the changeset viewer.