Beispiel #1
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;
     }
 }
Beispiel #2
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;
                    }
                }
            }
        }
    }