From f31e4af6d9104cdad8635d2d8a646eb9cd7b178b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 14 Jul 2005 20:15:37 +0000 Subject: [PATCH] remove Preview element, use Scroll instead --- stepmania/src/ScreenSelectMaster.cpp | 144 ++++++++++++--------------- stepmania/src/ScreenSelectMaster.h | 13 +-- 2 files changed, 66 insertions(+), 91 deletions(-) diff --git a/stepmania/src/ScreenSelectMaster.cpp b/stepmania/src/ScreenSelectMaster.cpp index 02b17dd9ba..4f419323c6 100644 --- a/stepmania/src/ScreenSelectMaster.cpp +++ b/stepmania/src/ScreenSelectMaster.cpp @@ -24,7 +24,6 @@ CString OPTION_ORDER_NAME( size_t dir ) { return "OptionOrder"+MenuDirToSt REGISTER_SCREEN_CLASS( ScreenSelectMaster ); ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sClassName ), SHOW_ICON(m_sName,"ShowIcon"), - SHOW_PREVIEW(m_sName,"ShowPreview"), SHOW_CURSOR(m_sName,"ShowCursor"), SHOW_SCROLLER(m_sName,"ShowScroller"), SHARED_PREVIEW_AND_CURSOR(m_sName,"SharedPreviewAndCursor"), @@ -84,16 +83,18 @@ void ScreenSelectMaster::Init() vpns.push_back( p ); } -#define APPEND_STRING_WITH_SPACE(p) (SHARED_PREVIEW_AND_CURSOR ? CString() : ssprintf(" P%d",(p)+1)) -#define APPEND_STRING_NO_SPACE(p) (SHARED_PREVIEW_AND_CURSOR ? CString() : ssprintf("P%d",(p)+1)) +#define PLAYER_APPEND_WITH_SPACE(p) (SHARED_PREVIEW_AND_CURSOR ? CString() : ssprintf(" P%d",(p)+1)) +#define PLAYER_APPEND_NO_SPACE(p) (SHARED_PREVIEW_AND_CURSOR ? CString() : ssprintf("P%d",(p)+1)) // init cursor if( SHOW_CURSOR ) { FOREACH( PlayerNumber, vpns, p ) { - m_sprCursor[*p].Load( THEME->GetPathG(m_sName,"Cursor"+APPEND_STRING_WITH_SPACE(*p)) ); - m_sprCursor[*p]->SetName( "Cursor"+APPEND_STRING_NO_SPACE(*p) ); + CString sElement = "Cursor" + PLAYER_APPEND_WITH_SPACE(*p); + m_sprCursor[*p].Load( THEME->GetPathG(m_sName,sElement) ); + sElement.Replace( " ", "" ); + m_sprCursor[*p]->SetName( sElement ); this->AddChild( m_sprCursor[*p] ); } } @@ -109,51 +110,46 @@ void ScreenSelectMaster::Init() SCROLLER_FAST_CATCHUP, SCROLLER_TRANSFORM, false ); - m_Scroller[*p].SetName( "Scroller"+APPEND_STRING_NO_SPACE(*p) ); + m_Scroller[*p].SetName( "Scroller"+PLAYER_APPEND_NO_SPACE(*p) ); this->AddChild( &m_Scroller[*p] ); - - for( unsigned c=0; cGet(); - mc.PushSelf( L ); - GAMESTATE->m_Environment->Set( L, "ThisGameCommand" ); - LUA->Release( L ); - - m_sprScroll[c][*p].Load( THEME->GetPathG(m_sName,ssprintf("Scroll Choice%s",mc.m_sName.c_str())+APPEND_STRING_WITH_SPACE(*p)) ); - m_sprScroll[c][*p]->SetName( "Scroll"+APPEND_STRING_NO_SPACE(*p) ); - m_Scroller[*p].AddChild( m_sprScroll[c][*p] ); - - L = LUA->Get(); - GAMESTATE->m_Environment->Unset( L, "ThisGameCommand" ); - LUA->Release( L ); - } } } for( unsigned c=0; cGet(); + mc.PushSelf( L ); + GAMESTATE->m_Environment->Set( L, "ThisGameCommand" ); + LUA->Release( L ); // init icon if( SHOW_ICON ) { - m_sprIcon[c].Load( THEME->GetPathG(m_sName,ssprintf("Icon Choice%s",mc.m_sName.c_str())) ); - m_sprIcon[c]->SetName( ssprintf("IconChoice%s",mc.m_sName.c_str()) ); + CString sElement = ssprintf( "Icon Choice%s", mc.m_sName.c_str() ); + m_sprIcon[c].Load( THEME->GetPathG(m_sName,sElement) ); + sElement.Replace( " ", "" ); + m_sprIcon[c]->SetName( sElement ); this->AddChild( m_sprIcon[c] ); } - // init preview - if( SHOW_PREVIEW ) + // init scroll + if( SHOW_SCROLLER ) { FOREACH( PlayerNumber, vpns, p ) { - m_sprPreview[c][*p].Load( THEME->GetPathG(m_sName,ssprintf("Preview Choice%s",mc.m_sName.c_str())+APPEND_STRING_NO_SPACE(*p)) ); - m_sprPreview[c][*p]->SetName( "Preview"+APPEND_STRING_NO_SPACE(*p) ); - this->AddChild( m_sprPreview[c][*p] ); + CString sElement = ssprintf( "Scroll Choice%s", mc.m_sName.c_str() ) + PLAYER_APPEND_WITH_SPACE(*p); + m_sprScroll[c][*p].Load( THEME->GetPathG(m_sName,sElement) ); + sElement.Replace( " ", "" ); + m_sprScroll[c][*p]->SetName( sElement ); + m_Scroller[*p].AddChild( m_sprScroll[c][*p] ); } } + + L = LUA->Get(); + GAMESTATE->m_Environment->Unset( L, "ThisGameCommand" ); + LUA->Release( L ); } @@ -275,12 +271,12 @@ void ScreenSelectMaster::HandleScreenMessage( const ScreenMessage SM ) } } - if( SHOW_PREVIEW ) + if( SHOW_SCROLLER ) { FOREACH( PlayerNumber, vpns, p ) { int iChoice = m_iChoice[*p]; - COMMAND( m_sprPreview[iChoice][*p], "PostSwitchPage" ); + COMMAND( m_sprScroll[iChoice][*p], "PostSwitchPage" ); } } @@ -340,7 +336,7 @@ void ScreenSelectMaster::UpdateSelectableChoices() for( unsigned c=0; cPlayCommand( m_aGameCommands[c].IsPlayable()? "Enabled":"Disabled" ); FOREACH( PlayerNumber, vpns, p ) if( m_sprScroll[c][*p].IsLoaded() ) @@ -487,22 +483,19 @@ bool ScreenSelectMaster::ChangePage( int iNewChoice ) COMMAND( m_sprIcon[c], sIconAndExplanationCommand ); } - if( SHARED_PREVIEW_AND_CURSOR ) + if( SHOW_SCROLLER ) { - if( SHOW_PREVIEW ) + if( SHARED_PREVIEW_AND_CURSOR ) { int iChoice = m_iChoice[GetSharedPlayer()]; - COMMAND( m_sprPreview[iChoice][0], "PreSwitchPage" ); + COMMAND( m_sprScroll[iChoice][0], "PreSwitchPage" ); } - } - else - { - if( SHOW_PREVIEW ) + else { FOREACH_HumanPlayer( p ) { int iChoice = m_iChoice[p]; - COMMAND( m_sprPreview[iChoice][p], "PreSwitchPage" ); + COMMAND( m_sprScroll[iChoice][p], "PreSwitchPage" ); } } } @@ -553,29 +546,15 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew if( p!=pn ) continue; // skip - if( SHOW_PREVIEW ) - { - if( SHARED_PREVIEW_AND_CURSOR ) - { - COMMAND( m_sprPreview[iOldChoice][0], "LoseFocus" ); - COMMAND( m_sprPreview[iNewChoice][0], "GainFocus" ); - } - else - { - COMMAND( m_sprPreview[iOldChoice][p], "LoseFocus" ); - COMMAND( m_sprPreview[iNewChoice][p], "GainFocus" ); - } - } - if( SHOW_ICON ) { /* XXX: If !SharedPreviewAndCursor, this is incorrect. (Nothing uses * both icon focus and !SharedPreviewAndCursor right now.) */ - COMMAND( m_sprIcon[iOldChoice], "LoseFocus" ); - COMMAND( m_sprIcon[iNewChoice], "GainFocus" ); + m_sprIcon[iOldChoice]->PlayCommand( "LoseFocus" ); + m_sprIcon[iNewChoice]->PlayCommand( "GainFocus" ); } - if( SHOW_PREVIEW ) + if( SHOW_CURSOR ) { if( SHARED_PREVIEW_AND_CURSOR ) { @@ -612,13 +591,17 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew m_Scroller[0].SetDestinationItem( (float)iNewChoice ); else m_Scroller[p].SetDestinationItem( (float)iNewChoice ); - + if( SHARED_PREVIEW_AND_CURSOR ) - for( unsigned c=0; cPlayCommand( "LoseFocus" ); + m_sprScroll[iNewChoice][0]->PlayCommand( "GainFocus" ); + } else - for( unsigned c=0; cPlayCommand( "LoseFocus" ); + m_sprScroll[iNewChoice][p]->PlayCommand( "GainFocus" ); + } } } @@ -767,24 +750,14 @@ void ScreenSelectMaster::TweenOnScreen() vpns.push_back( p ); } - for( unsigned c=0; cPlayCommand( (int(c) == m_iChoice[0])? "GainFocus":"LoseFocus" ); m_sprIcon[c]->FinishTweening(); SET_XY_AND_ON_COMMAND( m_sprIcon[c] ); } - - if( SHOW_PREVIEW ) - { - FOREACH( PlayerNumber, vpns, p ) - { - COMMAND( m_sprPreview[c][*p], (int(c) == m_iChoice[*p])? "GainFocus":"LoseFocus" ); - m_sprPreview[c][*p]->FinishTweening(); - SET_XY_AND_ON_COMMAND( m_sprPreview[c][*p] ); - } - } } // Need to SetXY of Cursor after Icons since it depends on the Icons' positions. @@ -804,7 +777,12 @@ void ScreenSelectMaster::TweenOnScreen() // 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_sprScroll[c][*p]->FinishTweening(); + ON_COMMAND( m_sprScroll[c][*p] ); + } + m_Scroller[*p].SetCurrentAndDestinationItem( (float)m_iChoice[*p] ); SET_XY_AND_ON_COMMAND( m_Scroller[*p] ); } @@ -860,15 +838,15 @@ void ScreenSelectMaster::TweenOffScreen() if( SHOW_ICON ) { OFF_COMMAND( m_sprIcon[c] ); - COMMAND( m_sprIcon[c], SelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); + m_sprIcon[c]->PlayCommand( SelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); } - if( SHOW_PREVIEW ) + if( SHOW_SCROLLER ) { FOREACH( PlayerNumber, vpns, p ) { - OFF_COMMAND( m_sprPreview[c][*p] ); - COMMAND( m_sprPreview[c][*p], SelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); + OFF_COMMAND( m_sprScroll[c][*p] ); + COMMAND( m_sprScroll[c][*p], SelectedByEitherPlayer? "OffFocused":"OffUnfocused" ); } } } diff --git a/stepmania/src/ScreenSelectMaster.h b/stepmania/src/ScreenSelectMaster.h index 0d5480d40e..17db21cf33 100644 --- a/stepmania/src/ScreenSelectMaster.h +++ b/stepmania/src/ScreenSelectMaster.h @@ -34,7 +34,6 @@ protected: Page GetCurrentPage() const; ThemeMetric SHOW_ICON; - ThemeMetric SHOW_PREVIEW; ThemeMetric SHOW_CURSOR; ThemeMetric SHOW_SCROLLER; ThemeMetric SHARED_PREVIEW_AND_CURSOR; @@ -74,15 +73,13 @@ protected: AutoActor m_sprExplanation[NUM_PAGES]; AutoActor m_sprMore[NUM_PAGES]; - // icon is the piece shared, per-choice piece + // icon is the shared, per-choice piece AutoActor m_sprIcon[MAX_CHOICES]; - // preview is per-choice, per-player piece - AutoActor m_sprPreview[MAX_CHOICES][NUM_PLAYERS]; - // cursor is the per-player that's shared by all choices - AutoActor m_sprCursor[NUM_PLAYERS]; - // scroll is the per-player, per-choice piece that's scrolled - AutoActor m_sprScroll[MAX_CHOICES][NUM_PLAYERS]; + // preview is per-player, per-choice piece + AutoActor m_sprScroll[MAX_CHOICES][NUM_PLAYERS]; ActorScroller m_Scroller[NUM_PLAYERS]; + // cursor is the per-player, shared by all choices + AutoActor m_sprCursor[NUM_PLAYERS]; RageSound m_soundChange; RandomSample m_soundDifficult;