unit uMenu;

interface
uses
  uScene, uPage;
type
  TMenuPage = class(TPage)
    Button_Ok : TPageButton;
    constructor Create(const X, Y, W_, H_, Color_: Integer;
                const Scene: TScene);overload;
  end;

  TMenu = class(TScene)
    Page : TMenuPage;
    procedure   Draw;   override;
    procedure   Update; override;
    destructor  Free;   override;
  end;

implementation
uses
  uMyApp, zglHeader;

const
  c_button_dw = 256;
  c_button_dh = 128;
  c_button_w = 184;
  c_button_h = 40;
  c_button_startY = - c_button_h;

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

procedure TMenu.Draw;
begin
  Page.Draw;
end;

destructor TMenu.Free;
begin
  inherited;
  Page.Free;
end;

procedure TMenu.Update;
begin
  Page.Update;
  if Key_Press(K_ESCAPE) then
  with (PSceneMng as TMyApp) do
    ChangeScene(MainMenu, 0);
end;

{ TMenuPage }

constructor TMenuPage.Create(const X, Y, W_, H_, Color_: Integer;
  const Scene: TScene);
begin
  inherited Create(X, Y, W_, H_, Color_, Scene);
  Button_Ok := TButton.Create( 0, H_ + c_button_startY, 'Μενώ', Scene.PSceneMng);
  AddButton(Button_Ok);
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;
end;

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


end.
