unit units_panel;

// PLEASE DO NOT REMOVE THE {*} COMMENTS, YOU CAN LOOSE YOU SOURCE!

interface

// Store here uses or proc definition
{INTERFACE}
uses zglGui,SysUtils;
{END}

var
  PanelForm: zglTForm;
  NonameLabel24: zglTLabel;
  NonameImage25: zglTImage;
  SoldierLabel: zglTLabel;
  NonameImage27: zglTImage;
  RocketManLabel: zglTLabel;
  NonameImage29: zglTImage;
  TankLabel: zglTLabel;
  NonameImage31: zglTImage;
  MedicLabel: zglTLabel;
  NonameImage33: zglTImage;
  CapitanLabel: zglTLabel;
  NonameImage35: zglTImage;
  SniperLabel: zglTLabel;
  NonameLabel37: zglTLabel;
  ScoreLabel: zglTLabel;
  MenuButton: zglTButton;
  NonameLabel19: zglTLabel;
  MovesLeftLabel: zglTLabel;
  Log: zglTList;
  NonameLabel21: zglTLabel;
  RepairsLabel: zglTLabel;
  Log1: zglTList;
  NonameButton32: zglTButton;
  winForm: zglTForm;
  NonameLabel25: zglTLabel;
  NonameButton26: zglTButton;
  winScoreLabel: zglTLabel;
  failForm: zglTForm;
  NonameLabel29: zglTLabel;
  FailScoreLabel: zglTLabel;
  NonameButton31: zglTButton;
  Font1548: zglTFontContainer;

procedure InitGui(gui: zglTGui);

type
  zglTGuiEventHandler = class
    class procedure Add_Soldier(Sender: zglTGUIObject; X, Y: integer);
    class procedure Add_RocketMan(Sender: zglTGUIObject; X, Y: integer);
    class procedure Add_Tank(Sender: zglTGUIObject; X, Y: integer);
    class procedure Add_Medic(Sender: zglTGUIObject; X, Y: integer);
    class procedure Add_Capitan(Sender: zglTGUIObject; X, Y: integer);
    class procedure Add_Sniper(Sender: zglTGUIObject; X, Y: integer);
    class procedure Display_Menu(Sender: zglTGUIObject; X, Y: integer);
    class procedure IconMouseEnter(Sender: zglTGUIObject; X, Y: integer);
    class procedure IconMouseLeave(Sender: zglTGUIObject; X, Y: integer);
    class procedure SolButtonDraw(Sender: zglTGUIObject; X, Y, W, H, scrX, scrY: Single);
    class procedure AddNewUnit(Sender: zglTGUIObject; X, Y: integer);
  end;

{WORKINGDIR=G:\code\qoodle_SVN\cubiz\bin}

implementation

// Store here recursive uses or proc implementation
{IMPLEMENTATION}
  uses LevelUnit,Var_const,zglHeader;
{END}

class procedure zglTGuiEventHandler.Add_Soldier(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_Soldier:zglTMouseEvent}
begin
  TLevelScene(GameScene).takenUnit:=Unit_Soldier;
snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Add_RocketMan(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_RocketMan:zglTMouseEvent}
begin
   TLevelScene(GameScene).takenUnit:=Unit_RocketMan;
   snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Add_Tank(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_Tank:zglTMouseEvent}
begin
    TLevelScene(GameScene).takenUnit:=Unit_Tank;
    snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Add_Medic(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_Medic:zglTMouseEvent}
begin
    TLevelScene(GameScene).takenUnit:=Unit_Medic;
    snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Add_Capitan(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_Capitan:zglTMouseEvent}
begin
    TLevelScene(GameScene).takenUnit:=Unit_Capitan;
    snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Add_Sniper(Sender: zglTGUIObject; X, Y: integer);
{EVENT Add_Sniper:zglTMouseEvent}
begin
    TLevelScene(GameScene).takenUnit:=Unit_Sniper;
    snd_Play(MissSound,false,CalcX2d(Game.GetScreenW()/2),CalcY2d(Game.GetScreenH()/2));
end;
{END}

class procedure zglTGuiEventHandler.Display_Menu(Sender: zglTGUIObject; X, Y: integer);
{EVENT Display_Menu:zglTMouseEvent}
begin
Game.PauseScene('LevelScene');
Game.DelScene('LevelScene');
Game.PlayScene('MenuScene');
end;
{END}

class procedure zglTGuiEventHandler.IconMouseEnter(Sender: zglTGUIObject; X, Y: integer);
{EVENT IconMouseEnter:zglTMouseEvent}
begin

