function MinigameQuitDlg::onWake(%this)
{
   pauseSchedulesLCA("Minigame");
   
   %this.showQuitButton = false;
   %this.minigameObj = "";
       
   // Unlock the vault
   if($CurTake $= 2 && playMinigameDlg.currentLevel $= "SpyLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = SliderMinigame;
   }
   
   // Tune the piano
   if($CurTake $= 1 && playMinigameDlg.currentLevel $= "MusicalLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = SimonMinigame;
   }
   
   // Tone deaf talent   
   if($CurTake $= 4 && playMinigameDlg.currentLevel $= "MusicalLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = SimonMinigame;
   }
   
   // Unbaggin the Wagon
   if($CurTake $= 4 && playMinigameDlg.currentLevel $= "WesternLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = SliderMinigame;      
   }
   
   // Howdown Showdown
   if($CurTake $= 2 && playMinigameDlg.currentLevel $= "WesternLevel")   
   {
      %this.showQuitButton = true;
      %this.minigameObj = SimonMinigame;            
   }   

   // From swatter with love
   if($CurTake $= 1 && PlayMinigameDlg.currentLevel $= "SpyLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = InsectMinigame;
   }
      
   // From swatter with love
   if($CurTake $= 4 && PlayMinigameDlg.currentLevel $= "SpyLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = InsectMinigame;
   }
   
   // You have the right to remain clothed
   if($CurTake $= 2 && PlayMinigameDlg.currentLevel $= "GangsterLevel")                        
   {
      %this.showQuitButton = true;
      %this.minigameObj = BejeweledMinigame;
   }

   if($CurTake $= 3 && PlayMinigameDlg.currentLevel $= "GangsterLevel")
      %this.minigameObj = MazeMinigame;
      
   if($CurTake $= 1 && PlayMinigameDlg.currentLevel $= "KungFuLevel")      
      %this.minigameObj = PicResortMinigame;
            
   if($CurTake $= 3 && PlayMinigameDlg.currentLevel $= "KungFuLevel")
      %this.minigameObj = MazeMinigame;
      
   if($CurTake $= 4 && PlayMinigameDlg.currentLevel $= "KungFuLevel")
      %this.minigameObj = MazeMinigame;      

   if($CurTake $= 2 && PlayMinigameDlg.currentLevel $= "DinosaurLevel")
      %this.minigameObj = PipeMinigame;
   
   // Getting the gang back together
   if($CurTake $= 4 && PlayMinigameDlg.currentLevel $= "SciFiLevel")
   {
      //%this.showQuitButton = true;
      %this.minigameObj = PicResortMinigame;
   }

   // Close encounters of the costumed kind
   if(($CurTake $= 1 || $CurTake $= 3) && PlayMinigameDlg.currentLevel $= "SciFiLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = BejeweledMinigame;
   }
   
   // Close encounters of the costumed kind
   if($CurTake $= 3 && PlayMinigameDlg.currentLevel $= "SciFiLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = BejeweledMinigame;
   }
       
   if($CurTake $= 3 && PlayMinigameDlg.currentLevel $= "DinosaurLevel")
       %this.minigameObj = MazeMinigame;

   if($CurTake $= 4 && PlayMinigameDlg.currentLevel $= "DinosaurLevel")
       %this.minigameObj = MazeMinigame;
       
   if($CurTake $= 4 && PlayMinigameDlg.currentLevel $= "MonsterLevel")
       %this.minigameObj = MazeMinigame;
    
   // Punch the paparazzi
   if($CurTake $= 1 && PlayMinigameDlg.currentLevel $= "MonsterLevel")
   {
      %this.showQuitButton = true;   
      %this.minigameObj = PunchMinigame;
   }
       
   // Punch the paparazzi
   if($CurTake $= 3 && PlayMinigameDlg.currentLevel $= "MonsterLevel")
   {
      %this.showQuitButton = true;
      %this.minigameObj = PunchMinigame;
   }
      
   if(%this.showQuitButton)
   {
      MQBG.setBitmap("scriptsAndAssets/data/ui/minigame/wineffect/minigame_hints.jpg");
      if(PlayMinigameDlg.isPlayingMinigame)
         MQBG.setBitmap("scriptsAndAssets/data/ui/menu/minigames/minigame_stars.jpg");
   }
   else
   {
      MQBG.setBitmap("scriptsAndAssets/data/ui/minigame/wineffect/minigame_nohints.jpg");
      if(PlayMinigameDlg.isPlayingMinigame)
         MQBG.setBitmap("scriptsAndAssets/data/ui/menu/minigames/minigame_nostars.jpg");
   }
      
}

function MinigameQuitDlg::onYes(%this)
{
   Canvas.popDialog(MinigameQuitDlg);   
   MainMenuGui.playButtonPressSound();
   
   resumeSchedulesLCA("Minigame");   

   if(%this.showQuitButton)
      %this.minigameObj.gameFinished = true;
   
   %this.minigameObj.quit();   
}

function MinigameQuitDlg::onNo(%this)
{      
   MainMenuGui.playButtonPressSound();
     
   // Hide cursor only for minigames that don't show the cursor
   if(%this.minigameObj $= PunchMinigame ||
      %this.minigameObj $= InsectMinigame ||
      %this.minigameObj $= SliderMinigame)
      Canvas.hideCursor();      
   
   resumeSchedulesLCA("Minigame");   
   
   Canvas.popDialog(MinigameQuitDlg);    
}
