// Called when minigame GUI shows up
function PunchMinigame::onWake(%this)
{
   %this.isPlaying = true;
   
   exec("~/data/ui/minigame/punch/"@playMinigameDlg.currentLevel@"/PunchConfig.cs");
   
   // Set skip button
   PunchSkipButton.setBitmap("scriptsAndAssets/data/ui/minigame/quit.png");   
   
   %this.gameCtrl = new GuiContainer() {
      canSaveDynamicFields = "1";
      Enabled = "1";
      className = "PunchGameCtrl";    
      isContainer = "1";
      HorizSizing = "relative";
      VertSizing = "relative";
      Position = "0 0";
      Extent = "800 600";
      MinExtent = "1 1";
      canSave = "1";
      Visible = "1";
      hovertime = "1000";
      alpha = "1";
      color = "255 255 255 255";
      unitClip = "0 0 1 1";
      lockMouse = "0";
      Margin = "0 0 0 0";
      Padding = "0 0 0 0";
      AnchorTop = "1";
      AnchorBottom = "0";
      AnchorLeft = "1";
      AnchorRight = "0";
      useMouseEvents = "1";
   };                           

   MinigameRefCenter.add(%this.gameCtrl);   
   
   PunchGui.init(); 
   
   MinigameRefCenter.pushToBack(%this.gameCtrl);
   MinigameRefCenter.pushToBack(PunchSkipButton);   
   
   %this.gameFinished = false;
   
   // Force resizing
   %this.setExtent(getWord(Canvas.extent,0), getWord(Canvas.extent,1));
   Canvas.setWidescreen(MinigameRefCenter, 0, false);
}

// Linear interpolation helper function
//#define LERP(a,b,t)     (((b) - (a)) * (t) + (a))

function PunchMinigame::lerp(%this, %a, %b, %t)
{
   //return %start*(1-%t) + %end*%t;
   return (%b - %a) * %t + %a;
}

// Return true if the given two AABB rectangles do intersect
// %l1 = Left position of rectangle 1
// %t1 = Top position of rectangle 1
// %r1 = Right position of rectangle 1
// %b1 = Bottom position of rectangle 1
// %l2 = Left position of rectangle 2
// %t2 = Top position of rectangle 2
// %r2 = Right position of rectangle 2
// %b2 = Bottom position of rectangle 2
function PunchMinigame::intersectRect(%this, %l1, %t1, %r1, %b1, %l2, %t2, %r2, %b2)
{
   return !(%l2 > %r1 || %r2 < %l1 || %t2 > %b1 || %b2 < %t1);
}

// Called by miniGame.cs
function PunchMinigame::start(%this)
{
   %this.swatterIsPlaying = false;
   %this.swatterCurrentImage = 1;   
   
   %this.personSpawnInterval = 200; // 1400
   
   %this.score = 0;
   %this.isIdle = false;
   
   %this.newPersonIdx = 0;
   %this.personNum = 0;
   %this.spawnPerson();
      
   Canvas.hideCursor();   
   %this.timerCounter = 61;
   %this.onIdle();
   %this.onTick();
   
   %this.hitSfxIteration = 1;
   %this.missSfxIteration = 1;
   
   %this.isConfettiAnimating = false;
   
   sfxPlay(MonsterLevel);
      
   PunchGui.pushToBack(Swatter);
   PunchGui.pushToBack(PunchSkipButton);
}

