From 58d4434e7dee77e7f37ce150d9534479e87f30bb Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sat, 31 Jul 2010 15:45:28 -0500 Subject: [PATCH] remove giant two lists hack on SSMaster --- src/ScreenSelect.cpp | 142 +---------- src/ScreenSelect.h | 7 - src/ScreenSelectMaster.cpp | 499 ++++++------------------------------- src/ScreenSelectMaster.h | 5 +- 4 files changed, 87 insertions(+), 566 deletions(-) diff --git a/src/ScreenSelect.cpp b/src/ScreenSelect.cpp index ca3c73462e..e2aba3ac13 100644 --- a/src/ScreenSelect.cpp +++ b/src/ScreenSelect.cpp @@ -14,23 +14,6 @@ #define IDLE_TIMEOUT_SCREEN THEME->GetMetric (m_sName,"IdleTimeoutScreen") #define UPDATE_ON_MESSAGE THEME->GetMetric (m_sName,"UpdateOnMessage") -#if defined(SSC_FUTURES) -#define LIST_NAMES THEME->GetMetric (m_sName,"ListNames") -#else -// xxx: USE_TWO_LISTS is just a hack for two players. -aj -#define USE_TWO_LISTS THEME->GetMetricB (m_sName,"UseTwoLists") -#endif - -#if defined(SSC_FUTURES) -#define LIST_CONDITION( s ) THEME->GetMetricR (m_sName,"List%sCondition",s.c_str()) -#define CHOICE_NAMES_MULTI( s ) THEME->GetMetric (m_sName,ssprintf("List%sChoiceNames",s.c_str())) -#define CHOICEMULTI( s1, s2 ) THEME->GetMetric (m_sName,ssprintf("List%sChoice%s",s1.c_str(),s2.c_str())) -#else -// xxx: these are used by USE_TWO_LISTS. -aj -#define CHOICE_NAMESB THEME->GetMetric (m_sName,"ChoiceNamesB") -#define CHOICEB( s ) THEME->GetMetric (m_sName,ssprintf("ChoiceB%s",s.c_str())) -#endif - void ScreenSelect::Init() { IDLE_COMMENT_SECONDS.Load( m_sName, "IdleCommentSeconds" ); @@ -67,55 +50,16 @@ void ScreenSelect::Init() mc.Load( c, cmd ); m_aGameCommands.push_back( mc ); } - - m_iSelectedList = 0; - if(USE_TWO_LISTS) - { - m_bUsingTwoLists = true; - vector asChoiceNames2; - split( CHOICE_NAMESB, ",", asChoiceNames2, true ); - - for( unsigned c=0; cGetNumSidesJoined() > 1 ) - { - m_iSelectedList = 1; - this->UpdateSelectableChoices(); - } - } - m_timerIdleComment.GetDeltaTime(); m_timerIdleTimeout.GetDeltaTime(); } @@ -163,19 +107,11 @@ void ScreenSelect::Input( const InputEventPlus &input ) if( input.MenuI == GAME_BUTTON_START && input.type == IET_FIRST_PRESS && GAMESTATE->JoinInput(input.pn) ) { + // HACK: Only play start sound for the 2nd player who joins. The + // start sound for the 1st player will be played by ScreenTitleMenu + // when the player makes a selection on the screen. if( GAMESTATE->GetNumSidesJoined() > 1 ) - { - if(USE_TWO_LISTS) - { - m_iSelectedList = 1; - this->UpdateSelectableChoices(); - } - - // HACK: Only play start sound for the 2nd player who joins. The - // start sound for the 1st player will be played by ScreenTitleMenu - // when the player makes a selection on the screen. SCREENMAN->PlayStartSound(); - } if( !ALLOW_DISABLED_PLAYER_INPUT ) return; // don't let the screen handle the MENU_START press @@ -223,72 +159,20 @@ void ScreenSelect::HandleScreenMessage( const ScreenMessage SM ) if( bAllPlayersChoseTheSame ) { - if(USE_TWO_LISTS) // using two lists - { - if(m_iSelectedList == 0) // first list is selected - { - const GameCommand &gc = m_aGameCommands[iMastersIndex]; - - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.ApplyToAllPlayers(); - } - else // second list is selected - { - const GameCommand &gc = m_aGameCommandsB[iMastersIndex]; - - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.ApplyToAllPlayers(); - - } - - } - else // not using two lists - { - const GameCommand &gc = m_aGameCommands[iMastersIndex]; - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.ApplyToAllPlayers(); - } + const GameCommand &gc = m_aGameCommands[iMastersIndex]; + m_sNextScreen = gc.m_sScreen; + if( !gc.m_bInvalid ) + gc.ApplyToAllPlayers(); } else { - if(USE_TWO_LISTS) // using two lists + FOREACH_HumanPlayer( p ) { - if(m_iSelectedList == 0) // first list is selected - { - FOREACH_HumanPlayer( p ) - { - int iIndex = this->GetSelectionIndex(p); - const GameCommand &gc = m_aGameCommands[iIndex]; - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.Apply( p ); - } - } - else - { - FOREACH_HumanPlayer( p ) - { - int iIndex = this->GetSelectionIndex(p); - const GameCommand &gc = m_aGameCommandsB[iIndex]; - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.Apply( p ); - } - } - } - else // only using a single list - { - FOREACH_HumanPlayer( p ) - { - int iIndex = this->GetSelectionIndex(p); - const GameCommand &gc = m_aGameCommands[iIndex]; - m_sNextScreen = gc.m_sScreen; - if( !gc.m_bInvalid ) - gc.Apply( p ); - } + int iIndex = this->GetSelectionIndex(p); + const GameCommand &gc = m_aGameCommands[iIndex]; + m_sNextScreen = gc.m_sScreen; + if( !gc.m_bInvalid ) + gc.Apply( p ); } } diff --git a/src/ScreenSelect.h b/src/ScreenSelect.h index d4d058fb8c..d3174e3f9a 100644 --- a/src/ScreenSelect.h +++ b/src/ScreenSelect.h @@ -25,13 +25,6 @@ protected: virtual int GetSelectionIndex( PlayerNumber pn ) = 0; virtual void UpdateSelectableChoices() = 0; // derived screens must handle this - unsigned int m_iSelectedList; -#if defined(SSC_FUTURES) - int m_iNumLists; -#else - bool m_bUsingTwoLists; -#endif - vector m_aGameCommands; // derived classes should look here for what choices are available #if defined(SSC_FUTURES) // this is gonna become awkward... -aj diff --git a/src/ScreenSelectMaster.cpp b/src/ScreenSelectMaster.cpp index ff6d772c37..dc6c5f60b5 100644 --- a/src/ScreenSelectMaster.cpp +++ b/src/ScreenSelectMaster.cpp @@ -29,8 +29,6 @@ static RString CURSOR_OFFSET_Y_FROM_ICON_NAME( size_t p ) { return ssprintf("Cur // e.g. "OptionOrderLeft=0:1,1:2,2:3,3:4" static RString OPTION_ORDER_NAME( size_t dir ) { return "OptionOrder"+MenuDirToString((MenuDir)dir); } -static RString OPTION_ORDER_NAME_LIST2( size_t dir ) { return "OptionOrderB"+MenuDirToString((MenuDir)dir); } - REGISTER_SCREEN_CLASS( ScreenSelectMaster ); #define GetActiveElementPlayerNumbers( vpns ) \ @@ -62,9 +60,6 @@ void ScreenSelectMaster::Init() PRE_SWITCH_PAGE_SECONDS.Load( m_sName, "PreSwitchPageSeconds" ); POST_SWITCH_PAGE_SECONDS.Load( m_sName, "PostSwitchPageSeconds" ); OPTION_ORDER.Load( m_sName, OPTION_ORDER_NAME, NUM_MenuDir ); - - OPTION_ORDER2.Load( m_sName, OPTION_ORDER_NAME_LIST2, NUM_MenuDir ); - DO_SWITCH_ANYWAYS.Load( m_sName, "DoSwitchAnyways" ); WRAP_CURSOR.Load( m_sName, "WrapCursor" ); @@ -154,125 +149,6 @@ void ScreenSelectMaster::Init() } } - // using two lists, load the stuff for the 2nd one - if(m_bUsingTwoLists) - { - // Resize vectors depending on how many choices there are - m_vsprIconB.resize( m_aGameCommandsB.size() ); - FOREACH( PlayerNumber, vpns, p ) - m_vsprScrollB[*p].resize( m_aGameCommandsB.size() ); - - for( unsigned c=0; c vs; - vs.push_back( "List2 Icon" ); - if( PER_CHOICE_ICON_ELEMENT ) - vs.push_back( "List2 Choice" + mc.m_sName ); - RString sElement = join( " ", vs ); - m_vsprIconB[c].Load( THEME->GetPathG(m_sName,sElement) ); - RString sName = "List2 Icon" "List2 Choice" + mc.m_sName; - m_vsprIconB[c]->SetName( sName ); - if( USE_ICON_METRICS ) - LOAD_ALL_COMMANDS_AND_SET_XY( m_vsprIconB[c] ); - this->AddChild( m_vsprIconB[c] ); - } - - // init scroll - if( SHOW_SCROLLER ) - { - FOREACH( PlayerNumber, vpns, p ) - { - vector vs; - vs.push_back( "List2 Scroll" ); - if( PER_CHOICE_SCROLL_ELEMENT ) - vs.push_back( "List2 Choice" + mc.m_sName ); - if( !SHARED_SELECTION ) - vs.push_back( PLAYER_APPEND_NO_SPACE(*p) ); - RString sElement = join( " ", vs ); - m_vsprScrollB[*p][c].Load( THEME->GetPathG(m_sName,sElement) ); - RString sName = "List2 Scroll" "List2 Choice" + mc.m_sName; - if( !SHARED_SELECTION ) - sName += PLAYER_APPEND_NO_SPACE(*p); - m_vsprScrollB[*p][c]->SetName( sName ); - m_ScrollerB[*p].AddChild( m_vsprScrollB[*p][c] ); - } - } - } - - // init scroll - if( SHOW_SCROLLER ) - { - FOREACH( PlayerNumber, vpns, p ) - { - m_ScrollerB[*p].SetLoop( LOOP_SCROLLER ); - m_ScrollerB[*p].SetNumItemsToDraw( SCROLLER_NUM_ITEMS_TO_DRAW ); - m_ScrollerB[*p].Load2(); - m_ScrollerB[*p].SetTransformFromReference( SCROLLER_TRANSFORM ); - m_ScrollerB[*p].SetSecondsPerItem( SCROLLER_SECONDS_PER_ITEM ); - m_ScrollerB[*p].SetNumSubdivisions( SCROLLER_SUBDIVISIONS ); - m_ScrollerB[*p].SetName( "Scroller"+PLAYER_APPEND_NO_SPACE(*p) ); - LOAD_ALL_COMMANDS_AND_SET_XY( m_ScrollerB[*p] ); - this->AddChild( &m_ScrollerB[*p] ); - } - } - - FOREACH_MenuDir( dir ) - { - const RString order = OPTION_ORDER2.GetValue( dir ); - vector parts; - split( order, ",", parts, true ); - - for( unsigned part = 0; part < parts.size(); ++part ) - { - int from, to; - if( sscanf( parts[part], "%d:%d", &from, &to ) != 2 ) - { - LOG->Warn( "%s::OptionOrderB%s parse error", m_sName.c_str(), MenuDirToString(dir).c_str() ); - continue; - } - - --from; - --to; - - m_mapCurrentChoiceToNextChoiceB[dir][from] = to; - } - - if( m_mapCurrentChoiceToNextChoiceB[dir].empty() ) // Didn't specify any mappings - { - // Fill with reasonable defaults - for( unsigned c = 0; c < m_aGameCommandsB.size(); ++c ) - { - int add; - switch( dir ) - { - case MenuDir_Up: - case MenuDir_Left: - add = -1; - break; - default: - add = +1; - break; - } - - m_mapCurrentChoiceToNextChoiceB[dir][c] = c + add; - // Always wrap around MenuDir_Auto. - if( dir == MenuDir_Auto || (bool)WRAP_CURSOR ) - wrap( m_mapCurrentChoiceToNextChoiceB[dir][c], m_aGameCommandsB.size() ); - else - m_mapCurrentChoiceToNextChoiceB[dir][c] = clamp( m_mapCurrentChoiceToNextChoiceB[dir][c], 0, (int)m_aGameCommandsB.size()-1 ); - } - } - } - } // end of list2 init - - // init scroll if( SHOW_SCROLLER ) { @@ -303,7 +179,6 @@ void ScreenSelectMaster::Init() this->AddChild( m_sprExplanation[page] ); } - m_soundChange.Load( THEME->GetPathS(m_sName,"change"), true ); m_soundDifficult.Load( ANNOUNCER->GetPathTo("select difficulty challenge") ); m_soundStart.Load( THEME->GetPathS(m_sName,"start") ); @@ -469,62 +344,14 @@ void ScreenSelectMaster::UpdateSelectableChoices() vector vpns; GetActiveElementPlayerNumbers( vpns ); - // using two lists and on the 2nd list - if(m_bUsingTwoLists && m_iSelectedList == 1) + for( unsigned c=0; cPlayCommand( "List2Enabled" ); - } + if( SHOW_ICON ) + m_vsprIcon[c]->PlayCommand( m_aGameCommands[c].IsPlayable()? "Enabled":"Disabled" ); - FOREACH( PlayerNumber, vpns, p ) - if( m_vsprScroll[*p][c].IsLoaded() ) - { - m_vsprScroll[*p][c]->PlayCommand( "List2Enabled" ); - } - } - - for( unsigned c=0; cPlayCommand( "List2Enabled" ); - m_vsprIconB[c]->PlayCommand( m_aGameCommandsB[c].IsPlayable()? "Enabled":"Disabled" ); - - // we will make element 0 the new selection, so it will gain focus - if(c==0) - m_vsprIconB[c]->PlayCommand( "GainFocus" ); - else // everything else loses focus - m_vsprIconB[c]->PlayCommand( "LoseFocus" ); - } - - FOREACH( PlayerNumber, vpns, p ) - if( m_vsprScrollB[*p][c].IsLoaded() ) - { - m_vsprScrollB[*p][c]->PlayCommand( "List2Enabled" ); - m_vsprScrollB[*p][c]->PlayCommand( m_aGameCommandsB[c].IsPlayable()? "Enabled":"Disabled" ); - - if(c==0) - m_vsprScrollB[*p][c]->PlayCommand( "GainFocus" ); - else // everything else loses focus - m_vsprScrollB[*p][c]->PlayCommand( "LoseFocus" ); - - } - } - } - else - { - for( unsigned c=0; cPlayCommand( m_aGameCommands[c].IsPlayable()? "Enabled":"Disabled" ); - - FOREACH( PlayerNumber, vpns, p ) - if( m_vsprScroll[*p][c].IsLoaded() ) - m_vsprScroll[*p][c]->PlayCommand( m_aGameCommands[c].IsPlayable()? "Enabled":"Disabled" ); - } + FOREACH( PlayerNumber, vpns, p ) + if( m_vsprScroll[*p][c].IsLoaded() ) + m_vsprScroll[*p][c]->PlayCommand( m_aGameCommands[c].IsPlayable()? "Enabled":"Disabled" ); } /* If no options are playable at all, just wait. Some external @@ -532,36 +359,16 @@ void ScreenSelectMaster::UpdateSelectableChoices() * If any options are playable, make sure one is selected. */ FOREACH_HumanPlayer( p ) { - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - // reset their choice position since we are moving to the new list: - m_iChoice[p] = 0; - if( !m_aGameCommandsB[m_iChoice[p]].IsPlayable() ) - Move( p, MenuDir_Auto ); - } - else - { - if( !m_aGameCommands[m_iChoice[p]].IsPlayable() ) - Move( p, MenuDir_Auto ); - } + if( !m_aGameCommands[m_iChoice[p]].IsPlayable() ) + Move( p, MenuDir_Auto ); } } bool ScreenSelectMaster::AnyOptionsArePlayable() const { - // if they're using the second list - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - for( unsigned i = 0; i < m_aGameCommandsB.size(); ++i ) - if( m_aGameCommandsB[i].IsPlayable() ) - return true; - } - else - { - for( unsigned i = 0; i < m_aGameCommands.size(); ++i ) - if( m_aGameCommands[i].IsPlayable() ) - return true; - } + for( unsigned i = 0; i < m_aGameCommands.size(); ++i ) + if( m_aGameCommands[i].IsPlayable() ) + return true; return false; } @@ -575,37 +382,18 @@ bool ScreenSelectMaster::Move( PlayerNumber pn, MenuDir dir ) set seen; try_again: - // moving list 2 - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - map::const_iterator iter = m_mapCurrentChoiceToNextChoiceB[dir].find( iSwitchToIndex ); - if( iter != m_mapCurrentChoiceToNextChoiceB[dir].end() ) - iSwitchToIndex = iter->second; + map::const_iterator iter = m_mapCurrentChoiceToNextChoice[dir].find( iSwitchToIndex ); + if( iter != m_mapCurrentChoiceToNextChoice[dir].end() ) + iSwitchToIndex = iter->second; - if( iSwitchToIndex < 0 || iSwitchToIndex >= (int) m_aGameCommandsB.size() ) // out of choice range - return false; // can't go that way - if( seen.find(iSwitchToIndex) != seen.end() ) - return false; // went full circle and none found - seen.insert( iSwitchToIndex ); + if( iSwitchToIndex < 0 || iSwitchToIndex >= (int) m_aGameCommands.size() ) // out of choice range + return false; // can't go that way + if( seen.find(iSwitchToIndex) != seen.end() ) + return false; // went full circle and none found + seen.insert( iSwitchToIndex ); - if( !m_aGameCommandsB[iSwitchToIndex].IsPlayable() ) - goto try_again; - } - else - { - map::const_iterator iter = m_mapCurrentChoiceToNextChoice[dir].find( iSwitchToIndex ); - if( iter != m_mapCurrentChoiceToNextChoice[dir].end() ) - iSwitchToIndex = iter->second; - - if( iSwitchToIndex < 0 || iSwitchToIndex >= (int) m_aGameCommands.size() ) // out of choice range - return false; // can't go that way - if( seen.find(iSwitchToIndex) != seen.end() ) - return false; // went full circle and none found - seen.insert( iSwitchToIndex ); - - if( !m_aGameCommands[iSwitchToIndex].IsPlayable() && !DO_SWITCH_ANYWAYS ) - goto try_again; - } + if( !m_aGameCommands[iSwitchToIndex].IsPlayable() ) + goto try_again; return ChangeSelection( pn, dir, iSwitchToIndex ); } @@ -834,72 +622,13 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew if(DOUBLE_PRESS_TO_SELECT) { - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - // this player is currently on a single press, which they are cancelling - if(m_bDoubleChoice[pn]) - { - if( !bOldStillHasFocus ) - m_vsprIconB[iOldChoice]->PlayCommand( "LostSelectedLoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIconB[iNewChoice]->PlayCommand( "LostSelectedGainFocus" ); - } - else - { - if( !bOldStillHasFocus ) - m_vsprIconB[iOldChoice]->PlayCommand( "LoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIconB[iNewChoice]->PlayCommand( "GainFocus" ); - } - } - else - { - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - // this player is currently on a single press, which they are cancelling - if(m_bDoubleChoice[pn]) - { - if( !bOldStillHasFocus ) - m_vsprIcon[iOldChoice]->PlayCommand( "LostSelectedLoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIcon[iNewChoice]->PlayCommand( "LostSelectedGainFocus" ); - } - else - { - if( !bOldStillHasFocus ) - m_vsprIcon[iOldChoice]->PlayCommand( "LoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIcon[iNewChoice]->PlayCommand( "GainFocus" ); - } - } - else - { - // this player is currently on a single press, which they are cancelling - if(m_bDoubleChoice[pn]) - { - if( !bOldStillHasFocus ) - m_vsprIcon[iOldChoice]->PlayCommand( "LostSelectedLoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIcon[iNewChoice]->PlayCommand( "LostSelectedGainFocus" ); - } - else - { - if( !bOldStillHasFocus ) - m_vsprIcon[iOldChoice]->PlayCommand( "LoseFocus" ); - if( !bNewAlreadyHadFocus ) - m_vsprIcon[iNewChoice]->PlayCommand( "GainFocus" ); - } - } - } - } - else // not using double selection - { - if(m_bUsingTwoLists && m_iSelectedList == 1) + // this player is currently on a single press, which they are cancelling + if(m_bDoubleChoice[pn]) { if( !bOldStillHasFocus ) - m_vsprIconB[iOldChoice]->PlayCommand( "LoseFocus" ); + m_vsprIcon[iOldChoice]->PlayCommand( "LostSelectedLoseFocus" ); if( !bNewAlreadyHadFocus ) - m_vsprIconB[iNewChoice]->PlayCommand( "GainFocus" ); + m_vsprIcon[iNewChoice]->PlayCommand( "LostSelectedGainFocus" ); } else { @@ -909,6 +638,13 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew m_vsprIcon[iNewChoice]->PlayCommand( "GainFocus" ); } } + else // not using double selection + { + if( !bOldStillHasFocus ) + m_vsprIcon[iOldChoice]->PlayCommand( "LoseFocus" ); + if( !bNewAlreadyHadFocus ) + m_vsprIcon[iNewChoice]->PlayCommand( "GainFocus" ); + } } if( SHOW_CURSOR ) @@ -919,50 +655,27 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew if( SHOW_SCROLLER ) { - ActorScroller &scroller = (m_bUsingTwoLists && m_iSelectedList == 1)?(SHARED_SELECTION ? m_ScrollerB[0] : m_ScrollerB[*p]):(SHARED_SELECTION || page != PAGE_1 ? m_Scroller[0] : m_Scroller[*p]); - vector &vScroll = (m_bUsingTwoLists && m_iSelectedList == 1)?(SHARED_SELECTION ? m_vsprScrollB[0] : m_vsprScrollB[*p]):(SHARED_SELECTION || page != PAGE_1 ? m_vsprScroll[0] : m_vsprScroll[*p]); + ActorScroller &scroller = (SHARED_SELECTION || page != PAGE_1 ? m_Scroller[0] : m_Scroller[*p]); + vector &vScroll = (SHARED_SELECTION || page != PAGE_1 ? m_vsprScroll[0] : m_vsprScroll[*p]); - // second list - if(m_bUsingTwoLists && m_iSelectedList == 1) + if( WRAP_SCROLLER ) { - if( WRAP_SCROLLER ) + // HACK: We can't tell from the option orders whether or not we wrapped. + // For now, assume that the order is increasing left to right. + int iPressedDir = (dir == MenuDir_Left || dir == MenuDir_Up) ? -1 : +1; + int iActualDir = (iOldChoice < iNewChoice) ? +1 : -1; + + if( iPressedDir != iActualDir ) // wrapped { - // HACK: We can't tell from the option orders whether or not we wrapped. - // For now, assume that the order is increasing left to right. - int iPressedDir = (dir == MenuDir_Left || dir == MenuDir_Up) ? -1 : +1; - int iActualDir = (iOldChoice < iNewChoice) ? +1 : -1; - - if( iPressedDir != iActualDir ) // wrapped - { - float fItem = scroller.GetCurrentItem(); - int iNumChoices = m_aGameCommandsB.size(); - fItem += iActualDir * iNumChoices; - scroller.SetCurrentAndDestinationItem( fItem ); - } + float fItem = scroller.GetCurrentItem(); + int iNumChoices = m_aGameCommands.size(); + fItem += iActualDir * iNumChoices; + scroller.SetCurrentAndDestinationItem( fItem ); } - - scroller.SetDestinationItem( (float)iNewChoice ); } - else - { - if( WRAP_SCROLLER ) - { - // HACK: We can't tell from the option orders whether or not we wrapped. - // For now, assume that the order is increasing left to right. - int iPressedDir = (dir == MenuDir_Left || dir == MenuDir_Up) ? -1 : +1; - int iActualDir = (iOldChoice < iNewChoice) ? +1 : -1; - if( iPressedDir != iActualDir ) // wrapped - { - float fItem = scroller.GetCurrentItem(); - int iNumChoices = m_aGameCommands.size(); - fItem += iActualDir * iNumChoices; - scroller.SetCurrentAndDestinationItem( fItem ); - } - } + scroller.SetDestinationItem( (float)iNewChoice ); - scroller.SetDestinationItem( (float)iNewChoice ); - } // using double selections if(DOUBLE_PRESS_TO_SELECT) { @@ -1065,23 +778,15 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input ) if(SHOW_SCROLLER) { - if(m_bUsingTwoLists && m_iSelectedList == 1) - { - vector &vScroll = SHARED_SELECTION ? m_vsprScrollB[0] : m_vsprScrollB[pn]; - vScroll[m_iChoice[pn]]->PlayCommand( "InitialSelection" ); - } - else - { - vector &vScroll = SHARED_SELECTION ? m_vsprScroll[0] : m_vsprScroll[pn]; - vScroll[m_iChoice[pn]]->PlayCommand( "InitialSelection" ); - } + vector &vScroll = SHARED_SELECTION ? m_vsprScroll[0] : m_vsprScroll[pn]; + vScroll[m_iChoice[pn]]->PlayCommand( "InitialSelection" ); } return; } - const GameCommand &mc = (m_bUsingTwoLists && m_iSelectedList == 1)?m_aGameCommandsB[m_iChoice[pn]]:m_aGameCommands[m_iChoice[pn]]; + const GameCommand &mc = m_aGameCommands[m_iChoice[pn]]; /* If no options are playable, then we're just waiting for one to become available. * If any options are playable, then the selection must be playable. */ @@ -1139,55 +844,26 @@ void ScreenSelectMaster::TweenOnScreen() if( SHOW_ICON ) { - if(m_bUsingTwoLists && m_iSelectedList == 1) + for( unsigned c=0; cPlayCommand( (int(c) == m_iChoice[0])? "GainFocus":"LoseFocus" ); - m_vsprIconB[c]->FinishTweening(); - } - } - else - { - for( unsigned c=0; cPlayCommand( (int(c) == m_iChoice[0])? "GainFocus":"LoseFocus" ); - m_vsprIcon[c]->FinishTweening(); - } + m_vsprIcon[c]->PlayCommand( (int(c) == m_iChoice[0])? "GainFocus":"LoseFocus" ); + m_vsprIcon[c]->FinishTweening(); } } if( SHOW_SCROLLER ) { - if(m_bUsingTwoLists && m_iSelectedList == 1) + FOREACH( PlayerNumber, vpns, p ) { - FOREACH( PlayerNumber, vpns, p ) + // Play Gain/LoseFocus before playing the on command. + // Gain/Lose will often stop tweening, which ruins the OnCommand. + for( unsigned c=0; cPlayCommand( int(c) == m_iChoice[*p]? "GainFocus":"LoseFocus" ); - m_vsprScrollB[*p][c]->FinishTweening(); - } - - m_ScrollerB[*p].SetCurrentAndDestinationItem( (float)m_iChoice[*p] ); + m_vsprScroll[*p][c]->PlayCommand( int(c) == m_iChoice[*p]? "GainFocus":"LoseFocus" ); + m_vsprScroll[*p][c]->FinishTweening(); } - } - else - { - FOREACH( PlayerNumber, vpns, p ) - { - // Play Gain/LoseFocus before playing the on command. - // Gain/Lose will often stop tweening, which ruins the OnCommand. - for( unsigned c=0; cPlayCommand( int(c) == m_iChoice[*p]? "GainFocus":"LoseFocus" ); - m_vsprScroll[*p][c]->FinishTweening(); - } - m_Scroller[*p].SetCurrentAndDestinationItem( (float)m_iChoice[*p] ); - } + m_Scroller[*p].SetCurrentAndDestinationItem( (float)m_iChoice[*p] ); } } @@ -1210,54 +886,25 @@ void ScreenSelectMaster::TweenOffScreen() vector vpns; GetActiveElementPlayerNumbers( vpns ); - // using two lists -- may need to consider throwing a wider range of commands - // for themers if tweening out with one/two lists/focused/not focused etc? - if(m_bUsingTwoLists && m_iSelectedList == 1) + for( unsigned c=0; cPlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); - - if( SHOW_SCROLLER ) - { - FOREACH( PlayerNumber, vpns, p ) - m_vsprScrollB[*p][c]->PlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); - } + if( m_iChoice[*p] == (int)c ) + bSelectedByEitherPlayer = true; } - } - else - { - for( unsigned c=0; cPlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); + + if( SHOW_SCROLLER ) { - if( GetPage(c) != GetCurrentPage() ) - continue; // skip - - bool bSelectedByEitherPlayer = false; FOREACH( PlayerNumber, vpns, p ) - { - if( m_iChoice[*p] == (int)c ) - bSelectedByEitherPlayer = true; - } - - if( SHOW_ICON ) - m_vsprIcon[c]->PlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); - - if( SHOW_SCROLLER ) - { - FOREACH( PlayerNumber, vpns, p ) - m_vsprScroll[*p][c]->PlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); - } + m_vsprScroll[*p][c]->PlayCommand( bSelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); } } } diff --git a/src/ScreenSelectMaster.h b/src/ScreenSelectMaster.h index 6e66a39d41..ce94e7bf69 100644 --- a/src/ScreenSelectMaster.h +++ b/src/ScreenSelectMaster.h @@ -75,11 +75,11 @@ protected: ThemeMetric SCROLLER_SECONDS_PER_ITEM; ThemeMetric SCROLLER_NUM_ITEMS_TO_DRAW; ThemeMetric SCROLLER_TRANSFORM; + //ThemeMetric SCROLLER_TWEEN; ThemeMetric SCROLLER_SUBDIVISIONS; ThemeMetric DEFAULT_CHOICE; map m_mapCurrentChoiceToNextChoice[NUM_MenuDir]; - map m_mapCurrentChoiceToNextChoiceB[NUM_MenuDir]; // if using two lists virtual int GetSelectionIndex( PlayerNumber pn ); virtual void UpdateSelectableChoices(); @@ -98,14 +98,11 @@ protected: AutoActor m_sprMore[NUM_Page]; // icon is the shared, per-choice piece vector m_vsprIcon; - vector m_vsprIconB; // used if a themer wants two lists // preview is per-player, per-choice piece vector m_vsprScroll[NUM_PLAYERS]; - vector m_vsprScrollB[NUM_PLAYERS]; // used if a themer wants two lists ActorScroller m_Scroller[NUM_PLAYERS]; - ActorScroller m_ScrollerB[NUM_PLAYERS]; // used if a themer wants two lists // cursor is the per-player, shared by all choices AutoActor m_sprCursor[NUM_PLAYERS];