//-----------------------------------------------------------------------------
// Handle events of GUI controls of the main menu.
//-----------------------------------------------------------------------------

function onMainMenuPlayGame()
{
   if(MainMenuGui.firstTime)
   {
      $CurPlayerNum = 1;
      MainMenuGui.pushThread(new_player_menu_thread);
   }
   else
   {
      if($CurPlayerName $= "" && $pref::Player::Name $= "")
         MainMenuGui.pushThread(select_player_menu_thread);
      else
         showWorldMap(false);
   }
}

function SavePlayerProfile()
{
   %myFolder = LCApickler.getUserHomeDir();

   %myPath = %myFolder @ "/My Games/BehindTheScenes/";
   LCApickler.createPath(%myPath);
   
   %myPath = "file://" @ %myPath @ "Profiles.xml";
   
   // Save profile   
   LCApickler.pickle(PlayerProfile, %myPath);   
}
/*
// Parse XML file looking for menu text tags
function parseMainMenuXML(%pXml)
{
   if(!isObject(%pXml))
      return;
      
   // Push the first child element named "main" onto the XML document stack.
   if(!%pXml.pushFirstChildElement("main"))
   {
      echo("Failed to load 'main' tag.");
      return;
   }

   if(%pXml.pushFirstChildElement("playgame"))
   {
      PlayGameButtonText.text = %pXml.attribute("text");
      //PlayGameButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }

   if(%pXml.pushFirstChildElement("playminigame"))
   {
      PlayMinigameButtonText.text = %pXml.attribute("text");
      //PlayMinigameButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }
   
   if(%pXml.pushFirstChildElement("selectplayer"))
   {
      SelectPlayerButtonText.text = %pXml.attribute("text");
      //SelectPlayerButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }   

   if(%pXml.pushFirstChildElement("options"))
   {
      OptionsButtonText.text = %pXml.attribute("text");
      //OptionsButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }

   if(%pXml.pushFirstChildElement("instructions"))
   {
      InstructionsButtonText.text = %pXml.attribute("text");
      //InstructionsButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }

   if(%pXml.pushFirstChildElement("exit"))
   {
      ExitButtonText.text = %pXml.attribute("text");
      //ExitButton.text = %pXml.attribute("text");
      %pXml.popElement();
   }
}
*/

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

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