- Timestamp:
- Jul 14, 2007, 1:15:47 AM (17 years ago)
- Location:
- oup/current
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/FileClasses/TXAN.pas
r234 r236 18 18 19 19 procedure TFile_TXAN.InitDataFields; 20 var21 tempi: Integer;22 arrargs: TArrayArgs;23 20 begin 24 21 inherited; 25 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);22 FDataFields := TBlock.Create(Self, nil, 'Base', '', []); 26 23 with FDataFields do 27 24 begin 28 AddField(TFileID, $00, 'FileID', '', nil);25 AddField(TFileID, 'FileID', '', []); 29 26 30 AddField(TLevelID, $04, 'LevelID', '', nil);27 AddField(TLevelID, 'LevelID', '', []); 31 28 32 tempi := 12; 33 AddField(TUnused, $08, 'Unused data', '', @tempi); 29 AddField(TUnused, 'Unused data', '', [12]); 34 30 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]); 37 35 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 50 37 begin 51 AddField(TLinkByID, $00, 'Texture', '', nil); 38 AddField(TLinkByID, 'Texture', '', ['*']); 39 SetCount; 52 40 end; 53 41 end; 42 FDataFields.Update(0, -1); 54 43 FFileStream.Free; 55 44 FFileStream := nil; -
oup/current/FileClasses/TXMP.pas
r233 r236 22 22 23 23 procedure TFile_TXMP.InitDataFields; 24 var25 tempi: Integer;26 temps: String;27 templist: TStringList;28 24 begin 29 25 inherited; 30 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil); 31 templist := TStringList.Create; 26 FDataFields := TBlock.Create(Self, nil, 'Base', '', []); 32 27 with FDataFields do 33 28 begin 34 AddField(TFileID, $00, 'FileID', '', nil); 29 AddField(TFileID, 'FileID', '', []); 30 AddField(TLevelID, 'LevelID', '', []); 35 31 36 AddField(T LevelID, $04, 'LevelID', '', nil);32 AddField(TString, 'FileName', '', [128]); 37 33 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']); 40 38 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']); 50 43 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']); 61 47 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']); 72 51 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]); 105 60 end; 106 templist.Free;61 FDataFields.Update(0, -1); 107 62 FFileStream.Free; 108 63 FFileStream := nil; -
oup/current/FileClasses/_DataTypes.pas
r234 r236 7 7 8 8 type 9 TContainer = class; 10 9 11 TDataField = class(TTreeElement) 10 12 function GetChildCount: Integer; override; … … 17 19 FDataLength: Integer; 18 20 FParentFile: TObject; 19 FParent Field: TDataField;21 FParentBlock: TContainer; 20 22 FChanged: Boolean; 21 function GetValueAsString: String; virtual; abstract;22 public 23 constructor Create(ParentFile: TObject; Parent Field: 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; 25 27 26 28 procedure Update(Offset, Length: Integer); virtual; abstract; … … 35 37 TFieldType = class of TDataField; 36 38 37 38 TBlock = class(TDataField) 39 TContainer = class(TDataField) 40 public 41 procedure UpdateSize; virtual; abstract; 42 end; 43 44 TBlock = class(TContainer) 39 45 private 40 46 FDataFields: array of TDataField; 41 FBlockLength: Integer;42 47 function GetChildCount: Integer; override; 43 48 function GetChild(ID: Integer): TTreeElement; override; 44 49 function GetFieldByOffset(Offset: Integer): TDataField; 45 50 public 46 // ExtraArgs: Pointer auf Integer: BlockLength 47 constructor Create(ParentFile: TObject; Parent Field: 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; 49 54 procedure Update(Offset, Length: Integer); override; 50 55 property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset; 51 56 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; 54 60 end; 55 61 … … 61 67 public 62 68 // ExtraArgs: Pointer auf Integer: Bytes of TInt 63 constructor Create(ParentFile: TObject; Parent Field: 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; 65 71 procedure Update(Offset, Length: Integer); override; 66 72 end; … … 74 80 public 75 81 // ExtraArgs: Pointer auf TStringList 76 constructor Create(ParentFile: TObject; Parent Field: 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; 78 84 procedure Update(Offset, Length: Integer); override; 79 85 end; … … 86 92 public 87 93 // ExtraArgs: keine 88 constructor Create(ParentFile: TObject; Parent Field: 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; 90 96 procedure Update(Offset, Length: Integer); override; 91 97 end; … … 98 104 public 99 105 // ExtraArgs: keine 100 constructor Create(ParentFile: TObject; Parent Field: 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; 102 108 procedure Update(Offset, Length: Integer); override; 103 109 end; … … 113 119 public 114 120 // ExtraArgs: Pointer auf String: Possible Exts 115 constructor Create(ParentFile: TObject; Parent Field: 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; 117 123 procedure Update(Offset, Length: Integer); override; 118 124 end; … … 125 131 public 126 132 // 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) 139 140 private 140 141 FDataFields: array of TBlock; 142 FTemplate: TBlock; 143 FCounterSize: Integer; 144 FBlockCount: Integer; 141 145 function GetChildCount: Integer; override; 142 146 function GetChild(ID: Integer): TTreeElement; override; 143 147 function GetFieldByOffset(Offset: Integer): TDataField; 144 148 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; 152 159 end; 153 160 … … 159 166 public 160 167 // ExtraArgs: keine 161 constructor Create(ParentFile: TObject; Parent Field: 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; 163 170 procedure Update(Offset, Length: Integer); override; 164 171 end; … … 170 177 public 171 178 // ExtraArgs: Pointer auf Integer: Length 172 constructor Create(ParentFile: TObject; Parent Field: 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; 174 181 procedure Update(Offset, Length: Integer); override; 175 182 end; … … 188 195 { TDataType } 189 196 190 constructor TDataField.Create(ParentFile: TObject; ParentField: TDataField; 191 Offset: Integer; Name, Description: String; ExtraArgs: Pointer); 192 begin 193 FOffset := Offset; 197 constructor TDataField.Create(ParentFile: TObject; ParentBlock: TContainer; 198 Name, Description: String; ExtraArgs: array of const); 199 begin 200 if Assigned(ParentBlock) then 201 FOffset := ParentBlock.Offset + ParentBlock.DataLength 202 else 203 FOffset := 0; 194 204 FName := Name; 195 205 FDescription := Description; 196 206 FParentFile := ParentFile; 197 FParent Field := ParentField;207 FParentBlock := ParentBlock; 198 208 FConnectionID := TFile(ParentFile).ConnectionID; 199 209 end; … … 214 224 end; 215 225 216 226 function TDataField.GetValueAsString: String; 227 begin 228 Result := ''; 229 end; 217 230 218 231 { TString } 219 232 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); 233 constructor TString.Create(ParentFile: TObject; ParentBlock: TContainer; 234 Name, Description: String; ExtraArgs: array of const); 235 begin 236 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 237 FDataLength := ExtraArgs[0].VInteger; 238 end; 239 240 function TString.GetValueAsString: String; 241 begin 242 Result := FString; 243 end; 244 245 procedure TString.Update(Offset, Length: Integer); 246 var 247 fstream: TMemoryStream; 248 i: Integer; 249 begin 250 fstream := TFile(FParentFile).FileStream; 251 fstream.Seek(FOffset, soFromBeginning); 230 252 SetLength(FString, FDataLength); 231 253 fstream.Read(FString[1], FDataLength); … … 238 260 end; 239 261 240 function TString.GetValueAsString: String;241 begin242 Result := FString;243 end;244 245 procedure TString.Update(Offset, Length: Integer);246 begin247 Exit;248 end;249 250 262 251 263 252 264 { TInt } 253 265 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^); 266 constructor TInt.Create(ParentFile: TObject; ParentBlock: TContainer; 267 Name, Description: String; ExtraArgs: array of const); 268 begin 269 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 270 FDataLength := ExtraArgs[0].VInteger; 261 271 FInt := 0; 262 fstream := TFile(ParentFile).FileStream; 263 fstream.Seek(Offset, soFromBeginning); 272 end; 273 274 function TInt.GetValueAsString: String; 275 begin 276 Result := IntToStr(FInt); 277 end; 278 279 procedure TInt.Update(Offset, Length: Integer); 280 var 281 fstream: TMemoryStream; 282 begin 283 fstream := TFile(FParentFile).FileStream; 284 fstream.Seek(FOffset, soFromBeginning); 264 285 fstream.Read(FInt, FDataLength); 265 286 end; 266 287 267 function TInt.GetValueAsString: String;268 begin269 Result := IntToStr(FInt);270 end;271 272 procedure TInt.Update(Offset, Length: Integer);273 begin274 Exit;275 end;276 277 288 278 289 279 290 { TArray } 280 291 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 292 function TArray.AddField(fieldtype: TFieldType; 293 Name, Description: String; ExtraArgs: array of const): TDataField; 294 var 295 i: Integer; 296 begin 297 Result := FTemplate.AddField(fieldtype, Name, Description, ExtraArgs); 298 end; 299 300 constructor TArray.Create(ParentFile: TObject; ParentBlock: TContainer; 301 Name, Description: String; ExtraArgs: array of const); 302 var 303 i: Integer; 304 fstream: TMemoryStream; 305 begin 306 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 307 FCounterSize := ExtraArgs[0].VInteger; 308 FBlockCount := ExtraArgs[1].VInteger; 309 if FCounterSize > 0 then 315 310 begin 316 311 fstream := TFile(ParentFile).FileStream; 317 312 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, '', '', []); 317 end; 318 319 function TArray.GetChildCount: Integer; 320 begin 321 Result := Length(FDataFields); 322 end; 323 324 function TArray.GetChild(ID: Integer): TTreeElement; 325 begin 326 Result := FDataFields[ID]; 327 end; 328 329 function TArray.GetFieldByOffset(Offset: Integer): TDataField; 330 begin 331 Exit; 332 end; 333 334 procedure TArray.SetCount; 335 var 336 fid: Integer; 337 arr_index: Integer; 338 field: TDataField; 339 begin 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; 360 end; 361 362 procedure TArray.SetCount(n: Integer); 363 begin 364 FParentBlock.UpdateSize; 365 end; 366 367 procedure TArray.Update(Offset, Length: Integer); 368 var 369 i: Integer; 370 field: TDataField; 371 begin 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; 391 end; 392 393 procedure TArray.UpdateSize; 394 var 395 i: Integer; 396 begin 397 FDataLength := FCounterSize; 322 398 if Length(FDataFields) > 0 then 323 begin324 399 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; 350 402 end; 351 403 … … 354 406 { TBlock } 355 407 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; 408 function TBlock.AddField(fieldtype: TFieldType; Name, 409 Description: String; ExtraArgs: array of const): TDataField; 410 begin 372 411 SetLength(FDataFields, Length(FDataFields) + 1); 373 412 FDataFields[High(FDataFields)] := TFieldType(fieldtype).Create( 374 FParentFile, Self, Offset,Name, Description, ExtraArgs);413 FParentFile, Self, Name, Description, ExtraArgs); 375 414 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; 418 end; 419 420 constructor TBlock.Create(ParentFile: TObject; ParentBlock: TContainer; 421 Name, Description: String; ExtraArgs: array of const); 422 begin 423 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 386 424 end; 387 425 … … 402 440 403 441 procedure TBlock.Update(Offset, Length: Integer); 404 begin 405 Exit; 442 var 443 i: Integer; 444 field: TDataField; 445 begin 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; 465 end; 466 467 procedure TBlock.UpdateSize; 468 var 469 i: Integer; 470 begin 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; 406 477 end; 407 478 … … 410 481 { TLevelID } 411 482 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); 483 constructor TLevelID.Create(ParentFile: TObject; ParentBlock: TContainer; 484 Name, Description: String; ExtraArgs: array of const); 485 begin 486 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 418 487 FDataLength := 4; 419 fstream := TFile(ParentFile).FileStream; 420 fstream.Seek(Offset, soFromBeginning); 488 FLevelID := 0; 489 end; 490 491 function TLevelID.GetValueAsString: String; 492 begin 493 Result := IntToStr(FLevelID); 494 end; 495 496 procedure TLevelID.Update(Offset, Length: Integer); 497 var 498 fstream: TMemoryStream; 499 begin 500 fstream := TFile(FParentFile).FileStream; 501 fstream.Seek(FOffset, soFromBeginning); 421 502 fstream.Read(FLevelID, 4); 422 503 FLevelID := FLevelID div 256 div 256 div 256 div 2; 423 504 end; 424 505 425 function TLevelID.GetValueAsString: String;426 begin427 Result := IntToStr(FLevelID);428 end;429 430 procedure TLevelID.Update(Offset, Length: Integer);431 begin432 Exit;433 end;434 435 506 436 507 437 508 { TFileID } 438 509 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); 510 constructor TFileID.Create(ParentFile: TObject; ParentBlock: TContainer; 511 Name, Description: String; ExtraArgs: array of const); 512 begin 513 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 445 514 FDataLength := 4; 446 fstream := TFile(ParentFile).FileStream; 447 fstream.Seek(Offset, soFromBeginning); 515 FFileID := -1; 516 end; 517 518 function TFileID.GetValueAsString: String; 519 begin 520 Result := IntToStr(FFileID); 521 end; 522 523 procedure TFileID.Update(Offset, Length: Integer); 524 var 525 fstream: TMemoryStream; 526 begin 527 fstream := TFile(FParentFile).FileStream; 528 fstream.Seek(FOffset, soFromBeginning); 448 529 fstream.Read(FFileID, 4); 449 530 if FFileID > 0 then … … 453 534 end; 454 535 455 function TFileID.GetValueAsString: String;456 begin457 Result := IntToStr(FFileID);458 end;459 460 procedure TFileID.Update(Offset, Length: Integer);461 begin462 Exit;463 end;464 465 536 466 537 467 538 { TLinkByID } 468 539 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); 540 constructor TLinkByID.Create(ParentFile: TObject; ParentBlock: TContainer; 541 Name, Description: String; ExtraArgs: array of const); 542 begin 543 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 475 544 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; 550 end; 551 552 function TLinkByID.GetChild(ID: Integer): TTreeElement; 553 begin 554 if FFileID > 0 then 555 Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].Child[ID] 556 else 557 Result := nil; 558 end; 559 560 function TLinkByID.GetChildCount: Integer; 561 begin 562 if FFileID > 0 then 563 Result := ConManager.Connection[FConnectionID].MetaData.FileById[FFileID].ChildCount 564 else 565 Result := 0; 566 end; 567 568 function TLinkByID.GetValueAsString: String; 569 begin 570 if FFileID >= 0 then 571 Result := IntToStr(FFileID) 572 else 573 Result := 'unused'; 574 end; 575 576 procedure TLinkByID.Update(Offset, Length: Integer); 577 var 578 fstream: TMemoryStream; 579 begin 580 fstream := TFile(FParentFile).FileStream; 581 fstream.Seek(FOffset, soFromBeginning); 479 582 fstream.Read(FFileID, 4); 480 583 if FFileID > 0 then … … 484 587 end; 485 588 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 593 constructor TRawLink.Create(ParentFile: TObject; ParentBlock: TContainer; 594 Name, Description: String; ExtraArgs: array of const); 595 begin 596 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 597 FDataLength := 4; 598 end; 599 600 function TRawLink.GetValueAsString: String; 601 begin 602 if FRawAddress > 0 then 603 Result := '0x' + IntToHex(FRawAddress, 8) 490 604 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'; 606 end; 607 608 procedure TRawLink.Update(Offset, Length: Integer); 609 var 610 fstream: TMemoryStream; 611 begin 612 fstream := TFile(FParentFile).FileStream; 613 fstream.Seek(FOffset, soFromBeginning); 614 fstream.Read(FRawAddress, 4); 615 end; 616 617 618 619 { TUnused } 620 621 constructor TUnused.Create(ParentFile: TObject; ParentBlock: TContainer; 622 Name, Description: String; ExtraArgs: array of const); 623 begin 624 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 625 FDataLength := ExtraArgs[0].VInteger; 626 end; 627 628 function TUnused.GetValueAsString: String; 629 begin 630 Result := ''; 631 end; 632 633 procedure TUnused.Update(Offset, Length: Integer); 508 634 begin 509 635 Exit; … … 512 638 513 639 514 { TRawLink }515 516 constructor TRawLink.Create(ParentFile: TObject; ParentField: TDataField;517 Offset: Integer; Name, Description: String; ExtraArgs: Pointer);518 var519 fstream: TMemoryStream;520 begin521 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 begin530 Result := IntToStr(FRawAddress);531 end;532 533 procedure TRawLink.Update(Offset, Length: Integer);534 begin535 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 begin545 inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);546 FDataLength := Integer(ExtraArgs^);547 end;548 549 function TUnused.GetValueAsString: String;550 begin551 Result := '';552 end;553 554 procedure TUnused.Update(Offset, Length: Integer);555 begin556 Exit;557 end;558 559 560 561 640 { TBitSet } 562 641 563 constructor TBitSet.Create(ParentFile: TObject; Parent Field: TDataField;564 Offset: Integer; Name, Description: String; ExtraArgs: Pointer);565 var 566 fstream: TMemoryStream;567 begin 568 inherited Create(ParentFile, Parent Field, Offset, Name, Description, ExtraArgs);642 constructor TBitSet.Create(ParentFile: TObject; ParentBlock: TContainer; 643 Name, Description: String; ExtraArgs: array of const); 644 var 645 i: Integer; 646 begin 647 inherited Create(ParentFile, ParentBlock, Name, Description, ExtraArgs); 569 648 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; 571 654 FDataLength := 1; 572 655 FBits := 0; 573 fstream := TFile(ParentFile).FileStream; 574 fstream.Seek(Offset, soFromBeginning); 656 end; 657 658 function 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; 669 begin 670 Result := IntToBits(FBits); 671 end; 672 673 procedure TBitSet.Update(Offset, Length: Integer); 674 var 675 fstream: TMemoryStream; 676 begin 677 fstream := TFile(FParentFile).FileStream; 678 fstream.Seek(FOffset, soFromBeginning); 575 679 fstream.Read(FBits, FDataLength); 576 680 end; 577 681 578 function TBitSet.GetValueAsString: String;579 begin580 Result := IntToStr(FBits);581 end;582 583 procedure TBitSet.Update(Offset, Length: Integer);584 begin585 Exit;586 end;587 588 682 end. -
oup/current/FileClasses/_EmptyFile.pas
r215 r236 20 20 begin 21 21 inherited; 22 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);22 FDataFields := TBlock.Create(Self, nil, 'Base', '', []); 23 23 end; 24 24 -
oup/current/FileClasses/_MetaTypes.pas
r233 r236 5 5 uses 6 6 _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; 16 17 17 18 type … … 22 23 TExtension = _Extensions.TExtension; 23 24 TExtensions = _Extensions.TExtensions; 25 TDataField = _DataTypes.TDataField; 24 26 25 27 TFileClass = class of TFile; … … 30 32 31 33 const 34 FileDescs: array[0..1] of TFileDesc = ( 35 (ext: 'TXAN'; ftype: TFile_TXAN), 36 (ext: 'TXMP'; ftype: TFile_TXMP) 37 ); 38 39 { 32 40 FileDescs: array[0..112] of TFileDesc = ( 33 41 (ext: 'ABNA'; ftype: TFile_ABNA), … … 145 153 (ext: 'WPge'; ftype: TFile_WPge) 146 154 ); 147 155 } 148 156 149 157 implementation -
oup/current/OniUnPacker.bdsproj
r228 r236 176 176 <Language Name="ProjectLang">$00000000</Language> 177 177 <Language Name="RootDir"></Language> 178 </Language> <Excluded_Packages> 178 </Language> 179 <Excluded_Packages> 179 180 <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages> 180 181 </Excluded_Packages> -
oup/current/OniUnPacker.dpr
r233 r236 26 26 LevelDB in 'Helper\LevelDB.pas' {Form_LevelDB}, 27 27 Img_DDSTypes in 'Global\Img_DDSTypes.pas', 28 TXMP in 'FileClasses\TXMP.pas',29 28 _MetaManager in 'FileClasses\_MetaManager.pas', 30 29 _EmptyFile in 'FileClasses\_EmptyFile.pas', 30 TXMP in 'FileClasses\TXMP.pas', 31 31 TXAN in 'FileClasses\TXAN.pas', 32 { 32 33 SUBT in 'FileClasses\SUBT.pas', 33 34 ABNA in 'FileClasses\ABNA.pas', … … 141 142 WMMB in 'FileClasses\WMMB.pas', 142 143 WPge in 'FileClasses\WPge.pas', 144 } 143 145 _BaseTemplate in 'Tools\_BaseTemplate.pas' {Form_BaseTemplate}, 144 146 _TemplateFile in 'Tools\_TemplateFile.pas' {Form_TemplateFile}, -
oup/current/Tools/MetaEditor.pas
r233 r236 205 205 CellText := IntToStr(TFile(Data.Field).FileInfo.ID); 206 206 end; 207 3: 208 begin 209 if Data.Field is TDataField then 210 CellText := TDataField(Data.Field).ValueAsString; 211 end; 207 212 end; 208 213 end;
Note:
See TracChangeset
for help on using the changeset viewer.