Beispiel #1
0
 // Used in case, when screen is hidden, and needs to be transitioned in
 public virtual bool UnhideScreen()
 {
     if ((m_state == MyGuiScreenState.UNHIDING) || (m_state == MyGuiScreenState.OPENED))
     {
         return(false);
     }
     else
     {
         m_state = MyGuiScreenState.UNHIDING;
         m_lastTransitionTime = MyMinerGame.TotalTimeInMilliseconds;
         return(true);
     }
 }
Beispiel #2
0
 protected MyGuiScreenBase(Vector2 position, Vector4?backgroundColor, Vector2?size, bool isTopMostScreen, MyTexture2D backgroundTexture)
 {
     m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK;
     m_position            = position;
     m_backgroundColor     = backgroundColor;
     m_size                        = size;
     m_isTopMostScreen             = isTopMostScreen;
     m_enableBackgroundFade        = false;
     m_backgroundTexture           = backgroundTexture;
     m_screenCanHide               = true;
     m_allowUnhidePreviousScreen   = true;
     m_controls.CollectionChanged += Controls_CollectionChanged;
     m_state                       = MyGuiScreenState.OPENING;
     m_lastTransitionTime          = MyMinerGame.TotalTimeInMilliseconds;
 }
Beispiel #3
0
        //  This will close/remove screen instantly, without fade-out effect
        public virtual void CloseScreenNow()
        {
            if (m_state == MyGuiScreenState.CLOSED)
            {
                return;
            }

            m_state = MyGuiScreenState.CLOSED;

            //  Notify GUI manager that this screen should be removed from the list
            RemoveScreen(this);

            OnClosed();

            if (Closed != null)
            {
                Closed(this);
            }
        }
Beispiel #4
0
        void UpdateTransition()
        {
            if (m_state == MyGuiScreenState.OPENING || m_state == MyGuiScreenState.UNHIDING)
            {
                int deltaTime = MyMinerGame.TotalTimeInMilliseconds - m_lastTransitionTime;

                // Play opening sound
                if (m_state == MyGuiScreenState.OPENING && m_openingCueEnum != null && m_openingCue == null)
                {
                    m_openingCue = MyAudio.AddCue2D(m_openingCueEnum.Value);
                }

                if (deltaTime >= GetTransitionOpeningTime())
                {
                    //  Opening phase finished, we are now in active state
                    m_state           = MyGuiScreenState.OPENED;
                    m_transitionAlpha = MyGuiConstants.TRANSITION_ALPHA_MAX;
                    m_openingCue      = null;

                    OnShow();
                }
                else
                {
                    m_transitionAlpha = MathHelper.Lerp(MyGuiConstants.TRANSITION_ALPHA_MIN, MyGuiConstants.TRANSITION_ALPHA_MAX, MathHelper.Clamp((float)deltaTime / (float)GetTransitionOpeningTime(), 0, 1));
                }
            }
            else if (m_state == MyGuiScreenState.CLOSING || m_state == MyGuiScreenState.HIDING)
            {
                int deltaTime = MyMinerGame.TotalTimeInMilliseconds - m_lastTransitionTime;

                if (deltaTime >= GetTransitionClosingTime())
                {
                    m_transitionAlpha = MyGuiConstants.TRANSITION_ALPHA_MIN;

                    //  Closing phase finished, we are now in close state
                    if (m_state == MyGuiScreenState.CLOSING)
                    {
                        CloseScreenNow();
                    }
                    else if (m_state == MyGuiScreenState.HIDING)
                    {
                        m_state = MyGuiScreenState.HIDDEN;

                        OnHide();
                    }
                }
                else
                {
                    //  While closing this screen, check if there is some screen that should unhide now, so that alpha transition goes in parallel with this screen
                    if (m_state == MyGuiScreenState.CLOSING && MyGuiManager.IsAnyScreenOpening() == false && m_transitionAlpha == 1.0f)
                    {
                        MyGuiScreenBase topHiddenScreen = MyGuiManager.GetTopHiddenScreen();
                        if (topHiddenScreen != null)
                        {
                            topHiddenScreen.UnhideScreen();
                        }
                    }
                    m_transitionAlpha = MathHelper.Lerp(MyGuiConstants.TRANSITION_ALPHA_MAX, MyGuiConstants.TRANSITION_ALPHA_MIN, MathHelper.Clamp((float)deltaTime / (float)GetTransitionClosingTime(), 0, 1));
                }
            }
        }