// Exit the minigame
function PunchMinigame::quit(%this)
{
   sfxStopAll();
   
   if(%this.isEnding)
      return;
      
   //lockMouse(false);
   Canvas.showCursor();  

   %this.isPlaying = false;
      
   // Avoid new schedules
   %this.isEnding = true;
      
   // Widescreen support
   if(isObject(MinigameCenter))
   {
      Minigame.bringToFront(%this);
      MinigameCenter.setVisible(true);   
      Minigame.pushToBack(MinigameCenter);   
   }
   
   // Number of hints won
   Minigame.hintsGained = PunchGui.meter.getHintsGained();   
         
   if(mFloor(Minigame.hintsGained) > 0 && %this.gameFinished /* && PlayMinigameDlg.isPlayingMinigame !$= true*/)
   {
      if(!%this.ConfettiIsPlaying)
      {
         if(isObject(PlayMinigameDlg))
         {            
            PlayMinigameDlgCenter.pushToBack(MinigameCircles);
            PlayMinigameDlgCenter.pushToBack(MinigameParticleFx);
            PlayMinigameDlgCenter.pushToBack(WinText);
            PlayMinigameDlgCenter.pushToBack(HintNumber);
            PlayMinigameDlgCenter.pushToBack(PMClapper);
            PlayMinigameDlgCenter.pushToBack(PMBoard);
            PlayMinigameDlgCenter.pushToBack(PMClapperStart);   
                     
            PlayMinigameDlg.bringToFront(%this);
            
            PlayMinigameDlg.setVisible(true);            
            PlayMinigameDlgCenter.setVisible(true);
         }
            
         // Play confetti
         MinigameParticleFx.ConfettiFx(15); // Play confetti for 15 secs
         %this.ConfettiIsPlaying = true;

         if(PlayMinigameDlg.isPlayingMinigame $= true)
            scheduleObjLCA(playMinigameDlg, "Minigame", 15*1000, "quitMinigame", 0);
         else
            // Quit a bit earlier
            scheduleObjLCA(playMinigameDlg, "Minigame", 12*1000, "quitMinigame", 0);
      }
   }
   else
   {
      Minigame.hintsGained = 0;
      
      if(isObject(PlayMinigameDlg))
         PlayMinigameDlg.bringToFront(PlayMinigameDlg.curMinigame);
      
      playMinigameDlg.quitMinigame();
   }
}

function PunchGameCtrl::onMouseMove(%this, %modifier, %worldPosition, %mouseClicks)
{
   %winScaleY = 1.0 / 600 * getWord(MinigameRefCenter.getExtent(),1);   
   
   // Get mouse position
   %mouseX = getWord(%worldPosition,0);
   %mouseY = getWord(%worldPosition,1);
   
   echo(%mouseY);
   if(%mouseY > 530*%winScaleY)
   {
      Swatter.setVisible(false);
      Canvas.showCursor();      
   }
   else
   {
      Swatter.setVisible(true);      
      Canvas.hideCursor();
      PunchMinigame.updateSwat(%mouseX, %mouseY);      
   }   
}

function PunchGameCtrl::onMouseEnter(%this)
{
   //lockMouse(true); 
   Canvas.hideCursor();
}

function PunchGameCtrl::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
   PunchMinigame.onClick(getWord(%worldPosition,0), getWord(%worldPosition,1));
}


// Update the swat GUI control according to current mouse cursor position
function PunchMinigame::updateSwat(%this, %cursorX, %cursorY)
{
   %winScaleX = 1.0 / 800 * getWord(MinigameRefCenter.getExtent(),0);
   %winScaleY = 1.0 / 600 * getWord(MinigameRefCenter.getExtent(),1);  
   
   // Compensate widescreen offset
   %rect2 = MinigameRefCenter.getPosition();      
   
   %cursorX = %cursorX - getWord(Swatter.Extent,0)/2 - getWord(%rect2,0);
   %cursorY = %cursorY - getWord(Swatter.Extent,1)/2 - getWord(%rect2,1);   
   Swatter.setPosition(%cursorX, %cursorY);   
/*   
   %cursorPos = Canvas.getCursorPos();
   Swatter.setPosition(getWord(%cursorPos,0) - getWord(Swatter.Extent,0)/2 - getWord(%rect2,0),
                       getWord(%cursorPos,1) - getWord(Swatter.Extent,1)/2 - getWord(%rect2,1));
   Swatter.setVisible(true);
   
   if(getWord(%cursorPos,1) > 530*%winScaleY)
   {
      Swatter.setVisible(false);
      Canvas.showCursor();      
   }
   else
   {
      Swatter.setVisible(true);      
      Canvas.hideCursor();
   } */
}

function PunchMinigame::onTick(%this, %i)
{
   sfxPlay("AudioTimerBeep"@ ((%i % 2) + 1));
   if (%i > 76)
   {/*do nothing :P*/}
   else if (%i > 64)
      scheduleObjLCA(%this, "Minigame", 250, "onTick", 1, %i+1 );   
   else if (%i > 50)
	  scheduleObjLCA(%this, "Minigame", 500, "onTick", 1, %i+1 );   
   else
      scheduleObjLCA(%this, "Minigame", 1000, "onTick", 1, %i+1 );   
}

function PunchMinigame::playSfxHit(%this)
{
	sfxPlay(%this.HitSoundString @ %this.hitSfxIteration);
	%this.hitSfxIteration = (%this.hitSfxIteration % %this.MaxHitSounds )+ 1;
}

