<commit_before>using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MenuUI : MonoBehaviour
{

	public GameObject MainMenu;
	public GameObject Settings;
	public GameObject Info;
	public GameObject ChaptersParent;
	public GameObject Chapters;
	public GameObject Levels;
	public GameObject InterstitialsParent;
	public GameObject[] Interstitials;
	public GameObject[] InterstitialScreens;
 
	public AudioClip MenuMusic;
	public AudioSource GameSound;
	public AudioSource GameMusic;

	public Levels LevelToLoad;

	private Toggle _soundToggle;
	private Toggle _musicToggle;

	private Slider _volumeSlider;

	private GameObject _settingsTitle;
	private GameObject _settingsBoard;
	private GameObject _settingsBack;
	private GameObject[] _settingsLanguages;

	private GameObject _infoBoard;
	private GameObject _infoVersion;
	private GameObject _infoBack;

	private GameObject _chaptersTitle;
	private GameObject _chapterSelect;
	private GameObject _chaptersBack;
	private GameObject[] _chapterButtons;

	private GameObject _levelsTitle;
	private Image[] _levelsChapterTitles;
	private Button[] _levelButtons;

	private GameObject _interstitialsBack;
	
	private GameObject objToFadeOut;
	private GameObject objToFadeIn;
	
	private bool _levelsOpen;
	private bool _interstitialsOpen;
	private int _selectedChapter;
	private int _selectedLevel;

	private bool _animating;
	private bool _buttonsDisabled;

	// Use this for initialization
	void Start ()
	{
		// Start menu music
		GameObject.Find("AudioController").GetComponent<AudioControl>().Fade(MenuMusic);
		
		// Find settings objects, toggles and sliders
		_settingsBoard = Settings.transform.Find("Board").gameObject;
		_settingsTitle = Settings.transform.Find("Title").gameObject;
		_settingsBack = Settings.transform.Find("Buttons/Back").gameObject;
		_settingsLanguages = new[]
		{
			_settingsBoard.transform.Find("Language/Selector/Mask/English").gameObject,
			_settingsBoard.transform.Find("Language/Selector/Mask/Tamil").gameObject
		};
		
		_soundToggle = _settingsBoard.transform.Find("Sound/Toggle").GetComponent<Toggle>();
		_musicToggle = _settingsBoard.transform.Find("Music/Toggle").GetComponent<Toggle>();
		_volumeSlider = _settingsBoard.transform.Find("Volume/Slider").GetComponent<Slider>();

		_infoBoard = Info.transform.Find("Board").gameObject;
		_infoVersion = _infoBoard.transform.Find("Version").gameObject;
		_infoVersion.GetComponent<Text>().text = "v"+Application.version;
		_infoBack = Info.transform.Find("Buttons/Back").gameObject;
		
		// Find chapters objects
		_chaptersTitle = Chapters.transform.Find("Text").gameObject;
		_chapterSelect = Chapters.transform.Find("Select").gameObject;
		_chaptersBack = ChaptersParent.transform.Find("Buttons/Back").gameObject;
		
		// Find levels objects
		_levelsTitle = Levels.transform.Find("Header").gameObject;
		_levelsChapterTitles = _levelsTitle.GetComponentsInChildren<Image>(true);
		_levelButtons = Levels.transform.Find("Select").GetComponentsInChildren<Button>();
		_interstitialsBack = InterstitialsParent.transform.Find("BackButton").gameObject;
		
		// Set toggles and sliders to player pref settings
		_soundToggle.isOn = PlayerPrefs.GetInt("sound") == 1;
		_musicToggle.isOn = PlayerPrefs.GetInt("music") == 1;
		_volumeSlider.value = PlayerPrefs.GetFloat("volume");

		_buttonsDisabled = false;
		
	}

	public void Update()
	{
		if (_animating && !_buttonsDisabled)
		{
			foreach (Button button in _levelButtons)
			{
				button.interactable = false;
			}

			_chaptersBack.GetComponent<Button>().interactable = false;
			_infoBack.GetComponent<Button>().interactable = false;
			_settingsBack.GetComponent<Button>().interactable = false;
			_interstitialsBack.GetComponent<Button>().interactable = false;

			_buttonsDisabled = true;
		}
		else if (!_animating && _buttonsDisabled)
		{
			foreach (Button button in _levelButtons)
			{
				button.interactable = true;
			}

			_chaptersBack.GetComponent<Button>().interactable = true;
			_infoBack.GetComponent<Button>().interactable = true;
			_settingsBack.GetComponent<Button>().interactable = true;
			_interstitialsBack.GetComponent<Button>().interactable = true;

			_buttonsDisabled = false;
		}
	}

	public void CloseMainMenu(string uiToLoad)
	{

		var moveLeft = uiToLoad == "Settings";
		iTween.MoveTo(MainMenu, iTween.Hash("position", new Vector3(moveLeft ? 540 : -540, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "Open" + uiToLoad, "oncompletetarget", gameObject));

	}

	void OpenSettings()
	{
		
		Settings.SetActive(true);
		iTween.MoveTo(Settings, iTween.Hash("position", new Vector3(0, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeOutBack));

		iTween.ScaleFrom(_settingsTitle, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .1f));
		iTween.ScaleFrom(_settingsBoard, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .2f));
		iTween.ScaleFrom(_settingsBack, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .3f));<commit_msg>Support for changing default language.<commit_after>using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MenuUI : MonoBehaviour
{

	public GameObject MainMenu;
	public GameObject Settings;
	public GameObject Info;
	public GameObject ChaptersParent;
	public GameObject Chapters;
	public GameObject Levels;
	public GameObject InterstitialsParent;
	public GameObject[] Interstitials;
	public GameObject[] InterstitialScreens;
 
	public AudioClip MenuMusic;
	public AudioSource GameSound;
	public AudioSource GameMusic;

	public Levels LevelToLoad;

	private Toggle _soundToggle;
	private Toggle _musicToggle;

	private Slider _volumeSlider;

	private GameObject _settingsTitle;
	private GameObject _settingsBoard;
	private GameObject _settingsBack;
	private GameObject[] _settingsLanguages;

	private GameObject _infoBoard;
	private GameObject _infoVersion;
	private GameObject _infoBack;

	private GameObject _chaptersTitle;
	private GameObject _chapterSelect;
	private GameObject _chaptersBack;
	private GameObject[] _chapterButtons;

	private GameObject _levelsTitle;
	private Image[] _levelsChapterTitles;
	private Button[] _levelButtons;

	private GameObject _interstitialsBack;
	
	private GameObject objToFadeOut;
	private GameObject objToFadeIn;
	
	private bool _levelsOpen;
	private bool _interstitialsOpen;
	private int _selectedChapter;
	private int _selectedLevel;

	private bool _animating;
	private bool _buttonsDisabled;

	// Use this for initialization
	void Start ()
	{
		// Start menu music
		GameObject.Find("AudioController").GetComponent<AudioControl>().Fade(MenuMusic);
		
		// Find settings objects, toggles and sliders
		_settingsBoard = Settings.transform.Find("Board").gameObject;
		_settingsTitle = Settings.transform.Find("Title").gameObject;
		_settingsBack = Settings.transform.Find("Buttons/Back").gameObject;
		_settingsLanguages = new[]
		{
			_settingsBoard.transform.Find("Language/Selector/Mask/English").gameObject,
			_settingsBoard.transform.Find("Language/Selector/Mask/Tamil").gameObject
		};

		if(GameConfig.CurrentLanguage == 1)
		{
			iTween.MoveTo(_settingsLanguages[0], iTween.Hash("position", new Vector3(0, 35, 0), "time", .001f, "islocal", true));
			iTween.MoveTo(_settingsLanguages[1], iTween.Hash("position", new Vector3(0, 0, 0), "time", .001f, "islocal", true));
		}

		_soundToggle = _settingsBoard.transform.Find("Sound/Toggle").GetComponent<Toggle>();
		_musicToggle = _settingsBoard.transform.Find("Music/Toggle").GetComponent<Toggle>();
		_volumeSlider = _settingsBoard.transform.Find("Volume/Slider").GetComponent<Slider>();

		_infoBoard = Info.transform.Find("Board").gameObject;
		_infoVersion = _infoBoard.transform.Find("Version").gameObject;
		_infoVersion.GetComponent<Text>().text = "v"+Application.version;
		_infoBack = Info.transform.Find("Buttons/Back").gameObject;
		
		// Find chapters objects
		_chaptersTitle = Chapters.transform.Find("Text").gameObject;
		_chapterSelect = Chapters.transform.Find("Select").gameObject;
		_chaptersBack = ChaptersParent.transform.Find("Buttons/Back").gameObject;
		
		// Find levels objects
		_levelsTitle = Levels.transform.Find("Header").gameObject;
		_levelsChapterTitles = _levelsTitle.GetComponentsInChildren<Image>(true);
		_levelButtons = Levels.transform.Find("Select").GetComponentsInChildren<Button>();
		_interstitialsBack = InterstitialsParent.transform.Find("BackButton").gameObject;
		
		// Set toggles and sliders to player pref settings
		_soundToggle.isOn = PlayerPrefs.GetInt("sound") == 1;
		_musicToggle.isOn = PlayerPrefs.GetInt("music") == 1;
		_volumeSlider.value = PlayerPrefs.GetFloat("volume");

		_buttonsDisabled = false;
		
	}

	public void Update()
	{
		if (_animating && !_buttonsDisabled)
		{
			foreach (Button button in _levelButtons)
			{
				button.interactable = false;
			}

			_chaptersBack.GetComponent<Button>().interactable = false;
			_infoBack.GetComponent<Button>().interactable = false;
			_settingsBack.GetComponent<Button>().interactable = false;
			_interstitialsBack.GetComponent<Button>().interactable = false;

			_buttonsDisabled = true;
		}
		else if (!_animating && _buttonsDisabled)
		{
			foreach (Button button in _levelButtons)
				button.interactable = true;

			_chaptersBack.GetComponent<Button>().interactable = true;
			_infoBack.GetComponent<Button>().interactable = true;
			_settingsBack.GetComponent<Button>().interactable = true;
			_interstitialsBack.GetComponent<Button>().interactable = true;

			_buttonsDisabled = false;
		}
	}

	public void CloseMainMenu(string uiToLoad)
	{

		var moveLeft = uiToLoad == "Settings";
		iTween.MoveTo(MainMenu, iTween.Hash("position", new Vector3(moveLeft ? 540 : -540, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "Open" + uiToLoad, "oncompletetarget", gameObject));

	}

	void OpenSettings()
	{
		
		Settings.SetActive(true);
		iTween.MoveTo(Settings, iTween.Hash("position", new Vector3(0, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeOutBack));

		iTween.ScaleFrom(_settingsTitle, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .1f));
		iTween.ScaleFrom(_settingsBoard, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .2f));
		iTween.ScaleFrom(_settingsBack, iTween.Hash("scale", Vector3.zero, "time", 1, "easetype", iTween.EaseType.easeOutElastic, "delay", .3f));
{'fraction_non_alphanumeric': 0.11678561497821856, 'fraction_numerical': 0.006488089721012142, 'mean_word_length': 5.731129132875858, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6504725', 'n_tokens_mistral': 3659, 'n_tokens_neox': 3286, 'n_words': 673}