end;
{END}

class procedure zglTGuiEventHandler.IconMouseLeave(Sender: zglTGUIObject; X, Y: integer);
{EVENT IconMouseLeave:zglTMouseEvent}
begin

end;
{END}

class procedure zglTGuiEventHandler.SolButtonDraw(Sender: zglTGUIObject; X, Y, W, H, scrX, scrY: Single);
{EVENT SolButtonDraw:zglTDrawEvent}
begin

end;
{END}

class procedure zglTGuiEventHandler.AddNewUnit(Sender: zglTGUIObject; X, Y: integer);
{EVENT AddNewUnit:zglTMouseEvent}
begin
  if TLevelScene(GameScene).score>=10 then
   begin
     TLevelScene(GameScene).score-=10;
     SoldierLabel.Caption:=inttostr((strtoint(SoldierLabel.Caption)+1));
   end;
end;
{END}

procedure InitGui(gui: zglTGui);
begin
  {INIT}
  Font1548 := zglTFontContainer.CreateDefaults(Gui);
  with Font1548 do begin
    Active.Size := 1.50; 
    Disabled.Size := 1.50; 
    FileName := 'data\fonts\Main.zfi'; 
    Normal.FileName := 'data\fonts\Main.zfi'; 
    Normal.Size := 1.50; 
  end;
  PanelForm := zglTForm.CreateDefaults(Gui); {ROOT}
  with PanelForm do begin
    Caption := 'Cubiz.PizelWars'; 
    CaptionAlign := faTopCenter;
    DisplayEffect := deSlideDown;
    Name := 'PanelForm'; 
    Rect.H := 696.00; 
    Rect.W := 139.00; 
    Rect.X := 0.00; 
    Rect.Y := 0.00; 
  end;
  Gui.Items.Add(PanelForm);
    NonameLabel24 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel24 do begin
      Caption := 'Buy units'; 
      Name := 'NonameLabel24'; 
      Rect.H := 22.00; 
      Rect.W := 122.00; 
      Rect.X := 0.00; 
      Rect.Y := 0.00; 
    end;
    PanelForm.Items.Add(NonameLabel24);
    NonameImage25 := zglTImage.CreateDefaults(Gui);
    with NonameImage25 do begin
      Name := 'NonameImage25'; 
      OnClick := zglTGuiEventHandler.Add_Soldier; 
      OnDraw := zglTGuiEventHandler.SolButtonDraw; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 0.00; 
      Rect.Y := 32.00; 
      Texture.FileName := 'data\textures\soldier.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage25);
    SoldierLabel := zglTLabel.CreateDefaults(Gui);
    with SoldierLabel do begin
      Caption := '2'; 
      Name := 'SoldierLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 32.00; 
      Rect.Y := 32.00; 
    end;
    PanelForm.Items.Add(SoldierLabel);
    NonameImage27 := zglTImage.CreateDefaults(Gui);
    with NonameImage27 do begin
      Name := 'NonameImage27'; 
      OnClick := zglTGuiEventHandler.Add_RocketMan; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 64.00; 
      Rect.Y := 32.00; 
      Texture.FileName := 'data\textures\rocketman.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage27);
    RocketManLabel := zglTLabel.CreateDefaults(Gui);
    with RocketManLabel do begin
      Caption := '1'; 
      Name := 'RocketManLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 96.00; 
      Rect.Y := 32.00; 
    end;
    PanelForm.Items.Add(RocketManLabel);
    NonameImage29 := zglTImage.CreateDefaults(Gui);
    with NonameImage29 do begin
      Name := 'NonameImage29'; 
      OnClick := zglTGuiEventHandler.Add_Tank; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 0.00; 
      Rect.Y := 70.00; 
      Texture.FileName := 'data\textures\tank.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage29);
    TankLabel := zglTLabel.CreateDefaults(Gui);
    with TankLabel do begin
      Caption := '1'; 
      Name := 'TankLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 32.00; 
      Rect.Y := 70.00; 
    end;
    PanelForm.Items.Add(TankLabel);
    NonameImage31 := zglTImage.CreateDefaults(Gui);
    with NonameImage31 do begin
      Name := 'NonameImage31'; 
      OnClick := zglTGuiEventHandler.Add_Medic; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 64.00; 
      Rect.Y := 70.00; 
      Texture.FileName := 'data\textures\medic.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage31);
    MedicLabel := zglTLabel.CreateDefaults(Gui);
    with MedicLabel do begin
      Caption := '1'; 
      Name := 'MedicLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 96.00; 
      Rect.Y := 70.00; 
    end;
    PanelForm.Items.Add(MedicLabel);
    NonameImage33 := zglTImage.CreateDefaults(Gui);
    with NonameImage33 do begin
      Name := 'NonameImage33'; 
      OnClick := zglTGuiEventHandler.Add_Capitan; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 0.00; 
      Rect.Y := 110.00; 
      Texture.FileName := 'data\textures\capitan.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage33);
    CapitanLabel := zglTLabel.CreateDefaults(Gui);
    with CapitanLabel do begin
      Caption := '1'; 
      Name := 'CapitanLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 31.00; 
      Rect.Y := 110.00; 
    end;
    PanelForm.Items.Add(CapitanLabel);
    NonameImage35 := zglTImage.CreateDefaults(Gui);
    with NonameImage35 do begin
      Name := 'NonameImage35'; 
      OnClick := zglTGuiEventHandler.Add_Sniper; 
      OnMouseEnter := zglTGuiEventHandler.IconMouseEnter; 
      OnMouseLeave := zglTGuiEventHandler.IconMouseLeave; 
      Rect.H := 32.00; 
      Rect.W := 32.00; 
      Rect.X := 64.00; 
      Rect.Y := 110.00; 
      Texture.FileName := 'data\textures\sniper.png'; 
      Texture.TexHeight := 32; 
      Texture.TexWidth := 32; 
    end;
    PanelForm.Items.Add(NonameImage35);
    SniperLabel := zglTLabel.CreateDefaults(Gui);
    with SniperLabel do begin
      Caption := '1'; 
      Name := 'SniperLabel'; 
      Rect.H := 32.00; 
      Rect.W := 20.00; 
      Rect.X := 96.00; 
      Rect.Y := 110.00; 
    end;
    PanelForm.Items.Add(SniperLabel);
    NonameLabel37 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel37 do begin
      Caption := 'Score:'; 
      Name := 'NonameLabel37'; 
      Rect.H := 20.00; 
      Rect.W := 51.00; 
      Rect.X := 4.00; 
      Rect.Y := 150.00; 
    end;
    PanelForm.Items.Add(NonameLabel37);
    ScoreLabel := zglTLabel.CreateDefaults(Gui);
    with ScoreLabel do begin
      Caption := '0'; 
      Name := 'ScoreLabel'; 
      Rect.H := 23.00; 
      Rect.W := 45.00; 
      Rect.X := 66.00; 
      Rect.Y := 148.00; 
    end;
    PanelForm.Items.Add(ScoreLabel);
    MenuButton := zglTButton.CreateDefaults(Gui);
    with MenuButton do begin
      Caption := 'Exit to menu'; 
      Name := 'MenuButton'; 
      OnClick := zglTGuiEventHandler.Display_Menu; 
      Rect.H := 49.00; 
      Rect.W := 122.00; 
      Rect.X := 1.00; 
      Rect.Y := 362.00; 
    end;
    PanelForm.Items.Add(MenuButton);
    NonameLabel19 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel19 do begin
      Caption := 'Moves Left:'; 
      Name := 'NonameLabel19'; 
      Rect.H := 32.00; 
      Rect.W := 93.00; 
      Rect.X := 1.00; 
      Rect.Y := 175.00; 
    end;
    PanelForm.Items.Add(NonameLabel19);
    MovesLeftLabel := zglTLabel.CreateDefaults(Gui);
    with MovesLeftLabel do begin
      Caption := '2'; 
      Name := 'MovesLeftLabel'; 
      Rect.H := 35.00; 
      Rect.W := 38.00; 
      Rect.X := 80.00; 
      Rect.Y := 174.00; 
    end;
    PanelForm.Items.Add(MovesLeftLabel);
    Log := zglTList.CreateDefaults(Gui);
    with Log do begin
      Name := 'Log'; 
      Rect.H := 44.00; 
      Rect.W := 116.00; 
      Rect.X := 6.00; 
      Rect.Y := 236.00; 
    end;
    PanelForm.Items.Add(Log);
    NonameLabel21 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel21 do begin
      Caption := 'CPU repairs left:'; 
      Rect.H := 19.00; 
      Rect.W := 111.00; 
      Rect.X := -2.00; 
      Rect.Y := 207.00; 
    end;
    PanelForm.Items.Add(NonameLabel21);
    RepairsLabel := zglTLabel.CreateDefaults(Gui);
    with RepairsLabel do begin
      Caption := '5'; 
      Name := 'RepairsLabel'; 
      Rect.H := 44.00; 
      Rect.W := 30.00; 
      Rect.X := 99.00; 
      Rect.Y := 195.00; 
    end;
    PanelForm.Items.Add(RepairsLabel);
    Log1 := zglTList.CreateDefaults(Gui);
    with Log1 do begin
      Name := 'Log1'; 
      Rect.H := 40.00; 
      Rect.W := 116.00; 
      Rect.X := 5.00; 
      Rect.Y := 287.00; 
    end;
    PanelForm.Items.Add(Log1);
    NonameButton32 := zglTButton.CreateDefaults(Gui);
    with NonameButton32 do begin
      Caption := 'Add unit soldier  ( -10 score)'; 
      OnClick := zglTGuiEventHandler.AddNewUnit; 
      Rect.H := 29.00; 
      Rect.W := 118.00; 
      Rect.X := 2.00; 
      Rect.Y := 330.00; 
    end;
    PanelForm.Items.Add(NonameButton32);
  winForm := zglTForm.CreateDefaults(Gui); {ROOT}
  with winForm do begin
    Caption := 'Epic WIN!'; 
    CaptionAlign := faMiddleCenter;
    DisplayEffect := deSlideDown;
    Name := 'winForm'; 
    Rect.H := 161.00; 
    Rect.W := 377.00; 
    Rect.X := 154.00; 
    Rect.Y := 218.00; 
    Visible := False;
  end;
  Gui.Items.Add(winForm);
    NonameLabel25 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel25 do begin
      Caption := 'Epic WIN!!!'; 
      Font := Font1548; 
      Rect.H := 45.00; 
      Rect.W := 206.00; 
      Rect.X := 80.00; 
      Rect.Y := 7.00; 
    end;
    winForm.Items.Add(NonameLabel25);
    NonameButton26 := zglTButton.CreateDefaults(Gui);
    with NonameButton26 do begin
      Caption := 'OK!'; 
      Font := Font1548; 
      OnClick := zglTGuiEventHandler.Display_Menu; 
      Rect.H := 45.00; 
      Rect.W := 169.00; 
      Rect.X := 100.00; 
      Rect.Y := 86.00; 
    end;
    winForm.Items.Add(NonameButton26);
    winScoreLabel := zglTLabel.CreateDefaults(Gui);
    with winScoreLabel do begin
      Caption := 'Score: 0'; 
      Name := 'winScoreLabel'; 
      Rect.H := 33.00; 
      Rect.W := 189.00; 
      Rect.X := 86.00; 
      Rect.Y := 48.00; 
    end;
    winForm.Items.Add(winScoreLabel);
  failForm := zglTForm.CreateDefaults(Gui); {ROOT}
  with failForm do begin
    Caption := 'Epic FAIL.'; 
    CaptionAlign := faMiddleCenter;
    DisplayEffect := deSlideDown;
    Name := 'failForm'; 
    Rect.H := 155.00; 
    Rect.W := 376.00; 
    Rect.X := 147.00; 
    Rect.Y := 206.00; 
    Visible := False;
  end;
  Gui.Items.Add(failForm);
    NonameLabel29 := zglTLabel.CreateDefaults(Gui);
    with NonameLabel29 do begin
      Caption := 'Epic Fail.'; 
      Font := Font1548; 
      Rect.H := 60.00; 
      Rect.W := 213.00; 
      Rect.X := 74.00; 
      Rect.Y := 1.00; 
    end;
    failForm.Items.Add(NonameLabel29);
    FailScoreLabel := zglTLabel.CreateDefaults(Gui);
    with FailScoreLabel do begin
      Caption := 'Score: 0'; 
      Name := 'FailScoreLabel'; 
      Rect.H := 32.00; 
      Rect.W := 124.00; 
      Rect.X := 114.00; 
      Rect.Y := 49.00; 
    end;
    failForm.Items.Add(FailScoreLabel);
    NonameButton31 := zglTButton.CreateDefaults(Gui);
    with NonameButton31 do begin
      Caption := 'Okay...'; 
      Font := Font1548; 
      OnClick := zglTGuiEventHandler.Display_Menu; 
      Rect.H := 43.00; 
      Rect.W := 156.00; 
      Rect.X := 101.00; 
      Rect.Y := 86.00; 
    end;
    failForm.Items.Add(NonameButton31);
  {END}
end;

end.
