pressing L+R for the sort code should end up back at the originally selected item

fix jumpy wheel when letting go of L+R near-simultaneously
fix MenuTimer doesn't choose a Random song if sitting on a section or sort
fix MenuTimer fire has no effect if wheel is tweening
This commit is contained in:
Chris Danford
2005-06-12 23:43:39 +00:00
parent 8f9951e38d
commit 49b3cbaf34
3 changed files with 199 additions and 146 deletions
+19 -7
View File
@@ -167,9 +167,9 @@ void MusicWheel::Load( CString sType )
CString times;
/* Build all of the wheel item data. Do this after selecting
* the extra stage, so it knows to always display it. */
for( int so=0; so<NUM_SORT_ORDERS; so++ )
FOREACH_SortOrder( so )
{
BuildWheelItemDatas( m_WheelItemDatas[so], SortOrder(so) );
BuildWheelItemDatas( m_WheelItemDatas[so], so );
times += ssprintf( "%i:%.3f ", so, timer.GetDeltaTime() );
}
LOG->Trace( "took: %s", times.c_str() );
@@ -876,7 +876,8 @@ void MusicWheel::UpdateItems(float fDeltaTime )
}
}
void MusicWheel::UpdateSwitch() {
void MusicWheel::UpdateSwitch()
{
switch( m_WheelState )
{
case STATE_FLYING_OFF_BEFORE_NEXT_SORT:
@@ -1148,7 +1149,7 @@ void MusicWheel::StartRoulette()
m_Moving = 1;
m_TimeBeforeMovingBegins = 0;
m_SpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS;
SetOpenGroup("", SortOrder(SORT_ROULETTE));
SetOpenGroup("", SORT_ROULETTE);
}
void MusicWheel::StartRandom()
@@ -1161,8 +1162,11 @@ void MusicWheel::StartRandom()
/* Shuffle and use the roulette wheel. */
RandomGen rnd;
random_shuffle( m_WheelItemDatas[SORT_ROULETTE].begin(), m_WheelItemDatas[SORT_ROULETTE].end(), rnd );
SetOpenGroup( "", SortOrder(SORT_ROULETTE) );
SetOpenGroup( "", SORT_ROULETTE );
}
else
{
SetOpenGroup( "", GAMESTATE->m_PreferredSortOrder );
}
m_Moving = -1;
@@ -1263,7 +1267,8 @@ void MusicWheel::TweenOffScreenUpdateItems(bool changing_sort) {
}
}
bool MusicWheel::MoveSpecific(int n) {
bool MusicWheel::MoveSpecific(int n)
{
/* If we're not selecting, discard this. We won't ignore it; we'll
* get called again every time the key is repeated. */
/* Still process Move(0) so we sometimes continue moving immediate
@@ -1373,6 +1378,13 @@ try_next:
return wid[0].m_pSong;
}
void MusicWheel::FinishChangingSorts()
{
FinishTweening();
m_WheelState = STATE_SELECTING_MUSIC;
m_fTimeLeftInState = 0;
}
/*
* (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard
* All rights reserved.
+1
View File
@@ -59,6 +59,7 @@ public:
void SetOpenGroup(CString group, SortOrder so = SORT_INVALID);
SortOrder GetSortOrder() const { return m_SortOrder; }
virtual void ChangeMusic(int dist); /* +1 or -1 */ //CHECK THIS
void FinishChangingSorts();
protected:
virtual void LoadFromMetrics( CString sType );
+46 -6
View File
@@ -828,7 +828,10 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
}
}
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
switch( MenuI.button )
{
case MENU_BUTTON_RIGHT:
case MENU_BUTTON_LEFT:
{
/* If we're rouletting, hands off. */
if( m_MusicWheel.IsRouletting() )
@@ -848,28 +851,53 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
bool bBothDown = bLeftIsDown && bRightIsDown;
bool bNeitherDown = !bLeftIsDown && !bRightIsDown;
if( bBothDown || bNeitherDown )
{
m_MusicWheel.Move( 0 );
if( type == IET_FIRST_PRESS )
{
switch( MenuI.button )
{
case MENU_BUTTON_LEFT:
m_MusicWheel.ChangeMusic( -1 );
break;
case MENU_BUTTON_RIGHT:
m_MusicWheel.ChangeMusic( +1 );
break;
}
}
}
else if( bLeftIsDown )
{
if( type != IET_RELEASE )
m_MusicWheel.Move( -1 );
}
else if( bRightIsDown )
{
if( type != IET_RELEASE )
m_MusicWheel.Move( +1 );
}
else
{
ASSERT(0);
}
// Reset the repeat timer when a key is released.
// This fixes jumping when you release Left and Right at the same
// time (e.g. after tapping Left+Right to change sort).
// Reset the repeat timer when the button is released.
// This fixes jumping when you release Left and Right after entering the sort
// code at the same if L & R aren't released at the exact same time.
if( type == IET_RELEASE )
{
FOREACH_EnabledPlayer( p )
FOREACH_HumanPlayer( p )
{
INPUTMAPPER->ResetKeyRepeat( MenuInput(p, MENU_BUTTON_LEFT) );
INPUTMAPPER->ResetKeyRepeat( MenuInput(p, MENU_BUTTON_RIGHT) );
}
}
}
break;
}
if( bSelectIsPressed )
@@ -1101,8 +1129,20 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
}
else
{
if( m_MusicWheel.GetSelectedType() != TYPE_SONG && m_MusicWheel.GetSelectedType() != TYPE_COURSE )
// Finish sort changing so that the wheel can respond immediately to our
// request to choose random.
m_MusicWheel.FinishChangingSorts();
switch( m_MusicWheel.GetSelectedType() )
{
case TYPE_SONG:
case TYPE_COURSE:
case TYPE_RANDOM:
case TYPE_PORTAL:
break;
default:
m_MusicWheel.StartRandom();
break;
}
MenuStart(PLAYER_INVALID);
}
return;