Exemplo n.º 1
0
 public static VLanguage AddLang()
 {
     languages.Add(new VIDE_Localization.VLanguage(defaultLanguage.playerDiags));
     currentLanguage = languages[languages.Count - 1];
     SaveSettings();
     return(currentLanguage);
 }
Exemplo n.º 2
0
 static VLanguage SetDefault()
 {
     languages = new List <VLanguage>();
     languages.Add(new VLanguage());
     languages[0].enabled  = true;
     languages[0].selected = true;
     languages[0].name     = "English";
     currentLanguage       = languages[0];
     defaultLanguage       = languages[0];
     isEnabled             = true;
     SaveSettings();
     return(defaultLanguage);
 }
Exemplo n.º 3
0
    public static VLanguage LoadSettings()
    {
        Dictionary <string, object> dict;

        if (!Application.isPlaying)
        {
            if (!File.Exists(Application.dataPath + "/../" + VIDE_EditorDB.videRoot + "/Resources/LocalizationSettings.json"))
            {
                if (File.Exists(Application.dataPath + "/../" + VIDE_EditorDB.videRoot + "/Resources/demo_loc.json"))
                {
                    dict = SerializeHelper.ReadFromFile("demo_loc" + ".json") as Dictionary <string, object>;
                }
                else
                {
                    return(SetDefault());
                }
            }
            else
            {
                dict = SerializeHelper.ReadFromFile("LocalizationSettings" + ".json") as Dictionary <string, object>;
            }
        }
        else
        {
            string jsonString = "";

            if (GameObject.Find("CanvasLocDemo") != null)
            {
                if (Resources.Load <TextAsset>("demo_loc") != null)
                {
                    jsonString = Resources.Load <TextAsset>("demo_loc").text;
                }
                else
                {
                    Debug.LogError("No demo_loc.json found in Resources!");
                }
            }

            if (jsonString == "")
            {
                if (Resources.Load <TextAsset>("LocalizationSettings") != null)
                {
                    jsonString = Resources.Load <TextAsset>("LocalizationSettings").text;
                }
                else
                {
                    return(null);
                }
            }
            dict = MiniJSON_VIDE.DiagJson.Deserialize(jsonString) as Dictionary <string, object>;
        }

        enabledInGame = (bool)dict["enabledInGame"];
        languages     = new List <VLanguage>();
        int langs = (int)((long)dict["langs"]);

        for (int i = 0; i < langs; i++)
        {
            languages.Add(new VLanguage());
            languages[i].enabled = (bool)dict["langEnabled_" + i.ToString()];
            languages[i].name    = (string)dict["lang_Name" + i.ToString()];
        }
        if ((int)((long)dict["current"]) != -1)
        {
            currentLanguage = languages[(int)((long)dict["current"])];
        }
        if ((int)((long)dict["default"]) != -1)
        {
            defaultLanguage = languages[(int)((long)dict["default"])];
        }

        if (defaultLanguage != null)
        {
            defaultLanguage.selected = true;
        }

        return(defaultLanguage);
    }