示例#1
0
 public ScreenInfo(UIControlBase controller, bool showmask, ScreenPopCallback popcallback)
 {
     screenController = controller;
     showDarkBG       = showmask;
     screenOrder      = 0;
     popCallback      = popcallback;
 }
示例#2
0
        private UIControlBase PopScreenAbove(string screeNname)
        {
            UIControlBase uIControlBase = null;
            string        text          = "";

            while (m_ScreenStack.Count != 0)
            {
                ScreenInfo screenInfo = m_ScreenStack.Peek();
                uIControlBase = screenInfo.screenController;
                text          = uIControlBase.ScreenName;
                if (text == screeNname)
                {
                    uIControlBase.OnPoppedToTop(text);
                    if (screenInfo.showDarkBG)
                    {
                        ShowDarkMask(screenInfo);
                    }
                    else
                    {
                        HideDarkMask();
                    }
                    return(uIControlBase);
                }
                PopScreen();
            }
            return(null);
        }
示例#3
0
        public void buildScreen(string screenName, GameObject screenRootGameObject)
        {
            TextAsset             textAsset             = Resources.Load("Screens/" + screenName) as TextAsset;
            XmlTextReader         xmlTextReader         = new XmlTextReader(new StringReader(textAsset.text));
            string                text                  = "";
            IUIElementsXMLHandler iUIElementsXMLHandler = null;

            while (xmlTextReader.Read())
            {
                switch (xmlTextReader.NodeType)
                {
                case XmlNodeType.Element:
                    if (xmlTextReader.Name == "Panels")
                    {
                        isCurrentNodePrefab = true;
                        if (xmlTextReader.MoveToNextAttribute() && xmlTextReader.Name == "controlScript" && screenRootGameObject.GetComponent(xmlTextReader.Value) == null)
                        {
                            UIControlBase uIControlBase = screenRootGameObject.AddComponent(Type.GetType(xmlTextReader.Value)) as UIControlBase;
                            if (uIControlBase != null)
                            {
                                uIControlBase.ScreenName = screenName;
                            }
                        }
                    }
                    else
                    {
                        if (!isCurrentNodePrefab)
                        {
                            break;
                        }
                        text = xmlTextReader.Name;
                        attributes.Clear();
                        while (xmlTextReader.MoveToNextAttribute())
                        {
                            if (xmlTextReader.IsEmptyElement)
                            {
                                Logger.LogWarning(this, "#EnptyElement\n");
                            }
                            else
                            {
                                attributes[xmlTextReader.Name] = xmlTextReader.Value;
                            }
                        }
                        GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("ScreenElements/" + text)) as GameObject;
                        gameObject.transform.SetParent(screenRootGameObject.transform, worldPositionStays: false);
                        iUIElementsXMLHandler = gameObject.GetComponent <UIElementBase>();
                        iUIElementsXMLHandler.ReadAttributesFromDictionary(attributes);
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (xmlTextReader.Name == "Panels")
                    {
                        isCurrentNodePrefab = false;
                    }
                    break;
                }
            }
        }
示例#4
0
        public void CloseTopScreen()
        {
            UIControlBase topScreen = Instance.GetTopScreen();

            if (topScreen != null)
            {
                topScreen.CloseScreen();
            }
        }
示例#5
0
        public override void ControlLoaded(UIControlBase cbase)
        {
            int layer = cbase.transform.parent.gameObject.layer;

            DisableAllListeners(cbase.gameObject);
            Utilities.SetLayers(cbase.transform.parent.gameObject, layer);
            GetUICamera().cullingMask = 1 << layer;
            SetEventReceiverMask(1 << layer);
        }
示例#6
0
        public UIControlBase GetTopScreen()
        {
            UIControlBase result = null;

            if (m_ScreenStack.Count > 0)
            {
                ScreenInfo screenInfo = m_ScreenStack.Peek();
                result = screenInfo.screenController;
            }
            return(result);
        }
