Exemplo n.º 1
0
 private void ClearAllPanel(UIDisplayControl ctrl)
 {
     if (ctrl == null)
     {
         return;
     }
     if (!ctrl.ClearOpened)
     {
         return;
     }
     for (int i = 0; i < OpenedUIList.Count; i++)
     {
         GameObject panel = OpenedUIList[i];
         // 不存在的跳过
         if (!panel)
         {
             continue;
         }
         UIPanelBehaviour script = panel.GetComponent <UIPanelBehaviour>();
         // 已关闭的跳过
         if (!script.GetActiveSelf())
         {
             continue;
         }
         // 关闭该界面
         StartCoroutine(ClosePanel(script, false));
     }
     OpenedUIList.Clear();
     ClosedUIList.Clear();
 }
Exemplo n.º 2
0
    public static UIDisplayControl GetUIDisplayControl(string name)
    {
        UIDisplayControl ctrl = null;

        UIDisplayControlList.TryGetValue(name, out ctrl);
        return(ctrl);
    }
Exemplo n.º 3
0
    public static bool LoadXml()
    {
        try {
            // 读配置文件
            TextAsset textAsset = ( TextAsset )Resources.Load("Config/Global", typeof(TextAsset));
            if (textAsset == null)
            {
                Debug.Log("can not load resource Config/Global.xml");
                return(false);
            }
            XmlDocument XmlDoc = new XmlDocument();
            XmlDoc.LoadXml(textAsset.text);

            XmlNodeList NodeList = XmlDoc.SelectSingleNode("Config").ChildNodes;
            foreach (XmlNode Node in NodeList)
            {
                if (Node.Name == "SysNotice")
                {
                    int    ID      = AnalyzeXmlToInt(Node, "ID");
                    string Content = AnalyzeXmlToString(Node, "Content");
                    if (Content == "")
                    {
                        continue;
                    }
                    if (!SysNoticeList.ContainsKey(ID))
                    {
                        SysNoticeList.Add(ID, Content);
                    }
                }
                else if (Node.Name == "UIDisplayControl")
                {
                    UIDisplayControl ctrl = new UIDisplayControl();
                    ctrl.UIName      = AnalyzeXmlToString(Node, "UIName");
                    ctrl.DontClose   = AnalyzeXmlToString(Node, "DontClose");
                    ctrl.ClearOpened = AnalyzeXmlToBool(Node, "ClearOpened");
                    ctrl.JustCloseSelfWhenClosing = AnalyzeXmlToBool(Node, "JustCloseSelfWhenClosing");
                    UIDisplayControlList.Add(ctrl.UIName, ctrl);
                }
            }

            InitFormationList();
            return(true);
        }
        catch (Exception err) {
            Debug.Log(err.Message);
            return(false);
        }
    }
Exemplo n.º 4
0
    private IEnumerator OnShowPanel(UIPanelBehaviour behaviour, object[] args)
    {
        string           uiName = behaviour.name;
        UIDisplayControl ctrl   = GlobalConfig.GetUIDisplayControl(uiName);

        ClearAllPanel(ctrl);
        string dontCloseUI = ctrl != null ? ctrl.DontClose : string.Empty;

        if (dontCloseUI != "All" && !string.IsNullOrEmpty(dontCloseUI))
        {
            CloseAllPanel(dontCloseUI.Split(','));
        }
        StartCoroutine(behaviour.Show(args));
        OpenedUIList.Add(behaviour.gameObject);
        ShowUIListContent();
        yield return(null);
    }
Exemplo n.º 5
0
    private IEnumerator OnClosePanel(UIPanelBehaviour script, bool bPlaySound)
    {
        bool bActive = script.GetActiveSelf();

        if (!bActive)
        {
            yield break;
        }
        yield return(StartCoroutine(ClosePanel(script, bPlaySound)));

        OpenedUIList.RemoveAt(OpenedUIList.Count - 1);
        string           uiName = script.name;
        UIDisplayControl ctrl   = GlobalConfig.GetUIDisplayControl(uiName);

        if (ctrl != null)
        {
            if (ctrl.JustCloseSelfWhenClosing)
            {
                yield break;
            }
        }
        if (ClosedUIList.Count <= 0)
        {
            yield break;
        }
        List <GameObject> lastClosedUIList = ClosedUIList[ClosedUIList.Count - 1];

        for (int i = 0; i < lastClosedUIList.Count; i++)
        {
            GameObject panel = lastClosedUIList[i];
            if (!panel)
            {
                continue;
            }
            UIPanelBehaviour panelScript = panel.GetComponent <UIPanelBehaviour>();
            StartCoroutine(panelScript.ReShow());
            OpenedUIList.Add(panel);
        }
        ClosedUIList.RemoveAt(ClosedUIList.Count - 1);
        ShowUIListContent();
    }
 void Awake()
 {
     instance = this;
 }