Changeset 212 for oup/current/FileClasses
- Timestamp:
- Jun 12, 2007, 6:42:53 PM (18 years ago)
- Location:
- oup/current/FileClasses
- Files:
-
- 3 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/TXMP.pas
r210 r212 27 27 templist: TStringList; 28 28 begin 29 FDataFields := TBlock.Create(Self, 0, 'Base', '', nil);29 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil); 30 30 templist := TStringList.Create; 31 31 with FDataFields do -
oup/current/FileClasses/_DataTypes.pas
r207 r212 14 14 FDataLength: Integer; 15 15 FParentFile: TObject; 16 FParentField: TDataField; 16 17 FChanged: Boolean; 17 18 function GetValueAsString: String; virtual; abstract; 18 19 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; 21 22 22 23 procedure Update(Offset, Length: Integer); virtual; abstract; … … 40 41 public 41 42 // 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; 44 45 procedure Update(Offset, Length: Integer); override; 45 46 property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; … … 47 48 property FieldCount: Integer read GetFieldCount; 48 49 49 procedureAddField(fieldtype: TFieldType; Offset: Integer;50 Name, Description: String; ExtraArgs: Pointer) ;50 function AddField(fieldtype: TFieldType; Offset: Integer; 51 Name, Description: String; ExtraArgs: Pointer): TDataField; 51 52 end; 52 53 … … 58 59 public 59 60 // 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; 62 63 procedure Update(Offset, Length: Integer); override; 63 64 end; … … 71 72 public 72 73 // 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; 75 76 procedure Update(Offset, Length: Integer); override; 76 77 end; … … 83 84 public 84 85 // 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; 87 88 procedure Update(Offset, Length: Integer); override; 88 89 end; … … 95 96 public 96 97 // 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; 99 100 procedure Update(Offset, Length: Integer); override; 100 101 end; … … 108 109 public 109 110 // 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; 112 113 procedure Update(Offset, Length: Integer); override; 113 114 end; … … 120 121 public 121 122 // 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; 124 125 procedure Update(Offset, Length: Integer); override; 125 126 end; … … 134 135 public 135 136 // 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; 138 139 procedure Update(Offset, Length: Integer); override; 139 140 property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; … … 141 142 property FieldCount: Integer read GetFieldCount; 142 143 143 procedureAddField(fieldtype: TFieldType; Offset: Integer;144 Name, Description: String; ExtraArgs: Pointer) ;144 function AddField(fieldtype: TFieldType; Offset: Integer; 145 Name, Description: String; ExtraArgs: Pointer): TDataField; 145 146 end; 146 147 … … 152 153 public 153 154 // 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; 156 157 procedure Update(Offset, Length: Integer); override; 157 158 end; … … 163 164 public 164 165 // 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; 167 168 procedure Update(Offset, Length: Integer); override; 168 169 end; … … 181 182 { TDataType } 182 183 183 constructor TDataField.Create(ParentFile: TObject; Offset: Integer;184 Name, Description: String; ExtraArgs: Pointer);184 constructor TDataField.Create(ParentFile: TObject; ParentField: TDataField; 185 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 185 186 begin 186 187 FOffset := Offset; 187 188 FName := Name; 188 189 FDescription := Description; 189 FParentFile := ParentFile; 190 FParentFile := ParentFile; 191 FParentField := ParentField; 190 192 end; 191 193 … … 194 196 { TString } 195 197 196 constructor TString.Create(ParentFile: TObject; Offset: Integer;197 Name, Description: String; ExtraArgs: Pointer);198 constructor TString.Create(ParentFile: TObject; ParentField: TDataField; 199 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 198 200 var 199 201 fstream: TMemoryStream; 200 202 i: Integer; 201 203 begin 202 inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);204 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 203 205 FDataLength := Integer(ExtraArgs^); 204 206 fstream := TFile(ParentFile).FileStream; … … 228 230 { TInt } 229 231 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);232 constructor TInt.Create(ParentFile: TObject; ParentField: TDataField; 233 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 234 var 235 fstream: TMemoryStream; 236 begin 237 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 236 238 FDataLength := Integer(ExtraArgs^); 237 239 FInt := 0; … … 255 257 { TArray } 256 258 257 procedureTArray.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);259 function TArray.AddField(fieldtype: TFieldType; Offset: Integer; 260 Name, Description: String; ExtraArgs: Pointer): TDataField; 261 begin 262 Exit; 263 end; 264 265 constructor TArray.Create(ParentFile: TObject; ParentField: TDataField; 266 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 267 begin 268 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 267 269 end; 268 270 … … 305 307 { TBlock } 306 308 307 procedureTBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,308 Description: String; ExtraArgs: Pointer);309 function TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name, 310 Description: String; ExtraArgs: Pointer): TDataField; 309 311 var 310 312 i: Integer; … … 323 325 SetLength(FDataFields, Length(FDataFields) + 1); 324 326 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)]; 329 end; 330 331 constructor TBlock.Create(ParentFile: TObject; ParentField: TDataField; 332 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 333 begin 334 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 332 335 end; 333 336 … … 356 359 { TLevelID } 357 360 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);361 constructor TLevelID.Create(ParentFile: TObject; ParentField: TDataField; 362 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 363 var 364 fstream: TMemoryStream; 365 begin 366 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 364 367 FDataLength := 4; 365 368 fstream := TFile(ParentFile).FileStream; … … 383 386 { TFileID } 384 387 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);388 constructor TFileID.Create(ParentFile: TObject; ParentField: TDataField; 389 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 390 var 391 fstream: TMemoryStream; 392 begin 393 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 391 394 FDataLength := 4; 392 395 fstream := TFile(ParentFile).FileStream; … … 413 416 { TLinkByID } 414 417 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);418 constructor TLinkByID.Create(ParentFile: TObject; ParentField: TDataField; 419 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 420 var 421 fstream: TMemoryStream; 422 begin 423 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 421 424 FDataLength := 4; 422 425 FPosExts := String(ExtraArgs^); … … 444 447 { TRawLink } 445 448 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);449 constructor TRawLink.Create(ParentFile: TObject; ParentField: TDataField; 450 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 451 var 452 fstream: TMemoryStream; 453 begin 454 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 452 455 FDataLength := 4; 453 456 fstream := TFile(ParentFile).FileStream; … … 470 473 { TUnused } 471 474 472 constructor TUnused.Create(ParentFile: TObject; Offset: Integer; Name,473 Description: String; ExtraArgs: Pointer);474 begin 475 inherited Create(ParentFile, Offset, Name, Description, ExtraArgs);475 constructor TUnused.Create(ParentFile: TObject; ParentField: TDataField; 476 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 477 begin 478 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 476 479 FDataLength := Integer(ExtraArgs^); 477 480 end; … … 491 494 { TBitSet } 492 495 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);496 constructor TBitSet.Create(ParentFile: TObject; ParentField: TDataField; 497 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 498 var 499 fstream: TMemoryStream; 500 begin 501 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs); 499 502 FNames := TStringList.Create; 500 503 FNames.AddStrings(TStringList(ExtraArgs^)); -
oup/current/FileClasses/_FileTypes.pas
r210 r212 17 17 FFileStream: TMemoryStream; 18 18 19 FCached: Boolean; 20 FChanged: Boolean; 21 19 22 FDatLinks: TDatLinkList; 20 23 FDataFields: TBlock; … … 31 34 function GetRawPartByOffset(Offset: Integer): TRawDataInfo; 32 35 function GetRawPartByIndex(ID: Integer): TRawDataInfo; 36 function GetChildCount: Integer; 33 37 public 34 38 constructor Create(ConnectionID, FileID: Integer); virtual; … … 42 46 property ConnectionID: Integer read FConnectionID; 43 47 48 property Cached: Boolean read FCached; 49 property Changed: Boolean read FChanged write FChanged; 50 51 property ChildCount: Integer read GetChildCount; 44 52 property LinkByOffset[Offset: Integer]: TDatLink read GetDatLinkByOffset; 45 53 property LinkByIndex[ID: Integer]: TDatLink read GetDatLinkByIndex; … … 63 71 64 72 uses 65 DatLinks, RawList, ConnectionManager, Dialogs ;73 DatLinks, RawList, ConnectionManager, Dialogs, _EmptyFile; 66 74 67 75 { TFileType } … … 79 87 FFileSize := fileinfo.Size; 80 88 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; 83 97 84 98 InitDatLinks(); … … 86 100 InitRawList(); 87 101 88 FFileStream.Free; 102 if not (Self is TFile_Empty) then 103 FFileStream.Free; 89 104 FFileStream := nil; 90 105 end; … … 97 112 98 113 function TFile.GetDatLinkByIndex(ID: Integer): TDatLink; 99 begin 100 if ID < Length(FDatLinks) then 101 Result := FDatLinks[ID] 114 var 115 i: Integer; 116 valids: Integer; 117 begin 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 102 131 else 103 132 with Result do … … 140 169 end; 141 170 171 172 function TFile.GetChildCount: Integer; 173 var 174 i: Integer; 175 begin 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; 184 end; 142 185 143 186 function TFile.GetRawPartByIndex(ID: Integer): TRawDataInfo;
Note:
See TracChangeset
for help on using the changeset viewer.