76 lines
2 KiB
C#
76 lines
2 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using TMPro;
|
|||
|
|
using UnityEngine.SceneManagement;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
public class ModSelectLanguageSettings : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[Header("━━━ DROPDOWNLAR ━━━━━━━━━━━━━━━━━━━━━━")]
|
|||
|
|
public TMP_Dropdown questionDropdown;
|
|||
|
|
public TMP_Dropdown answerDropdown;
|
|||
|
|
|
|||
|
|
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
|||
|
|
public Button closeButton;
|
|||
|
|
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
PopulateDropdowns();
|
|||
|
|
|
|||
|
|
questionDropdown.value = PlayerPrefs.GetInt("QuestionLangID", 1);
|
|||
|
|
answerDropdown.value = PlayerPrefs.GetInt("AnswerLangID", 0);
|
|||
|
|
|
|||
|
|
questionDropdown.RefreshShownValue();
|
|||
|
|
answerDropdown.RefreshShownValue();
|
|||
|
|
|
|||
|
|
closeButton.onClick.AddListener(SaveAndClose);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void PopulateDropdowns()
|
|||
|
|
{
|
|||
|
|
List<string> languageNames = new List<string>
|
|||
|
|
{
|
|||
|
|
"Türkçe", // 0
|
|||
|
|
"English", // 1
|
|||
|
|
"Español", // 2
|
|||
|
|
"Deutsch", // 3
|
|||
|
|
"Français", // 4
|
|||
|
|
"Português" // 5
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
questionDropdown.ClearOptions();
|
|||
|
|
answerDropdown.ClearOptions();
|
|||
|
|
|
|||
|
|
questionDropdown.AddOptions(languageNames);
|
|||
|
|
answerDropdown.AddOptions(languageNames);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void SaveAndClose()
|
|||
|
|
{
|
|||
|
|
int qID = questionDropdown.value;
|
|||
|
|
int aID = answerDropdown.value;
|
|||
|
|
|
|||
|
|
PlayerPrefs.SetInt("QuestionLangID", qID);
|
|||
|
|
PlayerPrefs.SetInt("AnswerLangID", aID);
|
|||
|
|
PlayerPrefs.SetString("QuestionLangCode", ToCode(qID));
|
|||
|
|
PlayerPrefs.SetString("AnswerLangCode", ToCode(aID));
|
|||
|
|
PlayerPrefs.SetString("AppLanguage", ToCode(qID));
|
|||
|
|
PlayerPrefs.Save();
|
|||
|
|
|
|||
|
|
gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string ToCode(int id)
|
|||
|
|
{
|
|||
|
|
return id switch
|
|||
|
|
{
|
|||
|
|
0 => "tr",
|
|||
|
|
1 => "en",
|
|||
|
|
2 => "es",
|
|||
|
|
3 => "de",
|
|||
|
|
4 => "fr",
|
|||
|
|
5 => "pt",
|
|||
|
|
_ => "en"
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|