Exemplo n.º 1
0
        /// <summary>
        /// 返回.
        /// </summary>
        /// <returns><c>true</c>, 返回成功, <c>false</c> 无上一步可返回/无需返回.</returns>
        private bool InnerBackUI()
        {
            if (0 < this._uiShowStack.Count)
            {
                UIComponentBase currUI = this._uiShowStack.Peek();
                if (null == currUI)
                {
                    return(false);
                }
                if (false == currUI.IsBackAble)
                {
                    return(false);
                }
                currUI = this._uiShowStack.Pop();
                if (null == currUI)
                {
                    return(false);
                }
                currUI.Close();

                // 替换的场合,回复上一个UI
                if (true == currUI.IsSwap)
                {
                    currUI = this._uiShowStack.Peek();
                    currUI.Open();
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 关闭UI(不包含指定预制体)
        /// </summary>
        /// <param name="uiPrefabName">UI预制体名.</param>
        public void CloseUITo(string uiPrefabName)
        {
            if (string.IsNullOrEmpty(uiPrefabName))
            {
                this.Warning("CloseUI():The prefab name is invalid!!");
                return;
            }

            if (0 >= this._uiShowStack.Count)
            {
                this.Warning("CloseUI():There is no ui left in ui show stack!!");
                return;
            }
            UIComponentBase currUI = null;

            while (true)
            {
                // 推出UI显示栈
                currUI = this._uiShowStack.Peek();
                if (null == currUI)
                {
                    break;
                }
                if (true == uiPrefabName.Equals(currUI.name))
                {
                    currUI.Open();
                    break;
                }
                currUI = this._uiShowStack.Pop();
                currUI.Close();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 打开UI
        /// </summary>
        /// <param name="uiPrefabName">UI预制体名</param>
        /// <returns></returns>
        public UIComponentBase OpenUI(string uiPrefabName)
        {
            UIComponentBase currUI;

            if (!_uiMainPool.TryGetValue(uiPrefabName, out currUI))
            {
                currUI = CreateOrGetUI(uiPrefabName);
                if (currUI != null)
                {
                    foreach (var relationalUIName in currUI.Data.RelationalUINames)
                    {
                        currUI.AddRelationalUI(CreateOrGetUI(relationalUIName));
                    }
                }
            }

            if (currUI != null)
            {
                // 取得上一层UI信息
                if (0 < this._uiShowStack.Count)
                {
                    UIComponentBase lastUI = null;
                    if (false == currUI.IsOverlapping)
                    {
                        lastUI = this._uiShowStack.Peek();
                        if (null != lastUI)
                        {
                            lastUI.Close();
                        }
                    }
                    // 替换UI的场合,把顶层所有Popup的UI移除后,在关闭上一UI
                    if (true == currUI.IsSwap)
                    {
                        while (true)
                        {
                            lastUI = this._uiShowStack.Peek();
                            if (null == lastUI)
                            {
                                break;
                            }
                            if (false == lastUI.IsOverlapping)
                            {
                                break;
                            }
                            lastUI = this._uiShowStack.Pop();
                            lastUI.Close();
                        }
                        if (null != lastUI)
                        {
                            lastUI.Close();
                        }
                    }
                }

                // 将新加载UI放入UI显示堆
                _uiShowStack.Push(currUI);
                currUI.Open();
            }
            return(currUI);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        public void CloseUI()
        {
            if (0 >= this._uiShowStack.Count)
            {
                this.Warning("CloseUI():There is no ui left in ui show stack!!");
                return;
            }
            // 推出UI显示栈
            UIComponentBase currUI = this._uiShowStack.Pop();

            // 推出UI显示栈
            if (null != currUI)
            {
                currUI.Close();
                // 替换的场合,重新打开上一个UI
                if (true == currUI.IsSwap)
                {
                    UIComponentBase _lastInfo = this._uiShowStack.Peek();
                    if (null != _lastInfo)
                    {
                        _lastInfo.Open();
                    }
                }
            }
        }
Exemplo n.º 5
0
    public UIComponentBase CreateUIComponent(string name)
    {
        UIComponentBase ui = null;

        uiComponentPrefabs.TryGetValue(name, out ui);
        var t = Instantiate <UIComponentBase>(ui);

        return(t);
    }
Exemplo n.º 6
0
 /// <summary>
 /// 根据名字来销毁UI(遗留机制所用)
 /// </summary>
 /// <param name="uiname"></param>
 public void DestroyUIByName(string uiname)
 {
     if (m_UITable[uiname] != null)
     {
         SetVisableByUIName(uiname, false);
         UIComponentBase.DestroyInstanceByName(uiname);
         //LuaInterface.Debugger.Log("Destroy:" + uiname);
         m_UITable[uiname] = null;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 取得最上层的UI
        /// </summary>
        /// <returns>最上层的UI.</returns>
        public UIComponentBase GetAboveUI()
        {
            if (0 >= this._uiShowStack.Count)
            {
                return(null);
            }
            UIComponentBase currUI = this._uiShowStack.Peek();

            if (null == currUI)
            {
                return(null);
            }
            return(currUI);
        }
Exemplo n.º 8
0
    /// <summary>
    /// 根据名字来创建UI(遗留机制类型)
    /// </summary>
    /// <param name="uiname"></param>
    public UIComponentBase CreateUIByName(string uiname)
    {
        if (m_UITable[uiname] == null)
        {
            UIComponentBase.CreateInstanceByName(uiname);
        }

        //Debug.Log("Create:" + uiname);
        if (!m_UITable[uiname].gameObject.activeInHierarchy)
        {
            SetVisableByUIName(uiname, true);
        }

        return(m_UITable[uiname]);
    }
        public override void Start()
        {
            UIComponentBase comBase = UISys.Instance.CreateUIByName(typeof(Loading).ToString());

            if (comBase != null)
            {
                Loading loading = comBase as Loading;
                if (loading != null)
                {
                    loading.SetLoadingDesc(mTips);
                }
            }
            //Messenger.BroadcastAsync<string>(MSG_DEFINE.MSG_SCENE_LOAD_LOADINGSCENE_COMPLETE, SceneMgr.Instance.CurrentScene);
            Complete();
        }
Exemplo n.º 10
0
 static int CreateUIByName(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UISys           obj  = (UISys)ToLua.CheckObject(L, 1, typeof(UISys));
         string          arg0 = ToLua.CheckString(L, 2);
         UIComponentBase o    = obj.CreateUIByName(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 11
0
    public T CreateComponent <T>(string name, Transform parent) where T : UIComponentBase
    {
        UIComponentBase ui = null;

        ui = ResourcesManager.instance.CreateUIComponent(name);
        if (ui == null)
        {
            Debug.Log("Check it !!!!");
            return(null);
        }
        ui.transform.SetParent(parent);
        T t = ui as T;

        ui.name = name;
        return(t);
    }
Exemplo n.º 12
0
    public void SetVisableByUIName(string uiname, bool bShow)
    {
        UIComponentBase uiPanel = m_UITable[uiname];

        if (uiPanel != null)
        {
            XY_UILayer.Layer uiLayer = uiPanel.GetUILayer();

            // 主面版直接处理
            if (uiLayer == XY_UILayer.Layer.MainBarLayer)
            {
                uiPanel.Visable(bShow);
                return;
            }

            // 其它面板层保存起来
            if (mCurPanelNameList.ContainsKey(uiLayer) == false)
            {
                mCurPanelNameList[uiLayer]  = null;
                mPanelToCreateList[uiLayer] = new Queue <string>();
            }

            // 先处理当前面板
            string uiNameOld = mCurPanelNameList[uiLayer];
            uiPanel.Visable(bShow);

            // 以下是互斥逻辑
            if (bShow == true)
            {
                if (uiname != uiNameOld)
                {
                    // 将同级的其它面板隐藏起来(互斥)
                    if (uiNameOld != null && uiNameOld.Length > 0)
                    {
                        UIComponentBase.DestroyInstanceByName(uiNameOld);
                        Queue <string> hidePanels = mPanelToCreateList[uiLayer];
                        hidePanels.Enqueue(uiNameOld);
                    }

                    // 更改当前显示的面板
                    mCurPanelNameList[uiLayer] = uiname;
                }
            }
            else
            {
                //从同层的面板中,找到上个显示的,并显示
                if (uiname != uiNameOld)
                {
                    uiPanel.Visable(bShow);
                    // 控制不了控件的销毁与创建时序,暂时用这种方案
                    Queue <string> hidePanels = mPanelToCreateList[uiLayer];
                    if (hidePanels.Contains(uiname))
                    {
                        Debug.Log("----hidePanels.Contains(uiPanel)---------");
                        Queue <string> tmp = new Queue <string>();
                        for (int i = 0; i < hidePanels.Count; ++i)
                        {
                            string tmpName = hidePanels.Dequeue();
                            if (tmpName == uiname)
                            {
                                break;
                            }
                            tmp.Enqueue(tmpName);
                        }

                        for (int i = 0; i < tmp.Count; ++i)
                        {
                            hidePanels.Enqueue(tmp.Dequeue());
                        }
                    }
                }
                else
                {
                    if (uiNameOld != null && uiNameOld.Length > 0)
                    {
                        mCurPanelNameList[uiLayer] = null;
                        Queue <string> hidePanels = mPanelToCreateList[uiLayer];
                        if (hidePanels != null && hidePanels.Count > 0)
                        {
                            mCurPanelNameList[uiLayer] = hidePanels.Dequeue();
                            CreateUIByName(uiNameOld);
                        }
                    }
                    else
                    {
                        mCurPanelNameList[uiLayer] = null;
                    }
                }
            }
        }
    }
Exemplo n.º 13
0
 public virtual void Awake()
 {
     m_UIComponentBase = new UIComponentBase();
     m_UIComponentBase.InitPanel(transform, gameObject);
 }