Beispiel #1
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽加载条∽-★-∽--------∽-★-∽------∽-★-∽--------//


        static IPop ShowLoadView(string type_)
        {
            if (string.IsNullOrEmpty(type_))
            {
                ClearLoadView();
                return(null);
            }

            IPop view = KUI.KUIApp.PopMgr.Show(type_, m_mainLoader);

            //ImgAbs2 view = CreateLoadView(type_);

            if (m_loadView == view)
            {
                return(view);
            }

            ClearLoadView();

            m_loadView = view;
            if (m_loadView != null)
            {
                m_loadView.Attach(LOAD_EVT.VIEW_COMPLETE, onMainLoadEvt, null);
            }

            return(null);
        }
Beispiel #2
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        override protected void DestroyPop(IPop pop_)
        {
            KUIPop pop = pop_ as KUIPop;

            pop.Destroy();
            AddToTrash(pop);
        }
Beispiel #3
0
        public static bool TryPeek <T>(this IPop <T> c, out T value)
        {
            bool isEmpty;

            value = c.TryPeek(out isEmpty);
            return(!isEmpty);
        }
Beispiel #4
0
        public static T TryPeek <T>(this IPop <T> c, T defaultValue)
        {
            bool isEmpty;
            T    value = c.TryPeek(out isEmpty);

            return(isEmpty ? defaultValue : value);
        }
Beispiel #5
0
 //是否需要存栈
 protected bool NeedStack(IPop pop_)
 {
     if (pop_.lifeType == POP_LIFE.STACK)
     {
         return(true);
     }
     return(false);
 }
Beispiel #6
0
        //从堆栈移除
        protected virtual void RemoveFromStack(IPop pop_)
        {
            m_openList.Remove(pop_);    //从开启栈移除

            if (NeedStack(pop_))
            {
                //从关闭栈移除
                m_closeList.Remove(pop_);
            }
        }
Beispiel #7
0
 static void ClearLoadView()
 {
     if (m_loadView == null)
     {
         return;
     }
     //m_loadView.Destroy();
     KUI.KUIApp.PopMgr.Close(m_loadView.popID);
     m_loadView = null;
 }
Beispiel #8
0
        /// <summary>
        /// 窗口是否打开
        /// </summary>
        /// <param name="popId_"></param>
        /// <returns></returns>
        public bool PopIsOpen(string popId_)
        {
            IPop pop = GetPop(popId_);

            if (pop == null)
            {
                return(false);
            }
            return(pop.isOpen);
        }
        public static T Peek <T>(this IPop <T> c)
        {
            bool isEmpty;
            T    next = c.TryPeek(out isEmpty);

            if (isEmpty)
            {
                throw new EmptySequenceException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType())));
            }
            return(next);
        }
Beispiel #10
0
        public static T Peek <T>(this IPop <T> c)
        {
            bool isEmpty;
            T    next = c.TryPeek(out isEmpty);

            if (isEmpty)
            {
                throw new InvalidOperationException("The {0} is empty".Localized(c.GetType().Name));
            }
            return(next);
        }
Beispiel #11
0
        public static T Pop <T>(this IPop <T> c)
        {
            bool isEmpty;
            T    next = c.TryPop(out isEmpty);

            if (isEmpty)
            {
                throw new InvalidOperationException(string.Format("The {0} is empty", c.GetType().Name));
            }
            return(next);
        }
Beispiel #12
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽堆栈管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        //添加到开启栈
        protected void AddToOpen(IPop pop_)
        {
            //放到栈头
            m_openList.Remove(pop_);
            m_openList.Add(pop_);

            if (NeedStack(pop_))
            {
                //需要缓存,从关闭列表移除
                m_closeList.Remove(pop_);
            }
        }
Beispiel #13
0
        //-------∽-★-∽窗口弹出∽-★-∽--------//

        public void Pop(IPop pop_)
        {
            string pop_id = pop_.popID;

            Log.Info("Pop Open: " + pop_id, this);

            AddToOpen(pop_);
            AddToLayer(pop_);

            NotifyWithEvent(POP_EVT.POP_OPEN, pop_id);

            //淡入动画
        }
Beispiel #14
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽层级管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        override protected void AddToLayer(IPop pop_)
        {
            KUIPop pop = pop_ as KUIPop;

            pop.popTime = DateUtil.TimeFromStart;  //记录开启时间

            RemoveFromTrash(pop);

            if (!m_sortPopCalled)
            {
                m_sortPopCalled = true;
                TimerMgr.inst.CallDelay(OnSortPop);
            }
        }
Beispiel #15
0
        /// <summary>
        /// 获取已打开的窗口
        /// </summary>
        /// <param name="popId_"></param>
        /// <returns></returns>
        public IPop GetPopOpened(string popId_)
        {
            IPop pop = GetPop(popId_);

            if (pop != null)
            {
                if (pop.isOpen)
                {
                    return(pop);
                }
            }

            return(null);
        }
