From f8104c073146c98ba35f98f96052934132c02ac6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 9 Dec 2005 04:25:30 +0000 Subject: [PATCH] separate exit row --- stepmania/src/ScreenMapControllers.cpp | 48 +++++++++++++++++++++----- stepmania/src/ScreenMapControllers.h | 5 ++- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index 4436aeaef9..3644f01203 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -104,9 +104,19 @@ void ScreenMapControllers::Init() m_LineScroller.AddChild( &m_Line[b] ); } + { + m_pExit = ActorUtil::MakeActor( THEME->GetPathG(m_sName,"exit") ); + m_pExit->SetName( "Exit" ); + ActorUtil::LoadAllCommands( *m_pExit, m_sName ); + + unsigned b = m_KeysToMap.size(); + m_Line[b].AddChild( m_pExit ); + m_LineScroller.AddChild( &m_Line[b] ); + } + m_LineScroller.SetName( "LineScroller" ); ActorUtil::LoadAllCommands( m_LineScroller, m_sName ); - m_LineScroller.Load2( (float) m_KeysToMap.size()*2, false ); + m_LineScroller.Load2( (float) m_LineScroller.GetNumChildren()*2, false ); this->AddChild( &m_LineScroller ); } @@ -136,6 +146,7 @@ void ScreenMapControllers::Update( float fDeltaTime ) return; /* keep waiting */ m_WaitingForPress.SetZero(); + ASSERT( m_iCurButton < (int) m_KeysToMap.size() ); const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; GameInput curGameI( (GameController)m_iCurController, pKey->m_GameButton ); @@ -268,6 +279,9 @@ void ScreenMapControllers::Input( const InputEventPlus &input ) case KEY_SPACE: case KEY_BACK: /* Clear the selected input mapping. */ #endif + if( m_iCurButton == (int) m_KeysToMap.size() ) + break; // on exit + { const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; GameInput curGameI( (GameController)m_iCurController, pKey->m_GameButton ); @@ -283,6 +297,8 @@ void ScreenMapControllers::Input( const InputEventPlus &input ) } break; case KEY_LEFT: /* Move the selection left, wrapping up. */ + if( m_iCurButton == (int) m_KeysToMap.size() ) + break; // on exit if( m_iCurSlot == 0 && m_iCurController == 0 ) break; // can't go left any more BeforeChangeFocus(); @@ -296,6 +312,8 @@ void ScreenMapControllers::Input( const InputEventPlus &input ) m_soundChange.Play(); break; case KEY_RIGHT: /* Move the selection right, wrapping down. */ + if( m_iCurButton == (int) m_KeysToMap.size() ) + break; // on exit if( m_iCurSlot == NUM_CHANGABLE_SLOTS-1 && m_iCurController == MAX_GAME_CONTROLLERS-1 ) break; // can't go right any more BeforeChangeFocus(); @@ -317,7 +335,7 @@ void ScreenMapControllers::Input( const InputEventPlus &input ) m_soundChange.Play(); break; case KEY_DOWN: /* Move the selection down. */ - if( m_iCurButton == (int) m_KeysToMap.size()-1 ) + if( m_iCurButton == (int) m_KeysToMap.size() ) break; // can't go down any more BeforeChangeFocus(); m_iCurButton++; @@ -336,6 +354,13 @@ void ScreenMapControllers::Input( const InputEventPlus &input ) break; case KEY_ENTER: /* Change the selection. */ case KEY_KP_ENTER: + if( m_iCurButton == (int) m_KeysToMap.size() ) + { + SCREENMAN->PlayStartSound(); + StartTransitioningScreen( SM_GoToNextScreen ); + break; + } + { const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; BitmapText *pText = pKey->m_textMappedTo[m_iCurController][m_iCurSlot]; @@ -362,18 +387,25 @@ void ScreenMapControllers::TweenOffScreen() OFF_COMMAND( m_LineScroller ); } +Actor *ScreenMapControllers::GetActorWithFocus() +{ + if( m_iCurButton == (int) m_KeysToMap.size() ) + return m_pExit; + + const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; + return pKey->m_textMappedTo[m_iCurController][m_iCurSlot]; +} + void ScreenMapControllers::BeforeChangeFocus() { - const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; - BitmapText *pText = pKey->m_textMappedTo[m_iCurController][m_iCurSlot]; - pText->PlayCommand( "LoseFocus" ); + Actor *pActor = GetActorWithFocus(); + pActor->PlayCommand( "LoseFocus" ); } void ScreenMapControllers::AfterChangeFocus() { - const KeyToMap *pKey = &m_KeysToMap[m_iCurButton]; - BitmapText *pText = pKey->m_textMappedTo[m_iCurController][m_iCurSlot]; - pText->PlayCommand( "GainFocus" ); + Actor *pActor = GetActorWithFocus(); + pActor->PlayCommand( "GainFocus" ); } void ScreenMapControllers::Refresh() diff --git a/stepmania/src/ScreenMapControllers.h b/stepmania/src/ScreenMapControllers.h index 88053a9e75..7d48678624 100644 --- a/stepmania/src/ScreenMapControllers.h +++ b/stepmania/src/ScreenMapControllers.h @@ -24,6 +24,7 @@ public: virtual void TweenOffScreen(); private: + Actor *GetActorWithFocus(); void BeforeChangeFocus(); void AfterChangeFocus(); virtual bool GenericTweenOn() const { return true; } @@ -44,8 +45,10 @@ private: BitmapText *m_textMappedTo[MAX_GAME_CONTROLLERS][NUM_SHOWN_GAME_TO_DEVICE_SLOTS]; }; vector m_KeysToMap; + // owned by m_Line + Actor *m_pExit; - ActorFrame m_Line[MAX_GAME_BUTTONS]; + ActorFrame m_Line[MAX_GAME_BUTTONS+1]; ActorScroller m_LineScroller; RageSound m_soundChange;