unit uGameText;
/////////////////////////
// версия 0,6
/////////////////////////
// модуль игрового
// текста
/////////////////////////

interface

uses OMEGA;

type tString=record
      Str:string;
      x,y,color:integer;
      size:real;
     end;

     tImage=record
      Image:PTexture;
      x,y,w,h,borderw,bordercolor:integer;
     end;

     tGameText=object
      Text:array [1..50] of tString;
      QText:integer;
      Pictures:array [1..5] of tImage;
      QPictures:integer;

      procedure LoadAll(patch:string);
      procedure Draw;
     end;

implementation

uses uGeneralData;

procedure tGameText.LoadAll(patch:string);
var DF:textfile;
    i:integer;
    p:string;
begin

assignfile(DF,patch);
reset(DF);
readln(DF,QText,QPictures);
if QText<>0 then
 for i:=1 to QText do begin
  readln(DF,Text[i].Str);
  readln(DF,Text[i].x,Text[i].y,Text[i].size,Text[i].color);
 end;
if QPictures<>0 then
 for i:=1 to QPictures do begin
  readln(DF,p);
  Pictures[i].Image:=Tex_LoadFromFile(PChar(DFld+p),-1,1);
  readln(DF,Pictures[i].x,Pictures[i].y,
            Pictures[i].w,Pictures[i].h,
            Pictures[i].borderw,Pictures[i].bordercolor);
 end;
closefile(DF);

end;

procedure tGameText.Draw;
var i:integer;
begin

if QText<>0 then
 for i:=1 to QText do
  Text_Draw(font,text[i].x,text[i].y,PChar(text[i].Str),text[i].size,0,255,text[i].color);

if QPictures<>0 then
 for i:=1 to QPictures do begin
  Pr2D_Rect(Pictures[i].x-Pictures[i].borderw,
            Pictures[i].y-Pictures[i].borderw,
            Pictures[i].w+2*Pictures[i].borderw,
            Pictures[i].h+2*Pictures[i].borderw,
            Pictures[i].bordercolor,255,PR_FILL );
  Ssprite_Draw(Pictures[i].Image,
               Pictures[i].x,Pictures[i].y,
               Pictures[i].w,Pictures[i].h,
               255,0,1);
 end;

end;

end.
