unit uMainMenu;

interface
uses
  uMenu, uScene, uPage;
type
  TMainMenu = class(TMenu)
    procedure Draw; override;
    constructor Create(const SceneMng : tSceneMng); //overload;
  end;

implementation
uses
  uMyApp, uGame, uConst, uMaterials, zglHeader;

const
  c_button_startY = 256;
  c_button_space = 20;
  c_button_w = 128;
  c_button_h = 64;
  c_button_dw = 256;
  c_button_dh = 128;
  c_button_y = c_button_h + c_button_space;

type
  TButton = class(TPageButton)
    PSceneMng : tSceneMng;
    constructor Create(const X, Y : Integer; const Text : string; const SceneMng : tSceneMng); // overload;
  end;

  TButton_Game = class(TButton)
    procedure Click; override;
  end;

  TButton_BackToGame = class(TButton)
    procedure Click; override;
  end;

  TButton_I = class(TButton)
    procedure Click; override;
  end;

  TButton_How = class(TButton)
    procedure Click; override;
  end;

  TButton_Exit = class(TButton)
    procedure Click; override;
  end;

{ TMenuLevel }

constructor TMainMenu.Create(const SceneMng : tSceneMng);
var
  Y : Integer;
begin
  inherited Create(SceneMng);
  Page := TMenuPage.Create(WinW div 2, 64, Self);
  Y := c_button_startY;
  Btn := TButton_BackToGame.Create( 0, Y, 'Вернуться', SceneMng);
  Btn.Enabled := false;
  Page.AddButton(Btn);
  Y := Y + c_button_y;
  Page.AddButton(TButton_Game.Create( 0, Y, 'Новая игра', SceneMng));
  Y := Y + c_button_y;
  Page.AddButton(TButton_How.Create( 0, Y, 'Как играть', SceneMng));
  Y := Y + c_button_y;
  Page.AddButton(TButton_I.Create( 0, Y, 'Автор', SceneMng));
  Y := Y + c_button_y;
  Page.AddButton(TButton_Exit.Create( 0, Y, 'Выход', SceneMng));
  Y := Y + c_button_y;
end;

constructor TButton.Create(const X, Y : Integer; const Text : string; const SceneMng : tSceneMng);
begin
  inherited Create(X, Y, c_button_dw, c_button_dh, c_button_w, c_button_h, Text, true);
  PSceneMng := SceneMng;
  Texture := m_btn_mm;
  TextureGlow := m_btn_mm_g;
end;

{ TButton_Game }
procedure TButton_Game.Click;
begin
  with (PSceneMng as TMyApp) do
    ChangeSceneAndPar(Game, 1, 0);
end;

procedure TButton_BackToGame.Click;
begin
  with (PSceneMng as TMyApp) do
    ChangeScene(Game, 0);
end;

{ TButton_Player }
procedure TButton_I.Click;
begin
  with (PSceneMng as TMyApp) do
    ChangeScene(MenuI, 0);
end;

{ TButton_ScoreList }
procedure TButton_How.Click;
begin
  with (PSceneMng as TMyApp) do
    ChangeScene(MenuHow, 0);
end;

{ TButton_Exit }
procedure TButton_Exit.Click;
begin
  zgl_Exit;
end;

procedure TMainMenu.Draw;
begin
  inherited;
  ssprite2d_Draw(mName, (WinW - 512) div 2, 42, 512, 256, 0);
end;

end.
