Exemple #1
0
        public static void LoadScene(string scene)
        {
            if (scene == null || scene == "")
            {
                return;
            }

            //prev clean
            if (loadStatus != LoadSceneStatus.NONE)
            {
                return;
            }

            next = scene;

            loadStatus = LoadSceneStatus.BEGIN;

            System.GC.Collect();

            if (!first)
            {
                UIFrame.SceneLoadProcessAtlases();
                sceneManager.xLoadScene("1");
            }
            else
            {
                first = false;
                sceneManager.NextLoadingScene();
            }
        }
Exemple #2
0
        private static UIFrame GetUI(string name, int index)
        {
            UIFrame ui = null;

            if (!indexToUI.ContainsKey(index))
            {
                List <string> atlases;
                uiInfo.TryGetValue(name, out atlases);

                List <string> textures;
                string        texName = name + "_IMG";
                uiInfo.TryGetValue(texName, out textures);

                if (atlases != null && textures != null)
                {
                    ui = new UIFrame(index, name, atlases, textures);
                    uiInfo.Remove(name);
                    uiInfo.Remove(texName);
                    allUI.Add(name, ui);
                    indexToUI.Add(index, ui);
                    if (initUICall != null)
                    {
                        LuaManager.CallFunc_VX(initUICall, index, ui);
                    }
                }
            }
            else
            {
                ui = allUI[name];
            }

            return(ui);
        }
        internal static void ProcessUnShowUILayer(int layer, UIFrame ui)
        {
            if (layer < 0)
            {
                return;
            }
            Dictionary <int, List <UIFrame> > .Enumerator e = layerUI.GetEnumerator();
            UIFrame        uf      = null;
            int            group   = ui.GetGroup();
            List <UIFrame> dirtyUI = new List <UIFrame>();

            while (e.MoveNext())
            {
                if (e.Current.Key < 0)
                {
                    continue;
                }
                if (e.Current.Key > layer)
                {
                    for (int i = 0, count = e.Current.Value.Count; i < count; i++)
                    {
                        uf = e.Current.Value[i];
                        uf.Show(false);
                        if (uf.IsDirty())
                        {
                            dirtyUI.Add(uf);
                        }
                    }
                }
            }
        }
Exemple #4
0
        public static void ShowUI(string name, int index, LuaInterface.LuaFunction showUICall, int scriptCallParam)
        {
            UIFrame ui = GetUI(name, index);

            ui.SetScriptShowCall(showUICall, scriptCallParam);
            ProcessUIShow(ui, true);
        }
Exemple #5
0
 internal static void UICreateCall(int index, UIFrame ui)
 {
     if (createUICall != null)
     {
         LuaManager.CallFunc_VX(createUICall, index, ui);
     }
 }
Exemple #6
0
        private static void ProcessUIShow(UIFrame ui, bool show)
        {
            if (ui == null)
            {
                return;
            }

            ui.Show(show);
        }
        internal static void RegisterUILayer(int layer, UIFrame ui)
        {
            if (!layerUI.ContainsKey(layer))
            {
                layerUI.Add(layer, new List <UIFrame>());
            }

            List <UIFrame> list = layerUI[layer];

            list.Add(ui);
        }
        public static void CallFunc_V(LuaFunction func, UIFrame ui)
        {
            if (func == null)
            {
                return;
            }

            func.BeginPCall();
            func.Push(ui);
            func.PCall();
            func.EndPCall();
        }
Exemple #9
0
        public static void DeleteUI(UIFrame ui)
        {
            if (ui == null)
            {
                return;
            }
            if (ui.IsShowing())
            {
                ui.Show(false);
            }

            ui.DirtyDel();
            allUI.Remove(ui.name);
            indexToUI.Remove(ui.id);
        }
Exemple #10
0
        public static void ClearData()
        {
            Debugger.Log("clear ui data");
            uiInfo.Clear();
            labelTextData.Clear();

            //for loading ui etc. which are show before update unshow first
            UIFrame.CacheOldUIData();

            //set old ui dirty to delete
            Dictionary <string, UIFrame> .Enumerator e = allUI.GetEnumerator();
            while (e.MoveNext())
            {
                e.Current.Value.SetDirty();
            }
        }
Exemple #11
0
        internal static void ProcessUIAlpha(UIFrame ui)
        {
            int layer = ui.GetLayer();

            if (layer < 0)
            {
                layer = -layer;
            }
            LayerAlpha la;

            if (!layerAlphaDic.TryGetValue(layer, out la))
            {
                la       = new LayerAlpha();
                la.alpha = 1;
                layerAlphaDic.Add(layer, la);
                return;
            }

            ui.SetAlpha(la.alpha);
        }
        private static void UnRegisterUILayer(int layer, UIFrame ui)
        {
            if (ui == null)
            {
                return;
            }
            if (!layerUI.ContainsKey(layer))
            {
                return;
            }

            List <UIFrame> list = layerUI[layer];

            for (int i = 0, count = list.Count; i < count; i++)
            {
                if (list[i] == ui)
                {
                    list.RemoveAt(i);
                    i--;
                    break;
                }
            }
        }
