Exemplo n.º 1
0
    private bool ReadTableData(TableItemVO item)
    {
        if (item == null)
        {
            UnityEngine.Debug.LogError("ERROR! TableToolManager:ReadTableData--->TableItemVO is null");
            return(false);
        }
        string path    = item.AbsolutePath;
        string content = FileHelper.GetTxtFileContent(path);

        if (content == null)
        {
            if (EditorUtility.DisplayDialog("Error!!!", "Load TableData Error!name = " + item.Name, "OK"))
            {
                return(false);
            }
        }
        DeleteNoMeanLines(content);
        UnityEngine.Debug.Log("TableToolManager:ReadTableData---> Load table " + item.Name + " Finish!");
        return(true);
    }
Exemplo n.º 2
0
    private void perpare2TableData()
    {
        if (tableConfigLineData == null || tableConfigLineData.Count <= 0)
        {
            UnityEngine.Debug.LogError("Error! TableToolManager:perpare2TableData--->TableConfig Read Faile!");
            return;
        }
        if (Directory.Exists(Ready2ChangeTablesPath))
        {
            Directory.Delete(Ready2ChangeTablesPath, true);
        }
        Directory.CreateDirectory(Ready2ChangeTablesPath);

        //TableItemVO tabConfig = new TableItemVO(0, "TableConfig", "","/TableConfig", "None", false, true, false, true);
        //TableList.Add(0, tabConfig);
        for (int i = 0; i < tableConfigLineData.Count; i++)
        {
            string   line     = tableConfigLineData[i];
            string[] linedata = line.Split(new string[1] {
                "\t"
            }, System.StringSplitOptions.None);
            TableItemVO item = new TableItemVO(int.Parse(linedata[0]), linedata[2], linedata[3],
                                               linedata[4], bool.Parse(linedata[5]), bool.Parse(linedata[6]),
                                               bool.Parse(linedata[7]), bool.Parse(linedata[8]));
            if (!item.IsCSharpTable)
            {
                continue;
            }
            var path      = TablePath + item.RelativePath + ".txt";
            var finalPath = Ready2ChangeTablesPath + item.RelativePath + ".txt";
            var outpath   = Path.GetDirectoryName(finalPath);
            Directory.CreateDirectory(outpath);
            File.Copy(path, finalPath, true);
            item.AbsolutePath = finalPath;
            CSTableList.Add(int.Parse(linedata[0]), item);
            Print("prepare " + i + "/" + tabelTotalCount + "  name = " + item.Name);
        }
    }
Exemplo n.º 3
0
    private void GenerateFbs(TableItemVO item)
    {
        if (columnNames == null || columnNames.Count <= 0 || typeNames == null || typeNames.Count <= 0)
        {
            UnityEngine.Debug.LogError("ERROR! TableToolManager:GenerateFbs--->typeName or columnNames is null!");
            return;
        }
        StringBuilder data = new StringBuilder();

        for (int i = 0; i < columnNames.Count; i++)
        {
            string line = string.Format("{0}:{1};", columnNames[i], typeNames[i]);
            data.AppendLine(line);
        }

        //var fbs = string.Format(fbsModle, namespaceStr, tablename, data.ToString());
        string fbs = fbsModle.Replace("{0}", item.NameSpace).Replace("{1}", item.Name).Replace("{2}", data.ToString());
        //Debug.Log("<color=#54b123>"+fbs+"</color>");

        string fullPath = FbsPath + item.RelativePath + ".fbs";

        FileHelper.CreateFile(fullPath, fbs);
    }
Exemplo n.º 4
0
    private void GenerateJson(TableItemVO item)
    {
        if (columnNames == null || columnNames.Count <= 0 || typeNames == null || typeNames.Count <= 0 || dataValues == null || dataValues.Count <= 0)
        {
            UnityEngine.Debug.LogError("ERROR! TableToolManager:GenerateJson--->typeName or columnNames or dataValues is null!");
            return;
        }
        StringBuilder data = new StringBuilder();

        for (int i = 0; i < dataValues.Count; i++)
        {
            string line = dataValues[i];
            data.Append("{");
            string[] linedata = line.Split('\t');
            if (linedata.Length == columnNames.Count)
            {
                for (int j = 0; j < linedata.Length; j++)
                {
                    string value = GetJsonTypeValue(typeNames[j], linedata[j]);
                    data.AppendFormat("\"{0}\":{1},", columnNames[j], value);
                }
                data.AppendLine("},");
            }
            else
            {
                UnityEngine.Debug.LogError("ERROR! TableToolManager:GenerateJson--->linedata.Length = " + linedata.Length + ",columnNames.Count = " + columnNames.Count);
            }
        }

        //string json = string.Format(jsonModle, data.ToString());
        string json = jsonModle.Replace("{0}", data.ToString());
        //Debug.Log("<color=#54b123>" + json + "</color>");
        string fullPath = JsonPath + item.RelativePath + ".json";

        FileHelper.CreateFile(fullPath, json);
    }