Ejemplo n.º 1
0
        private static SList <string> toGetDeepFileListForIgnore(bool isDeep, string path, params string[] exIgnore)
        {
            string[] files = Directory.GetFiles(path, "*", isDeep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

            SList <string> re = new SList <string>();

            string s;

            for (int i = files.Length - 1; i >= 0; --i)
            {
                s = files[i];

                if (s.EndsWith(".DS_Store"))
                {
                    continue;
                }

                if (exIgnore.Length > 0)
                {
                    if (Array.IndexOf(exIgnore, getFileExName(s)) != -1)
                    {
                        continue;
                    }
                }

                re.add(fixPath(s));
            }

            return(re);
        }
Ejemplo n.º 2
0
            public void loadOne(Action overFunc)
            {
                ++_refCount;

                //自定义
                if (id < -1)
                {
                    overFunc();
                }
                else
                {
                    if (_loadState == LoadState_Complete)
                    {
                        overFunc();
                    }
                    else
                    {
                        _callFuncs.add(overFunc);

                        if (_loadState == LoadState_Free)
                        {
                            _loadState = LoadState_Loading;

                            LoadControl.loadOne(id, onLoadComplete);
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加格子数据
        /// </summary>
        /// <param name="obj">要增加的格子数据</param>
        public void addData(object obj)
        {
            _dataList.add(obj);

            clearDataCache();

            doSetDataList();
        }
Ejemplo n.º 4
0
        /** intList转slist */
        public static SList <int> intListToSList(IntList arr)
        {
            SList <int> list = new SList <int>(arr.length());

            for (int i = 0; i < arr.length(); i++)
            {
                list.add(arr[i]);
            }
            return(list);
        }
Ejemplo n.º 5
0
        /** []数组转对象数组 */
        public static SList <T> arrToSList <T>(T[] arr)
        {
            SList <T> list = new SList <T>(arr.Length);

            for (int i = 0; i < arr.Length; i++)
            {
                list.add(arr[i]);
            }
            return(list);
        }
Ejemplo n.º 6
0
            public void toAddMethod(FMethod method)
            {
                //有了
                if (methodDic.contains(method.name))
                {
                    return;
                }

                methodList.add(method);
                methodDic.put(method.name, method);
            }
Ejemplo n.º 7
0
        /** SList拷贝SList */
        public static SList <T> sListCopyToSLst <T>(SList <T> sList)
        {
            SList <T> list = new SList <T>(sList.length());

            sList.forEach((v) =>
            {
                list.add(v);
            });

            return(list);
        }
Ejemplo n.º 8
0
        /** longMap转SList */
        public static SList <T> longObjectMapToSList <T>(LongObjectMap <T> map)
        {
            SList <T> sList = new SList <T>(map.length());

            map.forEach((k, v) =>
            {
                sList.add(v);
            });

            return(sList);
        }
Ejemplo n.º 9
0
        /** 获取名为name的子组 */
        public SList <XML> getChildrenByName(string name)
        {
            SList <XML> list = new SList <XML>();

            XML[] values = _children.getValues();
            XML   v;

            for (int i = 0, len = _children.size(); i < len; ++i)
            {
                if ((v = values[i])._name.Equals(name))
                {
                    list.add(v);
                }
            }

            return(list);
        }
Ejemplo n.º 10
0
        private string GetLinkedText(string text)
        {
            sb.Length = 0;
            m_HrefInfos.clear();
            var     indexText   = 0;
            Color32 defautcolor = m_LinkDefautColor;

            defautcolor.a = 0xff;
            string colorprefix   = string.Format("<color=#{0:x2}{1:x2}{2:x2}>", defautcolor.r, defautcolor.g, defautcolor.b);
            string colorappendix = "</color>";

            foreach (Match match in s_HrefRegex.Matches(text))
            {
                sb.Append(text.Substring(indexText, match.Index - indexText));
                bool bUnderLine = true;
                if (match.Groups[1].Value.Equals("noline"))
                {
                    bUnderLine = false;
                }
                string content = match.Groups[2].Value;
                if (content.Length > 0)
                {
                    sb.Append(colorprefix);                     // 超链接颜色
                    var hrefInfo = new HrefInfo
                    {
                        startpos_linkedtext = sb.Length,                  //一次处理后的文本起始索引
                        startIndex          = sb.Length * 4,              // 相应的顶点索引
                        endIndex            = (sb.Length + content.Length - 1) * 4 + 3,
                        bUnderline          = bUnderLine,
                        content             = content,
                        parameter           = match.Groups[3].Value
                    };
                    m_HrefInfos.add(hrefInfo);
                    sb.Append(content);
                    sb.Append(colorappendix);
                }
                indexText = match.Index + match.Length;
            }

            sb.Append(text.Substring(indexText, text.Length - indexText));

            //print(string.Format("found {0} links",m_HrefInfos.Count));
            return(sb.ToString());
        }
Ejemplo n.º 11
0
        /** 递归获取文件列表(多格式) */
        private static SList <string> toGetFileMutipleList(bool isDeep, string path, params string[] exNames)
        {
            SList <string> re = new SList <string>();

            foreach (string exName in exNames)
            {
                string[] files = Directory.GetFiles(path, "*." + exName, isDeep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

                for (int i = files.Length - 1; i >= 0; --i)
                {
                    if (files[i].EndsWith(".DS_Store"))
                    {
                        continue;
                    }

                    re.add(fixPath(files[i]));
                }
            }

            return(re);
        }
Ejemplo n.º 12
0
        private string ParseText()
        {
            string linkedtext = GetLinkedText(OriginalText);

            //先对文本中的超链接进行解析。
            //然后再解析表情标记。
            int lastpos = 0;

            sb.Length = 0;
            foreach (Match match in m_originTagRegex.Matches(linkedtext))
            {
                SpriteTagInfo tempSpriteTag = new SpriteTagInfo();
                string        str           = match.Groups[0].Value;
                sb.Append(linkedtext.Substring(lastpos, match.Index - lastpos));
                tempSpriteTag.start_index = sb.Length;
                lastpos = match.Index + match.Length;
                tempSpriteTag.sprite_name  = str.Substring(2, 3);
                tempSpriteTag.display_size = new Vector2(fontSize, fontSize);
                sti.add(tempSpriteTag);
                string imgstr = string.Format("<quad name={0} size={1} width=1 />", tempSpriteTag.sprite_name, fontSize);
                sb.Append(imgstr);

                //在这里要注意到因为[/ddd]被替换成更长的形式。所以要去更改链接索引。
                //即lastpos以前从[/ddd]到<quad>。
                int deta = (imgstr.Length - 6) * 4;
                foreach (var hrefInfo in m_HrefInfos)
                {
                    if (hrefInfo.startpos_linkedtext < lastpos)
                    {
                        continue;
                    }

                    hrefInfo.startIndex += deta;
                    hrefInfo.endIndex   += deta;
                }
            }

            sb.Append(linkedtext.Substring(lastpos));
            return(sb.ToString());
        }
Ejemplo n.º 13
0
        /** 获取值组 */
        public SList <V> getValueList()
        {
            SList <V> list = new SList <V>(_size);

            if (_size == 0)
            {
                return(list);
            }

            V[] vals = _values;
            V   v;

            for (int i = vals.Length - 1; i >= 0; --i)
            {
                if ((v = vals[i]) != null)
                {
                    list.add(v);
                }
            }

            return(list);
        }
Ejemplo n.º 14
0
        public void initSAdapters(SList <ILClassInfo> list)
        {
            ILClassInfo cls;

            list.add(cls = new ILClassInfo("MonoBehaviour"));
            cls.addMethod("Start", null, VisitType.Private, false);
            cls.addMethod("Update", null, VisitType.Private, false);
            cls.addMethod("FixedUpdate", null, VisitType.Private, false);
            cls.addMethod("OnGUI", null, VisitType.Private, false);
            cls.addMethod("OnDestroy", null, VisitType.Private, false);

            list.add(cls = new ILClassInfo("BaseData"));
            cls.addMethod("toReadBytesFull", VisitType.Protected, "BytesReadStream", "stream");
            cls.addMethod("toWriteBytesFull", VisitType.Protected, "BytesWriteStream", "stream");
            cls.addMethod("toReadBytesSimple", VisitType.Protected, "BytesReadStream", "stream");
            cls.addMethod("toWriteBytesSimple", VisitType.Protected, "BytesWriteStream", "stream");
            cls.addMethod("toCopy", VisitType.Protected, "BaseData", "data");
            cls.addMethod("toShadowCopy", VisitType.Protected, "BaseData", "data");
            cls.addMethod("toDataEquals", "bool", VisitType.Protected, true, "BaseData", "data");
            cls.addMethod("getDataClassName", "string", VisitType.Public, true);
            cls.addMethod("toWriteDataString", VisitType.Protected, "DataWriter", "writer");
            cls.addMethod("initDefault", VisitType.Public);
            cls.addMethod("beforeWrite", VisitType.Protected);
            cls.addMethod("afterRead", VisitType.Protected);

            list.add(cls = new ILClassInfo("BaseRequest"));
            cls.addMethod("copyData", VisitType.Protected);
            cls.addMethod("toWriteBytesSimple", VisitType.Protected, "BytesWriteStream", "stream");
            cls.addMethod("doWriteToStream", VisitType.Protected, "BytesWriteStream", "stream");
            cls.addMethod("doWriteBytesSimple", VisitType.Protected, "BytesWriteStream", "stream");


            list.add(cls = new ILClassInfo("BaseResponse"));
            cls.addMethod("toReadBytesSimple", VisitType.Protected, "BytesReadStream", "stream");
            cls.addMethod("readFromStream", "BaseResponse", VisitType.Public, true, "BytesReadStream", "stream");
            cls.addMethod("preExecute", VisitType.Protected);
            cls.addMethod("execute", null, VisitType.Protected, false);

            list.add(cls = new ILClassInfo("BytesHttpRequest"));
            cls.addMethod("copyData", VisitType.Protected);
            cls.addMethod("toWriteBytesSimple", VisitType.Protected, "BytesWriteStream", "stream");
            cls.addMethod("toRead", null, VisitType.Protected, false);
            cls.addMethod("onComplete", null, VisitType.Protected, false);

            list.add(new ILClassInfo("DataMaker"));

            list.add(cls = new ILClassInfo("DebugControl"));
            cls.addMethod("init", VisitType.Public);
            cls.addMethod("dispose", VisitType.Public);
            cls.addMethod("onPrint", VisitType.Public, "string", "str");

            list.add(cls = new ILClassInfo("UIContainer"));
            cls.addMethod("init", VisitType.Public, "GameObject", "obj");

            list.add(cls = new ILClassInfo("UIElement"));
            cls.addMethod("init", VisitType.Public, "GameObject", "obj");

            list.add(cls = new ILClassInfo("UIModel"));
            cls.addMethod("init", VisitType.Public, "GameObject", "obj");

            list.add(cls = new ILClassInfo("PoolObject"));
            cls.addMethod("clear", null, VisitType.Public, false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 读取字节流(完整版)
        /// </summary>
        protected override void toReadBytesFull(BytesReadStream stream)
        {
            stream.startReadObj();

            this.name = stream.readUTF();

            this.type = stream.readInt();

            this.style = stream.readUTF();

            if (stream.readBoolean())
            {
                int childrenLen = stream.readLen();
                if (this.children != null)
                {
                    this.children.clear();
                    this.children.ensureCapacity(childrenLen);
                }
                else
                {
                    this.children = new SList <UIObjectData>();
                }

                SList <UIObjectData> childrenT = this.children;
                for (int childrenI = childrenLen - 1; childrenI >= 0; --childrenI)
                {
                    UIObjectData childrenV;
                    if (stream.readBoolean())
                    {
                        childrenV = (UIObjectData)stream.createData(UIObjectData.dataID);
                        childrenV.readBytesFull(stream);
                    }
                    else
                    {
                        childrenV = null;
                    }

                    childrenT.add(childrenV);
                }
            }
            else
            {
                this.children = null;
            }

            if (stream.readBoolean())
            {
                int intArgsLen = stream.readLen();
                if (this.intArgs == null || this.intArgs.Length != intArgsLen)
                {
                    this.intArgs = new int[intArgsLen];
                }
                int[] intArgsT = this.intArgs;
                for (int intArgsI = 0; intArgsI < intArgsLen; ++intArgsI)
                {
                    int intArgsV;
                    intArgsV = stream.readInt();

                    intArgsT[intArgsI] = intArgsV;
                }
            }
            else
            {
                this.intArgs = null;
            }

            if (stream.readBoolean())
            {
                int strArgsLen = stream.readLen();
                if (this.strArgs == null || this.strArgs.Length != strArgsLen)
                {
                    this.strArgs = new string[strArgsLen];
                }
                string[] strArgsT = this.strArgs;
                for (int strArgsI = 0; strArgsI < strArgsLen; ++strArgsI)
                {
                    string strArgsV;
                    strArgsV = stream.readUTF();

                    strArgsT[strArgsI] = strArgsV;
                }
            }
            else
            {
                this.strArgs = null;
            }

            stream.endReadObj();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 复制(深拷贝)
        /// </summary>
        protected override void toCopy(BaseData data)
        {
            if (!(data is UIObjectData))
            {
                return;
            }

            UIObjectData mData = (UIObjectData)data;

            this.name = mData.name;

            this.type = mData.type;

            this.style = mData.style;

            if (mData.children != null)
            {
                if (this.children != null)
                {
                    this.children.clear();
                    this.children.ensureCapacity(mData.children.size());
                }
                else
                {
                    this.children = new SList <UIObjectData>();
                }

                SList <UIObjectData> childrenT = this.children;
                if (!mData.children.isEmpty())
                {
                    UIObjectData[] childrenVValues = mData.children.getValues();
                    for (int childrenVI = 0, childrenVLen = mData.children.length(); childrenVI < childrenVLen; ++childrenVI)
                    {
                        UIObjectData childrenV = childrenVValues[childrenVI];
                        UIObjectData childrenU;
                        if (childrenV != null)
                        {
                            childrenU = (UIObjectData)BytesControl.createData(UIObjectData.dataID);
                            childrenU.copy(childrenV);
                        }
                        else
                        {
                            childrenU = null;
                        }

                        childrenT.add(childrenU);
                    }
                }
            }
            else
            {
                this.children = null;
            }

            if (mData.intArgs != null)
            {
                int[] intArgsR   = mData.intArgs;
                int   intArgsLen = intArgsR.Length;
                if (this.intArgs == null || this.intArgs.Length != intArgsLen)
                {
                    this.intArgs = new int[intArgsLen];
                }
                BytesControl.arrayCopy(mData.intArgs, this.intArgs, intArgsLen);
            }
            else
            {
                this.intArgs = null;
            }

            if (mData.strArgs != null)
            {
                string[] strArgsR   = mData.strArgs;
                int      strArgsLen = strArgsR.Length;
                if (this.strArgs == null || this.strArgs.Length != strArgsLen)
                {
                    this.strArgs = new string[strArgsLen];
                }
                string[] strArgsT = this.strArgs;
                for (int strArgsI = 0; strArgsI < strArgsLen; ++strArgsI)
                {
                    string strArgsV = strArgsR[strArgsI];
                    string strArgsU;
                    strArgsU = strArgsV;

                    strArgsT[strArgsI] = strArgsU;
                }
            }
            else
            {
                this.strArgs = null;
            }
        }
Ejemplo n.º 17
0
        //--以下是Editor支持部分--//
        /** 处理一个prefab */
        public static void makeOnePrefab(GameObject obj)
        {
#if UNITY_EDITOR
            ImageLoader[] imageLoaders = obj.GetComponentsInChildren <ImageLoader>(true);
            foreach (ImageLoader imageLoader in imageLoaders)
            {
                imageLoader.source = null;

                Image image = imageLoader.GetComponent <Image>();
                if (image.sprite)
                {
                    string path = Path.GetFileName(AssetDatabase.GetAssetPath(image.sprite));
                    if (path == "unity_builtin_extra")
                    {
                        continue;
                    }

                    imageLoader.source = FileUtils.getBundleResourcePath(AssetDatabase.GetAssetPath(image.sprite));
                    image.sprite       = null;
                }
            }

            RawImageLoader[] rawImageLoaders = obj.GetComponentsInChildren <RawImageLoader>(true);
            foreach (RawImageLoader rawImageLoader in rawImageLoaders)
            {
                rawImageLoader.source = null;

                RawImage image = rawImageLoader.GetComponent <RawImage>();
                if (image.texture)
                {
                    string path = Path.GetFileName(AssetDatabase.GetAssetPath(image.texture));
                    if (path == "unity_builtin_extra")
                    {
                        continue;
                    }

                    rawImageLoader.source = FileUtils.getBundleResourcePath(AssetDatabase.GetAssetPath(image.texture));
                    image.texture         = null;
                }
            }

            SkeletonGraphicLoader[] skeletonGraphicLoaders = obj.GetComponentsInChildren <SkeletonGraphicLoader>(true);
            foreach (SkeletonGraphicLoader skeletonGraphicLoader in skeletonGraphicLoaders)
            {
                SkeletonGraphic skeletonGraphic = skeletonGraphicLoader.GetComponent <SkeletonGraphic>();
                if (skeletonGraphic.skeletonDataAsset)
                {
                    skeletonGraphicLoader.source      = FileUtils.getBundleResourcePath(AssetDatabase.GetAssetPath(skeletonGraphic.skeletonDataAsset));
                    skeletonGraphic.skeletonDataAsset = null;
                    skeletonGraphic.Clear();
                }
                else
                {
                    skeletonGraphicLoader.source = null;
                }
            }

            SScrollView[] sScrollViews = obj.GetComponentsInChildren <SScrollView>(true);
            foreach (SScrollView scrollView in sScrollViews)
            {
                GameObject         tmpObj   = scrollView.gameObject;
                Transform          tmpTrans = tmpObj.transform;
                SList <GameObject> tmpList  = new SList <GameObject>();
                for (int i = 0; i < tmpTrans.childCount; i++)
                {
                    GameObject tmpGo = tmpTrans.GetChild(i).gameObject;
                    if (tmpGo.name != "g0")
                    {
                        tmpList.add(tmpGo);
                    }
                }
                for (var i = 0; i < tmpList.Count; i++)
                {
                    Object.DestroyImmediate(tmpList[i]);
                }
            }

            SPageView[] sPageViews = obj.GetComponentsInChildren <SPageView>(true);
            foreach (SPageView sPageView in sPageViews)
            {
                GameObject         tmpObj   = sPageView.gameObject;
                Transform          tmpTrans = tmpObj.transform;
                SList <GameObject> tmpList  = new SList <GameObject>();
                for (int i = 0; i < tmpTrans.childCount; i++)
                {
                    GameObject tmpGo = tmpTrans.GetChild(i).gameObject;
                    if (tmpGo.name != "g0")
                    {
                        tmpList.add(tmpGo);
                    }
                }
                for (var i = 0; i < tmpList.Count; i++)
                {
                    Object.DestroyImmediate(tmpList[i]);
                }
            }
#endif
        }
Ejemplo n.º 18
0
 public static void addThread(BaseThread thread)
 {
     _threadList.add(thread);
 }
Ejemplo n.º 19
0
        private static void doOneGenerate(string xmlPath, string controlClsPath, string adapterOutPath, int projectType)
        {
            clearGenerate();

            _isShine = projectType == 0;

            //TODO:根据类型取父factory

            XML xml = FileUtils.readFileForXML(xmlPath);

            int aLen = "Assets/".Length;

            //处理屏蔽
            foreach (XML xl in xml.getChildrenByName("ignoreMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsIgnoreMethods.put(xl.getProperty("cls"), dd);
            }

            foreach (XML xl in xml.getChildrenByName("allowMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsAllowMethods.put(xl.getProperty("cls"), dd);
            }

            //先处理包路径
            foreach (XML xl in xml.getChildrenByName("root"))
            {
                SList <string> ignoreList = new SList <string>();

                foreach (XML pXml in xl.getChildrenByName("ignorePath"))
                {
                    ignoreList.add(pXml.getProperty("path"));
                }

                StringIntMap hotfixPathDic = new StringIntMap();

                foreach (XML pXml in xl.getChildrenByName("hotfixPath"))
                {
                    hotfixPathDic.put(pXml.getProperty("path"), pXml.getProperty("needFactory").Equals("true") ? 1 : 0);
                }

                string rootPath = "Assets/" + xl.getProperty("path");

                string[] deepFileList = FileUtils.getDeepFileList(rootPath, "cs");

                foreach (string s in deepFileList)
                {
                    //编辑器类的跳过
                    if (s.Contains("/Editor/"))
                    {
                        continue;
                    }

                    string tailPath = s.Substring(rootPath.Length + 1);

                    bool failed = false;

                    //排除组
                    foreach (string ig in ignoreList)
                    {
                        if (tailPath.StartsWith(ig))
                        {
                            failed = true;
                            break;
                        }
                    }

                    if (failed)
                    {
                        continue;
                    }

                    string fQName = FileUtils.getFileFrontName(s.Substring(aLen));

                    String fName = FileUtils.getFileName(fQName);

                    _clsNameToPathDic.put(fName, fQName);

                    string[] keys   = hotfixPathDic.getKeys();
                    int[]    values = hotfixPathDic.getValues();
                    string   k;
                    int      v;

                    for (int i = keys.Length - 1; i >= 0; --i)
                    {
                        if ((k = keys[i]) != null)
                        {
                            v = values[i];

                            //需要
                            if (tailPath.StartsWith(k))
                            {
                                _adapterClsDic.add(fName);

                                if (v == 1)
                                {
                                    _factoryClsDic.add(fName);
                                }

                                break;
                            }
                        }
                    }
                }
            }

            //再处理命名空间
            foreach (XML xl in xml.getChildrenByName("namespace"))
            {
                _allowNameSpace.add(xl.getProperty("name"));
            }

            //项目程序集
            Assembly assembly = typeof(ShineSetup).Assembly;

            Type[] types = assembly.GetTypes();

            foreach (Type vType in types)
            {
                string fullName = vType.FullName;

                //内部类不统计
                if (!fullName.Contains("+"))
                {
                    //命名空间允许
                    if (string.IsNullOrEmpty(vType.Namespace) || _allowNameSpace.contains(vType.Namespace))
                    {
                        string vName = vType.Name;

                        int index = vName.IndexOf('`');

                        //去掉泛型标记
                        if (index > 0)
                        {
                            vName = vName.Substring(0, index);
                        }

                        TypeInfo typeInfo = new TypeInfo();
                        typeInfo.clsName = vName;
                        typeInfo.clsType = vType;

                        if (_typeDic.contains(vName))
                        {
                            // Ctrl.print("类名重复",vName);
                            continue;
                        }

                        _typeDic.put(vName, typeInfo);
                        //类路径
                        typeInfo.clsPath = _clsNameToPathDic.get(vName);
                    }
                }
            }

            string clsStr = FileUtils.readFileForUTF(controlClsPath);

            string factoryClsPath = getFactoryClsPath(projectType);

            ClsAnalysis.FactoryClassInfo factoryClass = ClsAnalysis.readFactory(factoryClsPath);
            string projectMark = getProjectMark(projectType);

            string factoryClsName = FileUtils.getFileFrontName(FileUtils.getFileName(factoryClsPath));

            //遍历父
            for (int i = projectType - 1; i >= Project_Common; i--)
            {
                ClsAnalysis.FactoryClassInfo parentFactoryCls = ClsAnalysis.readFactory(getFactoryClsPath(i));

                factoryClass.addParent(parentFactoryCls);
            }


            StringBuilder sb = new StringBuilder();

            endClsLine(sb);

            if (!_isShine)
            {
                sb.Append("base.initOtherAdapters(appdomain);");
                endClsLine(sb);
            }


            XML reXMl = new XML();

            reXMl.name = "info";

            //工厂最后执行
            TypeInfo factoryTypeInfo = getTypeInfo(factoryClsName);

            _clsNameToPathDic.remove(factoryClsName);

            foreach (string k in _clsNameToPathDic.getSortedMapKeys())
            {
                TypeInfo typeInfo = getTypeInfo(k);

                if (typeInfo == null)
                {
                    Ctrl.throwError("不该找不到类型", k);
                }

                if (typeInfo.hasHotfixMark || !typeInfo.isEmpty())
                {
                    //需要工厂,并且不是虚类
                    if (!typeInfo.iCls.isAbstract && (typeInfo.needFactory || _factoryClsDic.contains(k)))
                    {
                        ClsAnalysis.FMethod method = factoryClass.addMethod(k, projectMark);

                        //补方法
                        factoryTypeInfo.iCls.addMethod("create" + method.name, method.returnType, VisitType.Public, true);
                    }

                    //需要适配器
                    if (typeInfo.hasHotfixMark || _adapterClsDic.contains(k))
                    {
                        doOneClass(typeInfo.iCls, adapterOutPath, _isShine, sb);
                    }

                    // reXMl.appendChild(typeInfo.writeXML());
                }
            }

            doOneClass(factoryTypeInfo.iCls, adapterOutPath, _isShine, sb);

            //去掉最后一个tab
            sb.Remove(sb.Length - 1, 1);

            clsStr = replaceMethod(clsStr, "protected " + (_isShine ? "virtual" : "override") + " void initOtherAdapters(AppDomain appdomain)", sb.ToString());

            factoryClass.writeToPath(factoryClsPath);
            FileUtils.writeFileForUTF(controlClsPath, clsStr);

            // FileUtils.writeFileForXML("/Users/sunming/E/temp3/aa.xml",reXMl);
        }
Ejemplo n.º 20
0
        private static void doOneGenerate(XML xml, string controlClsPath, string adapterOutPath, int projectType)
        {
            clearGenerate();

            string[] fileList = FileUtils.getFileList(adapterOutPath, "cs");

            SMap <string, string> fileMap = new SMap <string, string>();

            foreach (string s in fileList)
            {
                string fN = FileUtils.getFileNameWithoutEx(s);

                if (fN.EndsWith("Adapter"))
                {
                    fileMap.put(fN.Substring(0, fN.Length - 7), s);
                }
            }

            _isShine = projectType == 0;

            int aLen = "Assets/".Length;

            //先处理包路径
            foreach (XML xl in xml.getChildrenByName("root"))
            {
                SList <string> ignoreList = new SList <string>();

                foreach (XML pXml in xl.getChildrenByName("ignorePath"))
                {
                    ignoreList.add(pXml.getProperty("path"));
                }

                StringIntMap hotfixPathDic = new StringIntMap();

                foreach (XML pXml in xl.getChildrenByName("hotfixPath"))
                {
                    hotfixPathDic.put(pXml.getProperty("path"), pXml.getProperty("needFactory").Equals("true") ? 1 : 0);
                }

                string rootPath = "Assets/" + xl.getProperty("path");

                string[] deepFileList = FileUtils.getDeepFileList(rootPath, "cs");

                foreach (string s in deepFileList)
                {
                    //编辑器类的跳过
                    if (s.Contains("/Editor/"))
                    {
                        continue;
                    }

                    string tailPath = s.Substring(rootPath.Length + 1);

                    bool failed = false;

                    //排除组
                    foreach (string ig in ignoreList)
                    {
                        if (tailPath.StartsWith(ig))
                        {
                            failed = true;
                            break;
                        }
                    }

                    if (failed)
                    {
                        continue;
                    }

                    string fQName = FileUtils.getFileFrontName(s.Substring(aLen));

                    String fName = FileUtils.getFileName(fQName);

                    _clsNameToPathDic.put(fName, fQName);

                    string[] keys   = hotfixPathDic.getKeys();
                    int[]    values = hotfixPathDic.getValues();
                    string   k;
                    int      v;

                    for (int i = keys.Length - 1; i >= 0; --i)
                    {
                        if ((k = keys[i]) != null)
                        {
                            v = values[i];

                            //需要
                            if (tailPath.StartsWith(k))
                            {
                                _adapterClsDic.add(fName);

                                if (v == 1)
                                {
                                    _factoryClsDic.add(fName);
                                }

                                break;
                            }
                        }
                    }
                }
            }


            string clsStr = FileUtils.readFileForUTF(controlClsPath);

            string projectMark    = getProjectMark(projectType);
            string factoryClsPath = getFactoryClsPath(projectType);

            ClsAnalysis.FactoryClassInfo factoryClass = null;
            string factoryClsName = null;

            if (!_isShine)
            {
                factoryClass   = ClsAnalysis.readFactory(factoryClsPath);
                factoryClsName = FileUtils.getFileFrontName(FileUtils.getFileName(factoryClsPath));

                //遍历父
                for (int i = projectType - 1; i >= Project_Common; i--)
                {
                    ClsAnalysis.FactoryClassInfo parentFactoryCls = ClsAnalysis.readFactory(getFactoryClsPath(i));

                    factoryClass.addParent(parentFactoryCls);
                }
            }

            StringBuilder sb = new StringBuilder();

            endClsLine(sb);

            if (!_isShine)
            {
                sb.Append("base.initOtherAdapters(appdomain);");
                endClsLine(sb);
            }


            TypeInfo factoryTypeInfo = null;

            if (!_isShine)
            {
                //工厂最后执行
                factoryTypeInfo = getTypeInfo(factoryClsName);

                _clsNameToPathDic.remove(factoryClsName);
            }

            //ex
            foreach (XML xl in xml.getChildrenByName("customClass"))
            {
                ILClassInfo cls = new ILClassInfo(xl.getProperty("name"));

                foreach (XML mXml in xl.getChildrenByName("method"))
                {
                    string visitTypeStr = mXml.getProperty("visitType");
                    int    visitType    = visitTypeStr.isEmpty() ? VisitType.Protected : VisitType.getTypeByName(visitTypeStr);

                    string needBaseCallStr = mXml.getProperty("needBaseCall");
                    bool   needBaseCall    = needBaseCallStr.isEmpty() ? true : StringUtils.strToBoolean(needBaseCallStr);

                    string   argsStr = mXml.getProperty("args");
                    string[] args    = argsStr.isEmpty() ? ObjectUtils.EmptyStringArr : argsStr.Split(',');

                    cls.addMethod(mXml.getProperty("name"), mXml.getProperty("returnType"), visitType, needBaseCall, args);
                }

                doOneClass(cls, adapterOutPath, _isShine, sb);
                fileMap.remove(cls.clsName);
            }

            foreach (string k in _clsNameToPathDic.getSortedMapKeys())
            {
                TypeInfo typeInfo = getTypeInfo(k);

                if (typeInfo == null)
                {
                    if (!_isShine)
                    {
                        Ctrl.throwError("不该找不到类型", k);
                    }
                }
                else
                {
                    if (typeInfo.hasHotfixMark || !typeInfo.isEmpty())
                    {
                        //需要工厂,并且不是虚类
                        if (!_isShine && !typeInfo.iCls.isAbstract && (typeInfo.needFactory || _factoryClsDic.contains(k)))
                        {
                            ClsAnalysis.FMethod method = factoryClass.addMethod(k, projectMark);
                            //补方法
                            factoryTypeInfo.iCls.addMethod("create" + method.name, method.returnType, VisitType.Public, true);
                        }

                        //需要适配器
                        if (typeInfo.hasHotfixMark || _adapterClsDic.contains(k))
                        {
                            doOneClass(typeInfo.iCls, adapterOutPath, _isShine, sb);
                            fileMap.remove(typeInfo.clsName);
                        }
                    }
                }
            }

            if (!_isShine)
            {
                doOneClass(factoryTypeInfo.iCls, adapterOutPath, _isShine, sb);
                fileMap.remove(factoryTypeInfo.clsName);
            }

            //去掉最后一个tab
            sb.Remove(sb.Length - 1, 1);

            clsStr = replaceMethod(clsStr, "protected " + (_isShine ? "virtual" : "override") + " void initOtherAdapters(AppDomain appdomain)", sb.ToString());

            if (!_isShine)
            {
                factoryClass.writeToPath(factoryClsPath);
            }

            FileUtils.writeFileForUTF(controlClsPath, clsStr);

            if (!fileMap.isEmpty())
            {
                fileMap.forEach((k, v) =>
                {
                    FileUtils.deleteFile(v);
                });
            }
        }
Ejemplo n.º 21
0
        public static string ReplaceDirtWord(this string str, DirtWordNode root, out SList <DirtWordNode> match)
        {
            match = new SList <DirtWordNode>();
            if (str == null)
            {
                return(null);
            }

            char[]        arr     = str.ToCharArray();
            int           curIdx  = 0;
            int           wordIdx = 0;
            StringBuilder sb      = new StringBuilder();
            DirtWordNode  curNode = root;
            DirtWordNode  old     = curNode;

            while (curIdx < str.Length)
            {
                char c = arr[curIdx + wordIdx];
                old     = curNode;
                curNode = curNode[c];
                if (curNode != null)
                {
                    wordIdx++;
                    if (curNode.Terminated)
                    {
                        DirtWordNode newNode = new DirtWordNode();
                        newNode.Word  = curNode.Word;
                        newNode.Index = curIdx;
                        match.add(newNode);
                        for (int i = 0; i < curNode.Word.Length; i++)
                        {
                            sb.Append('*');
                        }

                        curIdx += wordIdx;
                        wordIdx = 0;
                        curNode = root;
                    }
                    else if (curIdx + wordIdx >= str.Length)
                    {
                        for (int i = 0; i < wordIdx; i++)
                        {
                            sb.Append(arr[curIdx + i]);
                        }

                        curIdx += wordIdx;
                    }
                }
                else
                {
                    if (old != null && old != root)
                    {
                        if (old.CanTerminate)
                        {
                            DirtWordNode newNode = new DirtWordNode();
                            newNode.Word  = curNode.Word;
                            newNode.Index = curIdx;
                            match.add(newNode);
                            for (int i = 0; i < old.Word.Length; i++)
                            {
                                sb.Append('*');
                            }
                        }
                        else
                        {
                            sb.Append(old.Word);
                        }

                        curNode = root;
                        curIdx += wordIdx;
                        wordIdx = 0;
                        old     = null;
                    }
                    else
                    {
                        sb.Append(c);
                        curNode = root;
                        curIdx++;
                        wordIdx = 0;
                    }
                }
            }

            if (old != null && old != root)
            {
                if (old.CanTerminate)
                {
                    DirtWordNode newNode = new DirtWordNode();
                    newNode.Word  = curNode.Word;
                    newNode.Index = curIdx;
                    match.add(newNode);
                    for (int i = 0; i < old.Word.Length; i++)
                    {
                        sb.Append('*');
                    }
                }
                else
                {
                    sb.Append(old.Word);
                }

                curNode = root;
                curIdx += wordIdx;
                wordIdx = 0;
                old     = null;
            }

            return(sb.ToString());
        }
Ejemplo n.º 22
0
        public static void init()
        {
            /** 初始化将枚举存储为数组 */
//			Array keyList=Enum.GetValues(typeof(KeyCode));
//			_keys=new KeyCode[keyList.Length];
//			for(int i=keyList.Length - 1;i>=0;--i)
//			{
//				_keys[i]=(KeyCode)keyList.GetValue(i);
//			}

            SList <KeyCode> list = new SList <KeyCode>();

            //a-z
            for (int i = (int)KeyCode.A, len = (int)KeyCode.Z; i <= len; ++i)
            {
                list.add((KeyCode)i);
            }

            //0-9
            for (int i = (int)KeyCode.Alpha0, len = (int)KeyCode.Alpha9; i <= len; ++i)
            {
                list.add((KeyCode)i);
            }

            //0-9
            for (int i = (int)KeyCode.Keypad0, len = (int)KeyCode.Keypad9; i <= len; ++i)
            {
                list.add((KeyCode)i);
            }

            //esc
            list.add(KeyCode.Escape);
            list.add(KeyCode.BackQuote);
            //enter
            list.add(KeyCode.Return);
            list.add(KeyCode.KeypadEnter);

            list.add(KeyCode.LeftControl);
            list.add(KeyCode.LeftCommand);
            list.add(KeyCode.LeftShift);
            list.add(KeyCode.LeftAlt);

            list.add(KeyCode.RightControl);
            list.add(KeyCode.RightCommand);
            list.add(KeyCode.RightShift);
            list.add(KeyCode.RightAlt);

            _keys = list.toArray();

            TimeDriver.instance.setUpdate(onUpdate);
        }
Ejemplo n.º 23
0
 /** 添加子项 */
 public void appendChild(XML xml)
 {
     _children.add(xml);
 }