unit uMenuPlayer;

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

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

type
  TPagePlayer = class(TMenuPage)
    PlayerName : string;
    TildT : byte;
    procedure Update; override;
    procedure Draw; override;
  end;

constructor TMenuPlayer.Create(const SceneMng : tSceneMng);
begin
  inherited Create(SceneMng);
  Page := TPagePlayer.Create(WinW div 2, WinH div 2 - 128, 400, 200, $AAAAAA, Self);
  Page.Button_Ok.Text := 'ОК';
  key_BeginReadText( (Page as TPagePlayer).PlayerName, 20 );
end;

{ TPagePlayer }

procedure TPagePlayer.Draw;
begin
  inherited;
  Text_DrawEx(mFont_1, PageX^ + pX,
             PageY^ + pY + 16, 1, 0,
             {AnsiToUtf8}('Введите свое имя:'), 240, $551111, TEXT_HALIGN_CENTER);
  Text_DrawEx(mFont_1, WinW div 2,
             PageY^ + pY + 64, 1, 0,
             {AnsiToUtf8}(PlayerName),  235, $772222, TEXT_HALIGN_CENTER);
  if TildT > 128 then
  pr2d_Rect(trunc(WinW + text_GetWidth( mFont_1, PlayerName)) div 2,
             PageY^ + pY + 64,
             10, 30, $992222, $77, PR2D_FILL );
end;

procedure TPagePlayer.Update;
var
  SetName : Boolean;
begin
  inherited;
  SetName := Button_Ok.Clicked;
  PlayerName := key_GetText();
  Inc(TildT, 8);

  if Key_Press(k_ENTER) then
  begin
  with (PScene.PSceneMng as TMyApp) do
    ChangeScene(MainMenu, 0);
     SetName := True;
  end;

  if SetName then


end;

end.