Beispiel #5
0
 public void SetState(MyGuiScreenState value)
 {
     m_state = value;
 }
        void UpdateTransition()
        {
            if (m_state == MyGuiScreenState.OPENING || m_state == MyGuiScreenState.UNHIDING)
            {
                int deltaTime = MyMinerGame.TotalTimeInMilliseconds - m_lastTransitionTime;

                // Play opening sound
                if (m_state == MyGuiScreenState.OPENING && m_openingCueEnum != null && m_openingCue == null) m_openingCue = MyAudio.AddCue2D(m_openingCueEnum.Value);

                if (deltaTime >= GetTransitionOpeningTime())
                {
                    //  Opening phase finished, we are now in active state
                    m_state = MyGuiScreenState.OPENED;
                    m_transitionAlpha = MyGuiConstants.TRANSITION_ALPHA_MAX;
                    m_openingCue = null;

                    OnShow();
                }
                else
                {
                    m_transitionAlpha = MathHelper.Lerp(MyGuiConstants.TRANSITION_ALPHA_MIN, MyGuiConstants.TRANSITION_ALPHA_MAX, MathHelper.Clamp((float)deltaTime / (float)GetTransitionOpeningTime(), 0, 1));
                }
            }
            else if (m_state == MyGuiScreenState.CLOSING || m_state == MyGuiScreenState.HIDING)
            {
                int deltaTime = MyMinerGame.TotalTimeInMilliseconds - m_lastTransitionTime;

                if (deltaTime >= GetTransitionClosingTime())
                {
                    m_transitionAlpha = MyGuiConstants.TRANSITION_ALPHA_MIN;

                    //  Closing phase finished, we are now in close state
                    if (m_state == MyGuiScreenState.CLOSING)
                    {
                        CloseScreenNow();
                    }
                    else if (m_state == MyGuiScreenState.HIDING)
                    {
                        m_state = MyGuiScreenState.HIDDEN;

                        OnHide();
                    }
                }
                else
                {
                    //  While closing this screen, check if there is some screen that should unhide now, so that alpha transition goes in parallel with this screen
                    if (m_state == MyGuiScreenState.CLOSING && MyGuiManager.IsAnyScreenOpening() == false && m_transitionAlpha == 1.0f)
                    {
                        MyGuiScreenBase topHiddenScreen = MyGuiManager.GetTopHiddenScreen();
                        if (topHiddenScreen != null)
                        {
                            topHiddenScreen.UnhideScreen();
                        }
                    }
                    m_transitionAlpha = MathHelper.Lerp(MyGuiConstants.TRANSITION_ALPHA_MAX, MyGuiConstants.TRANSITION_ALPHA_MIN, MathHelper.Clamp((float)deltaTime / (float)GetTransitionClosingTime(), 0, 1));
                }
            }
        }
        //  This will close/remove screen instantly, without fade-out effect
        public virtual void CloseScreenNow()
        {
            if (m_state == MyGuiScreenState.CLOSED)
            {
                return;
            }
            
            m_state = MyGuiScreenState.CLOSED;
            
            //  Notify GUI manager that this screen should be removed from the list
            RemoveScreen(this);

            OnClosed();

            if (Closed != null)
            {
                Closed(this);
            }
        }
 // Used in case, when screen is hidden, and needs to be transitioned in
 public virtual bool UnhideScreen()
 {
     if ((m_state == MyGuiScreenState.UNHIDING) || (m_state == MyGuiScreenState.OPENED))
     {
         return false;
     }
     else
     {
         m_state = MyGuiScreenState.UNHIDING;
         m_lastTransitionTime = MyMinerGame.TotalTimeInMilliseconds;
         return true;
     }
 }
 public void SetState(MyGuiScreenState value)
 {
     m_state = value;
 }
 protected MyGuiScreenBase(Vector2 position, Vector4? backgroundColor, Vector2? size, bool isTopMostScreen, MyTexture2D backgroundTexture) 
 {
     m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK;
     m_position = position;
     m_backgroundColor = backgroundColor;
     m_size = size;
     m_isTopMostScreen = isTopMostScreen;
     m_enableBackgroundFade = false;
     m_backgroundTexture = backgroundTexture;
     m_screenCanHide = true;
     m_allowUnhidePreviousScreen = true;
     m_controls.CollectionChanged += Controls_CollectionChanged;
     m_state = MyGuiScreenState.OPENING;
     m_lastTransitionTime = MyMinerGame.TotalTimeInMilliseconds;
 }