unit MenuButtons;

interface
uses DGLEngine_header, Windows, variables, gameutils;

type
TGLTextButton = class
X,Y : integer;
Text : string;
proc : procedure;
public
 constructor Create;
 procedure   Process;
 procedure   Draw;
private
 R : Trect;
 MDown,adec,onbut : boolean;
 Alpha : integer;
end;

var NewGame,  Aouthors, Quit, Ok : TGLTextButton;

procedure Null;

implementation
uses GameScenes;

//------------------------------------------------------------------------------
constructor TGLTextButton.Create;
begin
Alpha:=50;
MDown:=false;
adec:=false;
onbut:=false;
end;
//------------------------------------------------------------------------------
procedure TGLTextButton.Process;
begin
R.Left:=X;
R.Top:=Y;
R.Right:=X+GetTextWidth(Text,1,22);
R.Bottom:=Y+36;

 if PointInRect(GetMousePos,R) then
 begin
 onbut:=true;
 if Mdown and (GetMouseButtonPressed<>1)  then proc;
 if GetMouseButtonPressed=1 then Mdown:=true;
 if adec then Alpha:=Alpha-5 else Alpha:=Alpha+5;
 if Alpha>160 then adec:=true;
 if Alpha<5 then adec:=false;
 end else
 begin
 Mdown:=false;
 onbut:=false;
 adec:=false;
 if Alpha>5 then Alpha:=Alpha-5;
 end;

end;
//------------------------------------------------------------------------------
procedure TGLTextButton.Draw;
var Color: integer;
begin

if Alpha>0 then DrawTexture2D(tex_AlphaRound,X-20,Y-15,GetTextWidth(Text,1,22)+40,62,0,Alpha,$FFFF00,true);

if onbut then
if MDown then Color:=$462300 else Color:=$D26900
 else
Color:=$804000;

DrawText2D(tex_MainFont,X,Y,Color,Text,255,1,22);
end;
//------------------------------------------------------------------------------
procedure Null;
begin
//
end;

end.
