Sped up ScrollingBannerList a bit
This commit is contained in:
@@ -23,6 +23,12 @@
|
||||
#define MAXSONGSINBUFFER 5
|
||||
#define BANNERTYPE 1
|
||||
|
||||
enum
|
||||
{
|
||||
GOINGLEFT=0,
|
||||
GOINGRIGHT
|
||||
};
|
||||
|
||||
#define DEFAULT_SCROLL_DIRECTION THEME->GetMetricI("Notes","DefaultScrollDirection")
|
||||
|
||||
MusicBannerWheel::MusicBannerWheel()
|
||||
@@ -96,12 +102,99 @@ MusicBannerWheel::MusicBannerWheel()
|
||||
|
||||
LoadSongData();
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_debugtext.LoadFromFont( THEME->GetPathTo("Fonts","small titles") );
|
||||
m_debugtext.SetXY( 0, -120 );
|
||||
this->AddChild(&m_debugtext);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************ TODO: OPTIMIZE THIS: MUST!!!! ********************/
|
||||
/********************************************
|
||||
void MusicBannerWheel::InsertNewBanner(int direction)
|
||||
|
||||
Based upon the direction specified it will go off and
|
||||
figure out which banner went out of focus, (which is
|
||||
now our NEW! banner) and replace it with something new...
|
||||
works only if there are 5 banners in the scrolling list.
|
||||
********************************************/
|
||||
void MusicBannerWheel::InsertNewBanner(int direction)
|
||||
{
|
||||
Song* pSong = NULL;
|
||||
CString sGraphicPath;
|
||||
int elementtoreplace=0;
|
||||
|
||||
if( direction == GOINGLEFT)
|
||||
{
|
||||
/* Imagine this:
|
||||
[1][2][3][4][5]
|
||||
then they shift <-
|
||||
[?][1][2][3][4]
|
||||
gotta find out what ? is
|
||||
|
||||
scrlistpos = 0 0 1 2 [3] [4] [0] [1] [2] 3 4 0 1 2 3 4
|
||||
scrlistpos = 4 4 0 1 [2] [3] [4] [0] [1] 2 3 4 0 1 2 3 // we lost 2 and got a new one
|
||||
scrlistpos = 3 3 4 0 [1] [2] [3] [4] [0] 1 2 3 4 0 1 2 // we lost 1 and got a new one
|
||||
*/
|
||||
|
||||
if(currentPos-2 >= 0)
|
||||
pSong = arraySongs[currentPos-2];
|
||||
else
|
||||
pSong = arraySongs[(arraySongs.size()-1) + (currentPos-2)]; // wrap around. (it does honestly!)
|
||||
|
||||
if( pSong == NULL ) sGraphicPath = (THEME->GetPathTo("Graphics","fallback banner"));
|
||||
else if (pSong->HasBanner()) sGraphicPath = (pSong->GetBannerPath());
|
||||
else if (PREFSMAN->m_bUseBGIfNoBanner && pSong->HasBackground() ) sGraphicPath = (pSong->GetBannerPath());
|
||||
else sGraphicPath = (THEME->GetPathTo("Graphics","fallback banner"));
|
||||
|
||||
elementtoreplace = scrlistPos - 2;
|
||||
if(elementtoreplace < 0)
|
||||
{
|
||||
elementtoreplace = MAXSONGSINBUFFER + elementtoreplace;
|
||||
}
|
||||
m_ScrollingList.Replace(sGraphicPath, elementtoreplace);
|
||||
}
|
||||
else if( direction == GOINGRIGHT)
|
||||
{
|
||||
/* Imagine this:
|
||||
[1][2][3][4][5]
|
||||
then they shift ->
|
||||
[2][3][4][5][?]
|
||||
gotta find out what ? is
|
||||
scrlistpos = 0 1 2 [3] [4] [0] [1] [2] 3 4
|
||||
scrlistpos = 1 2 3 [4] [0] [1] [2] [3] 4 0 // we lost 3 and got a new one
|
||||
*/
|
||||
if(currentPos+2 <= arraySongs.size()-1)
|
||||
pSong = arraySongs[currentPos+2];
|
||||
else
|
||||
pSong = arraySongs[0+ (((currentPos+2) - (arraySongs.size()-1)) - 1)]; // wrap around. (it does honestly!)
|
||||
|
||||
if( pSong == NULL ) sGraphicPath = (THEME->GetPathTo("Graphics","fallback banner"));
|
||||
else if (pSong->HasBanner()) sGraphicPath = (pSong->GetBannerPath());
|
||||
else if (PREFSMAN->m_bUseBGIfNoBanner && pSong->HasBackground() ) sGraphicPath = (pSong->GetBannerPath());
|
||||
else sGraphicPath = (THEME->GetPathTo("Graphics","fallback banner"));
|
||||
|
||||
elementtoreplace = scrlistPos + 2;
|
||||
if(elementtoreplace > MAXSONGSINBUFFER-1)
|
||||
{
|
||||
elementtoreplace = elementtoreplace - MAXSONGSINBUFFER;
|
||||
}
|
||||
m_ScrollingList.Replace(sGraphicPath, elementtoreplace);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(0); // we should be going in some sort of direction.
|
||||
}
|
||||
PlayMusicSample();
|
||||
}
|
||||
|
||||
/****************************
|
||||
void MusicBannerWheel::LoadSongData()
|
||||
|
||||
Loads the Song Data, based upon
|
||||
its relative position. It's fairly
|
||||
slow, so should only get used once
|
||||
and once only.
|
||||
*****************************/
|
||||
void MusicBannerWheel::LoadSongData()
|
||||
{
|
||||
Song* pSong = NULL;
|
||||
@@ -219,9 +312,12 @@ void MusicBannerWheel::BannersLeft()
|
||||
scrlistPos--;
|
||||
|
||||
if(SingleLoad == 0)
|
||||
m_ScrollingList.Unload();
|
||||
LoadSongData();
|
||||
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
|
||||
// m_ScrollingList.Unload();
|
||||
// LoadSongData();
|
||||
InsertNewBanner(GOINGLEFT);
|
||||
#ifdef _DEBUG
|
||||
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
|
||||
#endif
|
||||
m_ScrollingList.Left();
|
||||
ChangeNotes();
|
||||
}
|
||||
@@ -239,9 +335,12 @@ void MusicBannerWheel::BannersRight()
|
||||
scrlistPos++;
|
||||
|
||||
if(SingleLoad == 0)
|
||||
m_ScrollingList.Unload();
|
||||
LoadSongData();
|
||||
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
|
||||
// m_ScrollingList.Unload();
|
||||
// LoadSongData();
|
||||
InsertNewBanner(GOINGRIGHT);
|
||||
#ifdef _DEBUG
|
||||
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
|
||||
#endif
|
||||
m_ScrollingList.Right();
|
||||
ChangeNotes();
|
||||
}
|
||||
|
||||
@@ -36,8 +36,11 @@ private:
|
||||
void PlayMusicSample();
|
||||
void LoadSongData();
|
||||
void ChangeNotes();
|
||||
void InsertNewBanner(int direction);
|
||||
|
||||
BitmapText m_debugtext;
|
||||
#ifdef _DEBUG
|
||||
BitmapText m_debugtext;
|
||||
#endif
|
||||
|
||||
ScrollingList m_ScrollingList;
|
||||
int currentPos;
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#define GUIDE_X THEME->GetMetricF("ScreenSelectMode","GuideX")
|
||||
#define GUIDE_Y THEME->GetMetricF("ScreenSelectMode","GuideY")
|
||||
|
||||
const float TWEEN_TIME = 0.5f;
|
||||
|
||||
const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User+1);
|
||||
const ScreenMessage SM_GoToNextScreen = ScreenMessage(SM_User+2);
|
||||
const ScreenMessage SM_NoSongs = ScreenMessage(SM_User+3);
|
||||
@@ -181,8 +183,9 @@ void ScreenEz2SelectMusic::HandleScreenMessage( const ScreenMessage SM )
|
||||
|
||||
void ScreenEz2SelectMusic::MenuRight( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
m_MusicBannerWheel.BannersRight();
|
||||
MusicChanged();
|
||||
m_Menu.StallTimer();
|
||||
m_MusicBannerWheel.BannersRight();
|
||||
MusicChanged();
|
||||
}
|
||||
|
||||
void ScreenEz2SelectMusic::MenuBack( PlayerNumber pn )
|
||||
@@ -193,8 +196,21 @@ void ScreenEz2SelectMusic::MenuBack( PlayerNumber pn )
|
||||
}
|
||||
|
||||
|
||||
void ScreenEz2SelectMusic::TweenOffScreen()
|
||||
{
|
||||
m_MusicBannerWheel.FadeOff( 0, "foldy", TWEEN_TIME );
|
||||
m_PumpDifficultyCircle.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
m_Guide.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
m_PumpDifficultyRating.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
m_Guide.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
m_ChoiceListFrame.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
m_ChoiceListHighlight.FadeOff( 0, "fade", TWEEN_TIME*2 );
|
||||
}
|
||||
|
||||
|
||||
void ScreenEz2SelectMusic::MenuLeft( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
m_Menu.StallTimer();
|
||||
m_MusicBannerWheel.BannersLeft();
|
||||
MusicChanged();
|
||||
}
|
||||
@@ -209,6 +225,8 @@ void ScreenEz2SelectMusic::MenuStart( PlayerNumber pn )
|
||||
|
||||
m_bMadeChoice = true;
|
||||
|
||||
TweenOffScreen();
|
||||
|
||||
// show "hold START for options"
|
||||
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
|
||||
m_sprOptionsMessage.BeginTweening( 0.25f ); // fade in
|
||||
|
||||
@@ -42,6 +42,8 @@ protected:
|
||||
void EasierDifficulty( PlayerNumber pn );
|
||||
void HarderDifficulty( PlayerNumber pn );
|
||||
|
||||
void TweenOffScreen();
|
||||
|
||||
Sprite m_ChoiceListFrame;
|
||||
Sprite m_ChoiceListHighlight;
|
||||
Sprite m_Guide;
|
||||
|
||||
@@ -250,6 +250,69 @@ void ScrollingList::Update( float fDeltaTime )
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollingList::Replace(CString sGraphicPath, int ElementNumber)
|
||||
{
|
||||
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
||||
{
|
||||
Sprite* pNewSprite = new Sprite;
|
||||
pNewSprite->Load( sGraphicPath );
|
||||
m_apSprites[ElementNumber] = pNewSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
CroppedSprite* pNewCSprite = new CroppedSprite;
|
||||
if(m_iBannerPrefs == BANNERPREFS_DDRFLAT)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
||||
}
|
||||
else if(m_iBannerPrefs == BANNERPREFS_DDRROT)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
||||
pNewCSprite->SetRotation( DDRROT_ROTATION );
|
||||
}
|
||||
else if(m_iBannerPrefs == BANNERPREFS_EZ2)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( EZ2_BANNER_WIDTH*2, EZ2_BANNER_HEIGHT*2 );
|
||||
}
|
||||
|
||||
pNewCSprite->Load( sGraphicPath );
|
||||
m_apCSprites[ElementNumber] = pNewCSprite;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollingList::AddElementAt(int loc, CString sGraphicPath)
|
||||
{
|
||||
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
||||
{
|
||||
Sprite* pNewSprite = new Sprite;
|
||||
pNewSprite->Load( sGraphicPath );
|
||||
// m_apSprites.push_back( pNewSprite );
|
||||
m_apSprites.insert(m_apSprites.begin()+loc, pNewSprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
CroppedSprite* pNewCSprite = new CroppedSprite;
|
||||
if(m_iBannerPrefs == BANNERPREFS_DDRFLAT)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
||||
}
|
||||
else if(m_iBannerPrefs == BANNERPREFS_DDRROT)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
||||
pNewCSprite->SetRotation( DDRROT_ROTATION );
|
||||
}
|
||||
else if(m_iBannerPrefs == BANNERPREFS_EZ2)
|
||||
{
|
||||
pNewCSprite->SetCroppedSize( EZ2_BANNER_WIDTH*2, EZ2_BANNER_HEIGHT*2 );
|
||||
}
|
||||
|
||||
pNewCSprite->Load( sGraphicPath );
|
||||
// m_apCSprites.push_back( pNewCSprite );
|
||||
m_apSprites.insert(m_apSprites.begin()+loc, pNewCSprite);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/********************************
|
||||
DrawPrimitives
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
virtual void Update( float fDeltaTime );
|
||||
virtual void DrawPrimitives();
|
||||
|
||||
void Replace(CString sGraphicPath, int ElementNumber);
|
||||
void AddElementAt(int loc, CString sGraphicPath);
|
||||
void SetSelection( int iIndex );
|
||||
int GetSelection();
|
||||
void SetNumberVisible( int iNumVisibleElements );
|
||||
|
||||
Reference in New Issue
Block a user