Esempio n. 1
0
        public void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView
        {
            string assetPath = CheckAssetPath(typeof(T));

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

            int hashCode = typeof(T).GetHashCode();

            if (_stackUiAsset.Count > 0)
            {
                UiAsset uiAsset = _stackUiAsset.Peek();
                //如果界面已经打开 则不在执行
                if (uiAsset.AssetPath == assetPath && !allowMulti)
                {
                    return;
                }
                IUIView uiView = GetUiView(uiAsset);

                //触发暂停事件
                _uiPauseArgs.UIView = uiView;
                _event.Trigger(this, _uiPauseArgs);

                uiView.OnPause();
            }

            UiAsset newUiAsset = null;

            if (!allowMulti)
            {
                if (!_allUiAssets.TryGetValue(hashCode, out newUiAsset))
                {
                    newUiAsset             = new UiAsset(assetPath);
                    _allUiAssets[hashCode] = newUiAsset;
                }
            }
            else
            {
                newUiAsset = new UiAsset(assetPath);
            }

            _stackUiAsset.Push(newUiAsset);
            UIView newUiView = GetUiView(newUiAsset);

            newUiView.OnEnter(parameters);

            //触发打开事件
            _uiEnterArgs.UIView = newUiView;
            _event.Trigger(this, _uiEnterArgs);
        }
Esempio n. 2
0
        public async void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView
        {
            AssetConfig assetConfig = CheckAssetPath(typeof(T));

            if (assetConfig == null)
            {
                return;
            }

            if (_stackUiAsset.Count > 0)
            {
                AssetConfig lastAssetConfig = _stackUiAsset.Peek();
                //如果界面已经打开 则不在执行
                if (Equals(lastAssetConfig, assetConfig) && !allowMulti)
                {
                    return;
                }

                IUIView uiView = await GetUiView(lastAssetConfig);

                //触发暂停事件
                _uiPauseArgs.UIView = uiView;
                _event.Trigger(this, _uiPauseArgs);

                uiView.OnPause();
            }

            AssetConfig newAssetConfig = null;

            if (allowMulti)
            {
                newAssetConfig = new AssetConfig(assetConfig.AssetBundleName, assetConfig.AssetPath);
            }
            else
            {
                newAssetConfig = assetConfig;
            }

            _stackUiAsset.Push(newAssetConfig);
            UIView newUiView = await GetUiView(newAssetConfig);

            newUiView.OnShow(parameters);

            //触发打开事件
            _uiShowArgs.UIView = newUiView;
            _event.Trigger(this, _uiShowArgs);
        }
Esempio n. 3
0
        /// <summary>
        /// 推一个UI界面到栈顶,并打开
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="allowMulti"></param>
        /// <param name="parameters"></param>
        public void Push <T>(bool allowMulti = false, params object[] parameters) where T : UIView
        {
            UIInstance config = GetUIInstance(typeof(T));

            if (config == null)
            {
                return;
            }

            //先将栈顶的UI界面置为暂停状态
            if (_stackUIAsset.Count > 0)
            {
                UIInstance lastConfig = _stackUIAsset.Peek();
                //若该UI已经打开,且不允许加载多个,则返回
                if (Equals(lastConfig, config) && !allowMulti)
                {
                    return;
                }

                IUIView uIView = GetUIView(lastConfig);

                UIEventArgs pauseArgs = new UIEventArgs();
                pauseArgs.UIView = uIView;
                _event.CallEvent(this, EventType.UIPause, pauseArgs);

                uIView.OnPause();
            }

            //UIInstance newConfig = null;
            //newConfig = config;

            //if (allowMulti)
            //    newConfig = new UIInstance(config.AssetBundleName, config.AssetPath);
            //else
            //    newConfig = config;

            _stackUIAsset.Push(config);
            UIView newUIView = GetUIView(config);

            newUIView.OnEnter(parameters);

            //触发打开事件
            UIEventArgs newargs = new UIEventArgs();

            newargs.UIView = newUIView;
            _event.CallEvent(this, EventType.UIEnter, newargs);
        }