Exemplo n.º 1
0
    private void RealShowWindow(UIWindowBase baseWindow, ShowWindowData?data = null)
    {
        object param = null;

        if (data != null)
        {
            ShowWindowData winData = data.Value;
            param = winData.param;
        }

        baseWindow.ShowWindow(param);
        showWindows [baseWindow.WindowID] = baseWindow;

        if (baseWindow.IsNavigationWindow)
        {
            lastShownWindow = curShownWindow;
            curShownWindow  = baseWindow;

            UIWindowData windowData = curShownWindow.windowData;
            if (lastShownWindow != null && lastShownWindow != curShownWindow && !windowData.forceClearNavigation)
            {
                curShownWindow.PreWindowID = lastShownWindow.WindowID;
            }

            Debug.Log("<color=magenta>### current Navigation window </color>" + baseWindow.WindowID.ToString());
        }
    }
Exemplo n.º 2
0
    private void OnEnterBtnClick(GameObject sender)
    {
        UIManager.Instance.ShowWindow(GameWindowID.WINDOWID_MAIN_GAME);

        // DestoryOtherWindow 包括固定窗口
        // 这里尝试给另外一个窗口传递参数
        ShowWindowData winData = ShowWindowData.Create();

        winData.param = CSUserManager.Instance.GetUserCoin();
        UIManager.Instance.ShowWindow(GameWindowID.WINDOWID_USER_INFO_BAR, winData);
    }
Exemplo n.º 3
0
    static public ShowWindowData Create()
    {
        ShowWindowData data = new ShowWindowData();

        data.forceResetWindow      = false;
        data.forceClearBackSeqData = false;
        data.executeNavLogic       = true;
        data.checkNavigation       = false;
        data.hideAllOtherWindow    = true;
        data.param = null;

        return(data);
    }
Exemplo n.º 4
0
    public static void ShowWindow(int windowId, LuaTable winData)
    {
        ShowWindowData data = ShowWindowData.Create();

        data.forceResetWindow      = winData.RawGet <bool>("forceResetWindow");
        data.forceClearBackSeqData = winData.RawGet <bool>("forceClearBackSeqData");
        data.executeNavLogic       = winData.RawGet <bool>("executeNavLogic");
        data.checkNavigation       = winData.RawGet <bool>("checkNavigation");
        data.hideAllOtherWindow    = winData.RawGet <bool>("hideAllOtherWindow");
        data.param = winData["param"];

        UIManager.Instance.ShowWindow(windowId, data);
    }
Exemplo n.º 5
0
    public void CloseWindow(int windowId)
    {
        if (!IsRegisterWindow(windowId))
        {
            Debug.LogError("## Current UI Manager has no control power of " + windowId.ToString());
            return;
        }

        UIWindowBase window = null;

        if (!showWindows.TryGetValue(windowId, out window))
        {
            return;
        }

        if (this.backSequence.Count > 0)
        {
            BackWindowSequenceData seqData = this.backSequence.Peek();
            if (seqData != null && seqData.hideTargetWindow == window)
            {
                ReturnWindow();
                Debug.Log("<color=magenta>## close window use PopNavigationWindow() ##</color>");
                return;
            }
        }

        HideWindow(windowId, delegate
        {
            ShowWindowData showData  = new ShowWindowData();
            showData.executeNavLogic = false;

            int preWindowId = window.PreWindowID;
            if (preWindowId == UIWindowID.WINDOWID_INVAILD)
            {
                Debug.LogWarning("## CurrentShownWindow " + window.WindowID + " preWindowId is " + UIWindowID.WINDOWID_INVAILD);
                return;
            }

            ShowWindow(preWindowId, null);
        });

        Debug.Log("<color=magenta>## close window without PopNavigationWindow() ##</color>");
    }
Exemplo n.º 6
0
    public override void ShowWindow(WindowID id, ShowWindowData data = null)
    {
        UIBaseWindow baseWindow = ReadyToShowBaseWindow(id, data);

        if (baseWindow != null)
        {
            RealShowWindow(baseWindow, id);

            // 是否清空当前导航信息(回到主菜单)
            if (baseWindow.windowData.isStartWindow)
            {
                Debug.Log("[Enter the start window, reset the backSequenceData for the navigation system.]");
                ClearBackSequence();
            }

            if (data != null && data.forceClearBackSeqData)
            {
                ClearBackSequence();
            }
        }
    }
Exemplo n.º 7
0
 protected virtual UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
 {
     return(null);
 }
Exemplo n.º 8
0
    private IEnumerator _ShowWindowDelay(float delayTime, WindowID id, ShowWindowData data = null)
    {
        yield return(new WaitForSeconds(delayTime));

        ShowWindow(id, data);
    }
Exemplo n.º 9
0
 /// <summary>
 /// Delay 显示界面
 /// </summary>
 /// <param name="delayTime"> 延迟时间</param>
 /// <param name="id"> 界面ID</param>
 /// <param name="data">显示数据</param>
 public virtual void ShowWindowDelay(float delayTime, WindowID id, ShowWindowData data = null)
 {
     StartCoroutine(_ShowWindowDelay(delayTime, id, data));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 显示界面
 /// </summary>
 /// <param name="id">界面ID</param>
 public virtual void ShowWindow(WindowID id, ShowWindowData data = null)
 {
 }
Exemplo n.º 11
0
    protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
    {
        // 检测控制权限
        if (!this.IsWindowInControl(id))
        {
            Debug.Log("UIManager has no control power of " + id.ToString());
            return(null);
        }
        if (shownWindows.ContainsKey(id))
        {
            return(null);
        }

        // 隐藏callWindowId指向窗口

        /*if(showData != null)
         *  HideWindow(showData.callWindowId, null);*/

        UIBaseWindow baseWindow = GetGameWindow(id);
        bool         newAdded   = false;

        if (!baseWindow)
        {
            newAdded = true;
            // 窗口不存在从内存进行加载
            if (UIResourceDefine.windowPrefabPath.ContainsKey(id))
            {
                string     prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[id];
                GameObject prefab     = Resources.Load <GameObject>(prefabPath);
                if (prefab != null)
                {
                    GameObject uiObject = (GameObject)GameObject.Instantiate(prefab);
                    NGUITools.SetActive(uiObject, true);
                    baseWindow = uiObject.GetComponent <UIBaseWindow>();
                    // 需要动态添加对应的控制界面,prefab不用添加脚本
                    Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType);
                    GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform);
                    allWindows[id] = baseWindow;
                }
            }
        }

        if (baseWindow == null)
        {
            Debug.LogError("[window instance is null.]" + id.ToString());
        }

        // 重置界面(第一次添加,强制Reset)
        if (newAdded || (showData != null && showData.forceResetWindow))
        {
            baseWindow.ResetWindow();
        }

        // 显示界面固定内容


        // 导航系统数据更新
        RefreshBackSequenceData(baseWindow);
        // 调整层级depth
        AdjustBaseWindowDepth(baseWindow);
        // 添加背景Collider
        AddColliderBgForWindow(baseWindow);
        return(baseWindow);
    }