Пример #1
0
    /// <summary>
    /// 退出UI(Normal)
    /// </summary>
    /// <param name="uiName"></param>
    private void ExitUIForms(string uiName)
    {
        BaseUIForm baseUIForm = null;

        currentUIForms.TryGetValue(uiName, out baseUIForm);

        if (baseUIForm == null)
        {
            return;
        }

        baseUIForm.Hiding();
        currentUIForms.Remove(uiName);
    }
Пример #2
0
    /// <summary>
    /// 根据UI窗体的名称,从_dicAllUIForms中加载,如果加载不出来,调用LoadUIForm从Resources中加载
    /// </summary>
    /// <param name="uriFormsName">UI窗体(预设)的名称</param>
    /// <returns>加载的UI窗体基类</returns>
    private BaseUIForm LoadFormsFromAllUIFormsCache(string strFormsName)
    {
        Debug.Log("LoadFormsToAllUIFormsCache:" + strFormsName);
        BaseUIForm baseUIResult = null;

        //判断“所有UI集合缓存”中是否有制定的UI窗体,没有则加载窗体
        _dicAllUIForms.TryGetValue(strFormsName, out baseUIResult);
        if (baseUIResult == null)
        {
            //加载制定名称的“UI窗体”
            baseUIResult = LoadUIForm(strFormsName);
        }

        return(baseUIResult);
    }
Пример #3
0
 //(“反向切换”属性)窗体的出栈逻辑
 private void PopUIForms()
 {
     if (CurrentUIFormsStack.Count >= 2)
     {
         BaseUIForm topUIForms = CurrentUIFormsStack.Pop();
         topUIForms.Hide();
         BaseUIForm nextUIForms = CurrentUIFormsStack.Peek();
         nextUIForms.Display();
     }
     else if (CurrentUIFormsStack.Count == 1)
     {
         BaseUIForm topUIForms = CurrentUIFormsStack.Pop();
         topUIForms.Hide();
     }
 }
Пример #4
0
 /// <summary>
 /// 退出UI(Reverse)
 /// </summary>
 private void Reverse()
 {
     if (stackUIForms.Count >= 2)
     {
         BaseUIForm toPop = stackUIForms.Pop();
         toPop.Hiding();
         BaseUIForm top = stackUIForms.Peek();
         top.ReDisplay();
     }
     else if (stackUIForms.Count == 1)
     {
         BaseUIForm toPop = stackUIForms.Pop();
         toPop.Hiding();
     }
 }
Пример #5
0
    /// <summary>
    /// 显示(打开)UI窗体
    /// 功能:
    /// 1: 根据UI窗体的名称,加载到“所有UI窗体”缓存集合中
    /// 2: 根据不同的UI窗体的“显示模式”,分别作不同的加载处理
    /// </summary>
    /// <param name="uiFormName">UI窗体预设的名称</param>
    public void ShowUIForms(string uiFormName)
    {
        if (currtUIFormName == uiFormName)
        {
            ExitUIForms(uiFormName);
        }
        BaseUIForm baseUIForms = null;                            //UI窗体基类

        //参数的检查
        if (string.IsNullOrEmpty(uiFormName))
        {
            return;
        }

        //根据UI窗体的名称,加载到“所有UI窗体”缓存集合中
        baseUIForms = LoadFormsToAllUIFormsCatch(uiFormName);
        if (baseUIForms == null)
        {
            return;
        }

        //是否清空“栈集合”中得数据
        if (baseUIForms.CurrentUIType.IsClearStack)
        {
            ClearStackArray();
        }
        currtUIFormName = uiFormName;
        //根据不同的UI窗体的显示模式,分别作不同的加载处理
        switch (baseUIForms.CurrentUIType.UIForms_ShowMode)
        {
        case UIFormShowMode.Normal:                                 //“普通显示”窗口模式
            //把当前窗体加载到“当前窗体”集合中。
            LoadUIToCurrentCache(uiFormName);
            break;

        case UIFormShowMode.ReverseChange:                          //需要“反向切换”窗口模式
            PushUIFormToStack(uiFormName);
            break;

        case UIFormShowMode.HideOther:                              //“隐藏其他”窗口模式
            EnterUIFormsAndHideOther(uiFormName);
            break;

        default:
            break;
        }
    }