function PunchMinigame::playSfxMiss(%this)
{
	sfxPlay(%this.MissSoundString @ %this.missSfxIteration);
	%this.hitSfxIteration = (%this.MissSfxIteration % %this.MaxMissSounds )+ 1;
}

// Idle event called at 30 FPS
function PunchMinigame::onIdle(%this)
{
   if(%this.isConfettiAnimating)
      return;
      
   if(%this.isEnding)
      return;
      
   %this.isIdle = true;
   
//   %this.updateSwat();
   
   %winScaleX = 1.0 / 800 * getWord(MinigameRefCenter.getExtent(),0);
   %winScaleY = 1.0 / 600 * getWord(MinigameRefCenter.getExtent(),1);   

   // Update position of each person   
   for(%j=0; %j<%this.personNum; %j++)
   {
      if(%this.personIdx[%j] $= "")
         continue;
      
      %obj  = ("Person"@%this.personIdx[%j]);
      if(%obj.hit)
         continue;
         
      %objExtent  = %obj.getExtent();
      %width  = getWord(%objExtent, 0);
      %height = getWord(%objExtent, 1);
               
      %newPosX = getWord(%obj.origPos,0)*(1-%obj.t) + getWord(%obj.destPos,0)*%obj.t;
      %newPosY = getWord(%obj.origPos,1)*(1-%obj.t) + getWord(%obj.destPos,1)*%obj.t;
      %newPosX *= %winScaleX;
      %newPosY *= %winScaleY;
      %obj.setPosition(%newPosX-%width/2, %newPosY-%height/2);
   
      if(!%obj.wait)
      {
         if(%obj.goingBack)
         {
            %obj.t -= %obj.speed;
            if(%obj.t <= 0)
               %this.killPerson(%j);
         }
         else
         {        
            %obj.t += %obj.speed;
            // Test if reached point of return
            if(%obj.t >= 1)
            {
               %obj.t = 1;
               
               if(%obj.badGuy)
               {
				  sfxPlay(MazeMinigameFlash);
                  %flash = new GuiPlasticBitmapCtrl() {
                     canSaveDynamicFields = "0";
                     Enabled = "1";
                     isContainer = "0";
                     Profile = "GuiContentProfile";
                     HorizSizing= "relative";
                     VertSizing = "relative";
                     Extent = "133 100";
                     MinExtent = "2 2";
                     canSave = "1";
                     Visible = "1";
                     hovertime = "1000";
                     alpha = "0";
                     color = "255 255 255 255";
                     unitClip = "0 0 1 1";
                     useVariable = "0";
                     tile = "0";      
                     rotation = "0";
                     deltaRotation = "0";
                     noClip = "0";
                     DML = "scriptsAndAssets/data/ui/minigame/punch/flash.png";
                  };
                  PunchHitLayer.add(%flash);
                  %flash.setPosition(%newPosX-(133/2), %newPosY-(%height/4.5));
                  %flash.animateAlpha(1, 0, 100, "0 0");
                  scheduleObjLCA(%this, "Minigame", 100, "killFlash", 1, %flash);                  
               }
               
               %obj.wait = true;
               scheduleObjLCA(%this, "Minigame", 1000, "endWait", 1, %obj);               
               
               %obj.goingBack = true;
            }
         }
      }
   }
   
   %this.isIdle = false;
   
   scheduleObjLCA(%this, "Minigame", 33, "onIdle", 0);   
}

function PunchMinigame::endWait(%this, %obj)
{
   %obj.wait = false;
}

// Kill flash
function PunchMinigame::killFlash(%this, %obj)
{
   %obj.animateAlpha(0, 0, 100, "0 0");
   scheduleObjLCA(%obj, "Minigame", 100, "delete", 0);
}

// Kill a paparazzi
function PunchMinigame::killPerson(%this, %i)
{
   %obj  = ("Person"@%this.personIdx[%i]);
   %this.personIdx[%i] = "";
   if(%obj.hit)
      PunchHitLayer.remove(%obj);
   else
      ("PunchObjLayer"@%obj.layer).add(%obj);   
      
   %this.layerSlot[%obj.sel]--;      
   
   %obj.delete();
}

