Ejemplo n.º 1
0
        public virtual void PopState()
        {
            if (states.Count > 0)
            {
                T current = states[states.Count - 1];
                T next    = default(T);
                if (states.Count > 1)
                {
                    next       = states[states.Count - 2];
                    next.State = ScreenState.Active;
                }
                leaveTransition = current.LeaveTransition;
                if (leaveTransition != null)
                {
                    leaveTransition.Init(current, next);
                }
                else
                {
                    leaveTransition = new EmptyTransition();
                }
                current.IsExiting = true;
                current.State     = ScreenState.TransitionOff; // ollaan häivyttämässä
                this.current      = current;
                this.next         = next;

                current.HasFocus = false;
                // viiminen ruutu
                if (next != null)
                {
                    next.HasFocus = false;
                }
            }
        }
Ejemplo n.º 2
0
 public virtual void ChangeState(T state)
 {
     if (states.Count != 0)
     {
         current         = states[states.Count - 1];
         next            = state;
         leaveTransition = current.LeaveTransition;
         if (leaveTransition == null)
         {
             leaveTransition = new EmptyTransition();
         }
         leaveTransition.Init(current, next);
         current.IsExiting = true;
     }
     current.State    = ScreenState.TransitionOff; // ollaan häivyttämässä
     current.HasFocus = false;
     next.HasFocus    = false;
     states.Add(state);
     InitState(state);
 }
Ejemplo n.º 3
0
 public virtual void PushState(T state)
 {
     if (states.Count != 0)
     {
         leaveTransition = (state.IsPopUp) ? null : states[states.Count - 1].LeaveTransition;
         if (leaveTransition != null)
         {
             leaveTransition.Init(states[states.Count - 1], state);
         }
         else
         {
             leaveTransition = new EmptyTransition();
         }
         current       = states[states.Count - 1];
         current.State = ScreenState.TransitionOff; // häivytetään
     }
     next             = state;
     next.HasFocus    = false;
     current.HasFocus = false;
     states.Add(state);
     InitState(state);
 }
Ejemplo n.º 4
0
        public virtual void Update(GameTime time)
        {
            // jos nykyisellä ruudulla on lopetus siirtymä
            if (leaveTransition != null)
            {
                if (!leaveTransition.IsStarted)
                {
                    leaveTransition.Start();
                }
                leaveTransition.Update(time);
                // jos siirtymä on valmis niin vaihdetaan ruutu seuraavaan
                // ja aletaan suorittamaan aloitus siirtymää
                if (leaveTransition.IsFinished)
                {
                    leaveTransition = null;
                    // jos on viiminen ruutu, niin nextiä ei sillon ole
                    if (next != null)
                    {
                        if (next.IsPopUp)
                        {
                            current.State = ScreenState.Background;
                        }
                        else
                        {
                            current.State = ScreenState.Hidden; // ei ole enää näkyvissä
                        }
                        // vaihdetaan ruutujen paikat
                        T prev = current;
                        current = next;
                        // tyhjennetään nykyisen ruudun viite
                        next          = default(T);
                        current.State = ScreenState.TransitionOn; // ollaan häivyttämässä kuvaa sisään
                        if (prev.IsPopUp)
                        {
                            enterTransition = new EmptyTransition();
                        }
                        else
                        {
                            enterTransition = current.EnterTransition;
                        }

                        if (enterTransition == null)
                        {
                            enterTransition = new EmptyTransition();
                        }
                        enterTransition.Init(current, prev);
                    }
                }
            }
            for (int i = states.Count - 1; i >= 0; i--)
            {
                T state = states[i];
                state.Update(time);
            }
            if (enterTransition != null)
            {
                if (!enterTransition.IsStarted)
                {
                    enterTransition.Start();
                }
                enterTransition.Update(time);
                if (enterTransition.IsFinished)
                {
                    enterTransition  = null;
                    current.State    = ScreenState.Active; // nyt ollaan näkyvissä
                    current.HasFocus = true;


                    for (int i = states.Count - 1; i >= 0; i--)
                    {
                        T state = states[i];
                        if (state.IsExiting)
                        {
                            Remove(state);
                        }
                    }
                }
            }
        }