unit u_Win;

interface
uses
  uConst, u_Button, LexUtils;

type
  t_Win = class
    B : T_Button;
    Point : Integer;
    S : array[0..3] of string;
    constructor Create;
    procedure Init(Point_ : Integer);
    procedure Work;
    procedure Draw;
  end;

var
  Wined : Boolean = False;
  Win : t_Win;

implementation

uses
  uGame, u_Menu, u_SceneM, u_Records, Setup, ZglHeader, uMaterials;

constructor t_Win.Create;
begin
  B := T_Button.Create('Далее', 1, (WinW - 192) div 2, WinH div 2 + 200 - 128, 192, 48, 0.8);
end;

procedure t_Win.Work;
begin
  if B.Work then
  begin
    if uGame.MyLevel < Menu.M_Level.MofLevel then
      uGame.Start(uGame.MyLevel + 1)
    else
      Main.SetScene(tg_menu);
  end;
end;

procedure t_Win.Draw;
var

  I : Integer;
begin
  // Pr2D_Rect(WinW / 2 - 260, WinH / 2 - 220, 520, 420, $FFFFFF, $E5, PR2D_FILL);
   ssprite2d_Draw(mBgMenu2, WinW / 2 - 260, WinH / 2 - 220, 520, 420, 0);
   Text_DrawEx(mFont_1,
            WinW div 2, WinH / 2 - 184, 1, 0,
             AnsiToUtf8(S[0]), 255, MBtnColor[2], TEXT_HALIGN_CENTER);

   for I := 1 to 3 do
   Text_DrawEx(mFont_1, WinW div 2,
             WinH / 2 - 155 + 60 * I, 0.8, 0,
             AnsiToUtf8(S[I]), 255, MBtnColor[1], TEXT_HALIGN_CENTER );
   B.Draw;
end;

procedure t_Win.Init;
begin
  Wined := True;
  Point := Point_;
  Rec.NewRec( Menu.M_Level.LevelS[MyLevel, 2], Point );
  Menu.M_Level.LevelS[MyLevel, 3] := Int2S(Rec.RecTable.R[1].P ) + '  (' +
    Rec.RecTable.R[1].N + ')';
  Menu.M_Level.List(1);
  if uGame.MyLevel < Menu.M_Level.MofLevel then
    begin
    Win.S[1] := 'Уровень "' + Menu.M_Level.LevelS[MyLevel, 1] + '" пройден';
    Win.S[2] := 'Вы набрали ' + Int2S(Point) + ' очков';
    Win.S[3] := '';
  end
  else
  begin
    Win.S[1] := 'ПОЗДРАВЛЯЮ!';
    Win.S[2] := 'Вы успешно прошли игру';
    Win.S[3] := 'и набрали ' + Int2S(Point) + ' очков';
    Menu.Button[1].S := 'Играть';
    Menu.StartGame := True;
  end;

end;

end.
