【Spine】Spine Runtime for Delphi移植笔记(四)

2017-07-29 21:27:23来源:cnblogs.com作者:spine.classes - 水中盗影人点击

//////////////////////////////////////////////////////////////////////////////////Generic delphi runtime v3.6 for Spine animation tool                        ////Runtime port by cjk (hzi1980@163.com)                                       //////////////////////////////////////////////////////////////////////////////////unit spine.classes;interfaceuses  System.Classes, System.SysUtils, System.Generics.Collections, spine.types;type  THashSet<T> = class  private  public    procedure Clear;    function Add(const Item: T): Boolean;  end;  TExposedList<T> = class(TList<T>)  private    FVersion: Integer;    procedure ClearEx(const AIndex, ALen: Integer); overload;    procedure Shift(const AStart, ADelta: Integer);  public    procedure EnsureCapacity(const AMin: Integer);    procedure ClearEx(const AClearArray: Boolean = True); overload;    function  Resize(const ANewSize: Integer): TExposedList<T>;    procedure RemoveAt(const AIndex: Integer);    procedure CopyFrom(const ASource: TExposedList<T>); overload;    procedure CopyFrom(const ASource: TExposedList<T>;      const ASourceStart, ATargetStart, ACount: Integer); overload;  end;  TSpineTexture = class(TObject)  end;  TAtlasPage = class(TObject)  public    Name: AnsiString;    Format: TPageFormat;    MinFilter: TPageTextureFilter;    MagFilter: TPageTextureFilter;    WrapU: TPageTextureWrap;    WrapV: TPageTextureWrap;    Texture: TSpineTexture;    Width: Integer;    Height: Integer;    end;  TAtlasRegion = class(TObject)    Page: TAtlasPage;    Name: AnsiString;    X: Integer;    Y: Integer;    Width: Integer;    Height: Integer;    U: Single;    V: Single;    U2: Single;    V2: Single;    OffsetX: Single;    OffsetY: Single;    OriginalWidth: Integer;    OriginalHeight: Integer;    Index: Integer;    Rotate: Boolean;    Splits: array of Integer;    Pads: array of Integer;    end;  ITextureLoader = class abstract    function LoadTexture(const Page: TAtlasPage; const TextureName: string): TSpineTexture; virtual; abstract;  end;  IUpdateable = class abstract    procedure Update; virtual; abstract;  end;  IAtlas = class abstract end;  ISkeleton = class abstract end;  IBone = class(IUpdateable) end;  ISlot = class abstract end;  IEvent = class abstract end;  IAnimation = class abstract end;  IAnimationState = class abstract end;  ISkin = class abstract end;  IAttachment = class abstract  protected    function GetID: Integer; virtual; abstract;    function GetName: string; virtual; abstract;  public    property ID: Integer read GetID;    property Name: string read GetName;  end;  IConstraint = class(IUpdateable)  protected    function GetOrder: Integer; virtual; abstract;  public    property Order: Integer read GetOrder;  end;  ITimeline = class abstract  protected    function GetPropertyId: Integer; virtual; abstract;  public    procedure Apply(const ASkeleton: ISkeleton;                    const ALastTime, ATime: Single;                    const AEvents: TList<IEvent>;                    const AAlpha: Single;                    const APose: TMixPose;                    const ADirection: TMixDirection); virtual; abstract;    property PropertyId: Integer read GetPropertyId;  end;implementationend.

类定义,I 开头的抽象类大多数只是为了定义一下,因为需要单元间交叉引用,但是又不想都是定义为TObject,写接口又没必要,只能这么写了。