Exemple #13
0
        public static void Init()
        {
            bool atlasDataInited = false;
            bool labelDataInited = false;
            bool fontInited      = false;

            if (!uiRootTrans)
            {
                GameObject go = GameObject.Find("UI Root");
                if (go == null)
                {
                    Debugger.LogError("UI Root is null");
                    return;
                }

                Object.DontDestroyOnLoad(go);

                uiRootTrans = go.transform;

                Transform camTrans = uiRootTrans.Find("Camera");
                if (camTrans == null)
                {
                    Debugger.LogError("Cam trans is null");
                    return;
                }

                _camera   = camTrans.GetComponent <Camera>();
                _uiCamera = camTrans.GetComponent <UICamera>();
            }
            else
            {
                fontInited = true;
            }

            System.Action checkOver = () =>
            {
                if (atlasDataInited && labelDataInited && fontInited)
                {
                    List <string> atlases;
                    if (!uiInfo.TryGetValue(UIATLASENAMES, out atlases))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UIATLASENAMES);
                        return;
                    }

                    List <string> textures;
                    if (!uiInfo.TryGetValue(UITEXTURENAMES, out textures))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UITEXTURENAMES);
                        return;
                    }

                    UIFrame.Init(atlases, textures);
                    uiInfo.Remove(UIATLASENAMES);
                    uiInfo.Remove(UITEXTURENAMES);

                    Debugger.Log("UI Init Over");
                    MessagePool.CSSendMessage(null, MessagePool.UIInitOver, Message.FilterTypeNothing, null);
                }
            };

            if (!fontInited)
            {
                ResLoader.LoadByName("MSYH", (asset, param) =>
                {
                    if (asset == null)
                    {
                        Debugger.Log("init font failed");
                        return;
                    }

                    comFont = ((GameObject)asset).GetComponent <UIFont>();
                    if (comFont == null)
                    {
                        Debugger.Log("font data not contains UIFont");
                        return;
                    }

                    UIFrame.SetFont(comFont);

                    fontInited = true;

                    checkOver();
                }, null);
            }

            ResLoader.AsynReadBytesByName(UIATLASDATAFILE, (arr, param) =>
            {
                if (arr == null)
                {
                    Debugger.LogError("init UI atlas data failed");
                    return;
                }

                ZLText zlt = new ZLText(arr);
                uiInfo     = zlt.ReadAll();
                zlt.Dispose();

                atlasDataInited = true;

                checkOver();
            }, null, true);

            ResLoader.AsynReadUTF8ByName(UILABELTEXTFILE, (str, param) =>
            {
                if (str == null)
                {
                    Debugger.LogError("init UI label text data failed");
                    return;
                }

                string[] lines = null;
                int index      = str.IndexOf("\r\n");
                if (index >= 0)
                {
                    lines = str.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);
                }
                else
                {
                    lines = str.Split(new string[] { "\n" }, System.StringSplitOptions.None);
                }

                labelTextData.AddRange(lines);
                labelDataInited = true;

                checkOver();
            }, null, true);
        }
Exemple #14
0
        public static void UnShowUI(string name, int index)
        {
            UIFrame ui = GetUI(name, index);

            ProcessUIShow(ui, false);
        }
Exemple #15
0
 public static void UnShowUI(UIFrame ui)
 {
     ProcessUIShow(ui, false);
 }
Exemple #16
0
        internal static void ResetUIAlpha(UIFrame ui)
        {
            int layer = ui.GetLayer();

            if (layer < 0)
            {
                layer = -layer;
            }

            currentLayer         = -1;
            currentLowLayerAlpha = -1;

            Dictionary <int, List <UIFrame> > .Enumerator e = layerUI.GetEnumerator();
            int     topLowLayer = -1;
            float   lowAlpha    = 1;
            UIFrame uii;
            float   uiAlpha;
            bool    doo    = false;
            int     clayer = -1;

            while (e.MoveNext())
            {
                doo    = false;
                clayer = e.Current.Key;
                if (clayer < 0)
                {
                    clayer = -clayer;
                }
                if (clayer < layer)
                {
                    if (clayer > topLowLayer)
                    {
                        for (int i = 0, count = e.Current.Value.Count; i < count; i++)
                        {
                            uii = e.Current.Value[i];
                            if (uii.IsShowing())
                            {
                                uiAlpha = uii.GetLowLayerAlpha();
                                if (uiAlpha < lowAlpha)
                                {
                                    lowAlpha = uiAlpha;
                                }
                                if (!doo)
                                {
                                    doo = true;
                                }
                            }
                        }

                        if (doo)
                        {
                            topLowLayer = clayer;
                        }
                    }
                }
            }

            Dictionary <int, LayerAlpha> .Enumerator ex = layerAlphaDic.GetEnumerator();
            List <UIFrame> list;

            while (ex.MoveNext())
            {
                clayer = ex.Current.Key;
                if (clayer >= topLowLayer)
                {
                    if (ex.Current.Value.alpha != 1)
                    {
                        ex.Current.Value.alpha = 1;

                        if (layerUI.TryGetValue(clayer, out list))
                        {
                            for (int i = 0, count = list.Count; i < count; i++)
                            {
                                uii = list[i];
                                if (uii.IsShowing())
                                {
                                    uii.SetAlpha(1);
                                }
                            }
                        }

                        if (layerUI.TryGetValue(-clayer, out list))
                        {
                            for (int i = 0, count = list.Count; i < count; i++)
                            {
                                uii = list[i];
                                if (uii.IsShowing())
                                {
                                    uii.SetAlpha(1);
                                }
                            }
                        }
                    }
                }
            }

            if (topLowLayer >= 0)
            {
                SetLessLayerUIAlpha(topLowLayer, lowAlpha);
            }
        }
Exemple #17
0
        public static int GetUIStatus(string name, int index)
        {
            UIFrame ui = GetUI(name, index);

            return(ui.GetUIStatus());
        }
Exemple #18
0
 public static void ClearOldCacheData()
 {
     UIFrame.ClearOldCacheData();
 }
Exemple #19
0
 public static void AddUnloadAtlas(string name)
 {
     UIFrame.AddUnloadAtlas(name);
 }