From d4f4a854cfe14d7db1d75e286fc051f435596641 Mon Sep 17 00:00:00 2001 From: Andrew Livy Date: Sun, 25 Aug 2002 23:10:28 +0000 Subject: [PATCH] Cleaned up Ez2SelectStyle (however 2p support removed). Now using new ScrollingList system (PUMP can make use of this for select style also) --- stepmania/src/ScreenEz2SelectPlayer.cpp | 34 +- stepmania/src/ScreenEz2SelectStyle.cpp | 612 +++--------------------- stepmania/src/ScreenEz2SelectStyle.h | 14 +- stepmania/src/ScrollingList.cpp | 403 ++++++++++++++++ stepmania/src/ScrollingList.h | 65 +++ stepmania/src/StepMania.dsp | 8 + 6 files changed, 567 insertions(+), 569 deletions(-) create mode 100644 stepmania/src/ScrollingList.cpp create mode 100644 stepmania/src/ScrollingList.h diff --git a/stepmania/src/ScreenEz2SelectPlayer.cpp b/stepmania/src/ScreenEz2SelectPlayer.cpp index 90e058db57..c49e505cc4 100644 --- a/stepmania/src/ScreenEz2SelectPlayer.cpp +++ b/stepmania/src/ScreenEz2SelectPlayer.cpp @@ -26,20 +26,13 @@ Andrew Livy #include "GameState.h" #include "RageException.h" #include "RageTimer.h" -#include "ScreenSelectStyle5th.h" /* Constants */ const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User + 1); const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User + 2); -#define SELECT_STYLE_TYPE THEME->GetMetricI("General","SelectStyleType") -enum SelectStyleType // for use with the metric above -{ - SELECT_STYLE_TYPE_MAX = 0, - SELECT_STYLE_TYPE_5TH, - SELECT_STYLE_TYPE_EZ2, -}; +#define USE_NORMAL_OR_EZ2_SELECT_STYLE THEME->GetMetricB("General","UseNormalOrEZ2SelectStyle") const float TWEEN_TIME = 0.35f; const D3DXCOLOR OPT_NOT_SELECTED = D3DXCOLOR(0.3f,0.3f,0.3f,1); @@ -117,6 +110,10 @@ ScreenEz2SelectPlayer::ScreenEz2SelectPlayer() MUSIC->Play( true ); } +// GAMESTATE->m_bPlayersCanJoin = true; +// GAMESTATE->m_bIsJoined[PLAYER_1] = false; +// GAMESTATE->m_bIsJoined[PLAYER_2] = false; + // AfterChange(); // TweenOnScreen(); m_Menu.TweenOnScreenFromBlack( SM_None ); @@ -247,21 +244,10 @@ void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM ) SCREENMAN->SetNewScreen( new ScreenTitleMenu ); break; case SM_GoToNextState: - switch( SELECT_STYLE_TYPE ) - { - case SELECT_STYLE_TYPE_MAX: - SCREENMAN->SetNewScreen( new ScreenSelectStyle ); - break; - case SELECT_STYLE_TYPE_5TH: - SCREENMAN->SetNewScreen( new ScreenSelectStyle5th ); - break; - case SELECT_STYLE_TYPE_EZ2: + if( USE_NORMAL_OR_EZ2_SELECT_STYLE ) SCREENMAN->SetNewScreen( new ScreenEz2SelectStyle ); - break; - default: - ASSERT(0); - break; - } + else + SCREENMAN->SetNewScreen( new ScreenSelectStyle ); break; } } @@ -316,11 +302,13 @@ void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p ) if (p == PLAYER_1) { +// GAMESTATE->m_bIsJoined[PLAYER_1] = true; m_iSelectedStyle = 0; } else { m_iSelectedStyle = 1; +// GAMESTATE->m_bIsJoined[PLAYER_2] = true; } m_soundSelect.PlayRandom(); ez2_lasttimercheck[1] = TIMER->GetTimeSinceStart(); // start the timer for going to next state @@ -328,6 +316,8 @@ void ScreenEz2SelectPlayer::MenuStart( PlayerNumber p ) else { m_iSelectedStyle = 2; +// GAMESTATE->m_bIsJoined[PLAYER_1] = true; +// GAMESTATE->m_bIsJoined[PLAYER_2] = true; m_soundSelect.PlayRandom(); } diff --git a/stepmania/src/ScreenEz2SelectStyle.cpp b/stepmania/src/ScreenEz2SelectStyle.cpp index 4ea04dcd7d..ae1cbfe047 100644 --- a/stepmania/src/ScreenEz2SelectStyle.cpp +++ b/stepmania/src/ScreenEz2SelectStyle.cpp @@ -4,8 +4,8 @@ Desc: See Header Copyright (C): Andrew Livy -NOTES: Needs a good cleanup. Code is messy -and sloppy and err needs cleaning up ;) +NOTES: Although cleaner, can still do with +a polish :) *****************************************/ /* Includes */ @@ -33,92 +33,19 @@ and sloppy and err needs cleaning up ;) /* Constants */ -// const CString BG_ANIMS_DIR = "BGAnimations\\"; - const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User + 1); const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User + 2); -/* -const CString DANCE_STYLES[] = { - "easy", - "hard", - "real", - "double", -}; -*/ + enum DStyles { - DS_CLUB, DS_EASY, DS_HARD, - DS_REAL - + DS_REAL, + DS_CLUB }; const float TWEEN_TIME = 0.35f; -const D3DXCOLOR OPT_NOT_SELECTED = D3DXCOLOR(0.3f,0.3f,0.3f,1); -const D3DXCOLOR OPT_SELECTED = D3DXCOLOR(1.0f,1.0f,1.0f,1); - -const float OPT_X[NUM_EZ2STYLE_GRAPHICS] = { - CENTER_X-350, - CENTER_X, - CENTER_X+350, - CENTER_X+700, -}; // tells us the default X position -const float OPT_Y[NUM_EZ2STYLE_GRAPHICS] = { - CENTER_Y, - CENTER_Y, - CENTER_Y, - CENTER_Y, -}; // tells us the default Y position - -const float CLUB_X[NUM_EZ2STYLE_GRAPHICS] = { - OPT_X[0]+0, - OPT_X[0]-350, - OPT_X[2]+0, - OPT_X[1]+0, -}; - -const float EASY_X[NUM_EZ2STYLE_GRAPHICS] = { - OPT_X[1]+0, - OPT_X[0]+0, - OPT_X[0]-350, - OPT_X[2]+0, -}; - -const float HARD_X[NUM_EZ2STYLE_GRAPHICS] = { - OPT_X[2]+0, - OPT_X[1]+0, - OPT_X[0]+0, - OPT_X[0]-350, -}; - -const float REAL_X[NUM_EZ2STYLE_GRAPHICS] = { - OPT_X[3]+0, - OPT_X[2]+0, - OPT_X[1]+0, - OPT_X[0]+0, -}; - -const float OPT_XP[NUM_EZ2P_GRAPHICS] = { - CENTER_X+200, // This is the pad X - CENTER_X-200, // This is the pad X - CENTER_X-198, // This is the 1p X - CENTER_X+195, // This is the 2p X -}; // tells us the default X position -const float OPT_YP[NUM_EZ2P_GRAPHICS] = { - CENTER_Y+130, - CENTER_Y+130, - CENTER_Y+115, - CENTER_Y+115, -}; // tells us the default Y position - - -#define SELECT_DIFFICULTY_TYPE THEME->GetMetricI("General","SelectDifficultyType") -enum SelectDifficultyType // for use with the metric above -{ - SELECT_DIFFICULTY_TYPE_SKIP = 0, - SELECT_DIFFICULTY_TYPE_MAX, -}; +#define SKIP_SELECT_DIFFICULTY THEME->GetMetricB("General","SkipSelectDifficulty") float ez2p_lasttimercheck[2]; @@ -134,8 +61,7 @@ ScreenEz2SelectStyle::ScreenEz2SelectStyle() { LOG->Trace( "ScreenEz2SelectStyle::ScreenEz2SelectStyle()" ); - m_iSelectedStyle=0; - ez2p_lasttimercheck[0] = TIMER->GetTimeSinceStart(); + m_iSelectedStyle=DS_EASY; // start on EASY // Load in the sprites we will be working with. for( int i=0; iAddSubActor( &m_sprBackground[i] ); } - for( i=0; iGetPathTo("Graphics",ssprintf("select style info game %d style %d",GAMESTATE->m_CurGame,i)) ); - m_sprOpt[i].SetXY( OPT_X[i], OPT_Y[i] ); - m_sprOpt[i].SetZoom( 1 ); - this->AddSubActor( &m_sprOpt[i] ); - } + m_ScrList.SetNumberVisibleElements( 3 ); + m_ScrList.CreateNewElement( "select style info game 2 style 1" ); + m_ScrList.CreateNewElement( "select style info game 2 style 2" ); + m_ScrList.CreateNewElement( "select style info game 2 style 3" ); + m_ScrList.CreateNewElement( "select style info game 2 style 0" ); // Excess so that the user is tricked into thinking + m_ScrList.CreateNewElement( "select style info game 2 style 1" ); // the list is infinite + m_ScrList.CreateNewElement( "select style info game 2 style 2" ); + m_ScrList.CreateNewElement( "select style info game 2 style 3" ); + m_ScrList.CreateNewElement( "select style info game 2 style 0" ); + m_ScrList.CreateNewElement( "select style info game 2 style 1" ); + m_ScrList.CreateNewElement( "select style info game 2 style 2" ); + m_ScrList.CreateNewElement( "select style info game 2 style 3" ); + m_ScrList.CreateNewElement( "select style info game 2 style 0" ); + m_ScrList.SetXY(CENTER_X, CENTER_Y); + m_ScrList.SetCurrentPosition( DS_EASY ); - for( i=0; iGetPathTo("Graphics",sPlyFileName) ); - m_sprPly[i].SetXY( OPT_XP[i], OPT_YP[i] ); - m_sprPly[i].SetZoom( 1 ); - this->AddSubActor( &m_sprPly[i] ); - } + this->AddSubActor( &m_ScrList ); m_Menu.Load( THEME->GetPathTo("Graphics","select style background"), THEME->GetPathTo("Graphics","select style top edge"), - ssprintf("Use %c %c to select, then press START", char(1), char(2) ), + ssprintf("Press %c on the pad you wish to play on", char(4) ), false, true, 40 ); this->AddSubActor( &m_Menu ); - m_soundChange.Load( THEME->GetPathTo("Sounds","select style change") ); m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") ); - m_soundInvalid.Load( THEME->GetPathTo("Sounds","menu invalid") ); - /* Chris: if EZ2 shouldn't play a sound here, then make a slient sound file. */ - SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_STYLE_INTRO) ); + GAMESTATE->m_bPlayersCanJoin = true; - - if( !MUSIC->IsPlaying() ) - { - MUSIC->Load( THEME->GetPathTo("Sounds","select style music") ); - MUSIC->Play( true ); - } - - /* - TODO: Get all the EZ2 specific stuff out of here - */ - - if ( GAMESTATE->m_bSideIsJoined[PLAYER_1] && GAMESTATE->m_CurStyle == STYLE_EZ2_SINGLE) //if p1 already selected hide graphic. - { - m_iSelectedPlayer = 0; - m_sprPly[1].BeginTweening( 0 ); - m_sprPly[1].SetTweenZoomY( 0 ); - m_sprPly[2].BeginTweening( 0 ); - m_sprPly[2].SetTweenZoomY( 0 ); - } - else if ( GAMESTATE->m_bSideIsJoined[PLAYER_2] && GAMESTATE->m_CurStyle == STYLE_EZ2_SINGLE) //if p2 already selected hide graphic. - { - m_iSelectedPlayer = 1; - m_sprPly[3].BeginTweening( 0 ); - m_sprPly[3].SetTweenZoomY( 0 ); - m_sprPly[0].BeginTweening( 0 ); - m_sprPly[0].SetTweenZoomY( 0 ); - } - else // if both are already selected, hide the graphics alltogether - { - m_iSelectedPlayer = 2; - m_sprPly[1].BeginTweening( 0 ); - m_sprPly[1].SetTweenZoomY( 0 ); - m_sprPly[2].BeginTweening( 0 ); - m_sprPly[2].SetTweenZoomY( 0 ); - m_sprPly[3].BeginTweening( 0 ); - m_sprPly[3].SetTweenZoomY( 0 ); - m_sprPly[0].BeginTweening( 0 ); - m_sprPly[0].SetTweenZoomY( 0 ); - - // hide the CLUB graphic... - m_sprOpt[0].BeginTweening( 0 ); - m_sprOpt[0].SetTweenZoomY( 0 ); - m_iSelectedStyle = 1; // make sure we DONT have CLUB selected - m_sprOpt[DS_EASY].SetXY( EASY_X[m_iSelectedStyle]-350, OPT_Y[0] ); - m_sprOpt[DS_HARD].SetXY( HARD_X[m_iSelectedStyle]-350, OPT_Y[0] ); - m_sprOpt[DS_REAL].SetXY( HARD_X[m_iSelectedStyle], OPT_Y[0] ); - MenuLeft( PLAYER_1 ); // shift left so that we're clean again. - - } - GAMESTATE->m_CurStyle = STYLE_NONE; // why reset this? because we want player2 to be able to input at this stage. - - m_Menu.TweenOnScreenFromBlack( SM_None ); } @@ -258,14 +123,17 @@ Desc: Draws the screen =P void ScreenEz2SelectStyle::DrawPrimitives() { - if (m_iSelectedPlayer != 2) // no need to animate graphics if we have no graphics to animate ;) +/* if (m_iSelectedPlayer != 2) // no need to animate graphics if we have no graphics to animate ;) { AnimateGraphics(); } +*/ AnimateBackground(); + m_Menu.DrawBottomLayer(); Screen::DrawPrimitives(); m_Menu.DrawTopLayer(); + } /************************************ @@ -294,50 +162,6 @@ void ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM ) switch( SM ) { case SM_MenuTimer: - - if (m_iSelectedPlayer == 2) // both players - { - // m_soundInvalid.PlayRandom(); - // return; - - if (m_iSelectedStyle == 0) // easy - { - } - else if (m_iSelectedStyle == 1) // hard - { - // m_soundInvalid.PlayRandom(); - // return; - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD_VERSUS; - } - else if (m_iSelectedStyle == 2) // real - { - GAMESTATE->m_CurStyle = STYLE_EZ2_REAL_VERSUS; - //m_soundInvalid.PlayRandom(); - //return; - } - - } - else - { - if (m_iSelectedStyle == 0) // easy - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; - } - else if (m_iSelectedStyle == 1) // hard - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD; - } - else if (m_iSelectedStyle == 2) // real - { - GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; - } - else // club - { - GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; -// GAMESTATE->m_MasterPlayerNumber = PLAYER_1; - } - } - m_soundSelect.PlayRandom(); GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; SCREENMAN->SetNewScreen( new ScreenSelectGroup ); @@ -348,17 +172,10 @@ void ScreenEz2SelectStyle::HandleScreenMessage( const ScreenMessage SM ) SCREENMAN->SetNewScreen( new ScreenTitleMenu ); break; case SM_GoToNextState: - switch( SELECT_DIFFICULTY_TYPE ) - { - case SELECT_DIFFICULTY_TYPE_SKIP: + if( SKIP_SELECT_DIFFICULTY ) SCREENMAN->SetNewScreen( new ScreenSelectGroup ); - break; - case SELECT_DIFFICULTY_TYPE_MAX: + else SCREENMAN->SetNewScreen( new ScreenSelectDifficulty ); - break; - default: - ASSERT(0); - } break; } } @@ -401,22 +218,7 @@ depending on the users choice. ************************************/ void ScreenEz2SelectStyle::SetFadedStyles() { - m_sprOpt[0].SetTweenDiffuseColor( OPT_NOT_SELECTED ); - m_sprOpt[1].SetTweenDiffuseColor( OPT_NOT_SELECTED ); - m_sprOpt[2].SetTweenDiffuseColor( OPT_NOT_SELECTED ); - m_sprOpt[3].SetTweenDiffuseColor( OPT_NOT_SELECTED ); - if (m_iSelectedStyle != 3) - { - m_sprOpt[m_iSelectedStyle + 1].SetTweenDiffuseColor( OPT_SELECTED ); - } - else - { - m_sprOpt[0].SetTweenDiffuseColor( OPT_SELECTED ); - } - if (m_iSelectedPlayer == 2 && m_iSelectedStyle == DS_REAL) - { - m_sprOpt[1].SetTweenDiffuseColor( OPT_SELECTED ); - } + } /************************************ @@ -426,121 +228,18 @@ presses the button bound to right ************************************/ void ScreenEz2SelectStyle::MenuRight( PlayerNumber p ) { - if (m_iSelectedPlayer != 2) // Single player + m_ScrList.ShiftRight(); + if (m_iSelectedStyle == 3) // wrap around + m_iSelectedStyle = 0; + else + m_iSelectedStyle++; + + switch (m_iSelectedStyle) { - if (((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) != TRUE) // make sure players who haven't selected yet can't choose a style - { - if( m_iSelectedStyle == 3 ) // wrap to the first dance style - m_iSelectedStyle = 0; // which is (club) easy (hard) - else - m_iSelectedStyle = m_iSelectedStyle + 1; // otherwise shuffle up a style... - - if(m_iSelectedStyle == 2) // If it's HARD and CLUB needs to appear from the other side... - { - m_sprOpt[0].SetXY( REAL_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - } - else if(m_iSelectedStyle == 3) // If it's REAL and EASY needs to appear from the other side... - { - m_sprOpt[1].SetXY( CLUB_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - } - else if(m_iSelectedStyle == 0) // If it's CLUB and HARD needs to appear from the other side... - { - m_sprOpt[2].SetXY( EASY_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[3].SetXY( EASY_X[m_iSelectedStyle]+1050, OPT_Y[0] ); // REAL must also move, due to the fact that it is the end item at the start, it moves differently to the rest. - } - - m_sprOpt[0].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[0].SetTweenX( CLUB_X[m_iSelectedStyle] ); - m_sprOpt[0].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - - m_sprOpt[1].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[1].SetTweenX( EASY_X[m_iSelectedStyle] ); - m_sprOpt[1].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - m_sprOpt[2].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[2].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[2].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - m_sprOpt[3].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[3].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[3].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - SetFadedStyles(); - } - } - else // Two Players (means NO club option...) - { - if (((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) != TRUE) // make sure players who haven't selected yet can't choose a style - { - if( m_iSelectedStyle == DS_REAL ) // wrap to the last dance style - m_iSelectedStyle = DS_EASY; - else - m_iSelectedStyle = m_iSelectedStyle + 1; - - if( m_iSelectedStyle == DS_REAL ) // (REALLY EASY) - { - m_sprOpt[DS_HARD].SetXY( CLUB_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_REAL].SetXY( REAL_X[m_iSelectedStyle]+350, OPT_Y[0] ); - m_sprOpt[DS_EASY].SetXY( CLUB_X[m_iSelectedStyle]+350, OPT_Y[0] ); - } - else if( m_iSelectedStyle == DS_HARD ) // (REALLY REAL) - { - m_sprOpt[DS_EASY].SetXY( REAL_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_HARD].SetXY( HARD_X[m_iSelectedStyle]+350, OPT_Y[0] ); - m_sprOpt[DS_REAL].SetXY( REAL_X[m_iSelectedStyle]+350, OPT_Y[0] ); - } - else if( m_iSelectedStyle == DS_EASY ) // (REALLY HARD) - { - m_sprOpt[DS_REAL].SetXY( HARD_X[m_iSelectedStyle]+700, OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_EASY].SetXY( EASY_X[m_iSelectedStyle]+350, OPT_Y[0] ); - m_sprOpt[DS_HARD].SetXY( HARD_X[m_iSelectedStyle]+350, OPT_Y[0] ); - } - - - /* NOTE: Because we're really shifting three values using a setup for four values - the DS_ values are shifted out of phase by 1, i.e. DS_REAL is now actually DS_EASY - Confused? I was =) Anyhow, this will only happen if there are two players and we don't want - them playing double - */ - if (m_iSelectedStyle == DS_REAL) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( CLUB_X[m_iSelectedStyle] ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( CLUB_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - else if (m_iSelectedStyle == DS_HARD) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( REAL_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - else if (m_iSelectedStyle == DS_EASY) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( EASY_X[m_iSelectedStyle] ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( HARD_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - } - SetFadedStyles(); + case DS_EASY: GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; break; + case DS_HARD: GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD; break; + case DS_REAL: GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; break; + case DS_CLUB: GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; break; } } @@ -551,119 +250,18 @@ presses the button bound to left ************************************/ void ScreenEz2SelectStyle::MenuLeft( PlayerNumber p ) { - if (m_iSelectedPlayer != 2) // Single player + m_ScrList.ShiftLeft(); + if (m_iSelectedStyle == 0) // wrap around + m_iSelectedStyle = 3; + else + m_iSelectedStyle--; + + switch (m_iSelectedStyle) { - if (((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) != TRUE) // make sure players who haven't selected yet can't choose a style - { - if( m_iSelectedStyle == 0 ) // wrap to the last dance style - m_iSelectedStyle = 3; - else - m_iSelectedStyle = m_iSelectedStyle - 1; - - if( m_iSelectedStyle == 3 ) - { - m_sprOpt[3].SetXY( CLUB_X[m_iSelectedStyle]-700, OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[2].SetXY( CLUB_X[m_iSelectedStyle]-1050, OPT_Y[0] ); - } - else if( m_iSelectedStyle == 2 ) - { - m_sprOpt[1].SetXY( HARD_X[m_iSelectedStyle]-700, OPT_Y[0] ); // First move it over the other side off-screen... - } - else if( m_iSelectedStyle == 1 ) - { - m_sprOpt[0].SetXY( EASY_X[m_iSelectedStyle]-1050, OPT_Y[0] ); // First move it over the other side off-screen... - } - - m_sprOpt[0].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[0].SetTweenX( CLUB_X[m_iSelectedStyle] ); - m_sprOpt[0].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - m_sprOpt[1].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[1].SetTweenX( EASY_X[m_iSelectedStyle] ); - m_sprOpt[1].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - m_sprOpt[2].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[2].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[2].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - m_sprOpt[3].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[3].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[3].SetTweenY( OPT_Y[m_iSelectedStyle] ); - - SetFadedStyles(); - } - } - else // Two Players (means NO club option...) - { - if (((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) != TRUE) // make sure players who haven't selected yet can't choose a style - { - if( m_iSelectedStyle == DS_EASY ) // wrap to the last dance style - m_iSelectedStyle = DS_REAL; - else - m_iSelectedStyle = m_iSelectedStyle - 1; - - if( m_iSelectedStyle == DS_REAL ) // (REALLY EASY) - { - m_sprOpt[DS_HARD].SetXY( CLUB_X[m_iSelectedStyle], OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_REAL].SetXY( REAL_X[m_iSelectedStyle]-350, OPT_Y[0] ); - } - else if( m_iSelectedStyle == DS_HARD ) // (REALLY REAL) - { - m_sprOpt[DS_EASY].SetXY( REAL_X[m_iSelectedStyle], OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_HARD].SetXY( HARD_X[m_iSelectedStyle]-350, OPT_Y[0] ); - } - else if( m_iSelectedStyle == DS_EASY ) // (REALLY HARD) - { - m_sprOpt[DS_REAL].SetXY( HARD_X[m_iSelectedStyle], OPT_Y[0] ); // First move it over the other side off-screen... - m_sprOpt[DS_EASY].SetXY( EASY_X[m_iSelectedStyle]-350, OPT_Y[0] ); - } - - - /* NOTE: Because we're really shifting three values using a setup for four values - the DS_ values are shifted out of phase by 1, i.e. DS_REAL is now actually DS_EASY - Confused? I was =) Anyhow, this will only happen if there are two players and we don't want - them playing double - */ - if (m_iSelectedStyle == DS_REAL) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( CLUB_X[m_iSelectedStyle] ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( CLUB_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - else if (m_iSelectedStyle == DS_HARD) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( REAL_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( REAL_X[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - else if (m_iSelectedStyle == DS_EASY) - { - m_sprOpt[DS_EASY].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_EASY].SetTweenX( EASY_X[m_iSelectedStyle] ); - m_sprOpt[DS_EASY].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_HARD].SetTweenX( HARD_X[m_iSelectedStyle] ); - m_sprOpt[DS_HARD].SetTweenY( OPT_Y[m_iSelectedStyle] ); - m_sprOpt[DS_REAL].BeginTweening( 0.2f, TWEEN_BIAS_BEGIN ); - m_sprOpt[DS_REAL].SetTweenX( HARD_X[m_iSelectedStyle] + 350 ); - m_sprOpt[DS_REAL].SetTweenY( OPT_Y[m_iSelectedStyle] ); - } - - - SetFadedStyles(); - } + case DS_EASY: GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; break; + case DS_HARD: GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD; break; + case DS_REAL: GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; break; + case DS_CLUB: GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; break; } } @@ -674,85 +272,21 @@ presses the button bound to start ************************************/ void ScreenEz2SelectStyle::MenuStart( PlayerNumber p ) { -// GAMESTATE->m_CurStyle = DANCE_STYLES[m_iSelectedStyle]; - - if ((m_iSelectedPlayer == 0 && p == PLAYER_2) || (m_iSelectedPlayer == 1 && p == PLAYER_1)) - { - //if (p == PLAYER_2) // CURRENTLY PLAYER 2 IS BROKEN - //{ - // m_soundInvalid.PlayRandom(); - // return; - //} - m_soundSelect.PlayRandom(); - TweenPlyOffScreen(); - m_iSelectedPlayer = 2; // set to BOTH players now. - // hide the CLUB graphic... - m_sprOpt[0].BeginTweening( 0 ); - m_sprOpt[0].SetTweenZoomY( 0 ); - m_iSelectedStyle = 1; // make sure we DONT have CLUB selected - m_sprOpt[DS_EASY].SetXY( EASY_X[m_iSelectedStyle]-350, OPT_Y[0] ); - m_sprOpt[DS_HARD].SetXY( HARD_X[m_iSelectedStyle]-350, OPT_Y[0] ); - m_sprOpt[DS_REAL].SetXY( HARD_X[m_iSelectedStyle], OPT_Y[0] ); - MenuLeft( p ); // shift left so that we're clean again. - } - else - { - if (m_iSelectedPlayer == 2) // both players - { - // m_soundInvalid.PlayRandom(); - // return; - - if (m_iSelectedStyle == 0 || m_iSelectedStyle == 3) // easy - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_VERSUS; - } - else if (m_iSelectedStyle == 1) // hard - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD_VERSUS; - } - else if (m_iSelectedStyle == 2) // real - { - GAMESTATE->m_CurStyle = STYLE_EZ2_REAL_VERSUS; - } - - } - else - { - if (m_iSelectedStyle == 0) // easy - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE; - } - else if (m_iSelectedStyle == 1) // hard - { - GAMESTATE->m_CurStyle = STYLE_EZ2_SINGLE_HARD; - } - else if (m_iSelectedStyle == 2) // real - { - GAMESTATE->m_CurStyle = STYLE_EZ2_REAL; - //m_soundInvalid.PlayRandom(); - //return; - } - else // club - { - GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; - GAMESTATE->m_CurStyle = STYLE_EZ2_DOUBLE; -// GAMESTATE->m_MasterPlayerNumber = PLAYER_1; - //m_soundInvalid.PlayRandom(); - //return; - } - } - m_soundSelect.PlayRandom(); - - this->ClearMessageQueue(); - - GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; - - m_Menu.TweenOffScreenToMenu( SM_GoToNextState ); - - TweenOffScreen(); - } +// if( p!=PLAYER_INVALID && !GAMESTATE->m_bIsJoined[p] ) +// { +// SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); +// GAMESTATE->m_bIsJoined[p] = true; +// SCREENMAN->RefreshCreditsMessages(); +// m_soundSelect.PlayRandom(); +// return; // don't fall through +// } + m_soundSelect.PlayRandom(); + this->ClearMessageQueue(); + GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; +// GAMESTATE->m_bPlayersCanJoin = false; + m_Menu.TweenOffScreenToMenu( SM_GoToNextState ); } /************************************ @@ -773,7 +307,7 @@ void ScreenEz2SelectStyle::AnimateGraphics() { //if (bounce < 10 && direct == 0 && wait == 2) // Bounce 1p/2p up - if (TIMER->GetTimeSinceStart() > ez2p_lasttimercheck[0] + 0.01f && ez2p_direct == 0) +/* if (TIMER->GetTimeSinceStart() > ez2p_lasttimercheck[0] + 0.01f && ez2p_direct == 0) { ez2p_lasttimercheck[0] = TIMER->GetTimeSinceStart(); ez2p_bounce+=1; @@ -800,6 +334,7 @@ void ScreenEz2SelectStyle::AnimateGraphics() ez2p_direct = 0; } } +*/ } /************************************ @@ -861,12 +396,5 @@ When selected. ************************************/ void ScreenEz2SelectStyle::TweenPlyOffScreen() { - m_sprPly[1].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); - m_sprPly[1].SetTweenZoomY( 0 ); - m_sprPly[2].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); - m_sprPly[2].SetTweenZoomY( 0 ); - m_sprPly[0].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); - m_sprPly[0].SetTweenZoomY( 0 ); - m_sprPly[3].BeginTweening( MENU_ELEMENTS_TWEEN_TIME ); - m_sprPly[3].SetTweenZoomY( 0 ); + } \ No newline at end of file diff --git a/stepmania/src/ScreenEz2SelectStyle.h b/stepmania/src/ScreenEz2SelectStyle.h index 58a1d4e199..5d668d38db 100644 --- a/stepmania/src/ScreenEz2SelectStyle.h +++ b/stepmania/src/ScreenEz2SelectStyle.h @@ -1,6 +1,6 @@ /******************************** ScreenEz2SelectStyle.h -Desc: The "Player Select Screen" for Ez2dancer +Desc: The "Style Select Screen" for Ez2dancer Copyright (c): Andrew Livy *********************************/ @@ -16,11 +16,12 @@ Andrew Livy #include "RandomSample.h" #include "Quad.h" #include "MenuElements.h" +#include "ScrollingList.h" /* Class Definition */ -const int NUM_EZ2STYLE_GRAPHICS = 4; -const int NUM_EZ2P_GRAPHICS = 4; + const int NUM_EZ2STYLE_GRAPHICS = 4; +// const int NUM_EZ2P_GRAPHICS = 4; class ScreenEz2SelectStyle : public Screen { @@ -51,10 +52,13 @@ private: /* Variable Declarations */ MenuElements m_Menu; - Sprite m_sprOpt[NUM_EZ2STYLE_GRAPHICS]; - Sprite m_sprPly[NUM_EZ2P_GRAPHICS]; +// Sprite m_sprOpt[NUM_EZ2STYLE_GRAPHICS]; +// Sprite m_sprPly[NUM_EZ2P_GRAPHICS]; Sprite m_sprBackground[NUM_EZ2STYLE_GRAPHICS]; + ScrollingList m_ScrList; + + int m_iSelectedStyle; int m_iSelectedPlayer; RandomSample m_soundChange; diff --git a/stepmania/src/ScrollingList.cpp b/stepmania/src/ScrollingList.cpp new file mode 100644 index 0000000000..2c9bb62555 --- /dev/null +++ b/stepmania/src/ScrollingList.cpp @@ -0,0 +1,403 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: ScrollingList + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Andrew Livy +----------------------------------------------------------------------------- +*/ + +#include "ScrollingList.h" +#include "RageUtil.h" +#include "GameConstantsAndTypes.h" +#include "PrefsManager.h" +#include "RageLog.h" +#include "PrefsManager.h" +#include "Course.h" +#include "SongManager.h" + +const int DEFAULT_VISIBLE_ELEMENTS = 3; + +const float SPACING3ELEMENTS = 310.0f; +const float SPACING4ELEMENTS = 225.0f; +const float SPACING5ELEMENTS = 150.0f; + + +ScrollingListDisplay::ScrollingListDisplay() +{ + +} + +/************************************ +Allows us to create a graphic element +in the scrolling list +*************************************/ + +void ScrollingListDisplay::Load( CString graphiclocation ) +{ + m_gLocation = graphiclocation; + m_sprListElement.Load( THEME->GetPathTo("Graphics",m_gLocation) ); + this->AddSubActor( &m_sprListElement ); +} + +/*********************************** +RedefineGraphic + +Allows us to change a graphic +element in the scrolling list +************************************/ + +void ScrollingListDisplay::RedefineGraphic( CString graphiclocation ) +{ + m_gLocation = graphiclocation; + m_sprListElement.Load( THEME->GetPathTo("Graphics",m_gLocation) ); +} + +/************************************* +GetGraphicLocation + +Returns the graphic filename from a +scrollinglist element +**************************************/ + +CString ScrollingListDisplay::GetGraphicLocation() +{ + return m_gLocation; +} + +/*************************************** +ScrollingList + +Initializes Variables for the ScrollingList +****************************************/ + +ScrollingList::ScrollingList() +{ + m_iNumContents = 0; + m_iNumVisElements = DEFAULT_VISIBLE_ELEMENTS; + m_iCurrentPos = 0; +} + +/************************************** +CreateNewElement + +Adds a new graphic element to the end of +the scrolling element +***************************************/ + +void ScrollingList::CreateNewElement( CString graphiclocation ) +{ + float CurrentSpacing; + if (m_iNumVisElements <= 3) + { + CurrentSpacing = SPACING3ELEMENTS; + } + else if (m_iNumVisElements == 4) + { + CurrentSpacing = SPACING4ELEMENTS; + } + else + { + CurrentSpacing = SPACING5ELEMENTS; + } + + m_ScrollingListDisplays[m_iNumContents].Load( graphiclocation ); + this->AddSubActor( &m_ScrollingListDisplays[m_iNumContents] ); + + m_ScrollingListDisplays[m_iNumContents].SetX( 0 - (CurrentSpacing * m_iNumContents) ); + + if (m_iNumContents != SCRLIST_MAX_TOTAL_CONTENTS) // make sure that we cannot 'over create' menus + m_iNumContents = m_iNumContents + 1; +} + + +/************************************** +ShiftLeft + +Make the entire list shuffle left +**************************************/ + +void ScrollingList::ShiftLeft() +{ + if ( m_iCurrentPos == 0 ) // if we're at the start of the list wrap to the end + { + m_iCurrentPos = m_iNumContents - 1; + } + else // just decrease our position + { + m_iCurrentPos--; + } + + float CurrentSpacing; + if (m_iNumVisElements <= 3) + { + CurrentSpacing = SPACING3ELEMENTS; + } + else if (m_iNumVisElements == 4) + { + CurrentSpacing = SPACING4ELEMENTS; + } + else + { + CurrentSpacing = SPACING5ELEMENTS; + } + + + SetCurrentPosition( m_iCurrentPos ); + + for (int i=10; i > 0; i-- ) // 21 elements (10 going in both directions plus a 0) + { + if (m_iCurrentPos - i >= 0) // set -ve -tweening + { + m_ScrollingListDisplays[m_iCurrentPos - i].SetX( 0 - ((i-1) * CurrentSpacing) - (CurrentSpacing * 2) ); + m_ScrollingListDisplays[m_iCurrentPos - i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos - i].SetTweenX( 0 - (CurrentSpacing * i) ); + } + else + { + m_ScrollingListDisplays[m_iNumContents - i].SetX( 0 - ((i-1) * CurrentSpacing) - (CurrentSpacing * 2)); + m_ScrollingListDisplays[m_iNumContents - i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iNumContents - i].SetTweenX( 0 - (CurrentSpacing * i) ); + } + + if (m_iCurrentPos + i <= m_iNumContents - 1) // set +ve tweening + { + m_ScrollingListDisplays[m_iCurrentPos + i].SetX( 0 + (CurrentSpacing * i) + CurrentSpacing - (CurrentSpacing * 2)); + m_ScrollingListDisplays[m_iCurrentPos + i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos + i].SetTweenX( 0 + (CurrentSpacing * i) ); + } + else + { + m_ScrollingListDisplays[i-1].SetX( 0 + (CurrentSpacing * i) + CurrentSpacing - (CurrentSpacing * 2)); + m_ScrollingListDisplays[i-1].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[i-1].SetTweenX( 0 + (CurrentSpacing * i) ); + } + } + + m_ScrollingListDisplays[m_iCurrentPos].SetX( 0 + CurrentSpacing - (CurrentSpacing * 2)); + m_ScrollingListDisplays[m_iCurrentPos].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos].SetTweenX( 0 ); +} + +/************************************** +ShiftRight + +Make the entire list shuffle right +**************************************/ + +void ScrollingList::ShiftRight() +{ + if ( m_iCurrentPos == m_iNumContents - 1 ) // if we're at the end of the list wrap to the start + { + m_iCurrentPos = 0; + } + else // just decrease our position + { + m_iCurrentPos++; + } + + float CurrentSpacing; + if (m_iNumVisElements <= 3) + { + CurrentSpacing = SPACING3ELEMENTS; + } + else if (m_iNumVisElements == 4) + { + CurrentSpacing = SPACING4ELEMENTS; + } + else + { + CurrentSpacing = SPACING5ELEMENTS; + } + + + SetCurrentPosition( m_iCurrentPos ); + + for (int i=10; i > 0; i-- ) // 21 elements (10 going in both directions plus a 0) + { + if (m_iCurrentPos - i >= 0) // set -ve -tweening + { + m_ScrollingListDisplays[m_iCurrentPos - i].SetX( 0 - ((i-1) * CurrentSpacing) ); + m_ScrollingListDisplays[m_iCurrentPos - i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos - i].SetTweenX( 0 - (CurrentSpacing * i) ); + } + else + { + m_ScrollingListDisplays[m_iNumContents - i].SetX( 0 - ((i-1) * CurrentSpacing) ); + m_ScrollingListDisplays[m_iNumContents - i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iNumContents - i].SetTweenX( 0 - (CurrentSpacing * i) ); + } + + if (m_iCurrentPos + i <= m_iNumContents - 1) // set +ve tweening + { + m_ScrollingListDisplays[m_iCurrentPos + i].SetX( 0 + (CurrentSpacing * i) + CurrentSpacing ); + m_ScrollingListDisplays[m_iCurrentPos + i].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos + i].SetTweenX( 0 + (CurrentSpacing * i) ); + } + else + { + m_ScrollingListDisplays[i-1].SetX( 0 + (CurrentSpacing * i) + CurrentSpacing ); + m_ScrollingListDisplays[i-1].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[i-1].SetTweenX( 0 + (CurrentSpacing * i) ); + } + } + + m_ScrollingListDisplays[m_iCurrentPos].SetX( 0 + CurrentSpacing ); + m_ScrollingListDisplays[m_iCurrentPos].BeginTweening( 0.3f, TWEEN_BIAS_BEGIN ); + m_ScrollingListDisplays[m_iCurrentPos].SetTweenX( 0 ); +} + +/*********************************** +SetCurrentPostion + +From the current postion in the array, add graphic elements +in either direction to make the list seem infinite. +***********************************/ + +void ScrollingList::SetCurrentPosition( int CurrentPos ) +{ + m_iCurrentPos = CurrentPos; + // Setup Spacing + float CurrentSpacing; + if (m_iNumVisElements <= 3) + { + CurrentSpacing = SPACING3ELEMENTS; + } + else if (m_iNumVisElements == 4) + { + CurrentSpacing = SPACING4ELEMENTS; + } + else + { + CurrentSpacing = SPACING5ELEMENTS; + } + + // ORDER SPECIFICALLY! + // Central Element at front, then the next two behind, then the outer two behind them e.t.c. + // 21012 << Central element is 0, 1's are either side, 2's either side of those 3's come off-screen (regardless of spacing) + // we need 3's incase the user suddenly scrolls!! + + for( int i=3; i > 0; i--) + { + // Find the -ve Element + if ((CurrentPos - i) >= 0) // Bounds Checking: If we aren't under the first element + { + m_ScrollingListDisplays[CurrentPos-i].SetX( 0 - (i * CurrentSpacing )); + } + else // if we are under the final limit (by i) + { + m_ScrollingListDisplays[m_iNumContents+(CurrentPos - i)].SetX( 0 - (i * CurrentSpacing )); + } + + // Find the +ve Element + if ((CurrentPos + i) <= m_iNumContents-1) // Bounds Checking: If we aren't over the final element + { + m_ScrollingListDisplays[CurrentPos+i].SetX( 0 + (i * CurrentSpacing )); + } + else // if we are over the final limit (by i) + { + m_ScrollingListDisplays[i-1].SetX( 0 + (i * CurrentSpacing )); + } + } + + // Set The MIDDLE element + m_ScrollingListDisplays[CurrentPos].SetX( 0 ); +} + +/****************************** +SetNumberVisibleElements + +Allows us to set whether 3,4 or 5 +elements are visible on screen at once +*******************************/ + +void ScrollingList::SetNumberVisibleElements( int VisibleElements ) +{ + m_iNumVisElements = VisibleElements; +} + +/******************************* +Update + +Updates the actorframe +********************************/ + +void ScrollingList::Update( float fDeltaTime ) +{ + ActorFrame::Update( fDeltaTime ); + + for( int i=0; i=0; i--) + { + if (i != m_iCurrentPos) + { + m_ScrollingListDisplays[i].SetDiffuseColor( OPT_NOT_SELECTED ); + } + else + { + m_ScrollingListDisplays[i].SetDiffuseColor( OPT_SELECTED ); + } + } + + + // Start Drawing in a Specific Order For the elements around the current element + if (m_iCurrentPos == 0) // start of list? + { + m_ScrollingListDisplays[m_iNumContents - 2].Draw(); + m_ScrollingListDisplays[2].Draw(); + + m_ScrollingListDisplays[m_iNumContents - 1].Draw(); + m_ScrollingListDisplays[1].Draw(); + } + else if (m_iCurrentPos == m_iNumContents - 1) // end of list + { + m_ScrollingListDisplays[1].Draw(); + m_ScrollingListDisplays[m_iNumContents - 3].Draw(); + + m_ScrollingListDisplays[0].Draw(); + m_ScrollingListDisplays[m_iNumContents - 2].Draw(); + } + else if (m_iCurrentPos == 1) // near start + { + m_ScrollingListDisplays[m_iNumContents - 2].Draw(); + m_ScrollingListDisplays[3].Draw(); + + m_ScrollingListDisplays[2].Draw(); + m_ScrollingListDisplays[0].Draw(); + } + else if (m_iCurrentPos == m_iNumContents - 2) // near end + { + m_ScrollingListDisplays[0].Draw(); + m_ScrollingListDisplays[m_iNumContents - 4].Draw(); + + m_ScrollingListDisplays[m_iNumContents - 1].Draw(); + m_ScrollingListDisplays[m_iNumContents - 3].Draw(); + } + else // we're somewhere in the middle + { + m_ScrollingListDisplays[m_iCurrentPos + 2].Draw(); + m_ScrollingListDisplays[m_iCurrentPos - 2].Draw(); + m_ScrollingListDisplays[m_iCurrentPos - 1].Draw(); + m_ScrollingListDisplays[m_iCurrentPos + 1].Draw(); + } + + m_ScrollingListDisplays[m_iCurrentPos].Draw(); + +} diff --git a/stepmania/src/ScrollingList.h b/stepmania/src/ScrollingList.h new file mode 100644 index 0000000000..227280421a --- /dev/null +++ b/stepmania/src/ScrollingList.h @@ -0,0 +1,65 @@ +/* +----------------------------------------------------------------------------- + Class: ScrollingList.h + + Desc: Creates an array of graphics which can scroll left and right. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Andrew Livy +----------------------------------------------------------------------------- +*/ + +#pragma once +#include "Screen.h" +#include "Sprite.h" +#include "BitmapText.h" +#include "TransitionFade.h" +#include "RandomSample.h" +#include "RandomStream.h" + + +// const int SCRLIST_MAX_VISIBLE_CONTENTS = 5; +const int SCRLIST_MAX_TOTAL_CONTENTS = 20; // this is only meant for menu systems, not song lists + + +class ScrollingListDisplay : public ActorFrame +{ +public: + ScrollingListDisplay(); + + void Load( CString graphiclocation ); + void RedefineGraphic( CString graphiclocation ); + CString GetGraphicLocation(); + + CString m_gLocation; + Sprite m_sprListElement; +}; + + +class ScrollingList : public ActorFrame +{ +public: + ScrollingList(); + + void SetCurrentPosition( int CurrentPos ); + void SetNumberVisibleElements( int VisibleElements ); + void CreateNewElement( CString graphiclocation); + virtual void Update( float fDeltaTime ); + virtual void DrawPrimitives(); + void ShiftLeft(); + void ShiftRight(); + +// void SetFromCourse( Course* pCourse ); + +protected: + +// Quad m_quad; + + int m_iCurrentPos; + int m_iNumVisElements; + int m_iNumContents; + ScrollingListDisplay m_ScrollingListDisplays[SCRLIST_MAX_TOTAL_CONTENTS]; // stores the list of elements (from start to finish) + +// float m_fTimeUntilScroll; +// float m_fItemAtTopOfList; // between 0 and m_iNumContents +}; \ No newline at end of file diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index ff051810f4..86346829c6 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -704,6 +704,14 @@ SOURCE=.\ScrollBar.h # End Source File # Begin Source File +SOURCE=.\ScrollingList.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScrollingList.h +# End Source File +# Begin Source File + SOURCE=.\SnapDisplay.cpp # End Source File # Begin Source File