private static void ParseCachedPHFonts()
 {
     _PHFontNameToAssetName.Clear();
     _PHFontAssetNameToFontName.Clear();
     if (PlatDependant.IsFileExist("EditorOutput/Runtime/phfont.txt"))
     {
         string json = "";
         using (var sr = PlatDependant.OpenReadText("EditorOutput/Runtime/phfont.txt"))
         {
             json = sr.ReadToEnd();
         }
         try
         {
             var jo = new JSONObject(json);
             try
             {
                 var phf = jo["phfonts"] as JSONObject;
                 if (phf != null && phf.type == JSONObject.Type.OBJECT)
                 {
                     for (int i = 0; i < phf.list.Count; ++i)
                     {
                         var key = phf.keys[i];
                         var val = phf.list[i].str;
                         _PHFontNameToAssetName[key]     = val;
                         _PHFontAssetNameToFontName[val] = key;
                     }
                 }
             }
             catch { }
         }
         catch { }
     }
 }
Example #2
0
        public static List <string> ParseHotFixList()
        {
            List <string> list     = new List <string>();
            var           prelists = CapsModEditor.FindAssetsInMods("LuaHotFix/MemberList.txt");

            foreach (var listfile in prelists)
            {
                using (var sr = PlatDependant.OpenReadText(listfile))
                {
                    while (true)
                    {
                        var line = sr.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        if (!string.IsNullOrEmpty(line))
                        {
                            if (line.StartsWith("--"))
                            {
                            }
                            else
                            {
                                list.Add(line);
                            }
                        }
                    }
                }
            }
            return(list);
        }
        private static bool LoadCachedReplacement()
        {
            bool dirty = false;

            _FontReplacements.Clear();
            _FontReplacementDescs.Clear();
            if (PlatDependant.IsFileExist("EditorOutput/Runtime/rfont.txt"))
            {
                string json = "";
                using (var sr = PlatDependant.OpenReadText("EditorOutput/Runtime/rfont.txt"))
                {
                    json = sr.ReadToEnd();
                }
                try
                {
                    var jo = new JSONObject(json);
                    try
                    {
                        var phr = jo["replacements"] as JSONObject;
                        if (phr != null && phr.type == JSONObject.Type.ARRAY)
                        {
                            for (int i = 0; i < phr.list.Count; ++i)
                            {
                                var val = phr.list[i].str;
                                dirty |= !AddFontReplacement(val);
                            }
                        }
                    }
                    catch { }
                }
                catch { }
            }
            return(dirty);
        }
