unit Unit5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons, SRLabel, SRGrad;

type
  TTopMenu = class(TForm)
    imgClose: TImage;
    imgMenuOn: TImage;
    imgMin: TImage;
    tmrFORminimize: TTimer;
    img1: TImage;
    img2: TImage;
    lbl1: TLabel;
    lbl2: TLabel;
    tmrFORvisible: TTimer;
    img3: TImage;
    lbl3: TLabel;
    img4: TImage;
    lblFood: TLabel;
    img5: TImage;
    lblResult: TLabel;
    GiveVis: TSRGradient;
    procedure FormCreate(Sender: TObject);
    procedure btn1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure tmrFORminimizeTimer(Sender: TObject);
    procedure lbl1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure lbl2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure lbl2MouseLeave(Sender: TObject);
    procedure lbl1MouseLeave(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure tmrFORvisibleTimer(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure lbl1Click(Sender: TObject);
    procedure lbl2Click(Sender: TObject);
    procedure lbl3MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure lbl3MouseLeave(Sender: TObject);
    procedure lbl3Click(Sender: TObject);
    procedure GiveVisMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  TopMenu: TTopMenu;

implementation

uses Unit1, Unit2, Unit3, unit4, settings;


{$R *.dfm}

procedure TTopMenu.FormCreate(Sender: TObject);
begin
  Width:= Screen.Width;
  Height := 145;
  Top    := 0;
  Left   := 0;
  GiveVis.Width:= Width;

  imgClose.Left := Screen.Width-55;
  imgMin.Left := Screen.Width-105;

  img1.Left := Screen.Width-105;
  img2.Left := Screen.Width-55;
  lblResult.Left := Screen.Width-85;
  img5.Left := lblResult.Left-55;

  lbl1.Left := Screen.Width-105;
  lbl2.Left := Screen.Width-55;

  lbl1.Hint := 'Свернуть игру';
  lbl2.Hint := 'Выйти';
  lbl3.Hint := 'Меню';
  lblFood.Font.Color:= $0057b5ef;
  lblResult.Font.Color:= $003bd3ff;
  Show;

  background.tmrVisibleTopMenu.Enabled:= true;
  end;

procedure TTopMenu.btn1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  SetActiveWindow(SG.Handle);
end;

procedure TTopMenu.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    SetActiveWindow(SG.Handle);
end;

procedure TTopMenu.tmrFORminimizeTimer(Sender: TObject);
begin
  background.AlphaBlendValue := background.AlphaBlendValue-4;
  GG.AlphaBlendValue := GG.AlphaBlendValue-4;

  if (AlphaBlendValue-4) > 0 then
  AlphaBlendValue := AlphaBlendValue-4;

  if   0 < (shadow.AlphaBlendValue-4)  then
  shadow.AlphaBlendValue := shadow.AlphaBlendValue-4;

  if background.AlphaBlendValue = 3  then
  begin
     tmrFORminimize.Enabled := false;
     SetActiveWindow(SG.Handle);
     ShowWindow(Application.Handle, SW_MINIMIZE);
  end;

  if (SG.AlphaBlendValue-4) > 0 then
  SG.AlphaBlendValue := SG.AlphaBlendValue-4;
  
end;
procedure TTopMenu.lbl1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
   background.tmrVisibleTopMenu.Enabled := false;
   tmrFORvisible.Enabled := True;

  img1.Visible   := True;
end;

procedure TTopMenu.lbl2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  img2.Visible     := True;
end;

procedure TTopMenu.lbl2MouseLeave(Sender: TObject);
begin
  img2.Visible     := false;
end;

procedure TTopMenu.lbl1MouseLeave(Sender: TObject);
begin
  img1.Visible   := false;
end;

procedure TTopMenu.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
   background.tmrVisibleTopMenu.Enabled := false;
   tmrFORvisible.Enabled := True;
end;

procedure TTopMenu.tmrFORvisibleTimer(Sender: TObject);
var a: Byte;
begin
 a := TopMenu.AlphaBlendValue;
  if (TopMenu.AlphaBlendValue+5) <= 255 then
      TopMenu.AlphaBlendValue := TopMenu.AlphaBlendValue+5;

  if (TopMenu.AlphaBlendValue+4) <= 255 then
      TopMenu.AlphaBlendValue := TopMenu.AlphaBlendValue+4;

  if (TopMenu.AlphaBlendValue+3) <= 255 then
      TopMenu.AlphaBlendValue := TopMenu.AlphaBlendValue+3;

  if (TopMenu.AlphaBlendValue+2) <= 255 then
      TopMenu.AlphaBlendValue := TopMenu.AlphaBlendValue+2;

  if (TopMenu.AlphaBlendValue+1) <= 255 then
      TopMenu.AlphaBlendValue := TopMenu.AlphaBlendValue+1;

background.tmrVisibleTopMenu.Enabled := false;

 if (a) = (TopMenu.AlphaBlendValue) then
     tmrFORvisible.Enabled := False;
end;

procedure TTopMenu.btn1Click(Sender: TObject);
begin
img1.Visible := false;
end;

procedure TTopMenu.lbl1Click(Sender: TObject);
begin
  tmrFORminimize.Enabled := true;
end;

procedure TTopMenu.lbl2Click(Sender: TObject);
begin
  SG.Close;
end;

procedure TTopMenu.lbl3MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  img3.Visible := True;
end;

procedure TTopMenu.lbl3MouseLeave(Sender: TObject);
begin
  img3.Visible := False;
end;

procedure TTopMenu.lbl3Click(Sender: TObject);
begin
  SG.Visible := False;
  GG.Visible := False;
  shadow.Width := Screen.Width;
  shadow.Height:= Screen.Height;
  shadow.shp1.Visible := True;
    shadow.Left := 0;
    shadow.Top  := 0;

  Setting.Show;

end;

procedure TTopMenu.GiveVisMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
   background.tmrVisibleTopMenu.Enabled := false;
   tmrFORvisible.Enabled := True;

end;

end.
