add manual scrolling to ScreenRanking

This commit is contained in:
Chris Danford
2005-02-28 18:49:17 +00:00
parent 6a20525872
commit c7bacb5a21
5 changed files with 101 additions and 40 deletions
+1
View File
@@ -3326,6 +3326,7 @@ StepsTypeColor4=1.0,1,1.0,1
StepsTypeColor5=1.0,1,1.0,1
SongScoreRowsToShow=6
SongScoreSecondsPerRow=0.4
ManualScroling=0
BannerX=SCREEN_CENTER_X+197
BannerY=SCREEN_CENTER_Y-196
+35 -36
View File
@@ -14,12 +14,17 @@
#include "RageTexture.h"
//
// TODO: Merge this with ActorScroller
//
ListDisplay::ListDisplay()
{
m_iNumItemsToShow = 0;
m_fItemWidth = 0;
m_fItemHeight = 0;
m_fItemAtTopOfList = 0;
m_fCurrentItemAtTopOfList = 0;
m_fDestinationItemAtTopOfList = 0;
m_quadMask.SetBlendMode( BLEND_NO_EFFECT ); // don't change color values
m_quadMask.SetUseZBuffer( true ); // we want to write to the Zbuffer
@@ -50,7 +55,8 @@ void ListDisplay::Load(
m_fSecondsPerItem = fSecondsPerItem;
m_fSecondsPauseBetweenItems = fSecondsPauseBetweenItems;
m_bSlide = bSlide;
m_fItemAtTopOfList = m_bLoop ? 0 : (float)-m_iNumItemsToShow;
m_fCurrentItemAtTopOfList = m_bLoop ? 0 : (float)-m_iNumItemsToShow;
m_fDestinationItemAtTopOfList = m_vpItems.size()+1;
m_fSecondsPauseCountdown = 0;
RectF rectBarSize(-m_fItemWidth/2, -m_fItemHeight/2,
@@ -73,40 +79,33 @@ void ListDisplay::Update( float fDeltaTime )
if( !m_SubActors.size() )
return;
while( fDeltaTime > 0 )
// handle pause
if( fDeltaTime > m_fSecondsPauseCountdown )
{
// handle pause
if( fDeltaTime > m_fSecondsPauseCountdown )
{
fDeltaTime -= m_fSecondsPauseCountdown;
m_fSecondsPauseCountdown = 0;
}
else
{
m_fSecondsPauseCountdown -= fDeltaTime;
fDeltaTime = 0;
break;
}
// handle scrolling
float fPercentUntilNextItem = (int)m_fItemAtTopOfList+1 - m_fItemAtTopOfList;
float fSecsUntilNextItem = fPercentUntilNextItem * m_fSecondsPerItem;
if( fDeltaTime > fSecsUntilNextItem )
{
fDeltaTime -= fSecsUntilNextItem;
m_fItemAtTopOfList += fPercentUntilNextItem;
}
else
{
m_fItemAtTopOfList += fDeltaTime / m_fSecondsPerItem;
fDeltaTime = 0;
break;
}
if( m_bLoop )
m_fItemAtTopOfList = fmodf( m_fItemAtTopOfList, (float) m_SubActors.size() );
fDeltaTime -= m_fSecondsPauseCountdown;
m_fSecondsPauseCountdown = 0;
}
else
{
m_fSecondsPauseCountdown -= fDeltaTime;
fDeltaTime = 0;
return;
}
if( m_fCurrentItemAtTopOfList == m_fDestinationItemAtTopOfList )
return; // done scrolling
float fOldItemAtTop = m_fCurrentItemAtTopOfList;
fapproach( m_fCurrentItemAtTopOfList, m_fDestinationItemAtTopOfList, fDeltaTime/m_fSecondsPerItem );
// if items changed, then pause
if( (int)fOldItemAtTop != (int)m_fCurrentItemAtTopOfList )
m_fSecondsPauseCountdown = m_fSecondsPauseBetweenItems;
if( m_bLoop )
wrap( m_fCurrentItemAtTopOfList, (float) m_SubActors.size() );
}
void ListDisplay::DrawPrimitives()
@@ -125,8 +124,8 @@ void ListDisplay::DrawPrimitives()
m_quadMask.SetY( fIndexCompletelyOffScreenBottom * m_fItemHeight );
m_quadMask.Draw();
int iItemToDraw = (int)m_fItemAtTopOfList;
float fRemainder = m_fItemAtTopOfList - (int)m_fItemAtTopOfList;
int iItemToDraw = (int)m_fCurrentItemAtTopOfList;
float fRemainder = m_fCurrentItemAtTopOfList - (int)m_fCurrentItemAtTopOfList;
float fIndex = fIndexFullyOnScreenTop - fRemainder;
float fY = (fIndex)*m_fItemHeight;
+6 -2
View File
@@ -22,7 +22,10 @@ public:
float fSecondsPauseBetweenItems,
bool bSlide );
float GetSecondsForCompleteScrollThrough();
float GetSecondsForCompleteScrollThrough();
void SetCurrentItem( float fItem ) { m_fCurrentItemAtTopOfList = fItem; }
void SetDestinationItem( float fItem ) { m_fDestinationItemAtTopOfList = fItem; }
float GetDestinationItem() { return m_fDestinationItemAtTopOfList; }
protected:
int m_iNumItemsToShow;
@@ -33,7 +36,8 @@ protected:
float m_fSecondsPauseBetweenItems;
bool m_bSlide;
float m_fItemAtTopOfList;
float m_fCurrentItemAtTopOfList; // approaches destination
float m_fDestinationItemAtTopOfList;
float m_fSecondsPauseCountdown;
Quad m_quadMask;
};
+48 -2
View File
@@ -69,6 +69,7 @@ ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName )
STEPS_TYPE_COLOR (m_sName,STEPS_TYPE_COLOR_NAME,5),
SONG_SCORE_ROWS_TO_SHOW (m_sName,"SongScoreRowsToShow"),
SONG_SCORE_SECONDS_PER_ROW (m_sName,"SongScoreSecondsPerRow"),
MANUAL_SCROLLING (m_sName,"ManualScroling"),
BULLET_START_X (m_sName,"BulletStartX"),
BULLET_START_Y (m_sName,"BulletStartY"),
@@ -383,6 +384,42 @@ ScreenRanking::~ScreenRanking()
delete m_vpCourseScoreRowItem[c];
}
void ScreenRanking::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
LOG->Trace( "ScreenRanking::Input()" );
// If manually scrolling, then pass the input to Scree::Input so it will call Menu*
if( (bool)MANUAL_SCROLLING )
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
else
ScreenAttract::Input( DeviceI, type, GameI, MenuI, StyleI );
}
void ScreenRanking::Scroll( int iDir )
{
float fDest = m_ListScoreRowItems.GetDestinationItem();
float fOldDest = fDest;
fDest += iDir;
CLAMP( fDest, 0.0f, (float)m_vpStepsScoreRowItem.size()-SONG_SCORE_ROWS_TO_SHOW );
if( fOldDest != fDest )
{
// TODO: play sound
m_ListScoreRowItems.SetDestinationItem( fDest );
}
}
void ScreenRanking::MenuStart( PlayerNumber pn )
{
if( !IsTransitioning() )
StartTransitioning( SM_GoToNextScreen );
}
void ScreenRanking::MenuBack( PlayerNumber pn )
{
if( !IsTransitioning() )
StartTransitioning( SM_GoToNextScreen );
}
void ScreenRanking::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
@@ -393,11 +430,14 @@ void ScreenRanking::HandleScreenMessage( const ScreenMessage SM )
float fSecsToShow = SetPage( m_vPagesToShow[0] );
this->SortByDrawOrder();
m_vPagesToShow.erase( m_vPagesToShow.begin() );
this->PostScreenMessage( SM_HidePage, fSecsToShow-PAGE_FADE_SECONDS );
// If manually scrolling, don't automatically change pages.
if( !(bool)MANUAL_SCROLLING )
this->PostScreenMessage( SM_HidePage, fSecsToShow-PAGE_FADE_SECONDS );
}
else
{
m_Out.StartTransitioning(SM_GoToNextScreen);
StartTransitioning(SM_GoToNextScreen);
}
break;
case SM_HidePage:
@@ -602,6 +642,12 @@ float ScreenRanking::SetPage( PageToShow pts )
vpActors.push_back( m_vpStepsScoreRowItem[i] );
m_ListScoreRowItems.Load( vpActors, SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0, false );
if( (bool)MANUAL_SCROLLING )
{
m_ListScoreRowItems.SetCurrentItem( 0 );
m_ListScoreRowItems.SetDestinationItem( 0 );
}
for( unsigned s=0; s<m_vpStepsScoreRowItem.size(); s++ )
{
StepsScoreRowItem *pStepsScoreRowItems = m_vpStepsScoreRowItem[s];
+11
View File
@@ -34,6 +34,16 @@ public:
virtual void Init();
~ScreenRanking();
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void MenuLeft( PlayerNumber pn, const InputEventType type ) { Scroll(-1); }
virtual void MenuRight( PlayerNumber pn, const InputEventType type ) { Scroll(+1); }
virtual void MenuUp( PlayerNumber pn, const InputEventType type ) { Scroll(-1); }
virtual void MenuDown( PlayerNumber pn, const InputEventType type ) { Scroll(+1); }
virtual void Scroll( int iDir );
virtual void MenuStart( PlayerNumber pn );
virtual void MenuBack( PlayerNumber pn );
void HandleScreenMessage( const ScreenMessage SM );
protected:
@@ -113,6 +123,7 @@ protected:
ThemeMetric1D<RageColor> STEPS_TYPE_COLOR;
ThemeMetric<int> SONG_SCORE_ROWS_TO_SHOW;
ThemeMetric<float> SONG_SCORE_SECONDS_PER_ROW;
ThemeMetric<bool> MANUAL_SCROLLING;
ThemeMetric<float> BULLET_START_X;
ThemeMetric<float> BULLET_START_Y;