Пример #6
0
 /// <summary>
 /// UI界面出栈
 /// </summary>
 private void PopUIForms()
 {
     if (_stackCurrentUIForms.Count >= 2)
     {
         //栈顶出栈并隐藏
         BaseUIForm topUIForm = _stackCurrentUIForms.Pop();
         topUIForm.Hiding();
         //新栈顶显示
         BaseUIForm nextUIForm = _stackCurrentUIForms.Peek();
         nextUIForm.ReDisplay();
     }
     else if (_stackCurrentUIForms.Count == 1)
     {
         //栈顶出栈并隐藏
         BaseUIForm topUIForm = _stackCurrentUIForms.Pop();
         topUIForm.Hiding();
     }
 }
Пример #7
0
    /// <summary>
    /// UI窗体入栈
    /// </summary>
    /// <param name="uiFormName">窗体的名称</param>
    private void PushUIFormToStack(string uiFormName)
    {
        if (CurrentUIFormsStack.Count > 0)
        {
            BaseUIForm topUIForm = CurrentUIFormsStack.Peek();
            topUIForm.Freeze();
        }

        AllUIFormDict.TryGetValue(uiFormName, out BaseUIForm baseUIForm);
        if (baseUIForm != null)
        {
            baseUIForm.Display();
            CurrentUIFormsStack.Push(baseUIForm);
        }
        else
        {
            Debug.Log("baseUIForm==null,Please Check, 参数 uiFormName=" + uiFormName);
        }
    }
Пример #8
0
    /// <summary>
    /// 显示UI窗口
    /// 1.根据UI窗体的名称,加载到“所有UI窗体”缓存集合中
    /// 2.根据不同的UI窗体的“显示模式”,分别做不同的加载处理
    /// </summary>
    /// <param name="uriFormName">UI窗体预设的名称</param>
    public void ShowUIForms(string uriFormName)
    {
        Debug.Log("ShowUIForms:" + uriFormName);
        BaseUIForm baseUIForm = null;

        //参数检查
        if (string.IsNullOrEmpty(uriFormName))
        {
            return;
        }

        //加载UI窗体到所有窗体缓存中
        baseUIForm = LoadFormsFromAllUIFormsCache(uriFormName);
        if (baseUIForm == null)
        {
            return;
        }

        //判断是否清空“栈”集合
        if (baseUIForm.CurrentUIType.IsClearReverseChange)
        {
            ClearStackArray();
        }

        switch (baseUIForm.CurrentUIType.UIForm_ShowMode)
        {
        case UIFormShowMode.Normal:
            EnterUIformCache(uriFormName);
            break;

        case UIFormShowMode.ReverseChange:
            PushUIForms(uriFormName);
            break;

        case UIFormShowMode.HideOther:
            EnterUIFormsToCacheHideOther(uriFormName);
            break;

        default:
            break;
        }
    }
Пример #9
0
    /// <summary>
    /// 弹窗入栈(Reverse)
    /// </summary>
    /// <param name="uiName"></param>
    private void PushUIFormToStack(string uiName)
    {
        BaseUIForm baseUIForm;

        if (stackUIForms.Count > 0)
        {
            BaseUIForm topUIForm = stackUIForms.Peek();
            topUIForm.Freeze();
        }
        allUIForms.TryGetValue(uiName, out baseUIForm);
        if (baseUIForm != null)
        {
            stackUIForms.Push(baseUIForm);
            baseUIForm.Display();
        }
        else
        {
            Debug.LogError("error:该控件不存在");
        }
    }
Пример #10
0
 //(“反向切换”属性)窗体的出栈逻辑
 private void PopUIFroms()
 {
     if (_StaCurrentUIForms.Count >= 2)
     {
         //出栈处理
         BaseUIForm topUIForms = _StaCurrentUIForms.Pop();
         //做隐藏处理
         topUIForms.Hiding();
         //出栈后,下一个窗体做“重新显示”处理。
         BaseUIForm nextUIForms = _StaCurrentUIForms.Peek();
         nextUIForms.Redisplay();
     }
     else if (_StaCurrentUIForms.Count == 1)
     {
         //出栈处理
         BaseUIForm topUIForms = _StaCurrentUIForms.Pop();
         //做隐藏处理
         topUIForms.Hiding();
     }
 }
