allow overlay layers to grab focus

This commit is contained in:
Glenn Maynard
2005-02-28 05:33:24 +00:00
parent 1d854909c6
commit 38b5955b52
2 changed files with 36 additions and 5 deletions
+29 -4
View File
@@ -54,6 +54,7 @@ void ScreenManager::Register( const CString& sClassName, CreateScreenFn pfn )
ScreenManager::ScreenManager()
{
m_pSharedBGA = new Actor;
m_pInputFocus = NULL;
m_MessageSendOnPop = SM_None;
@@ -239,8 +240,12 @@ void ScreenManager::Input( const DeviceInput& DeviceI, const InputEventType type
// DeviceI.device, DeviceI.button, GameI.controller, GameI.button, MenuI.player, MenuI.button, StyleI.player, StyleI.col );
// pass input only to topmost state
if( !m_ScreenStack.empty() )
m_ScreenStack.back()->Input( DeviceI, type, GameI, MenuI, StyleI );
Screen *pInputFocus = m_pInputFocus;
if( pInputFocus == NULL && !m_ScreenStack.empty() )
pInputFocus = m_ScreenStack.back();
if( pInputFocus != NULL )
pInputFocus->Input( DeviceI, type, GameI, MenuI, StyleI );
}
/* Just create a new screen; don't do any associated cleanup. */
@@ -551,11 +556,31 @@ void ScreenManager::SystemMessageNoAnimate( const CString &sMessage )
MESSAGEMAN->Broadcast( "SystemMessageNoAnimate" );
}
CString ScreenManager::GetCurrentSystemMessage() const
bool ScreenManager::GrabInputFocus( const Screen *pScreen )
{
return m_sSystemMessage;
if( m_pInputFocus != NULL )
return false;
/* Sanity check: make sure that the screen is in m_OverlayScreens. */
for( unsigned i = 0; i < m_OverlayScreens.size(); ++i )
{
if( m_OverlayScreens[i] == pScreen )
{
m_pInputFocus = m_OverlayScreens[i];
return true;
}
}
FAIL_M( "GrabInputFocus: unknown screen" );
}
void ScreenManager::ReleaseInputFocus( const Screen *pScreen )
{
ASSERT( m_pInputFocus == pScreen );
m_pInputFocus = NULL;
}
void ScreenManager::RefreshCreditsMessages()
{
MESSAGEMAN->Broadcast( "RefreshCreditText" );
+7 -1
View File
@@ -53,7 +53,12 @@ public:
void RefreshCreditsMessages();
void ThemeChanged();
CString GetCurrentSystemMessage() const;
CString GetCurrentSystemMessage() const { return m_sSystemMessage; }
/* Overlay screens can grab input focus. Only one screen may grab at a time;
* if another screen has already taken focus, this returns false. */
bool GrabInputFocus( const Screen *pScreen );
void ReleaseInputFocus( const Screen *pScreen );
Screen *GetTopScreen();
@@ -66,6 +71,7 @@ public:
private:
vector<Screen*> m_ScreenStack; // bottommost to topmost
vector<Screen*> m_OverlayScreens;
Screen *m_pInputFocus; // NULL = top of m_ScreenStack
CString m_sLastLoadedBackgroundPath;
CString m_sDelayedScreen;