From 7df95cd0d482af25bdd1417322e0e111919c93f7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 1 Feb 2006 06:54:15 +0000 Subject: [PATCH] ScreenType is being overloaded in incompatible ways: - the editor sets "system_menu" to trick StepMania.cpp into not allowing the operator menu button, to prevent losing data; - the editor also sets "gameplay" in "playback" mode to influence ScreenSyncOverlay and ScreenDebugOverlay; this breaks the above, allowing scroll lock in play mode. A similar problem happens when we push screens: scroll lock works in the MiniMenus in the editor. It's semantically unintuitive to call the editor a "system_menu", anyway. Split out AllowOperatorMenuButton, and use it directly. Check all screens, and don't allow it if any screen on the stack disallows it. --- stepmania/src/Screen.h | 1 + stepmania/src/ScreenEdit.h | 2 +- stepmania/src/ScreenManager.cpp | 11 +++++++++++ stepmania/src/ScreenManager.h | 1 + stepmania/src/StepMania.cpp | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 27f920b97c..8fb9e0ca44 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -56,6 +56,7 @@ public: virtual bool UsesBackground() const { return true; } // override and set false if this screen shouldn't load a background virtual ScreenType GetScreenType() const { return ALLOW_OPERATOR_MENU_BUTTON ? game_menu : system_menu; } + bool AllowOperatorMenuButton() const { return ALLOW_OPERATOR_MENU_BUTTON; } static bool JoinInput( const MenuInput &MenuI ); // return true if a player joined diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 6ca301366d..8acbe39e66 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -160,7 +160,7 @@ public: virtual void HandleScreenMessage( const ScreenMessage SM ); protected: - virtual ScreenType GetScreenType() const { return m_EditState==STATE_PLAYING ? gameplay : system_menu; } + virtual ScreenType GetScreenType() const { return m_EditState==STATE_PLAYING ? gameplay : ScreenWithMenuElements::GetScreenType(); } void TransitionEditState( EditState em ); void ScrollTo( float fDestinationBeat ); diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 68680faf98..a5d4dfb5f7 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -283,6 +283,17 @@ Screen *ScreenManager::GetTopScreen() return g_ScreenStack[g_ScreenStack.size()-1].m_pScreen; } +bool ScreenManager::AllowOperatorMenuButton() const +{ + FOREACH( LoadedScreen, g_ScreenStack, s ) + { + if( !s->m_pScreen->AllowOperatorMenuButton() ) + return false; + } + + return true; +} + bool ScreenManager::IsStackedScreen( const Screen *pScreen ) const { /* True if the screen is in the screen stack, but not the first. */ diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index c09e727042..a8df7bfa5f 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -40,6 +40,7 @@ public: void PopTopScreen( ScreenMessage SM ); void PopAllScreens(); Screen *GetTopScreen(); + bool AllowOperatorMenuButton() const; // System messages void SystemMessage( const RString &sMessage ); diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index bbbbadc9a4..16b52ec3fd 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1223,7 +1223,7 @@ bool HandleGlobalInputs( const InputEventPlus &input ) /* Global operator key, to get quick access to the options menu. Don't * do this if we're on a "system menu", which includes the editor * (to prevent quitting without storing changes). */ - if( SCREENMAN->GetTopScreen()->GetScreenType() != system_menu ) + if( SCREENMAN->AllowOperatorMenuButton() ) { SCREENMAN->SystemMessage( SERVICE_SWITCH_PRESSED ); GAMESTATE->Reset();