// Swatter Animation
function PunchMinigame::swatterAnimation(%this)
{
   if(%this.swatterCurrentImage == 5){
      %this.swatterCurrentImage = 1;
      Swatter.setDML("scriptsAndAssets/data/ui/minigame/punch/glove/glove01.png");
      %this.swatterIsPlaying = false;
      return;
   }
   %this.swatterCurrentImage++;

   Swatter.setDML("scriptsAndAssets/data/ui/minigame/punch/glove/glove0"@%this.swatterCurrentImage@".png");

   scheduleObjLCA(%this, "Minigame", 40, "swatterAnimation", 0);
}

// Callback of left mouse button click
function PunchMinigame::onClick(%this, %mouseX, %mouseY)
{
   //animate swatter
   if(!%this.swatterIsPlaying)
   {
      %this.playSfxMiss();
	   %this.swatterIsPlaying = true;
      scheduleObjLCA(%this, "Minigame", 0, "swatterAnimation", 0);      
   }
   
   %HitSomething = false;
   
   if(%this.isConfettiAnimating || %this.isEnding)
      return;
   
   // Get mouse coordinates
//   %curMousePos = canvas.getCursorPos();
//   %mouseX = getWord(%curMousePos,0);
//   %mouseY = getWord(%curMousePos,1);

   // Compensate widescreen offset
   %rect2 = MinigameRefCenter.getPosition();
   %mouseX -= getWord(%rect2,0);
   %mouseY -= getWord(%rect2,1);   
   
   // First rectangle
   %l1 = %mouseX - getWord(Swatter.Extent,0)/12;
   %t1 = %mouseY - getWord(Swatter.Extent,1)/12;
   %r1 = %mouseX + getWord(Swatter.Extent,0)/12;
   %b1 = %mouseY + getWord(Swatter.Extent,1)/12;
      
   %winScaleX = 1.0 / 800 * getWord(MinigameRefCenter.getExtent(),0);
   %winScaleY = 1.0 / 600 * getWord(MinigameRefCenter.getExtent(),1);     
   
   // Check paparazzi
   for(%j=0; %j<%this.personNum; %j++)
   {
      if(%this.personIdx[%j] $= "")
         continue;

      %obj = ("Person"@%this.personIdx[%j]);
      if(%obj.hit)
         continue;
      
      %posX = getWord(%obj.origPos,0)*(1-%obj.t) + getWord(%obj.destPos,0)*%obj.t;
      %posY = getWord(%obj.origPos,1)*(1-%obj.t) + getWord(%obj.destPos,1)*%obj.t;
      %posX *= %winScaleX;
      %posY *= %winScaleY;
      
      %pos = %obj.Position;
      %dim = %obj.Extent;
      
      %marginX = getWord(%dim, 0) / 5.0;
      %marginY = getWord(%dim, 1) / 5.0;      
            
      %l2 = %posX - %marginX;
      %t2 = %posY - %marginY;
      %r2 = %posX + %marginX;
      %b2 = %posY + %marginY;
      
      if(%obj.t > 0.3 && 
         %this.intersectRect(%l1, %t1, %r1, %b1, %l2, %t2, %r2, %b2))
      {
         %obj.rotation = 0;
         if(%obj.badGuy)
         {
			%this.playSfxHit();
            %obj.setDML("scriptsAndAssets/data/ui/minigame/punch/hit.png");
            %obj.setExtent(219, 134);            
         }
         else
         {
			%this.playSfxHit();
            %obj.setDML("scriptsAndAssets/data/ui/minigame/punch/wrong_hit.png");
            %obj.setExtent(87, 88);
         }
         %obj.hit = true;
         
         ("PunchObjLayer"@%obj.layer).remove(%obj);
         PunchHitLayer.add(%obj);
         
         // Centerize hit splat
         %cx = getWord(%pos, 0) + getWord(%dim, 0)/2;
         %cy = getWord(%pos, 1) + getWord(%dim, 1)/2;
         %ext = %obj.getExtent();
         %obj.setPosition(%cx-(getWord(%ext,0)/2)*%winScaleX, 
                          %cy-(getWord(%ext,1)/2)*%winScaleY);
                  
         scheduleObjLCA(%this, "Minigame", 400, "killPerson", 1, %j);
         
         if(%obj.badGuy)
         {
            %this.score += 2;
            PunchGui.scoreMatch(2, true);
         }
         else
         {
            %this.score--;
            if(%this.score >= 1)
               PunchGui.scoreMatch(1, false);
            if(%this.score < 0)
               %this.score = 0;
         }
      }
   }
}

