Example #1
0
        protected override IEnumerator Start()
        {
            yield return(base.Start());

            //wait for LoL to load/initialize
            while (!LoLManager.instance.isReady)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(0.5f));

            //start title
            if (titleText)
            {
                titleText.text = LoLLocalize.Get(titleStringRef);
            }
            if (titleGO)
            {
                titleGO.SetActive(true);
            }

            //show other stuff

            if (loadingGO)
            {
                loadingGO.SetActive(false);
            }
            if (readyGO)
            {
                readyGO.SetActive(true);
            }

            isStarted = true;
        }
Example #2
0
        public static bool ApplyAsset(LoLLocalize localize, ref string error)
        {
            var excelParser = new M8.SpreadsheetParser.ExcelParser(localize.editorExcelPath);

            if (excelParser.sheetCount == 0)
            {
                error = "No sheets are found.";
                return(false);
            }

            var dataLookup = excelParser.DeserializeAllSheets <Item>(null);

            var extraInfoLookup = new Dictionary <string, LoLLocalize.LanguageExtraInfo>();

            var jsonStringBuffer = new System.Text.StringBuilder();

            //populate meta data
            var metaLookup = new Dictionary <string, MetaItem>();

            foreach (var pair in dataLookup)
            {
                List <Item> items = pair.Value;
                foreach (var item in items)
                {
                    if (metaLookup.ContainsKey(item.Key))
                    {
                        metaLookup[item.Key] = new MetaItem(item);
                    }
                    else
                    {
                        metaLookup.Add(item.Key, new MetaItem(item));
                    }
                }
            }

            int counter = 0;

            //fill JSON

            jsonStringBuffer.Append("{\n");

            //fill in meta data to JSON
            jsonStringBuffer.Append("  \"_meta\": {\n");

            //max chars
            jsonStringBuffer.Append("    \"maxChars\": {");

            counter = 0;
            foreach (var pair in metaLookup)
            {
                if (pair.Value.maxChar <= 0) //ignore
                {
                    continue;
                }

                if (counter > 0 && counter < metaLookup.Count - 1)
                {
                    jsonStringBuffer.Append(',');
                }

                jsonStringBuffer.Append('\n');
                jsonStringBuffer.Append("      \"").Append(pair.Key).Append("\": \"").Append(pair.Value.maxChar).Append('"');

                counter++;
            }

            jsonStringBuffer.Append('\n').Append("    }\n");
            //

            jsonStringBuffer.Append("  }");
            //

            //fill in languages
            foreach (var pair in dataLookup)
            {
                jsonStringBuffer.Append(",\n");

                jsonStringBuffer.Append("  \"").Append(pair.Key).Append("\": {");

                //fill in items
                counter = 0;
                List <Item> items = pair.Value;
                foreach (var item in items)
                {
                    //add extra info
                    if (item.IsExtraInfoValid())
                    {
                        if (extraInfoLookup.ContainsKey(item.Key))
                        {
                            extraInfoLookup[item.Key] = item.CreateExtraInfo();
                        }
                        else
                        {
                            extraInfoLookup.Add(item.Key, item.CreateExtraInfo());
                        }
                    }

                    //fill item
                    jsonStringBuffer.Append('\n');
                    jsonStringBuffer.Append("    \"").Append(item.Key).Append("\": \"").Append(item.Value).Append('"');

                    counter++;
                    if (counter < items.Count)
                    {
                        jsonStringBuffer.Append(',');
                    }
                }

                jsonStringBuffer.Append('\n').Append("  }");
            }
            //

            jsonStringBuffer.Append('\n').Append('}');

            //save json
            System.IO.File.WriteAllText(localize.editorLanguagePath, jsonStringBuffer.ToString());

            if (!string.IsNullOrEmpty(localize.editorLanguagePathExtra))
            {
                System.IO.File.WriteAllText(localize.editorLanguagePathExtra, jsonStringBuffer.ToString());
            }

            //save extra info
            var languageExtraInfoList = new List <LoLLocalize.LanguageExtraInfo>();

            foreach (var pair in extraInfoLookup)
            {
                languageExtraInfoList.Add(pair.Value);
            }

            localize.languageExtraInfos = languageExtraInfoList.ToArray();
            //

            localize.ClearEntries(); //this will refresh lookup for keys

            EditorUtility.SetDirty(localize);

            AssetDatabase.SaveAssets();

            return(true);
        }