Пример #11
0
    /// <summary>
    /// 退出UI(HideOther)
    /// </summary>
    /// <param name="uiName"></param>
    private void ExitUIFormsAndShowOther(string uiName)
    {
        BaseUIForm baseUIForm = null;

        currentUIForms.TryGetValue(uiName, out baseUIForm);

        if (baseUIForm == null)
        {
            return;
        }
        baseUIForm.Hiding();
        currentUIForms.Remove(uiName);
        foreach (BaseUIForm b in currentUIForms.Values)
        {
            b.ReDisplay();
        }
        foreach (BaseUIForm b in stackUIForms)
        {
            b.ReDisplay();
        }
    }
Пример #12
0
    /// <summary>
    /// 加载UI到当前UI缓存池中(Normal)
    /// </summary>
    /// <param name="uiName"></param>
    /// <returns></returns>
    private void LoadUIFormToCurrentUIFormCache(string uiName)
    {
        BaseUIForm baseUIForm           = null;
        BaseUIForm baseUIFormInAllCache = null;

        //先在当前UI缓存中查找
        currentUIForms.TryGetValue(uiName, out baseUIForm);
        if (baseUIForm != null)
        {
            return;
        }
        //在UI缓存中查找
        allUIForms.TryGetValue(uiName, out baseUIFormInAllCache);
        if (baseUIFormInAllCache != null)
        {
            currentUIForms.Add(uiName, baseUIFormInAllCache);
            baseUIFormInAllCache.Display();
        }
        else
        {
            Debug.LogError("error:该控件不存在");
        }
    }
Пример #13
0
    /// <summary>
    /// 显示UI
    /// </summary>
    /// <param name="uiName"></param>
    public void ShowUIForm(string uiName)
    {
        BaseUIForm baseUIForm = null;

        if (uiName == null)
        {
            return;
        }
        baseUIForm = LoadUIFormToAllUIFormsCache(uiName);
        if (baseUIForm == null)
        {
            return;
        }

        if (baseUIForm.CurrentUIType.isClear)
        {
            stackUIForms.Clear();
        }

        switch (baseUIForm.CurrentUIType.uIFormShowMode)
        {
        case UIFormShowMode.Normal:
            LoadUIFormToCurrentUIFormCache(uiName);
            break;

        case UIFormShowMode.Reverse:
            PushUIFormToStack(uiName);
            break;

        case UIFormShowMode.HideOther:
            ShowUIFormAndHideOther(uiName);
            break;

        default:
            break;
        }
    }
Пример #14
0
    private void PushUIForms(string strUIFormName)
    {
        BaseUIForm baseUIForm;

        //冻结栈顶的界面
        if (_stackCurrentUIForms.Count > 0)
        {
            BaseUIForm topUIForms = _stackCurrentUIForms.Peek();
            topUIForms.Freeze();
        }

        //显示指定名称的界面
        _dicAllUIForms.TryGetValue(strUIFormName, out baseUIForm);
        if (baseUIForm != null)
        {
            baseUIForm.Display();
        }
        else
        {
            Debug.Log("PushUIForms出错, strUIFormName = " + strUIFormName);
        }
        //指定的UI界面入栈
        _stackCurrentUIForms.Push(baseUIForm);
    }
Пример #15
0
    public BaseUIForm ShowUIForm(string uiFormName)
    {
        BaseUIForm baseUIForms = LoadFormsToAllUIFormsCache(uiFormName); //根据UI窗体的名称,加载到“所有UI窗体”缓存集合中

        if (baseUIForms == null)
        {
            return(null);
        }
        if (baseUIForms.UIType.IsClearStack)
        {
            ClearStackArray();                                  //是否清空“栈集合”中得数据
        }
        //根据不同的UI窗体的显示模式,分别作不同的加载处理
        switch (baseUIForms.UIType.UIForms_ShowMode)
        {
        case UIFormShowModes.Normal:     //“普通显示”窗口模式
            //把当前窗体加载到“当前窗体”集合中。
            LoadUIToCurrentCache(uiFormName);
            break;

        case UIFormShowModes.Return:     //“反向切换”窗口模式
            PushUIFormToStack(uiFormName);
            break;

        case UIFormShowModes.ReturnHideOther:     //“反向切换且隐藏其他窗口”窗口模式
            EnterUIFormsAndHideOtherAndReturn(uiFormName);
            break;

        case UIFormShowModes.HideOther:     //“隐藏其他”窗口模式
            EnterUIFormsAndHideOther(uiFormName);
            break;
        }

        //Debug.Log("showUI  " + uiFormName);
        return(baseUIForms);
    }
