Ignore:
Timestamp:
Jun 12, 2007, 6:42:53 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/current/FileClasses
Files:
3 added
1 deleted
3 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;
Note: See TracChangeset for help on using the changeset viewer.