add m_iMusicWheelSwitchSpeed

This commit is contained in:
Glenn Maynard
2003-01-21 07:04:53 +00:00
parent 17c455e5a8
commit 00793032b2
3 changed files with 88 additions and 117 deletions
+73 -115
View File
@@ -40,7 +40,6 @@
#define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds") #define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds")
#define SWITCH_SECONDS THEME->GetMetricF("MusicWheel","SwitchSeconds") #define SWITCH_SECONDS THEME->GetMetricF("MusicWheel","SwitchSeconds")
#define ROULETTE_SWITCH_SECONDS THEME->GetMetricF("MusicWheel","RouletteSwitchSeconds") #define ROULETTE_SWITCH_SECONDS THEME->GetMetricF("MusicWheel","RouletteSwitchSeconds")
#define FAST_SPIN_SWITCH_SECONDS 0.05 // THEME->GetMetricF("MusicWheel","RouletteSwitchSeconds")
#define ROULETTE_SLOW_DOWN_SWITCHES THEME->GetMetricI("MusicWheel","RouletteSlowDownSwitches") #define ROULETTE_SLOW_DOWN_SWITCHES THEME->GetMetricI("MusicWheel","RouletteSlowDownSwitches")
#define LOCKED_INITIAL_VELOCITY THEME->GetMetricF("MusicWheel","LockedInitialVelocity") #define LOCKED_INITIAL_VELOCITY THEME->GetMetricF("MusicWheel","LockedInitialVelocity")
#define SCROLL_BAR_X THEME->GetMetricF("MusicWheel","ScrollBarX") #define SCROLL_BAR_X THEME->GetMetricF("MusicWheel","ScrollBarX")
@@ -50,7 +49,7 @@
#define NUM_SECTION_COLORS THEME->GetMetricI("MusicWheel","NumSectionColors") #define NUM_SECTION_COLORS THEME->GetMetricI("MusicWheel","NumSectionColors")
#define SECTION_COLORS( i ) THEME->GetMetricC("MusicWheel",ssprintf("SectionColor%d",i+1)) #define SECTION_COLORS( i ) THEME->GetMetricC("MusicWheel",ssprintf("SectionColor%d",i+1))
const float WHEEL_SOUND_DELAY = 1/16.f; const int MAX_WHEEL_SOUND_SPEED = 15;
float g_fItemSpacingY, g_fItemCurveX; // cache float g_fItemSpacingY, g_fItemCurveX; // cache
inline RageColor GetNextSectionColor() { inline RageColor GetNextSectionColor() {
@@ -812,16 +811,6 @@ void MusicWheel::Update( float fDeltaTime )
{ {
m_TimeBeforeMovingBegins -= fDeltaTime; m_TimeBeforeMovingBegins -= fDeltaTime;
m_TimeBeforeMovingBegins = max(m_TimeBeforeMovingBegins, 0); m_TimeBeforeMovingBegins = max(m_TimeBeforeMovingBegins, 0);
if(m_TimeBeforeMovingBegins == 0 && m_WheelState != STATE_LOCKED &&
fabsf(m_fPositionOffsetFromSelection) < 0.5f)
{
// spin as fast as possible
if(m_Moving == 1) NextMusic();
else PrevMusic();
if(m_WheelState == STATE_RANDOM_SPINNING)
m_iSwitchesLeftInSpinDown--;
}
} }
// update wheel state // update wheel state
@@ -944,9 +933,9 @@ void MusicWheel::Update( float fDeltaTime )
LOG->Trace( "m_iSwitchesLeftInSpinDown id %d, m_fTimeLeftInState is %f", m_iSwitchesLeftInSpinDown, m_fTimeLeftInState ); LOG->Trace( "m_iSwitchesLeftInSpinDown id %d, m_fTimeLeftInState is %f", m_iSwitchesLeftInSpinDown, m_fTimeLeftInState );
if( m_iSwitchesLeftInSpinDown < 2 ) if( m_iSwitchesLeftInSpinDown < 2 )
randomf(0,1) >= 0.5f ? NextMusic() : PrevMusic(); ChangeMusic(randomf(0,1) >= 0.5f? 1:-1);
else else
NextMusic(); ChangeMusic(1);
} }
break; break;
default: default:
@@ -955,7 +944,6 @@ void MusicWheel::Update( float fDeltaTime )
} }
} }
if( m_WheelState == STATE_LOCKED ) if( m_WheelState == STATE_LOCKED )
{ {
/* Do this in at most .1 sec chunks, so we don't get weird if we /* Do this in at most .1 sec chunks, so we don't get weird if we
@@ -984,14 +972,38 @@ void MusicWheel::Update( float fDeltaTime )
} }
} }
} }
else if( IsMoving() )
{
/* We're automatically moving. Move linearly, and don't clamp
* to the selection. */
float fSpinSpeed = m_SpinSpeed*m_Moving;
m_fPositionOffsetFromSelection -= fSpinSpeed*fDeltaTime;
/* Make sure that we don't go further than 1 away, in case the
* speed is very high or we miss a lot of frames. */
m_fPositionOffsetFromSelection = clamp(m_fPositionOffsetFromSelection, -1.0f, 1.0f);
/* If it passed the selection, move again. */
if((m_Moving == -1 && m_fPositionOffsetFromSelection >= 0) ||
(m_Moving == 1 && m_fPositionOffsetFromSelection <= 0))
{
ChangeMusic(m_Moving);
if(PREFSMAN->m_iMusicWheelSwitchSpeed < MAX_WHEEL_SOUND_SPEED)
m_soundChangeMusic.Play();
}
if(PREFSMAN->m_iMusicWheelSwitchSpeed >= MAX_WHEEL_SOUND_SPEED &&
m_MovingSoundTimer.PeekDeltaTime() >= 1.0f / MAX_WHEEL_SOUND_SPEED)
{
m_MovingSoundTimer.GetDeltaTime();
m_soundChangeMusic.Play();
}
}
else else
{ {
// "rotate" wheel toward selected song // "rotate" wheel toward selected song
float fSpinSpeed; float fSpinSpeed = 0.2f + fabsf(m_fPositionOffsetFromSelection)/SWITCH_SECONDS;
if( m_Moving && m_TimeBeforeMovingBegins == 0 )
fSpinSpeed = m_SpinSpeed;
else
fSpinSpeed = 0.2f + fabsf(m_fPositionOffsetFromSelection)/SWITCH_SECONDS;
if( m_fPositionOffsetFromSelection > 0 ) if( m_fPositionOffsetFromSelection > 0 )
{ {
@@ -1009,92 +1021,23 @@ void MusicWheel::Update( float fDeltaTime )
} }
void MusicWheel::PrevMusic() void MusicWheel::ChangeMusic(int dist)
{ {
if( m_WheelState == STATE_LOCKED ) m_iSelection += dist;
{
m_fLockedWheelVelocity = LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play();
return;
}
if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is busy spinning
return;
switch( m_WheelState )
{
case STATE_SELECTING_MUSIC:
case STATE_ROULETTE_SPINNING:
case STATE_ROULETTE_SLOWING_DOWN:
case STATE_RANDOM_SPINNING:
break; // fall through
default:
return; // don't fall through
}
// decrement m_iSelection
m_iSelection--;
if( m_iSelection < 0 ) if( m_iSelection < 0 )
m_iSelection = m_CurWheelItemData.size()-1; m_iSelection = m_CurWheelItemData.size()-1;
else if( m_iSelection > int(m_CurWheelItemData.size()-1) )
RebuildWheelItemDisplays();
m_fPositionOffsetFromSelection -= 1;
/* If we're moving fast, only play the change music occasionally.
* If we play full throttle, we'll play as many as the sound driver
* will do, which is slow. This doesn't sound too great, though
* it's better than the intermittent effect we had before ... */
if(!m_Moving || m_MovingSoundTimer.PeekDeltaTime() >= WHEEL_SOUND_DELAY)
{
m_MovingSoundTimer.GetDeltaTime();
m_soundChangeMusic.Play();
}
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
}
void MusicWheel::NextMusic()
{
if( m_WheelState == STATE_LOCKED )
{
m_fLockedWheelVelocity = -LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play();
return;
}
if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is very busy spinning
return;
switch( m_WheelState )
{
case STATE_SELECTING_MUSIC:
case STATE_ROULETTE_SPINNING:
case STATE_ROULETTE_SLOWING_DOWN:
case STATE_RANDOM_SPINNING:
break;
default:
LOG->Trace( "NextMusic() ignored" );
return; // don't continue
}
// increment m_iSelection
m_iSelection++;
if( m_iSelection > int(m_CurWheelItemData.size()-1) )
m_iSelection = 0; m_iSelection = 0;
RebuildWheelItemDisplays(); RebuildWheelItemDisplays();
m_fPositionOffsetFromSelection += 1; m_fPositionOffsetFromSelection += dist;
if(!m_Moving || m_MovingSoundTimer.PeekDeltaTime() >= WHEEL_SOUND_DELAY)
{
m_MovingSoundTimer.GetDeltaTime();
m_soundChangeMusic.Play();
}
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 ); SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
/* If we're moving automatically, don't play this; it'll be called in Update. */
if(!IsMoving())
m_soundChangeMusic.Play();
} }
bool MusicWheel::PrevSort() bool MusicWheel::PrevSort()
@@ -1262,8 +1205,7 @@ bool MusicWheel::IsRouletting() const
int MusicWheel::IsMoving() const int MusicWheel::IsMoving() const
{ {
if(!m_Moving) return false; return m_Moving && m_TimeBeforeMovingBegins == 0;
return m_TimeBeforeMovingBegins == 0;
} }
void MusicWheel::TweenOnScreen(bool changing_sort) void MusicWheel::TweenOnScreen(bool changing_sort)
@@ -1395,25 +1337,41 @@ void MusicWheel::Move(int n)
if(n == m_Moving) if(n == m_Moving)
return; return;
/* Give us one last chance to move. This will ensure that we're at least if( m_WheelState == STATE_LOCKED )
* 0.5f from the selection, so we have a chance to spin down smoothly. */ {
Update(0); if(n)
{
m_fLockedWheelVelocity = LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play();
}
return;
}
bool Stopping = (m_Moving != 0 && n == 0 && m_TimeBeforeMovingBegins == 0); /* If we're not selecting, discard this. We won't ignore it; we'll
* get called again every time the key is repeated. */
if( m_WheelState != STATE_SELECTING_MUSIC )
return;
if(m_Moving != 0 && n == 0 && m_TimeBeforeMovingBegins == 0)
{
/* We were moving, and now we're stopping. If we're really close to
* the selection, move to the next one, so we have a chance to spin down
* smoothly. */
if(fabsf(m_fPositionOffsetFromSelection) < 0.25f )
ChangeMusic(m_Moving);
/* Make sure the user always gets an SM_SongChanged when
* Moving() is 0, so the final banner, etc. always gets set. */
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
}
m_TimeBeforeMovingBegins = TIME_BEFORE_SLOW_REPEATS; m_TimeBeforeMovingBegins = TIME_BEFORE_SLOW_REPEATS;
m_SpinSpeed = 1.0f/FAST_SPIN_SWITCH_SECONDS; m_SpinSpeed = float(PREFSMAN->m_iMusicWheelSwitchSpeed);
m_Moving = n; m_Moving = n;
if(Stopping) if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is very busy spinning
{ return;
/* Make sure the user always gets an SM_SongChanged when
* Moving() is 0, so the final banner, etc. always get set. */ if(m_Moving)
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 ); ChangeMusic(m_Moving);
} else {
if(n == 1)
NextMusic();
else if(n == -1)
PrevMusic();
}
} }
+1 -2
View File
@@ -131,8 +131,7 @@ protected:
void SetOpenGroup(CString group, SongSortOrder so = NUM_SORT_ORDERS); void SetOpenGroup(CString group, SongSortOrder so = NUM_SORT_ORDERS);
bool SelectSong(const Song *p); bool SelectSong(const Song *p);
bool SelectCourse(const Course *p); bool SelectCourse(const Course *p);
void NextMusic(); void ChangeMusic(int dist); /* +1 or -1 */
void PrevMusic();
ScrollBar m_ScrollBar; ScrollBar m_ScrollBar;
Sprite m_sprSelectionOverlay; Sprite m_sprSelectionOverlay;
+14
View File
@@ -29,6 +29,7 @@ enum {
IO_AUTOPLAY, IO_AUTOPLAY,
IO_DELAYED_ESCAPE, IO_DELAYED_ESCAPE,
IO_OPTIONS_NAVIGATION, IO_OPTIONS_NAVIGATION,
IO_WHEEL_SPEED,
NUM_INPUT_OPTIONS_LINES NUM_INPUT_OPTIONS_LINES
}; };
@@ -40,6 +41,7 @@ OptionRowData g_InputOptionsLines[NUM_INPUT_OPTIONS_LINES] = {
{ "AutoPlay", 2, {"OFF","ON"} }, { "AutoPlay", 2, {"OFF","ON"} },
{ "Back\nDelayed", 2, {"INSTANT","HOLD"} }, { "Back\nDelayed", 2, {"INSTANT","HOLD"} },
{ "Options\nNavigation",2, {"SM STYLE","ARCADE STYLE"} }, { "Options\nNavigation",2, {"SM STYLE","ARCADE STYLE"} },
{ "Wheel\nSpeed", 4, {"SLOW","NORMAL","FAST","REALLY FAST"} },
}; };
ScreenInputOptions::ScreenInputOptions() : ScreenInputOptions::ScreenInputOptions() :
@@ -77,6 +79,10 @@ void ScreenInputOptions::ImportOptions()
m_iSelectedOption[0][IO_AUTOPLAY] = PREFSMAN->m_bAutoPlay; m_iSelectedOption[0][IO_AUTOPLAY] = PREFSMAN->m_bAutoPlay;
m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0; m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0;
m_iSelectedOption[0][IO_OPTIONS_NAVIGATION] = PREFSMAN->m_bArcadeOptionsNavigation ? 1:0; m_iSelectedOption[0][IO_OPTIONS_NAVIGATION] = PREFSMAN->m_bArcadeOptionsNavigation ? 1:0;
m_iSelectedOption[0][IO_WHEEL_SPEED] =
(PREFSMAN->m_iMusicWheelSwitchSpeed <= 5)? 0:
(PREFSMAN->m_iMusicWheelSwitchSpeed <= 10)? 1:
(PREFSMAN->m_iMusicWheelSwitchSpeed <= 15)? 2:3;
} }
void ScreenInputOptions::ExportOptions() void ScreenInputOptions::ExportOptions()
@@ -86,6 +92,14 @@ void ScreenInputOptions::ExportOptions()
PREFSMAN->m_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1; PREFSMAN->m_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1;
PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1; PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1;
PREFSMAN->m_bArcadeOptionsNavigation= m_iSelectedOption[0][IO_OPTIONS_NAVIGATION] == 1; PREFSMAN->m_bArcadeOptionsNavigation= m_iSelectedOption[0][IO_OPTIONS_NAVIGATION] == 1;
switch(m_iSelectedOption[0][IO_WHEEL_SPEED])
{
case 0: PREFSMAN->m_iMusicWheelSwitchSpeed = 5; break;
case 1: PREFSMAN->m_iMusicWheelSwitchSpeed = 10; break;
case 2: PREFSMAN->m_iMusicWheelSwitchSpeed = 15; break;
case 3: PREFSMAN->m_iMusicWheelSwitchSpeed = 25; break;
default: ASSERT(0);
}
} }
void ScreenInputOptions::GoToPrevState() void ScreenInputOptions::GoToPrevState()