示例#7
0
        public virtual void PopScreen()
        {
            if (m_ScreenStack.Count == 0)
            {
                Logger.LogWarning(this, "Stack empty when pop called");
                return;
            }
            ScreenInfo    screenInfo       = m_ScreenStack.Pop();
            UIControlBase screenController = screenInfo.screenController;

            Logger.LogInfo(this, "Popping " + screenController.name);
            if (m_ScreenStack.Count > 0)
            {
                UIControlBase uIControlBase = screenController;
                ScreenInfo    screenInfo2   = m_ScreenStack.Peek();
                if (screenInfo2.screenController != null)
                {
                    screenInfo2.screenController.OnPoppedToTop(uIControlBase.ScreenName);
                }
                ScreenInfo screenInfo3 = null;
                foreach (ScreenInfo item in m_ScreenStack)
                {
                    if (item.showDarkBG)
                    {
                        screenInfo3 = item;
                        break;
                    }
                }
                if (screenInfo3 != null)
                {
                    ShowDarkMask(screenInfo3);
                }
                else
                {
                    HideDarkMask();
                }
            }
            else
            {
                HideDarkMask();
            }
            if (screenInfo.popCallback != null)
            {
                screenInfo.popCallback(screenInfo.screenController);
            }
            screenController.UnloadUI();
            Object.Destroy(screenController.gameObject);
        }
示例#8
0
        public void ScreenWillBePopped(UIControlBase screenToBePopped)
        {
            if (!(screenToBePopped == CurrentScreen))
            {
                return;
            }
            int num = 0;

            foreach (ScreenInfo item in m_ScreenStack)
            {
                if (num == 1)
                {
                    item.screenController.OnToBePoppedToTop(CurrentScreen.ScreenName);
                }
                num++;
            }
        }
示例#9
0
        public UIControlBase OpenScreen(string screenname, bool toShowDarkMask, ScreenPopCallback popcallback, Dictionary <string, string> propertyList)
        {
            Logger.LogInfo(this, "UIControlBase.AddScreen screen name=" + screenname + " toShowDarkMask=" + toShowDarkMask + " propertyList=" + propertyList);
            UIControlBase uIControlBase = null;
            GameObject    gameObject    = new GameObject(screenname);
            RectTransform rectTransform = gameObject.AddComponent <RectTransform>();

            gameObject.transform.SetParent(ScreenRootObject.transform, worldPositionStays: false);
            rectTransform.anchorMin  = Vector2.zero;
            rectTransform.anchorMax  = Vector2.one;
            rectTransform.offsetMin  = Vector2.zero;
            rectTransform.offsetMax  = Vector2.zero;
            rectTransform.localScale = Vector3.one;
            UIBuilder.Instance.buildScreen(screenname, gameObject);
            uIControlBase = gameObject.GetComponent <UIControlBase>();
            uIControlBase.LoadUI(propertyList);
            ScreenInfo screen = new ScreenInfo(uIControlBase, toShowDarkMask, popcallback);

            PushScreen(screen);
            return(uIControlBase);
        }
示例#10
0
        protected void PushScreen(ScreenInfo screen)
        {
            UIControlBase screenController = screen.screenController;
            UIControlBase uIControlBase    = null;

            if (m_ScreenStack.Count != 0)
            {
                uIControlBase = m_ScreenStack.Peek().screenController;
                if (uIControlBase != null)
                {
                    uIControlBase.OnStacked(screenController.ScreenName);
                }
            }
            m_ScreenStack.Push(screen);
            screen.screenOrder = m_ScreenStack.Count;
            foreach (UIElementBase value in screenController.Elements.Values)
            {
                AdjustScreenDeapth(value.gameObject, MaxDepthPerScreen * m_ScreenStack.Count);
            }
            if (screen.showDarkBG)
            {
                ShowDarkMask(screen);
            }
        }
示例#11
0
 public virtual void ControlLoaded(UIControlBase cbase)
 {
 }