Esempio n. 1
0
    static void ReloadDataSafe(ICollection <string> xlsxList, bool force)
    {
        if (xlsxList.Count == 0)
        {
            Debug.Log("Already up-to-date.");
            return;
        }

        var dataSet = new DataSet();

        if (force == false)
        {
            EditorUtility.DisplayProgressBar("Reload Data", "Loading the previous DataSet", 0);
            dataSet = Data.LoadSharedDataSet();
        }

        var csvForDiffPath = Path.Combine("Data", "CsvForDiff");

        Directory.CreateDirectory(csvForDiffPath);

        var xlsxIndex = 0;

        foreach (var xlsx in xlsxList)
        {
            ConDebug.Log($"Loading {xlsx}...");
            EditorUtility.DisplayProgressBar("Reload Data", xlsx, (xlsxIndex + 1.0f) / xlsxList.Count);
            var tableList = new ExcelToObject.TableList(xlsx);
            tableList.MapInto(dataSet);
            xlsxIndex++;

            Xlsx2Csv20.Xlsx2Csv.Convert(xlsx,
                                        Path.Combine(csvForDiffPath, Path.GetFileNameWithoutExtension(xlsx) + ".csv"));
        }

        // 번역되는 텍스트는 diff를 쉽게 볼 수 있도록 텍스트파일로도 쓴다.
        WriteStringDataToTextFile(Path.Combine("Data", "StrKoData.txt"), dataSet.StrKoData, true, 0.2f);
        WriteStringDataToTextFile(Path.Combine("Data", "StrEnData.txt"), dataSet.StrEnData, true, 1.0f);

        ConDebug.Log($"{dataSet.StageSequenceData.Count} entries on StageSequenceData");

        EditorUtility.DisplayProgressBar("Reload Data", "Serializing and writing...", 0.0f);

        SerializeAndWriteDataSet(dataSet);

        EditorUtility.ClearProgressBar();

        if (force == false)
        {
            Debug.Log("Updated Xlsx List");
            foreach (var xlsx in xlsxList)
            {
                Debug.Log($"- {xlsx}");
            }
        }
    }
Esempio n. 2
0
    static void ReloadData()
    {
        var dataSet = new DataSet();

        var xlsxList = new string[] {
            "Data/StrKo.xlsx",
            "Data/StrEn.xlsx",
        };

        foreach (var xlsx in xlsxList)
        {
            var tableList = new ExcelToObject.TableList(xlsx);
            tableList.MapInto(dataSet);
        }

        // Characters.txt 파일 만든다. (TM Pro 폰트 생성에 쓰임)
        StringBuilder sb = new StringBuilder();

        foreach (var kv in dataSet.StrKoData)
        {
            sb.AppendLine(kv.Value.str[0]);
        }
        foreach (var kv in dataSet.StrEnData)
        {
            sb.AppendLine(kv.Value.str[0]);
        }
        for (int i = 1; i < 256; i++)
        {
            sb.Append((char)i);
        }
        sb.Append('…');
        File.WriteAllText("Assets/Fonts/Characters.txt", sb.ToString());

        IFormatter formatter       = new BinaryFormatter();
        var        balloonDataPath = "Assets/Resources/Data/Balloon.bytes";

        using (Stream stream = new FileStream(balloonDataPath, FileMode.Create, FileAccess.Write, FileShare.None)) {
            formatter.Serialize(stream, dataSet);
            stream.Close();
        }

        AssetDatabase.Refresh();
    }