Beispiel #16
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽窗口预制相关∽-★-∽--------∽-★-∽------∽-★-∽--------//


        //创建窗口
        protected IPop CreatePop(string popId_)
        {
            string url = CC_POP_ID.GetPrefebPath(popId_);

            if (string.IsNullOrEmpty(url))
            {
                Log.Warn("窗口未注册: " + popId_);
                return(null);
            }

            IPop pop = ClassUtil.New(popId_) as IPop;

            pop.popID = popId_;
            return(pop);
        }
Beispiel #17
0
        //移除窗口
        protected void DelPop(string popId_)
        {
            if (!m_id2pop.ContainsKey(popId_))
            {
                return;
            }

            IPop pop = m_id2pop[popId_];

            m_id2pop.Remove(popId_);

            RemoveFromStack(pop);

            pop.DestroyRemove();
            pop.Release(this);
            //GameObjUtil.Delete(pop);
        }
Beispiel #18
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽窗口管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        //添加窗口
        protected void AddPop(IPop pop_)
        {
            string pop_id = pop_.popID;

            if (!m_id2pop.ContainsKey(pop_id))
            {
                m_id2pop[pop_id] = pop_;
                pop_.Retain(this);
            }
            else
            {
                if (m_id2pop[pop_id] != pop_)
                {
                    Log.Assert(false, "repeat pop: " + pop_id, this);
                    return;
                }
            }
        }
Beispiel #19
0
        //-------∽-★-∽窗口关闭∽-★-∽--------//

        /// <summary>
        /// 关闭窗口
        /// </summary>
        /// <param name="popId_"></param>
        /// <param name="force_">强制关闭</param>
        public void Close(string popId_, bool force_ = false)
        {
            IPop pop = GetPopOpened(popId_);

            if (pop == null)
            {
                return;
            }

            if (force_)
            {
                //直接关闭
                ExcuteClose(pop);
                return;
            }

            //淡出动画 -> ExcuteClose
            ExcuteClose(pop);
        }
Beispiel #20
0
        //窗口对齐


        //-------∽-★-∽------∽-★-∽--------∽-★-∽窗口操作∽-★-∽--------∽-★-∽------∽-★-∽--------//


        /// <summary>
        /// 打开窗口
        /// </summary>
        /// <param name="popId_"></param>
        /// <param name="showObjs_"></param>
        public IPop Show(string popId_, object showObjs_, params object[] params_)
        {
            IPop pop = GetPop(popId_);

            if (pop != null)
            {
                pop.Show(showObjs_);
                return(pop);
            }

            pop = CreatePop(popId_);    //创建窗口
            if (pop == null)
            {
                return(null);
            }

            AddPop(pop);    //添加到缓存
            pop.Show(showObjs_, params_);

            return(pop);
        }
Beispiel #21
0
        //执行关闭
        protected void ExcuteClose(IPop pop)
        {
            if (!pop.isOpen)
            {
                return;
            }

            string pop_id = pop.popID;

            DestroyPop(pop);
            AddToClose(pop);

            if (m_openList.Count == 0)
            {
                //没有开启的窗口了
                NotifyWithEvent(POP_EVT.POP_CLOSE_ALL);
            }

            Log.Info("Pop Close: " + pop_id, this);
            NotifyWithEvent(POP_EVT.POP_CLOSE, pop_id);
        }
Beispiel #22
0
        //添加到关闭栈
        protected void AddToClose(IPop pop_)
        {
            m_openList.Remove(pop_);    //从开启栈移除

            if (NeedStack(pop_))
            {
                //放到栈尾
                m_closeList.Remove(pop_);
                m_closeList.Add(pop_);

                if (m_closeList.Count > m_stackMax)
                {
                    //大于最大堆栈数量,删除栈头
                    DelPop(m_closeList[0].popID);
                }
            }
            else if (pop_.lifeType == POP_LIFE.WEAK)
            {
                //弱引用, 直接删除
                DelPop(pop_.popID);
            }
        }
Beispiel #23
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        protected virtual void DestroyPop(IPop pop_)
        {
            pop_.DestroyRemove();
        }
Beispiel #24
0
        public static T TryPeek <T>(this IPop <T> c)
        {
            bool isEmpty;

            return(c.TryPeek(out isEmpty));
        }
Beispiel #25
0
        protected override void RemoveFromStack(IPop pop_)
        {
            base.RemoveFromStack(pop_);

            RemoveFromTrash(pop_ as KUIPop);
        }
    public static void PrintFirstCarDetails(IPop <Car> carStack)
    {
        Car myCar = carStack.Pop();

        Console.WriteLine("Car value popped: {0}", myCar);
    }
Beispiel #27
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽层级管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        /// <summary>
        /// 添加到层级
        /// </summary>
        /// <param name="pop_"></param>
        protected virtual void AddToLayer(IPop pop_)
        {
        }