unit Resources;

interface

uses
  QuadEngine, direct3d9;

type
  String1251 = type AnsiString(1251);

type
  TFonts = class
  private
    const PATH = 'Data\Fonts\';
  public
    Console: IQuadFont;
    Gost: IQuadFont;
    procedure LoadFonts(AQuadDevice: IQuadDevice);
    destructor Destroy; override;
  end;

  TTextures = class
  private
    const PATH = 'Data\Textures\';
  public
    Sheet: IQuadTexture;
    Table: IQuadTexture;
    Grid: IQuadTexture;
    GridMain: IQuadTexture;
    Num: IQuadTexture;
    Ship: IQuadTexture;
    ShipGun: IQuadTexture;
    Line: IQuadTexture;
    Line1: IQuadTexture;
    Line2: IQuadTexture;
    SheetFields: IQuadTexture;
    SheetSide: IQuadTexture;
    SheetSidePath: IQuadTexture;
    Point: IQuadTexture;
    Point1: IQuadTexture;
    Arrow: IQuadTexture;
    Shot: IQuadTexture;
    Hp: IQuadTexture;
    Ship1: IQuadTexture;
    Ship2: IQuadTexture;
    Gun: IQuadTexture;
    procedure LoadTextures(AQuadDevice: IQuadDevice; AQuadRender: IQuadRender);
    destructor Destroy; override;
  end;

  TShaders = class
  private
    const PATH = 'Data\Shaders\';
  public
    procedure LoadShaders(AQuadDevice: IQuadDevice);
    destructor Destroy; override;
  end;

var
  Textures: TTextures;
  Fonts: TFonts;
  Shaders: TShaders;

implementation

{ TTextures }

destructor TTextures.destroy;
begin
  Sheet := nil;
  Table := nil;
  Grid := nil;
  GridMain := nil;
  SheetFields := nil;
  SheetSide := nil;
  SheetSidePath := nil;
  Num := nil;
  Line := nil;
  Line1 := nil;
  Line2 := nil;
  Point := nil;
  Point1 := nil;
  Ship := nil;
  ShipGun := nil;
  Arrow := nil;
  Shot := nil;
  Hp := nil;
  Ship1 := nil;
  Ship2 := nil;
  Gun := nil;
  inherited;
end;

procedure TTextures.LoadTextures(AQuadDevice: IQuadDevice; AQuadRender: IQuadRender);
begin
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'sheet.png', Sheet);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'table.jpg', Table);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'grid.png', Grid);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'grid_main.png', GridMain);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'num.png', Num, 40, 40);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'ship.png', ship, 40, 160);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'ship_gun.png', ShipGun, 40, 40);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'line.png', Line);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'line1.png', Line1);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'line2.png', Line2);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'point.png', Point);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'point1.png', Point1);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'arrow.png', Arrow);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'shot.png', Shot);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'hp.png', Hp, 32, 4);

  AQuadDevice.CreateAndLoadTexture(0, PATH + 'ship1.png', Ship1, 10, 32);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'ship2.png', Ship2);
  AQuadDevice.CreateAndLoadTexture(0, PATH + 'gun.png', Gun, 40, 40);





  AQuadRender.CreateRenderTexture(1024, 768, SheetFields, 0);
  //AQuadRender.CreateRenderTexture(1001, 741, SheetSide, 0);
  AQuadRender.CreateRenderTexture(1024, 768, SheetSide, 0);
  AQuadRender.CreateRenderTexture(1024, 768, SheetSidePath, 0);
end;


{ TFonts }

destructor TFonts.Destroy;
begin
  Console := nil;
  Gost := nil;
  inherited;
end;

procedure TFonts.LoadFonts(AQuadDevice: IQuadDevice);
begin
  AQuadDevice.CreateFont(Console);
  Console.LoadFromFile(PATH + 'console.png', PATH + 'console.qef');

  AQuadDevice.CreateFont(Gost);
  Gost.LoadFromFile(PATH + 'gost.png', PATH + 'gost.qef');

end;

{ TShaders }

destructor TShaders.Destroy;
begin
  inherited;
end;

procedure TShaders.LoadShaders(AQuadDevice: IQuadDevice);
begin

end;

initialization
  Textures := TTextures.Create;
  Fonts := TFonts.Create;
  Shaders := TShaders.Create;

finalization
  Textures.Free;
  Fonts.Free;
  Shaders.Free;

end.