Пример #16
0
    /// <summary>
    /// 关闭或返回上一个UI窗口(关闭当前UI窗口)
    /// </summary>
    /// <param name="strUIFormName"></param>
    public void CloseOrReturnUIForms(string strUIFormName)
    {
        BaseUIForm baseUIForm = null;

        if (string.IsNullOrEmpty(strUIFormName))
        {
            return;
        }

        //"所有UI窗口缓存"如果没有记录,则直接返回
        _dicAllUIForms.TryGetValue(strUIFormName, out baseUIForm);
        print(baseUIForm == null);
        if (baseUIForm == null)
        {
            return;
        }

        //根据窗口的显示模式,进行退出处理
        switch (baseUIForm.CurrentUIType.UIForm_ShowMode)
        {
        case UIFormShowMode.Normal:
            ExitUIFormCache(strUIFormName);
            break;

        case UIFormShowMode.ReverseChange:
            PopUIForms();
            break;

        case UIFormShowMode.HideOther:
            ExitUIFormFromCacheAndShowOther(strUIFormName);
            break;

        default:
            break;
        }
    }
Пример #17
0
    public bool IsPeekUIForm <T>() where T : BaseUIForm
    {
        BaseUIForm peek = GetPeekUIForm();

        return(peek != null && peek is T);
    }
Пример #18
0
    /// <summary>
    /// 加载指定名称的“UI窗体”
    /// 功能:
    ///    1:根据“UI窗体名称”,加载预设克隆体。
    ///    2:根据不同预设克隆体中带的脚本中不同的“位置信息”,加载到“根窗体”下不同的节点。
    ///    3:隐藏刚创建的UI克隆体。
    ///    4:把克隆体,加入到“所有UI窗体”(缓存)集合中。
    ///
    /// </summary>
    /// <param name="uiFormName">UI窗体名称</param>
    private BaseUIForm LoadUIForm(string uiFormName)
    {
        string     strUIFormPaths   = null;             //UI窗体路径
        GameObject goCloneUIPrefabs = null;             //创建的UI克隆体预设
        BaseUIForm baseUiForm       = null;             //窗体基类


        //根据UI窗体名称,得到对应的加载路径
        _DicFormsPaths.TryGetValue(uiFormName, out strUIFormPaths);
        //根据“UI窗体名称”,加载“预设克隆体”
        if (!string.IsNullOrEmpty(strUIFormPaths))
        {
            goCloneUIPrefabs      = ResourcesMgr.GetInstance().LoadAsset(strUIFormPaths, false);
            goCloneUIPrefabs.name = uiFormName;
        }
        //设置“UI克隆体”的父节点(根据克隆体中带的脚本中不同的“位置信息”)
        if (_TraCanvasTransfrom != null && goCloneUIPrefabs != null)
        {
            baseUiForm = goCloneUIPrefabs.GetComponent <BaseUIForm>();
            if (baseUiForm == null)
            {
                Debug.Log("baseUiForm==null! ,请先确认窗体预设对象上是否加载了baseUIForm的子类脚本! 参数 uiFormName=" + uiFormName);
                return(null);
            }
            switch (baseUiForm.CurrentUIType.UIForms_Type)
            {
            case UIFormType.Normal:                     //普通窗体节点
                goCloneUIPrefabs.transform.SetParent(_TraNormal, false);
                break;

            case UIFormType.Fixed:                      //固定窗体节点
                goCloneUIPrefabs.transform.SetParent(_TraFixed, false);
                break;

            case UIFormType.Tip:                      //固定窗体节点
                goCloneUIPrefabs.transform.SetParent(_TraTip, false);
                break;

            case UIFormType.PopUp:                      //弹出窗体节点
                goCloneUIPrefabs.transform.SetParent(_TraPopUp, false);
                break;

            case UIFormType.PopUpAttendant:                      //弹出窗体节点
                goCloneUIPrefabs.transform.SetParent(_TraPopUp, false);
                break;

            default:
                break;
            }

            //设置隐藏
            //goCloneUIPrefabs.SetActive(false);
            //把克隆体,加入到“所有UI窗体”(缓存)集合中。
            _DicALLUIForms.Add(uiFormName, baseUiForm);
            return(baseUiForm);
        }
        else
        {
            Debug.Log("_TraCanvasTransfrom==null Or goCloneUIPrefabs==null!! ,Plese Check!, 参数uiFormName=" + uiFormName);
        }

        Debug.Log("出现不可以预估的错误,请检查,参数 uiFormName=" + uiFormName);
        return(null);
    }//Mehtod_end