Example #4
0
        public void TestVoidFunc()
        {
            HashSet <string> recordedMembers = new HashSet <string>();
            HashSet <string> compiledMembers = new HashSet <string>();

            var cachedPath = "Assets/Mods/CapsLua/LuaPrecompile/MemberList.txt";

            //var cachedPath = "EditorOutput/LuaPrecompile/CachedCommands.txt";
            if (PlatDependant.IsFileExist(cachedPath))
            {
                try
                {
                    using (var sr = PlatDependant.OpenReadText(cachedPath))
                    {
                        while (true)
                        {
                            var line = sr.ReadLine();
                            if (line == null)
                            {
                                break;
                            }

                            if (!string.IsNullOrEmpty(line))
                            {
                                recordedMembers.Add(line);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    PlatDependant.LogError(e);
                }
            }
        }
Example #5
0
 private static void LoadCachedAtlas2()
 {
     _CachedAtlasSpriteGUID.Clear();
     _CachedAtlasPath.Clear();
     if (PlatDependant.IsFileExist("EditorOutput/Runtime/atlas.txt"))
     {
         string json = "";
         using (var sr = PlatDependant.OpenReadText("EditorOutput/Runtime/atlas.txt"))
         {
             json = sr.ReadToEnd();
         }
         try
         {
             var jo = new JSONObject(json);
             try
             {
                 var joc = jo["atlas"] as JSONObject;
                 if (joc != null && joc.type == JSONObject.Type.ARRAY)
                 {
                     for (int i = 0; i < joc.list.Count; ++i)
                     {
                         var val = joc.list[i].str;
                         SaveSpriteGUID(val);
                     }
                 }
             }
             catch { }
         }
         catch { }
     }
 }
Example #6
0
 public static void LoadCachedAtlas()
 {
     _CachedAtlas.Clear();
     _CachedAtlasRev.Clear();
     //_TexInAtlas.Clear();
     if (PlatDependant.IsFileExist("EditorOutput/Runtime/atlas.txt"))
     {
         string json = "";
         using (var sr = PlatDependant.OpenReadText("EditorOutput/Runtime/atlas.txt"))
         {
             json = sr.ReadToEnd();
         }
         try
         {
             var jo = new JSONObject(json);
             try
             {
                 var joc = jo["atlas"] as JSONObject;
                 if (joc != null && joc.type == JSONObject.Type.ARRAY)
                 {
                     for (int i = 0; i < joc.list.Count; ++i)
                     {
                         var val  = joc.list[i].str;
                         var name = System.IO.Path.GetFileNameWithoutExtension(val);
                         _CachedAtlas[name]   = val;
                         _CachedAtlasRev[val] = name;
                     }
                 }
                 //joc = jo["tex"] as JSONObject;
                 //if (joc != null && joc.type == JSONObject.Type.OBJECT)
                 //{
                 //    for (int i = 0; i < joc.list.Count; ++i)
                 //    {
                 //        var key = joc.keys[i];
                 //        var val = joc.list[i];
                 //        if (val != null && val.type == JSONObject.Type.ARRAY)
                 //        {
                 //            var list = new List<string>();
                 //            _TexInAtlas[key] = list;
                 //            for (int j = 0; j < val.list.Count; ++j)
                 //            {
                 //                list.Add(val.list[i].str);
                 //            }
                 //        }
                 //    }
                 //}
             }
             catch { }
         }
         catch { }
     }
 }
Example #7
0
        public int TestReturnOutFunc(string filePath, int times, out string rv)
        {
            string last = null;

            for (int i = 0; i < times; ++i)
            {
                if (i == 3)
                {
                    rv = i.ToString();
                    return(i);
                }
                HashSet <string> recordedMembers = new HashSet <string>();
                HashSet <string> compiledMembers = new HashSet <string>();

                var cachedPath = filePath + i;
                //var cachedPath = "EditorOutput/LuaPrecompile/CachedCommands.txt";
                if (PlatDependant.IsFileExist(cachedPath))
                {
                    try
                    {
                        using (var sr = PlatDependant.OpenReadText(cachedPath))
                        {
                            while (true)
                            {
                                var line = sr.ReadLine();
                                if (line == null)
                                {
                                    break;
                                }
                                last = line;
                                if (!string.IsNullOrEmpty(line))
                                {
                                    recordedMembers.Add(line);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        PlatDependant.LogError(e);
                        rv = e.Message;
                        return(i);
                    }
                }
            }
            rv = last;
            return(last?.Length ?? 0);
        }
Example #8
0
        public void TestParamFunc(string filePath, int times)
        {
            for (int i = 0; i < times; ++i)
            {
                HashSet <string> recordedMembers = new HashSet <string>();
                HashSet <string> compiledMembers = new HashSet <string>();

                var cachedPath = filePath + i;
                //var cachedPath = "EditorOutput/LuaPrecompile/CachedCommands.txt";
                if (PlatDependant.IsFileExist(cachedPath))
                {
                    try
                    {
                        using (var sr = PlatDependant.OpenReadText(cachedPath))
                        {
                            while (true)
                            {
                                var line = sr.ReadLine();
                                if (line == null)
                                {
                                    break;
                                }

                                if (!string.IsNullOrEmpty(line))
                                {
                                    recordedMembers.Add(line);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        PlatDependant.LogError(e);
                    }
                }
            }
        }
Example #9
0
        public static CapsResManifest LoadManifest(string file)
        {
            CapsResManifest mani = new CapsResManifest();

            if (PlatDependant.IsFileExist(file))
            {
                using (var sr = PlatDependant.OpenReadText(file))
                {
                    if (sr != null)
                    {
                        List <CapsResManifestNode> nodeStack = new List <CapsResManifestNode>();
                        var root = new CapsResManifestNode(mani);
                        mani.Root = root;
                        nodeStack.Add(root);

                        int nxtChar = -1;
                        while ((nxtChar = sr.Peek()) > 0)
                        {
                            int lvl = 0;
                            while (nxtChar == '*')
                            {
                                sr.Read();
                                ++lvl;
                                nxtChar = sr.Peek();
                            }
                            string ppath = sr.ReadLine();
                            if (string.IsNullOrEmpty(ppath))
                            {
                                continue;
                            }

                            if (nodeStack.Count > lvl)
                            {
                                var last = nodeStack[nodeStack.Count - 1];
                                if (last.Children == null || last.Children.Count <= 0)
                                {
                                    CapsResManifestItem item;
                                    item      = new CapsResManifestItem(last);
                                    last.Item = item;
                                }

                                nodeStack.RemoveRange(lvl, nodeStack.Count - lvl);
                            }

                            {
                                var last = nodeStack[nodeStack.Count - 1];
                                if (last.Children == null)
                                {
                                    last.Children = new SortedList <string, CapsResManifestNode>();
                                }
                                var child = new CapsResManifestNode(last, ppath);
                                last.Children[ppath] = child;
                                nodeStack.Add(child);
                            }
                        }

                        if (nodeStack.Count > 1)
                        {
                            var last = nodeStack[nodeStack.Count - 1];
                            CapsResManifestItem item;
                            item      = new CapsResManifestItem(last);
                            last.Item = item;
                        }

                        mani.TrimExcess();
                    }
                }
            }
            return(mani);
        }
        public void Prepare(string output)
        {
            _Output = output;
            _OldMap.Clear();
            _NewMap.Clear();
            _FullSet.Clear();

            if (!string.IsNullOrEmpty(output))
            {
                var cachefile = output + "/res/inatlas.txt";
                if (PlatDependant.IsFileExist(cachefile))
                {
                    try
                    {
                        string json = "";
                        using (var sr = PlatDependant.OpenReadText(cachefile))
                        {
                            json = sr.ReadToEnd();
                        }
                        var jo  = new JSONObject(json);
                        var joc = jo["tex"] as JSONObject;
                        if (joc != null && joc.type == JSONObject.Type.OBJECT)
                        {
                            for (int i = 0; i < joc.list.Count; ++i)
                            {
                                var key = joc.keys[i];
                                var val = joc.list[i].str;
                                _OldMap[key] = val;
                            }
                        }
                    }
                    catch { }
                }
            }

            var assets = AssetDatabase.GetAllAssetPaths();

            if (assets != null)
            {
                for (int i = 0; i < assets.Length; ++i)
                {
                    var asset = assets[i];
                    if (asset.EndsWith(".spriteatlas"))
                    {
                        var atlas = AssetDatabase.LoadAssetAtPath <UnityEngine.U2D.SpriteAtlas>(asset);
                        if (atlas)
                        {
                            var name   = atlas.tag;
                            var packed = UnityEditor.U2D.SpriteAtlasExtensions.GetPackables(atlas);
                            if (packed != null)
                            {
                                for (int j = 0; j < packed.Length; ++j)
                                {
                                    var item = packed[j];
                                    var path = AssetDatabase.GetAssetPath(item);
                                    if (!string.IsNullOrEmpty(path))
                                    {
                                        _NewMap[path] = name;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (var kvp in _OldMap)
            {
                var key = kvp.Key;
                var val = kvp.Value;
                if (!_NewMap.ContainsKey(key) || _NewMap[key] != val)
                {
                    _FullSet.Add(key);
                }
            }
            foreach (var kvp in _NewMap)
            {
                var key = kvp.Key;
                var val = kvp.Value;
                if (!_OldMap.ContainsKey(key) || _OldMap[key] != val)
                {
                    _FullSet.Add(key);
                }
            }
        }