Changeset 234 for oup


Ignore:
Timestamp:
Jun 29, 2007, 7:23:56 PM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
3 edited

Legend:

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

    r233 r234  
    4747    arrargs.CounterSize := 2;
    4848    arrargs.BlockLength := 4;
    49     with AddField(TArray, $1C, 'AnimTextures array', '', @arrargs) do
     49    with TArray(AddField(TArray, $1C, 'AnimTextures array', '', @arrargs)) do
    5050    begin
    5151      AddField(TLinkByID, $00, 'Texture', '', nil);
  • oup/current/FileClasses/_DataTypes.pas

    r233 r234  
    281281function TArray.AddField(fieldtype: TFieldType; Offset: Integer;
    282282    Name, Description: String; ExtraArgs: Pointer): TDataField;
    283 begin
    284   Exit;
    285 end;
    286 
    287 constructor TArray.Create(ParentFile: TObject; ParentField: TDataField;
    288     Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
    289283var
    290284  i: Integer;
    291   args: TArrayArgs;
    292   fstream: TMemoryStream;
    293 begin
    294   inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
    295   args := TArrayArgs(ExtraArgs^);
    296   if args.CounterSize > 0 then
    297   begin
    298     fstream := TFile(ParentFile).FileStream;
    299     fstream.Seek(Offset, soFromBeginning);
    300     args.BlockCount := 0;
    301     fstream.Read(args.BlockCount, args.CounterSize);
    302   end;
    303   SetLength(FDataFields, args.BlockCount);
    304   if Length(FDataFields) > 0 then
    305   begin
    306     for i := 0 to High(FDataFields) do
    307     begin
    308       FDataFields[i] := TBlock.Create(ParentFile, Self,
    309           Offset + args.CounterSize + i * args.BlockLength, Name+'['+IntToStr(i)+']', '', @args.BlockLength);
    310     end;
    311   end;
    312 end;
    313 
    314 function TArray.GetChildCount: Integer;
    315 begin
    316   Result := Length(FDataFields);
    317 end;
    318 
    319 function TArray.GetChild(ID: Integer): TTreeElement;
    320 begin
    321   Result := FDataFields[ID];
    322 end;
    323 
    324 function TArray.GetFieldByOffset(Offset: Integer): TDataField;
    325 begin
    326   Exit;
    327 end;
    328 
    329 procedure TArray.Update(Offset, Length: Integer);
    330 begin
    331   Exit;
    332 end;
    333 
    334 
    335 
    336 { TBlock }
    337 
    338 function TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,
    339     Description: String; ExtraArgs: Pointer): TDataField;
    340 var
    341   i: Integer;
    342 begin
     285begin
     286(*
    343287  if Length(FDataFields) > 0 then
    344288  begin
     
    356300      FParentFile, Self, Offset, Name, Description, ExtraArgs);
    357301  Result := FDataFields[High(FDataFields)];
     302*)
     303end;
     304
     305constructor TArray.Create(ParentFile: TObject; ParentField: TDataField;
     306    Offset: Integer; Name, Description: String; ExtraArgs: Pointer);
     307var
     308  i: Integer;
     309  args: TArrayArgs;
     310  fstream: TMemoryStream;
     311begin
     312  inherited Create(ParentFile, ParentField, Offset, Name, Description, ExtraArgs);
     313  args := TArrayArgs(ExtraArgs^);
     314  if args.CounterSize > 0 then
     315  begin
     316    fstream := TFile(ParentFile).FileStream;
     317    fstream.Seek(Offset, soFromBeginning);
     318    args.BlockCount := 0;
     319    fstream.Read(args.BlockCount, args.CounterSize);
     320  end;
     321  SetLength(FDataFields, args.BlockCount);
     322  if Length(FDataFields) > 0 then
     323  begin
     324    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;
     330end;
     331
     332function TArray.GetChildCount: Integer;
     333begin
     334  Result := Length(FDataFields);
     335end;
     336
     337function TArray.GetChild(ID: Integer): TTreeElement;
     338begin
     339  Result := FDataFields[ID];
     340end;
     341
     342function TArray.GetFieldByOffset(Offset: Integer): TDataField;
     343begin
     344  Exit;
     345end;
     346
     347procedure TArray.Update(Offset, Length: Integer);
     348begin
     349  Exit;
     350end;
     351
     352
     353
     354{ TBlock }
     355
     356function TBlock.AddField(fieldtype: TFieldType; Offset: Integer; Name,
     357    Description: String; ExtraArgs: Pointer): TDataField;
     358var
     359  i: Integer;
     360begin
     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;
     372  SetLength(FDataFields, Length(FDataFields) + 1);
     373  FDataFields[High(FDataFields)] := TFieldType(fieldtype).Create(
     374      FParentFile, Self, Offset, Name, Description, ExtraArgs);
     375  Result := FDataFields[High(FDataFields)];
    358376end;
    359377
Note: See TracChangeset for help on using the changeset viewer.