// Spawn paparazzi
function PunchMinigame::spawnPerson(%this)
{
   if(%this.isIdle)
      return;
      
   if(%this.isConfettiAnimating || %this.isEnding)
      return;
   
   %winScaleX = 1.0 / 800 * getWord(MinigameRefCenter.getExtent(),0);
   %winScaleY = 1.0 / 600 * getWord(MinigameRefCenter.getExtent(),1);

   %scale = 0.6;
   %badGuy = false;
   %path = "scriptsAndAssets/data/ui/minigame/punch/";
   switch(getRandom(0,8))
   {
      case 0: %path = %path @ "crew.png";     %extent = "129 129";
      case 1: %path = %path @ "director.png"; %extent = "142 142";
      case 2: %path = %path @ "kong.png";     %extent = "195 195"; %scale = 0.3;
      case 3: %path = %path @ "pap1.png";     %extent = "125 125"; %badGuy = true;
      case 4: %path = %path @ "pap2.png";     %extent = "109 109"; %badGuy = true;
      case 5: %path = %path @ "pap3.png";     %extent = "120 120"; %badGuy = true;
      case 6: %path = %path @ "pap1.png";     %extent = "125 125"; %badGuy = true;
      case 7: %path = %path @ "pap2.png";     %extent = "109 109"; %badGuy = true;
      case 8: %path = %path @ "pap3.png";     %extent = "120 120"; %badGuy = true;
   }
   
   // Width and height of the object to be spawned
   %objWidth  = getWord(%extent,0);
   %objHeight = getWord(%extent,1);

   %obj = new GuiPlasticBitmapCtrl("Person"@%this.newPersonIdx) {
      canSaveDynamicFields = "0";
      Enabled = "1";
      isContainer = "0";
      Profile = "GuiContentProfile";
      HorizSizing= "relative";
      VertSizing = "relative";
      MinExtent = "2 2";
      canSave = "1";
      Visible = "0";
      hovertime = "1000";
      alpha = "1";
      color = "255 255 255 255";
      unitClip = "0 0 1 1";
      useVariable = "0";
      tile = "0";      
      rotation = "0";
      deltaRotation = "0";
      noClip = "0";
      DML = %path;
   };
      
   %addItem = true;
      
   %obj.badGuy = %badGuy;
   %obj.hit = false;
   %obj.layer = getRandom(1,5);
   
   switch(%obj.layer)
   {
      case 1: 
         if(getRandom(0,1) $= 0)
         {
            // Left building
            %obj.origPos = "146 432";
            %val = getRandom(0,2);
            switch(%val)
            {
               case 0: %obj.destPos = "53 438";  %obj.sel = "100"; %obj.rotation = "90";
               case 1: %obj.destPos = "113 335"; %obj.sel = "101"; %scale = 0.6; 
               case 2: %obj.destPos = "241 430"; %obj.sel = "102"; %obj.rotation = "-90";
            }
         }
         else
         {
            // Right building
            %obj.origPos = "648 488";
            %val = getRandom(0,2);
            switch(%val)
            {
               case 0: %obj.destPos = "491 436"; %obj.sel = "110"; %scale = 0.6;
               case 1: %obj.destPos = "632 392"; %obj.sel = "111"; %scale = 0.6;
               case 2: %obj.origPos = "716 488"; %obj.destPos = "726 370"; %obj.sel = "112"; %scale = 0.6;
            }            
         }
      case 2:
         // Broken tower
         %obj.origPos = "383 378";
         %val = getRandom(0,1);
         switch(%val)
         {
            case 0: %obj.destPos = "315 389"; %obj.sel = "20"; %obj.rotation = "90";
            case 1: %obj.destPos = "449 376"; %obj.sel = "21"; %obj.rotation = "-90";
         }
      case 3:
         // Two towers
         %val = getRandom(0,2);
         switch(%val)
         {
            case 0: %obj.origPos = "316 319"; %obj.destPos = "259 338";  %obj.sel = "30"; %obj.rotation = "90";
            case 1: %obj.origPos = "411 90";  %obj.destPos = "488 118";  %obj.sel = "31"; %obj.rotation = "-90"; %scale = 0.6;
            case 2: %obj.origPos = "300 115"; %obj.destPos = "300 50";   %obj.sel = "32"; 
         }
      case 4:
         %val = getRandom(0,1);
         if(%val $= 0)
         {
            // Left 
            %obj.origPos = "482 350"; %obj.destPos = "530 347"; %obj.sel = "40"; %obj.rotation = "-90";
         }
         else
         { 
            // Right
            %obj.origPos = "654 316"; %obj.destPos = "674 233"; %obj.sel = "41";
         }
      case 5:
         %val = getRandom(0,3);
         switch(%val)
         {
            case 0:
               %obj.origPos = "104 317";
               %val = getRandom(0,1);
               switch(%val)
               {
                  case 0: %obj.destPos = "45 324"; %obj.sel = "500"; %obj.rotation = "90";
                  case 1: %obj.destPos = "90 240"; %obj.sel = "501";
               }
            case 1: 
               %obj.origPos = "255 260";
               %val = getRandom(0,1);
               switch(%val)
               {
                  case 0: %obj.destPos = "198 264"; %obj.sel = "510"; %obj.rotation = "90";
                  case 1: %obj.destPos = "238 186"; %obj.sel = "511";
               }
            case 2: 
               %obj.origPos = "500 270"; 
               %obj.destPos = "500 180";
               %obj.sel = "52";
               %scale = 0.6;
            case 3:
               %obj.origPos = "735 362";
               %obj.destPos = "745 265";
               %obj.sel = "53";
               %scale = 0.6;
         }
   }
   
   // Choose initial position
   %scale *= 3;   
   %width = %objWidth*%scale*%winScaleX;
   %height = %objHeight*%scale*%winScaleY;   
   
   if(%this.layerSlot[%obj.sel] $= "" || %this.layerSlot[%obj.sel] $= 0)
      %this.layerSlot[%obj.sel]++;
   else
   {
      %obj.delete();
      scheduleObjLCA(%this, "Minigame", %this.personSpawnInterval, "spawnPerson", 0);
      return;
   }
   
   for(%j=0; %j<%this.personNum; %j++)
   {
      if(%this.personIdx[%j] $= "")
      {
         %obj = ("Person"@%this.newPersonIdx);
         %this.personIdx[%j] = %this.newPersonIdx;
         %addItem = false;
         break;
      }
   }   
   
   ("PunchObjLayer"@%obj.layer).add(%obj);   
      
   %obj.speed = 1 / getRandom(15,25);
   %obj.t = 0;
   %obj.scale = %scale;
   %obj.goingBack = false;
   
   %obj.setPosition(getWord(%obj.origPos,0)*%winScaleX - %width/2, 
                    getWord(%obj.origPos,1)*%winScaleY - %height/2);
   %obj.setExtent(%width, %height);   
   %obj.setVisible(true);
              
   if(%addItem)
   {
      %this.personIdx[%this.personNum] = %this.newPersonIdx;
      %this.personNum++;
   }
      
   %this.newPersonIdx++;
      
   // Respawn
   scheduleObjLCA(%this, "Minigame", %this.personSpawnInterval, "spawnPerson", 0);
}

