コード例 #1
0
    public ProjectPathEditorTool()
    {
        CSEditorPath.InitPath();
        PathDic = new Dictionary <string, List <CSEditorPath> >()
        {
            { "工程内路径", new List <CSEditorPath>()
              {
                  new CSEditorPath(EEditorPath.LocalTableProtoClassPath, "表格proto代码生成路径"),
                  new CSEditorPath(EEditorPath.LocalServerProtoClassPath, "服务器proto代码生成路径"),
                  new CSEditorPath(EEditorPath.LocalServerProtoFunctionPath, "服务器XML方法生成路径"),
                  new CSEditorPath(EEditorPath.LuaPath, "LUA脚本存放路径"),
              } },
            { "本地资源路径", new List <CSEditorPath>()
              {
                  new CSEditorPath(EEditorPath.ClientLoadRootPath, "本地资源根目录"),
                  new CSEditorPath(EEditorPath.LocalResourcesLoadPath, "本地资源读取路径"),

                  new CSEditorPath(EEditorPath.LocalTablePath, "XLS表格存放"),
                  new CSEditorPath(EEditorPath.LocalTableBytesPath, "表格bytes路径"),

                  new CSEditorPath(EEditorPath.LocalTableProtoPath, "表格proto路径"),

                  new CSEditorPath(EEditorPath.LocalServerProtoPath, "本地服务器Proto文件路径"),
                  new CSEditorPath(EEditorPath.LocalServerProtoXMLPath, "本地服务器ProtoXML文件路径"),
              } },
            { "服务器资源路径", new List <CSEditorPath>()
              {
                  new CSEditorPath(EEditorPath.RealServerProtoPath, "外部服务器Proto文件路径"),
                  new CSEditorPath(EEditorPath.RealServerProtoXMLPath, "外部服务器ProtoXML文件路径"),
              } }
        };
    }
コード例 #2
0
        public static Dictionary <uint, T> GetCfgData <T, TArray>(string cfgName)
        {
            string cfgMapPath        = CSEditorPath.Get(EEditorPath.LocalResourcesLoadPath) + "Table/" + cfgName + ".bytes";
            Dictionary <uint, T> dic = new Dictionary <uint, T>();
            TArray list = default(TArray);

            byte[] cfgData = File.ReadAllBytes(cfgMapPath);
            using (MemoryStream stream = new MemoryStream(cfgData))
            {
                list = ProtoBuf.Serializer.Deserialize <TArray>(stream);
            }
            if (list == null)
            {
                return(dic);
            }
            Type arrayType = list.GetType();

            //foreach (var cur in list.rows)
            //{
            //    if (!dic.ContainsKey(cur.id))
            //    {
            //        dic.Add(cur.id, cur);
            //    }
            //}
            return(dic);
        }
コード例 #3
0
    public ProtobufParseTool()
    {
        ParseFolderList.Clear();

        ParseFolderList.Add(new CSProtobufParseFolder(CSEditorPath.Get(EEditorPath.LocalTableProtoPath),
                                                      CSEditorPath.Get(EEditorPath.LocalTableProtoClassPath), EProtobufParseFolderType.Table));

        ParseFolderList.Add(new CSProtobufParseFolder(CSEditorPath.Get(EEditorPath.LocalServerProtoPath),
                                                      CSEditorPath.Get(EEditorPath.LocalServerProtoClassPath), EProtobufParseFolderType.Server));
    }
コード例 #4
0
    public static void SavePath(EEditorPath type, string path)
    {
        if (pathDic.ContainsKey(type))
        {
            pathDic[type] = path;
        }
        else
        {
            pathDic.Add(type, path);
        }

        PlayerPrefs.SetString(CSEditorPath.GetKeyPath(type), path);
    }
コード例 #5
0
    public void ParseXMLToRsp(string fileUrl, string outPath, bool isOpenFile, bool isSingleFile = false)
    {
        CSProtoFileData.ParseProtoFile(CSEditorPath.Get(EEditorPath.LocalServerProtoPath) + "activity.proto");

        return;

        outXMLDefineContent = string.Empty;

        FileUtilityEditor.DetectCreateDirectory(outPath);

        FileInfo file = new FileInfo(fileUrl);

        XmlNode doc         = XmlEditorUtil.LoadXml(fileUrl);
        XmlNode messageNode = XmlEditorUtil.ReadXml(doc, "messages");

        if (messageNode == null)
        {
            messageNode = XmlEditorUtil.ReadXml(doc, "message");
        }
        if (messageNode == null)
        {
            UnityEngine.Debug.LogError("无法解析xml,没有messages 节点 = " + fileUrl);
            return;
        }

        XmlElement mElement = messageNode as XmlElement;

        int groupID = System.Convert.ToInt32(mElement.GetAttribute("id").ToString());

        //该XML文件生成的枚举文本
        string msgDefine = string.Empty;

        XmlNodeList nList = messageNode.ChildNodes;

        foreach (var node in nList)
        {
            XmlElement e = node as XmlElement;
            if (e == null)
            {
                UnityEngine.Debug.Log("XmlElement is null = " + fileUrl + " " + node.ToString());
                continue;
            }
            if (!e.HasAttribute("id"))
            {
                continue;
            }

            int    id       = System.Convert.ToInt32(e.GetAttribute("id").ToString());
            int    msgId    = groupID * 1000 + id;
            string enumName = e.GetAttribute("class").ToString();
            string desc     = e.GetAttribute("desc").ToString();
            bool   toClient = e.GetAttribute("type").ToString() == "toClient";

            //增加一行枚举定义
            AddInfo_MsgDefine(enumName, msgId, desc, ref msgDefine);

            XmlElement protoNode = XmlEditorUtil.ReadXml(e, "proto") as XmlElement;
            //if (protoNode != null)//没有任何内容需要解析,这个消息只是一个空的消息
            //{
            //    if (!toClient)//如果不是从服务器返回的消息(即客户端发送的服务器的消息)
            //    {
            //        AddInfo_ReqString(enumName,)
            //    }
            //}
            //else
            //{

            //    string protoClass = protoNode.GetAttribute("name").ToString();

            //    string patten = "com.sh.game.proto.(\\S+)\\.";
            //    MatchCollection mc = Regex.Matches(protoClass, patten);
            //    if (mc.Count > 0)
            //    {
            //        protoClass = protoClass.Substring(protoClass.LastIndexOf(".") + 1);
            //        string java_outer_classname = mc[0].Groups[1].ToString();
            //        Dictionary<string, CSProtoMessageData> protoDic = GetProtoDic(java_outer_classname);
            //        if (protoDic != null)
            //        {
            //            if (protoDic.ContainsKey(protoClass))
            //            {
            //                CSProtoMessageData data = protoDic[protoClass];
            //                AddInfo(toClient, enumName, desc, msgId, data, ref rspString, ref rspFuncString, ref reqString, ref msgDefine, ref netMsgString);
            //            }
            //            else
            //            {
            //                //UnityEngine.Debug.LogError(protoClass + " is not in protoDic");
            //                AddInfo(toClient, enumName, desc, msgId, null, ref rspString, ref rspFuncString, ref reqString, ref msgDefine, ref netMsgString);
            //            }
            //        }
            //    }
            //}
        }

        ParseToESocketEventEnum(OutFolder, file.Name, groupID, msgDefine, ref outXMLDefineContent);

        AssetDatabase.Refresh();
    }