Changeset 236 for oup/current


Ignore:
Timestamp:
Jul 14, 2007, 1:15:47 AM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
9 edited

Legend:

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

    r234 r236  
    1818
    1919procedure TFile_TXAN.InitDataFields;
    20 var
    21   tempi: Integer;
    22   arrargs: TArrayArgs;
    2320begin
    2421  inherited;
    25   FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
     22  FDataFields := TBlock.Create(Self, nil, 'Base', '', []);
    2623  with FDataFields do
    2724  begin
    28     AddField(TFileID, $00, 'FileID', '', nil);
     25    AddField(TFileID, 'FileID', '', []);
    2926
    30     AddField(TLevelID, $04, 'LevelID', '', nil);
     27    AddField(TLevelID, 'LevelID', '', []);
    3128
    32     tempi := 12;
    33     AddField(TUnused, $08, 'Unused data', '', @tempi);
     29    AddField(TUnused, 'Unused data', '', [12]);
    3430
    35     tempi := 2;
    36     AddField(TInt, $14, 'Loop speed', '', @tempi);
     31    AddField(TInt, 'Loop speed', '', [2]);
     32    AddField(TInt, 'Unknown', '', [2]);
     33    AddField(TInt, 'Unknown', '', [2]);
     34    AddField(TUnused, 'Unused', '', [2]);
    3735
    38     tempi := 2;
    39     AddField(TInt, $16, 'Unknown', '', @tempi);
    40 
    41     tempi := 2;
    42     AddField(TInt, $18, 'Unknown', '', @tempi);
    43 
    44     tempi := 2;
    45     AddField(TUnused, $1A, 'Unused', '', @tempi);
    46 
    47     arrargs.CounterSize := 2;
    48     arrargs.BlockLength := 4;
    49     with TArray(AddField(TArray, $1C, 'AnimTextures array', '', @arrargs)) do
     36    with TArray(AddField(TArray, 'AnimTextures array', '', [4, 0])) do
    5037    begin
    51       AddField(TLinkByID, $00, 'Texture', '', nil);
     38      AddField(TLinkByID, 'Texture', '', ['*']);
     39      SetCount;
    5240    end;
    5341  end;
     42  FDataFields.Update(0, -1);
    5443  FFileStream.Free;
    5544  FFileStream := nil;
  • oup/current/FileClasses/TXMP.pas

    r233 r236  
    2222
    2323procedure TFile_TXMP.InitDataFields;
    24 var
    25   tempi: Integer;
    26   temps: String;
    27   templist: TStringList;
    2824begin
    2925  inherited;
    30   FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
    31   templist := TStringList.Create;
     26  FDataFields := TBlock.Create(Self, nil, 'Base', '', []);
    3227  with FDataFields do
    3328  begin
    34     AddField(TFileID, $00, 'FileID', '', nil);
     29    AddField(TFileID, 'FileID', '', []);
     30    AddField(TLevelID, 'LevelID', '', []);
    3531
    36     AddField(TLevelID, $04, 'LevelID', '', nil);
     32    AddField(TString, 'FileName', '', [128]);
    3733
    38     tempi := 128;
    39     AddField(TString, $08, 'FileName', '', @tempi);
     34    AddField(TBitSet, 'Flags1', '',
     35        ['MipMapping enabled', 'unknown', 'U wrapping disabled',
     36         'V wrapping disabled', 'EnvMapped/EnvMap', 'unused',
     37         'Play anim back to back', 'Random anim order + frame time']);
    4038
    41     templist.Add('MipMapping enabled');
    42     templist.Add('unknown');
    43     templist.Add('U wrapping disabled');
    44     templist.Add('V wrapping disabled');
    45     templist.Add('EnvMapped/EnvMap');
    46     templist.Add('unused');
    47     templist.Add('Play anim back to back');
    48     templist.Add('Random anim order + frame time');
    49     AddField(TBitSet, $88, 'Flags1', '', @templist);
     39    AddField(TBitSet, 'Flags2', '',
     40        ['Random anim time offset', 'High byte as EnvMap', 'High byte as alpha',
     41         'Different alpha formula', 'Data swapping (always set)', 'used at runtime',
     42         'TXAN looping on/off', '16 bit blue']);
    5043
    51     templist.Clear;
    52     templist.Add('Random anim time offset');
    53     templist.Add('High byte as EnvMap');
    54     templist.Add('High byte as alpha');
    55     templist.Add('Different alpha formula');
    56     templist.Add('Data swapping (always set)');
    57     templist.Add('used at runtime');
    58     templist.Add('TXAN looping on/off');
    59     templist.Add('16 bit blue');
    60     AddField(TBitSet, $89, 'Flags2', '', @templist);
     44    AddField(TBitSet, 'Flags3', '',
     45        ['16 bit alpha', '16 bit red', 'unknown', 'unknown',
     46         'unknown', 'unknown', 'unknown', 'unknown']);
    6147
    62     templist.Clear;
    63     templist.Add('16 bit alpha');
    64     templist.Add('16 bit red');
    65     templist.Add('unknown');
    66     templist.Add('unknown');
    67     templist.Add('unknown');
    68     templist.Add('unknown');
    69     templist.Add('unknown');
    70     templist.Add('unknown');
    71     AddField(TBitSet, $8A, 'Flags3', '', @templist);
     48    AddField(TBitSet, 'Flags4', '',
     49        ['unknown', 'unknown', 'unknown', 'unknown',
     50         'unknown', 'unknown', 'unknown', 'unknown']);
    7251
    73     templist.Clear;
    74     templist.Add('unknown');
    75     templist.Add('unknown');
    76     templist.Add('unknown');
    77     templist.Add('unknown');
    78     templist.Add('unknown');
    79     templist.Add('unknown');
    80     templist.Add('unknown');
    81     templist.Add('unknown');
    82     AddField(TBitSet, $8B, 'Flags4', '', @templist);
    83 
    84     tempi := 2;
    85     AddField(TInt, $8C, 'Width', '', @tempi);
    86 
    87     tempi := 2;
    88     AddField(TInt, $8E, 'Height', '', @tempi);
    89 
    90     tempi := 4;
    91     AddField(TInt, $90, 'StoreType', '', @tempi);
    92 
    93     temps := '*';
    94     AddField(TLinkByID, $94, 'TXAN', '', @temps);
    95 
    96     temps := 'TXMP';
    97     AddField(TLinkByID, $98, 'TXMP', '', @temps);
    98 
    99     AddField(TRawLink, $9C, 'RawLink', '', nil);
    100 
    101     AddField(TRawLink, $A0, 'SepLink', '', nil);
    102 
    103     tempi := $1C;
    104     AddField(TUnused, $A4, 'Unused', '', @tempi);
     52    AddField(TInt, 'Width', '', [2]);
     53    AddField(TInt, 'Height', '', [2]);
     54    AddField(TInt, 'StoreType', '', [4]);
     55    AddField(TLinkByID, 'TXAN', '', ['*']);
     56    AddField(TLinkByID, 'TXMP', '', ['TXMP']);
     57    AddField(TRawLink, 'RawLink', '', []);
     58    AddField(TRawLink, 'SepLink', '', []);
     59    AddField(TUnused, 'Unused', '', [$1C]);
    10560  end;
    106   templist.Free;
     61  FDataFields.Update(0, -1);
    10762  FFileStream.Free;
    10863  FFileStream := nil;
  • oup/current/FileClasses/_DataTypes.pas

    r234 r236  
    77
    88type
     9  TContainer = class;
     10 
    911  TDataField = class(TTreeElement)
    1012      function GetChildCount: Integer; override;
     
    1719      FDataLength: Integer;
    1820      FParentFile: TObject;
    19       FParentField: TDataField;
     21      FParentBlock: TContainer;
    2022      FChanged: Boolean;
    21       function GetValueAsString: String; virtual; abstract;
    22     public
    23       constructor Create(ParentFile: TObject; ParentField: TDataField;
    24           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); virtual;
     23      function GetValueAsString: String; virtual;
     24    public
     25      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     26          Name, Description: String; ExtraArgs: array of const); virtual;
    2527
    2628      procedure Update(Offset, Length: Integer); virtual; abstract;
     
    3537  TFieldType = class of TDataField;
    3638
    37 
    38   TBlock = class(TDataField)
     39  TContainer = class(TDataField)
     40    public
     41      procedure UpdateSize; virtual; abstract;
     42  end;
     43
     44  TBlock = class(TContainer)
    3945    private
    4046      FDataFields: array of TDataField;
    41       FBlockLength: Integer;
    4247      function GetChildCount: Integer; override;
    4348      function GetChild(ID: Integer): TTreeElement; override;
    4449      function GetFieldByOffset(Offset: Integer): TDataField;
    4550    public
    46       // ExtraArgs: Pointer auf Integer: BlockLength
    47       constructor Create(ParentFile: TObject; ParentField: TDataField;
    48           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     51      // ExtraArgs: Pointer auf Integer: BlockLength <- no longer
     52      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     53          Name, Description: String; ExtraArgs: array of const); override;
    4954      procedure Update(Offset, Length: Integer); override;
    5055      property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset;
    5156
    52       function AddField(fieldtype: TFieldType; Offset: Integer;
    53           Name, Description: String; ExtraArgs: Pointer): TDataField;
     57      function AddField(fieldtype: TFieldType; Name, Description: String;
     58          ExtraArgs: array of const): TDataField;
     59      procedure UpdateSize; override;
    5460  end;
    5561
     
    6167    public
    6268      // ExtraArgs: Pointer auf Integer: Bytes of TInt
    63       constructor Create(ParentFile: TObject; ParentField: TDataField;
    64           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     69      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     70          Name, Description: String; ExtraArgs: array of const); override;
    6571      procedure Update(Offset, Length: Integer); override;
    6672  end;
     
    7480    public
    7581      // ExtraArgs: Pointer auf TStringList
    76       constructor Create(ParentFile: TObject; ParentField: TDataField;
    77           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     82      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     83          Name, Description: String; ExtraArgs: array of const); override;
    7884      procedure Update(Offset, Length: Integer); override;
    7985  end;
     
    8692    public
    8793      // ExtraArgs: keine
    88       constructor Create(ParentFile: TObject; ParentField: TDataField;
    89           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     94      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     95          Name, Description: String; ExtraArgs: array of const); override;
    9096      procedure Update(Offset, Length: Integer); override;
    9197  end;
     
    98104    public
    99105      // ExtraArgs: keine
    100       constructor Create(ParentFile: TObject; ParentField: TDataField;
    101           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     106      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     107          Name, Description: String; ExtraArgs: array of const); override;
    102108      procedure Update(Offset, Length: Integer); override;
    103109  end;
     
    113119    public
    114120      // ExtraArgs: Pointer auf String: Possible Exts
    115       constructor Create(ParentFile: TObject; ParentField: TDataField;
    116           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     121      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     122          Name, Description: String; ExtraArgs: array of const); override;
    117123      procedure Update(Offset, Length: Integer); override;
    118124  end;
     
    125131    public
    126132      // ExtraArgs: Pointer auf Integer: Length
    127       constructor Create(ParentFile: TObject; ParentField: TDataField;
    128           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    129       procedure Update(Offset, Length: Integer); override;
    130   end;
    131 
    132 
    133   TArrayArgs = packed record
    134     CounterSize: Integer;
    135     BlockLength: Integer;
    136     BlockCount:  Integer;
    137   end;
    138   TArray = class(TDataField)
     133      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     134          Name, Description: String; ExtraArgs: array of const); override;
     135      procedure Update(Offset, Length: Integer); override;
     136  end;
     137
     138
     139  TArray = class(TContainer)
    139140    private
    140141      FDataFields: array of TBlock;
     142      FTemplate: TBlock;
     143      FCounterSize: Integer;
     144      FBlockCount:  Integer;
    141145      function GetChildCount: Integer; override;
    142146      function GetChild(ID: Integer): TTreeElement; override;
    143147      function GetFieldByOffset(Offset: Integer): TDataField;
    144148    public
    145       // ExtraArgs: Pointer auf 3 Integer: CounterSize+Length+Count (packed record...)
    146       constructor Create(ParentFile: TObject; ParentField: TDataField;
    147           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
    148       procedure Update(Offset, Length: Integer); override;
    149 
    150       function AddField(fieldtype: TFieldType; Offset: Integer;
    151           Name, Description: String; ExtraArgs: Pointer): TDataField;
     149      // ExtraArgs: Pointer auf 2 Integer: CounterSize+Count (packed record...)
     150      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     151          Name, Description: String; ExtraArgs: array of const); override;
     152      procedure Update(Offset, Length: Integer); override;
     153
     154      function AddField(fieldtype: TFieldType; Name, Description: String;
     155          ExtraArgs: array of const): TDataField;
     156      procedure SetCount; overload;
     157      procedure SetCount(n: Integer); overload;
     158      procedure UpdateSize; override;
    152159  end;
    153160
     
    159166    public
    160167      // ExtraArgs: keine
    161       constructor Create(ParentFile: TObject; ParentField: TDataField;
    162           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     168      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     169          Name, Description: String; ExtraArgs: array of const); override;
    163170      procedure Update(Offset, Length: Integer); override;
    164171  end;
     
    170177    public
    171178      // ExtraArgs: Pointer auf Integer: Length
    172       constructor Create(ParentFile: TObject; ParentField: TDataField;
    173           Offset: Integer; Name, Description: String; ExtraArgs: Pointer); override;
     179      constructor Create(ParentFile: TObject; ParentBlock: TContainer;
     180          Name, Description: String; ExtraArgs: array of const); override;
    174181      procedure Update(Offset, Length: Integer); override;
    175182  end;
     
    188195{ TDataType }
    189196
    190 constructor TDataField.Create(ParentFile: TObject; ParentField: TDataField;
    191     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    192 begin
    193   FOffset := Offset;
     197constructor TDataField.Create(ParentFile: TObject; ParentBlock: TContainer;
     198    Name, Description: String; ExtraArgs: array of const);
     199begin
     200  if Assigned(ParentBlock) then
     201    FOffset := ParentBlock.Offset + ParentBlock.DataLength
     202  else
     203    FOffset := 0;
    194204  FName := Name;
    195205  FDescription := Description;
    196206  FParentFile := ParentFile;
    197   FParentField := ParentField;
     207  FParentBlock := ParentBlock;
    198208  FConnectionID := TFile(ParentFile).ConnectionID;
    199209end;
     
    214224end;
    215225
    216 
     226function TDataField.GetValueAsString: String;
     227begin
     228  Result := '';
     229end;
    217230
    218231{ TString }
    219232
    220 constructor TString.Create(ParentFile: TObject; ParentField: TDataField;
    221     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    222 var
    223   fstream: TMemoryStream;
    224   i: Integer;
    225 begin
    226   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    227   FDataLength := Integer(ExtraArgs^);
    228   fstream := TFile(ParentFile).FileStream;
    229   fstream.Seek(Offset, soFromBeginning);
     233constructor TString.Create(ParentFile: TObject; ParentBlock: TContainer;
     234    Name, Description: String; ExtraArgs: array of const);
     235begin
     236  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
     237  FDataLength := ExtraArgs[0].VInteger;
     238end;
     239
     240function TString.GetValueAsString: String;
     241begin
     242  Result := FString;
     243end;
     244
     245procedure TString.Update(Offset, Length: Integer);
     246var
     247  fstream: TMemoryStream;
     248  i: Integer;
     249begin
     250  fstream := TFile(FParentFile).FileStream;
     251  fstream.Seek(FOffset, soFromBeginning);
    230252  SetLength(FString, FDataLength);
    231253  fstream.Read(FString[1], FDataLength);
     
    238260end;
    239261
    240 function TString.GetValueAsString: String;
    241 begin
    242   Result := FString;
    243 end;
    244 
    245 procedure TString.Update(Offset, Length: Integer);
    246 begin
    247   Exit;
    248 end;
    249 
    250262
    251263
    252264{ TInt }
    253265
    254 constructor TInt.Create(ParentFile: TObject; ParentField: TDataField;
    255     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    256 var
    257   fstream: TMemoryStream;
    258 begin
    259   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    260   FDataLength := Integer(ExtraArgs^);
     266constructor TInt.Create(ParentFile: TObject; ParentBlock: TContainer;
     267    Name, Description: String; ExtraArgs: array of const);
     268begin
     269  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
     270  FDataLength := ExtraArgs[0].VInteger;
    261271  FInt := 0;
    262   fstream := TFile(ParentFile).FileStream;
    263   fstream.Seek(Offset, soFromBeginning);
     272end;
     273
     274function TInt.GetValueAsString: String;
     275begin
     276  Result := IntToStr(FInt);
     277end;
     278
     279procedure TInt.Update(Offset, Length: Integer);
     280var
     281  fstream: TMemoryStream;
     282begin
     283  fstream := TFile(FParentFile).FileStream;
     284  fstream.Seek(FOffset, soFromBeginning);
    264285  fstream.Read(FInt, FDataLength);
    265286end;
    266287
    267 function TInt.GetValueAsString: String;
    268 begin
    269   Result := IntToStr(FInt);
    270 end;
    271 
    272 procedure TInt.Update(Offset, Length: Integer);
    273 begin
    274   Exit;
    275 end;
    276 
    277288
    278289
    279290{ TArray }
    280291
    281 function TArray.AddField(fieldtype: TFieldType; Offset: Integer;
    282     Name, Description: String; ExtraArgs: Pointer): TDataField;
    283 var
    284   i: Integer;
    285 begin
    286 (*
    287   if Length(FDataFields) > 0 then
    288   begin
    289     for i := 0 to High(FDataFields) do
    290       if FDataFields[i].FOffset = Offset then
    291         Break;
    292     if i < Length(FDataFields) then
    293     begin
    294       ShowMessage('Field already exists');
    295       Exit;
    296     end;
    297   end;
    298   SetLength(FDataFields, Length(FDataFields) + 1);
    299   FDataFields[High(FDataFields)] := TFieldType(fieldtype).Create(
    300       FParentFile, Self, Offset, Name, Description, ExtraArgs);
    301   Result := FDataFields[High(FDataFields)];
    302 *)
    303 end;
    304 
    305 constructor TArray.Create(ParentFile: TObject; ParentField: TDataField;
    306     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    307 var
    308   i: Integer;
    309   args: TArrayArgs;
    310   fstream: TMemoryStream;
    311 begin
    312   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    313   args := TArrayArgs(ExtraArgs^);
    314   if args.CounterSize > 0 then
     292function TArray.AddField(fieldtype: TFieldType;
     293    Name, Description: String; ExtraArgs: array of const): TDataField;
     294var
     295  i: Integer;
     296begin
     297  Result := FTemplate.AddField(fieldtype, Name, Description, ExtraArgs);
     298end;
     299
     300constructor TArray.Create(ParentFile: TObject; ParentBlock: TContainer;
     301    Name, Description: String; ExtraArgs: array of const);
     302var
     303  i: Integer;
     304  fstream: TMemoryStream;
     305begin
     306  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
     307  FCounterSize := ExtraArgs[0].VInteger;
     308  FBlockCount  := ExtraArgs[1].VInteger;
     309  if FCounterSize > 0 then
    315310  begin
    316311    fstream := TFile(ParentFile).FileStream;
    317312    fstream.Seek(Offset, soFromBeginning);
    318     args.BlockCount := 0;
    319     fstream.Read(args.BlockCount, args.CounterSize);
    320   end;
    321   SetLength(FDataFields, args.BlockCount);
     313    FBlockCount := 0;
     314    fstream.Read(FBlockCount, FCounterSize);
     315  end;
     316  FTemplate := TBlock.Create(ParentFile, Self, '', '', []);
     317end;
     318
     319function TArray.GetChildCount: Integer;
     320begin
     321  Result := Length(FDataFields);
     322end;
     323
     324function TArray.GetChild(ID: Integer): TTreeElement;
     325begin
     326  Result := FDataFields[ID];
     327end;
     328
     329function TArray.GetFieldByOffset(Offset: Integer): TDataField;
     330begin
     331  Exit;
     332end;
     333
     334procedure TArray.SetCount;
     335var
     336  fid: Integer;
     337  arr_index: Integer;
     338  field: TDataField;
     339begin
     340  FDataLength := FCounterSize;
     341  if FBlockCount > 0 then
     342  begin
     343    for arr_index := 0 to FBlockCount - 1 do
     344    begin
     345      SetLength(FDataFields, arr_index + 1);
     346      FDataFields[arr_index] := TBlock.Create(FParentFile, Self,
     347          FName + '[' + IntToStr(arr_index) + ']', '', []);
     348      if Length(FTemplate.FDataFields) > 0 then
     349      begin
     350        for fid := 0 to High(FTemplate.FDataFields) do
     351        begin
     352          field := FTemplate.FDataFields[fid];
     353          FDataFields[arr_index].AddField(TFieldType(field.ClassType), field.Name, field.Description, []);
     354        end;
     355      end;
     356    end;
     357  end;
     358  FName := FName + '[' + IntToStr(FBlockCount) + ']';
     359  FParentBlock.UpdateSize;
     360end;
     361
     362procedure TArray.SetCount(n: Integer);
     363begin
     364  FParentBlock.UpdateSize;
     365end;
     366
     367procedure TArray.Update(Offset, Length: Integer);
     368var
     369  i: Integer;
     370  field: TDataField;
     371begin
     372  if System.Length(FDataFields) > 0 then
     373  begin
     374    if Length > 0 then
     375    begin
     376      for i := 0 to High(FDataFields) do
     377      begin
     378        field := FDataFields[i];
     379        if ((field.Offset < Offset) and (field.Offset + field.DataLength > Offset + Length)) or
     380          ((field.Offset > Offset) and (field.Offset < Offset + Length)) or
     381          ((field.Offset + field.DataLength > Offset) and (field.Offset+field.DataLength < Offset + Length)) then
     382          field.Update(Offset, Length);
     383      end;
     384    end else begin
     385      for i := 0 to High(FDataFields) do
     386      begin
     387        FDataFields[i].Update(Offset, Length);
     388      end;
     389    end;
     390  end;
     391end;
     392
     393procedure TArray.UpdateSize;
     394var
     395  i: Integer;
     396begin
     397  FDataLength := FCounterSize;
    322398  if Length(FDataFields) > 0 then
    323   begin
    324399    for i := 0 to High(FDataFields) do
    325     begin
    326       FDataFields[i] := TBlock.Create(ParentFile, Self,
    327           Offset + args.CounterSize + i * args.BlockLength, Name+'['+IntToStr(i)+']', '', @args.BlockLength);
    328     end;
    329   end;
    330 end;
    331 
    332 function TArray.GetChildCount: Integer;
    333 begin
    334   Result := Length(FDataFields);
    335 end;
    336 
    337 function TArray.GetChild(ID: Integer): TTreeElement;
    338 begin
    339   Result := FDataFields[ID];
    340 end;
    341 
    342 function TArray.GetFieldByOffset(Offset: Integer): TDataField;
    343 begin
    344   Exit;
    345 end;
    346 
    347 procedure TArray.Update(Offset, Length: Integer);
    348 begin
    349   Exit;
     400      FDataLength := FDataLength + FDataFields[i].DataLength;
     401  FParentBlock.UpdateSize;
    350402end;
    351403
     
    354406{ TBlock }
    355407
    356 function TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,
    357     Description: String; ExtraArgs: Pointer): TDataField;
    358 var
    359   i: Integer;
    360 begin
    361   if Length(FDataFields) > 0 then
    362   begin
    363     for i := 0 to High(FDataFields) do
    364       if FDataFields[i].FOffset = Offset then
    365         Break;
    366     if i < Length(FDataFields) then
    367     begin
    368       ShowMessage('Field already exists');
    369       Exit;
    370     end;
    371   end;
     408function TBlock.AddField(fieldtype: TFieldType; Name,
     409    Description: String; ExtraArgs: array of const): TDataField;
     410begin
    372411  SetLength(FDataFields, Length(FDataFields) + 1);
    373412  FDataFields[High(FDataFields)] := TFieldType(fieldtype).Create(
    374       FParentFile, Self, Offset, Name, Description, ExtraArgs);
     413      FParentFile, Self, Name, Description, ExtraArgs);
    375414  Result := FDataFields[High(FDataFields)];
    376 end;
    377 
    378 constructor TBlock.Create(ParentFile: TObject; ParentField: TDataField;
    379     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    380 begin
    381   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    382   if ExtraArgs <> nil then
    383     FBlockLength := Integer(ExtraArgs^)
    384   else
    385     FBlockLength := -1;
     415  FDataLength := FDataLength + Result.DataLength;
     416  if Assigned(FParentBlock) then
     417    FParentBlock.UpdateSize;
     418end;
     419
     420constructor TBlock.Create(ParentFile: TObject; ParentBlock: TContainer;
     421    Name, Description: String; ExtraArgs: array of const);
     422begin
     423  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
    386424end;
    387425
     
    402440
    403441procedure TBlock.Update(Offset, Length: Integer);
    404 begin
    405   Exit;
     442var
     443  i: Integer;
     444  field: TDataField;
     445begin
     446  if System.Length(FDataFields) > 0 then
     447  begin
     448    if Length > 0 then
     449    begin
     450      for i := 0 to High(FDataFields) do
     451      begin
     452        field := FDataFields[i];
     453        if ((field.Offset < Offset) and (field.Offset + field.DataLength > Offset + Length)) or
     454          ((field.Offset > Offset) and (field.Offset < Offset + Length)) or
     455          ((field.Offset + field.DataLength > Offset) and (field.Offset+field.DataLength < Offset + Length)) then
     456          field.Update(Offset, Length);
     457      end;
     458    end else begin
     459      for i := 0 to High(FDataFields) do
     460      begin
     461        FDataFields[i].Update(Offset, Length);
     462      end;
     463    end;
     464  end;
     465end;
     466
     467procedure TBlock.UpdateSize;
     468var
     469  i: Integer;
     470begin
     471  FDataLength := 0;
     472  if Length(FDataFields) > 0 then
     473    for i := 0 to High(FDataFields) do
     474      FDataLength := FDataLength + FDataFields[i].FDataLength;
     475  if Assigned(FParentBlock) then
     476    FParentBlock.UpdateSize;
    406477end;
    407478
     
    410481{ TLevelID }
    411482
    412 constructor TLevelID.Create(ParentFile: TObject; ParentField: TDataField;
    413     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    414 var
    415   fstream: TMemoryStream;
    416 begin
    417   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
     483constructor TLevelID.Create(ParentFile: TObject; ParentBlock: TContainer;
     484    Name, Description: String; ExtraArgs: array of const);
     485begin
     486  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
    418487  FDataLength := 4;
    419   fstream := TFile(ParentFile).FileStream;
    420   fstream.Seek(Offset, soFromBeginning);
     488  FLevelID := 0;
     489end;
     490
     491function TLevelID.GetValueAsString: String;
     492begin
     493  Result := IntToStr(FLevelID);
     494end;
     495
     496procedure TLevelID.Update(Offset, Length: Integer);
     497var
     498  fstream: TMemoryStream;
     499begin
     500  fstream := TFile(FParentFile).FileStream;
     501  fstream.Seek(FOffset, soFromBeginning);
    421502  fstream.Read(FLevelID, 4);
    422503  FLevelID := FLevelID div 256 div 256 div 256 div 2;
    423504end;
    424505
    425 function TLevelID.GetValueAsString: String;
    426 begin
    427   Result := IntToStr(FLevelID);
    428 end;
    429 
    430 procedure TLevelID.Update(Offset, Length: Integer);
    431 begin
    432   Exit;
    433 end;
    434 
    435506
    436507
    437508{ TFileID }
    438509
    439 constructor TFileID.Create(ParentFile: TObject; ParentField: TDataField;
    440     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    441 var
    442   fstream: TMemoryStream;
    443 begin
    444   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
     510constructor TFileID.Create(ParentFile: TObject; ParentBlock: TContainer;
     511    Name, Description: String; ExtraArgs: array of const);
     512begin
     513  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
    445514  FDataLength := 4;
    446   fstream := TFile(ParentFile).FileStream;
    447   fstream.Seek(Offset, soFromBeginning);
     515  FFileID := -1;
     516end;
     517
     518function TFileID.GetValueAsString: String;
     519begin
     520  Result := IntToStr(FFileID);
     521end;
     522
     523procedure TFileID.Update(Offset, Length: Integer);
     524var
     525  fstream: TMemoryStream;
     526begin
     527  fstream := TFile(FParentFile).FileStream;
     528  fstream.Seek(FOffset, soFromBeginning);
    448529  fstream.Read(FFileID, 4);
    449530  if FFileID > 0 then
     
    453534end;
    454535
    455 function TFileID.GetValueAsString: String;
    456 begin
    457   Result := IntToStr(FFileID);
    458 end;
    459 
    460 procedure TFileID.Update(Offset, Length: Integer);
    461 begin
    462   Exit;
    463 end;
    464 
    465536
    466537
    467538{ TLinkByID }
    468539
    469 constructor TLinkByID.Create(ParentFile: TObject; ParentField: TDataField;
    470     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    471 var
    472   fstream: TMemoryStream;
    473 begin
    474   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
     540constructor TLinkByID.Create(ParentFile: TObject; ParentBlock: TContainer;
     541    Name, Description: String; ExtraArgs: array of const);
     542begin
     543  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
    475544  FDataLength := 4;
    476   FPosExts := String(ExtraArgs^);
    477   fstream := TFile(ParentFile).FileStream;
    478   fstream.Seek(Offset, soFromBeginning);
     545  case ExtraArgs[0].VType of
     546    vtChar: FPosExts := ExtraArgs[0].VChar;
     547    vtAnsiString: FPosExts := String(ExtraArgs[0].VAnsiString);
     548  end;
     549  FFileID := -1;
     550end;
     551
     552function TLinkByID.GetChild(ID: Integer): TTreeElement;
     553begin
     554  if FFileID > 0 then
     555    Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].Child[ID]
     556  else
     557    Result := nil;
     558end;
     559
     560function TLinkByID.GetChildCount: Integer;
     561begin
     562  if FFileID > 0 then
     563    Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].ChildCount
     564  else
     565    Result := 0;
     566end;
     567
     568function TLinkByID.GetValueAsString: String;
     569begin
     570  if FFileID >= 0 then
     571    Result := IntToStr(FFileID)
     572  else
     573    Result := 'unused';
     574end;
     575
     576procedure TLinkByID.Update(Offset, Length: Integer);
     577var
     578  fstream: TMemoryStream;
     579begin
     580  fstream := TFile(FParentFile).FileStream;
     581  fstream.Seek(FOffset, soFromBeginning);
    479582  fstream.Read(FFileID, 4);
    480583  if FFileID > 0 then
     
    484587end;
    485588
    486 function TLinkByID.GetChild(ID: Integer): TTreeElement;
    487 begin
    488   if FFileID > 0 then
    489     Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].Child[ID]
     589
     590
     591{ TRawLink }
     592
     593constructor TRawLink.Create(ParentFile: TObject; ParentBlock: TContainer;
     594    Name, Description: String; ExtraArgs: array of const);
     595begin
     596  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
     597  FDataLength := 4;
     598end;
     599
     600function TRawLink.GetValueAsString: String;
     601begin
     602  if FRawAddress > 0 then
     603    Result := '0x' + IntToHex(FRawAddress, 8)
    490604  else
    491     Result := nil;
    492 end;
    493 
    494 function TLinkByID.GetChildCount: Integer;
    495 begin
    496   if FFileID > 0 then
    497     Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].ChildCount
    498   else
    499     Result := 0;
    500 end;
    501 
    502 function TLinkByID.GetValueAsString: String;
    503 begin
    504   Result := IntToStr(FFileID);
    505 end;
    506 
    507 procedure TLinkByID.Update(Offset, Length: Integer);
     605    Result := 'unused';
     606end;
     607
     608procedure TRawLink.Update(Offset, Length: Integer);
     609var
     610  fstream: TMemoryStream;
     611begin
     612  fstream := TFile(FParentFile).FileStream;
     613  fstream.Seek(FOffset, soFromBeginning);
     614  fstream.Read(FRawAddress, 4);
     615end;
     616
     617
     618
     619{ TUnused }
     620
     621constructor TUnused.Create(ParentFile: TObject; ParentBlock: TContainer;
     622    Name, Description: String; ExtraArgs: array of const);
     623begin
     624  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
     625  FDataLength := ExtraArgs[0].VInteger;
     626end;
     627
     628function TUnused.GetValueAsString: String;
     629begin
     630  Result := '';
     631end;
     632
     633procedure TUnused.Update(Offset, Length: Integer);
    508634begin
    509635  Exit;
     
    512638
    513639
    514 { TRawLink }
    515 
    516 constructor TRawLink.Create(ParentFile: TObject; ParentField: TDataField;
    517     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    518 var
    519   fstream: TMemoryStream;
    520 begin
    521   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    522   FDataLength := 4;
    523   fstream := TFile(ParentFile).FileStream;
    524   fstream.Seek(Offset, soFromBeginning);
    525   fstream.Read(FRawAddress, 4);
    526 end;
    527 
    528 function TRawLink.GetValueAsString: String;
    529 begin
    530   Result := IntToStr(FRawAddress);
    531 end;
    532 
    533 procedure TRawLink.Update(Offset, Length: Integer);
    534 begin
    535   Exit;
    536 end;
    537 
    538 
    539 
    540 { TUnused }
    541 
    542 constructor TUnused.Create(ParentFile: TObject; ParentField: TDataField;
    543     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    544 begin
    545   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    546   FDataLength := Integer(ExtraArgs^);
    547 end;
    548 
    549 function TUnused.GetValueAsString: String;
    550 begin
    551   Result := '';
    552 end;
    553 
    554 procedure TUnused.Update(Offset, Length: Integer);
    555 begin
    556   Exit;
    557 end;
    558 
    559 
    560 
    561640{ TBitSet }
    562641
    563 constructor TBitSet.Create(ParentFile: TObject; ParentField: TDataField;
    564     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    565 var
    566   fstream: TMemoryStream;
    567 begin
    568   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
     642constructor TBitSet.Create(ParentFile: TObject; ParentBlock: TContainer;
     643    Name, Description: String; ExtraArgs: array of const);
     644var
     645  i: Integer;
     646begin
     647  inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs);
    569648  FNames := TStringList.Create;
    570   FNames.AddStrings(TStringList(ExtraArgs^));
     649  for i := 0 to High(ExtraArgs) do
     650    case ExtraArgs[i].VType of
     651      vtChar: FNames.Add(ExtraArgs[0].VChar);
     652      vtAnsiString: FNames.Add(String(ExtraArgs[0].VAnsiString));
     653    end;
    571654  FDataLength := 1;
    572655  FBits := 0;
    573   fstream := TFile(ParentFile).FileStream;
    574   fstream.Seek(Offset, soFromBeginning);
     656end;
     657
     658function TBitSet.GetValueAsString: String;
     659  function IntToBits(Int: Integer): String;
     660  var
     661    i: Integer;
     662  begin
     663    Result := '';
     664    for i := 0 to 7 do
     665    begin
     666      Result := IntToStr(FBits and (1 shl i) shr i) + Result;
     667    end;
     668  end;
     669begin
     670  Result := IntToBits(FBits);
     671end;
     672
     673procedure TBitSet.Update(Offset, Length: Integer);
     674var
     675  fstream: TMemoryStream;
     676begin
     677  fstream := TFile(FParentFile).FileStream;
     678  fstream.Seek(FOffset, soFromBeginning);
    575679  fstream.Read(FBits, FDataLength);
    576680end;
    577681
    578 function TBitSet.GetValueAsString: String;
    579 begin
    580   Result := IntToStr(FBits);
    581 end;
    582 
    583 procedure TBitSet.Update(Offset, Length: Integer);
    584 begin
    585   Exit;
    586 end;
    587 
    588682end.
  • oup/current/FileClasses/_EmptyFile.pas

    r215 r236  
    2020begin
    2121  inherited;
    22   FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
     22  FDataFields := TBlock.Create(Self, nil, 'Base', '', []);
    2323end;
    2424
  • oup/current/FileClasses/_MetaTypes.pas

    r233 r236  
    55uses
    66  _FileTypes, _EmptyFile, _Unlinked, _DataTypes, _Extensions, _TreeElement,
    7   ABNA, AGDB, AGQC, AGQG, AGQM, AGQR, AISA, AITR, AIWA, AKAA, AKBA, AKBP, AKDA,
    8   AKEV, AKOT, AKVA, BINA, CBPI, CBPM, CONS, CRSA, DOOR, DPge, EDIA, ENVP, FILM,
    9   FXLR, GMAN, HPge, IDXA, IGHH, IGPA, IGPG, IGSA, IGSt, Impt, IPge, KeyI, M3GA,
    10   M3GM, M3TA, Mtrl, NMSA, OBAN, OBDC, OBLS, OBOA, OFGA, ONCC, ONCP, ONCV, ONFA,
    11   ONGS, ONIA, ONLD, ONLV, ONMA, ONOA, ONSA, ONSK, ONTA, ONVL, ONWC, OPge, OSBD,
    12   OTIT, OTLF, PLEA, PNTA, PSpc, PSpL, PSUI, QTNA, QUDA, SNDD, StNA, SUBT, TMFA,
    13   TMRA, TRAC, TRAM, TRAS, TRBS, TRCM, TRFT, TRGA, TRGE, TRIA, TRIG, TRMA, TRSC,
    14   TRTA, TSFF, TSFL, TSFT, TSGA, TStr, TURR, TXAN, TXCA, TXMA, TXMB, TXMP, TXPC,
    15   TxtC, UUEA, UVDL, VCRA, WMCL, WMDD, WMM_, WMMB, WPge;
     7  TXAN, TXMP;
     8//  ABNA, AGDB, AGQC, AGQG, AGQM, AGQR, AISA, AITR, AIWA, AKAA, AKBA, AKBP, AKDA,
     9//  AKEV, AKOT, AKVA, BINA, CBPI, CBPM, CONS, CRSA, DOOR, DPge, EDIA, ENVP, FILM,
     10//  FXLR, GMAN, HPge, IDXA, IGHH, IGPA, IGPG, IGSA, IGSt, Impt, IPge, KeyI, M3GA,
     11//  M3GM, M3TA, Mtrl, NMSA, OBAN, OBDC, OBLS, OBOA, OFGA, ONCC, ONCP, ONCV, ONFA,
     12//  ONGS, ONIA, ONLD, ONLV, ONMA, ONOA, ONSA, ONSK, ONTA, ONVL, ONWC, OPge, OSBD,
     13//  OTIT, OTLF, PLEA, PNTA, PSpc, PSpL, PSUI, QTNA, QUDA, SNDD, StNA, SUBT, TMFA,
     14//  TMRA, TRAC, TRAM, TRAS, TRBS, TRCM, TRFT, TRGA, TRGE, TRIA, TRIG, TRMA, TRSC,
     15//  TRTA, TSFF, TSFL, TSFT, TSGA, TStr, TURR, TXAN, TXCA, TXMA, TXMB, TXMP, TXPC,
     16//  TxtC, UUEA, UVDL, VCRA, WMCL, WMDD, WMM_, WMMB, WPge;
    1617
    1718type
     
    2223  TExtension = _Extensions.TExtension;
    2324  TExtensions = _Extensions.TExtensions;
     25  TDataField = _DataTypes.TDataField;
    2426
    2527  TFileClass = class of TFile;
     
    3032
    3133const
     34  FileDescs: array[0..1] of TFileDesc = (
     35    (ext: 'TXAN'; ftype: TFile_TXAN),
     36    (ext: 'TXMP'; ftype: TFile_TXMP)
     37  );
     38
     39{
    3240  FileDescs: array[0..112] of TFileDesc = (
    3341    (ext: 'ABNA'; ftype: TFile_ABNA),
     
    145153    (ext: 'WPge'; ftype: TFile_WPge)
    146154  );
    147 
     155}
    148156
    149157implementation
  • oup/current/OniUnPacker.bdsproj

    r228 r236  
    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

    r233 r236  
    2626  LevelDB in 'Helper\LevelDB.pas' {Form_LevelDB},
    2727  Img_DDSTypes in 'Global\Img_DDSTypes.pas',
    28   TXMP in 'FileClasses\TXMP.pas',
    2928  _MetaManager in 'FileClasses\_MetaManager.pas',
    3029  _EmptyFile in 'FileClasses\_EmptyFile.pas',
     30  TXMP in 'FileClasses\TXMP.pas',
    3131  TXAN in 'FileClasses\TXAN.pas',
     32{
    3233  SUBT in 'FileClasses\SUBT.pas',
    3334  ABNA in 'FileClasses\ABNA.pas',
     
    141142  WMMB in 'FileClasses\WMMB.pas',
    142143  WPge in 'FileClasses\WPge.pas',
     144}
    143145  _BaseTemplate in 'Tools\_BaseTemplate.pas' {Form_BaseTemplate},
    144146  _TemplateFile in 'Tools\_TemplateFile.pas' {Form_TemplateFile},
  • oup/current/Tools/MetaEditor.pas

    r233 r236  
    205205            CellText := IntToStr(TFile(Data.Field).FileInfo.ID);
    206206        end;
     207      3:
     208        begin
     209          if Data.Field is TDataField then
     210            CellText := TDataField(Data.Field).ValueAsString;
     211        end;
    207212    end;
    208213  end;
Note: See TracChangeset for help on using the changeset viewer.