function PunchMinigame::onTimeOut(%this)
{      
   // Quit a bit earlier
   %this.gameFinished = true;
   %this.quit();
}

// Callback for resizing events
function PunchMinigame::onResize(%this, %width, %height)
{
   PunchGui.xScale    = getWord(PunchGui.getExtent(), 0)/800;
   PunchGui.yScale    = getWord(PunchGui.getExtent(), 1)/600; 
   PunchGui.x0        = mRound(getWord(PunchGui.boardPos, 0)  * PunchGui.xScale);
   PunchGui.y0        = mRound(getWord(PunchGui.boardPos, 1)  * PunchGui.yScale);
   PunchGui.gemWidth  = mRound(getWord(PunchGui.gemExtent, 0) * PunchGui.xScale);
   PunchGui.gemHeight = mRound(getWord(PunchGui.gemExtent, 1) * PunchGui.yScale); 

   Canvas.setWidescreen(MinigameRefCenter, 2000, true);   
}

function PunchGui::init(%this)
{   
   %this.initSpecificGui();
}

function PunchSkipButton::onMouseEnter(%this){
   %this.setBitmap("scriptsAndAssets/data/ui/minigame/quit_rollover.png");
}

function PunchSkipButton::onMouseLeave(%this){
   %this.setBitmap("scriptsAndAssets/data/ui/minigame/quit.png");
}

function PunchSkipButton::onMouseDown(%this){
   %this.setBitmap("scriptsAndAssets/data/ui/minigame/quit_pressed.png");
}
