Some Changes to ScrollingList to support different display modes on the music select screen.

This commit is contained in:
Andrew Livy
2002-12-10 23:16:44 +00:00
parent acf9c6b5fc
commit e8db36824a
7 changed files with 286 additions and 58 deletions
+5 -2
View File
@@ -3,8 +3,11 @@ X denotes task complete or no longer required to do.
- denotes task to do, but also being worked upon by other dev. - denotes task to do, but also being worked upon by other dev.
H denotes task on hold. H denotes task on hold.
TODO As of: 06:36:PM 10/12/02
* Optimize The Music Banner Wheel
TODO As of: 04:46:PM 27/11/02 TODO As of: 04:46:PM 27/11/02
* Systems Programming Assignment X Systems Programming Assignment
* Integrating Assignment 2 * Integrating Assignment 2
* Add Scoreboard Initials Entry Frontend * Add Scoreboard Initials Entry Frontend
@@ -18,7 +21,7 @@ TODO As of: 07:30:PM 28/10/02
X Networking Assignment X Networking Assignment
X Integrating Assignment 1 X Integrating Assignment 1
* Update Menu Graphics for Para - Update Menu Graphics for Para
H Update Menu Graphics for Ez2 H Update Menu Graphics for Ez2
H Finish The PUMP Graphics H Finish The PUMP Graphics
* Work on Beatmania Support * Work on Beatmania Support
+83 -14
View File
@@ -18,32 +18,75 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "RageMusic.h" #include "RageMusic.h"
#define MAXBANNERS 5
#define BANNERSPACING 200 #define BANNERSPACING 200
#define MAXSONGSINBUFFER 5
#define BANNERTYPE 1
MusicBannerWheel::MusicBannerWheel() MusicBannerWheel::MusicBannerWheel()
{ {
currentPos=0; currentPos=0;
scrlistPos=0;
m_ScrollingList.UseSpriteType(BANNERTYPE);
m_ScrollingList.SetXY( 0, 0 ); m_ScrollingList.SetXY( 0, 0 );
m_ScrollingList.SetSpacing( BANNERSPACING ); m_ScrollingList.SetSpacing( BANNERSPACING );
this->AddChild( &m_ScrollingList ); this->AddChild( &m_ScrollingList );
SetNewPos(currentPos); arraySongs = SONGMAN->m_pSongs;
PlayMusicSample();
LoadSongData();
m_debugtext.LoadFromFont( THEME->GetPathTo("Fonts","small titles") );
m_debugtext.SetXY( 0, -120 );
this->AddChild(&m_debugtext);
} }
void MusicBannerWheel::SetNewPos(int NewPos) /************ TODO: OPTIMIZE THIS: MUST!!!! ********************/
void MusicBannerWheel::LoadSongData()
{ {
CArray<Song*, Song*> arraySongs = SONGMAN->m_pSongs;
Song* pSong; Song* pSong;
// TODO: OPTIMIZE THIS. (SO IT LOADS THE ENTIRE SONG LIST)
CStringArray asGraphicPaths; CStringArray asGraphicPaths;
for( unsigned j=0; j<arraySongs.size() && j < MAXBANNERS; j++ ) for(int count=0; count<MAXSONGSINBUFFER; count++)
{ {
pSong = arraySongs[j]; /* In essence, this element is the central one so we want the scrolling list
to load in the song as specified by currentPos */
if(count == scrlistPos)
{
pSong = arraySongs[currentPos];
}
/* if it's the next element
*/
else if(count == scrlistPos+2 || (scrlistPos == MAXSONGSINBUFFER-2 && count == 0))
{
if(currentPos+2 <= arraySongs.size()-1)
pSong = arraySongs[currentPos+2];
else
pSong = arraySongs[0+2];
}
else if(count == scrlistPos-2 || (scrlistPos == 0 && count == MAXSONGSINBUFFER-2))
{
if(currentPos-2 >= 0)
pSong = arraySongs[currentPos-2];
else
pSong = arraySongs[arraySongs.size()-2];
}
else if(count == scrlistPos+1 || (scrlistPos == MAXSONGSINBUFFER-1 && count == 0))
{
if(currentPos+1 <= arraySongs.size()-1)
pSong = arraySongs[currentPos+1];
else
pSong = arraySongs[0];
}
/* if it's the previous element OR if we're at element 0..the 5th element (which will wrap to before element 0)
will actually appear as 5 songs along and not the one immediately before it,, so pull a sneaky and make the
final element actually be the song before... */
else if(count == scrlistPos-1 || (scrlistPos == 0 && count == MAXSONGSINBUFFER-1))
{
if(currentPos-1 >= 0)
pSong = arraySongs[currentPos-1];
else
pSong = arraySongs[arraySongs.size()-1];
}
if( pSong == NULL ) asGraphicPaths.push_back(THEME->GetPathTo("Graphics","fallback banner")); if( pSong == NULL ) asGraphicPaths.push_back(THEME->GetPathTo("Graphics","fallback banner"));
else if (pSong->HasBanner()) asGraphicPaths.push_back(pSong->GetBannerPath()); else if (pSong->HasBanner()) asGraphicPaths.push_back(pSong->GetBannerPath());
@@ -51,13 +94,14 @@ void MusicBannerWheel::SetNewPos(int NewPos)
else asGraphicPaths.push_back(THEME->GetPathTo("Graphics","fallback banner")); else asGraphicPaths.push_back(THEME->GetPathTo("Graphics","fallback banner"));
} }
m_ScrollingList.Load( asGraphicPaths ); m_ScrollingList.Load( asGraphicPaths );
PlayMusicSample();
} }
Song* MusicBannerWheel::GetSelectedSong() Song* MusicBannerWheel::GetSelectedSong()
{ {
CArray<Song*, Song*> arraySongs = SONGMAN->m_pSongs;
Song* pSong; Song* pSong;
pSong=arraySongs[m_ScrollingList.GetSelection()]; pSong=arraySongs[currentPos];
return(pSong); return(pSong);
} }
@@ -74,14 +118,39 @@ void MusicBannerWheel::PlayMusicSample()
void MusicBannerWheel::BannersLeft() void MusicBannerWheel::BannersLeft()
{ {
if(currentPos==0)
currentPos=arraySongs.size()-1;
else
currentPos--;
if(scrlistPos==0)
scrlistPos = MAXSONGSINBUFFER-1;
else
scrlistPos--;
m_ScrollingList.Unload();
LoadSongData();
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
m_ScrollingList.Left(); m_ScrollingList.Left();
PlayMusicSample();
} }
void MusicBannerWheel::BannersRight() void MusicBannerWheel::BannersRight()
{ {
if(currentPos>=arraySongs.size()-1)
currentPos=0;
else
currentPos++;
if(scrlistPos==MAXSONGSINBUFFER-1)
scrlistPos=0;
else
scrlistPos++;
m_ScrollingList.Unload();
LoadSongData();
m_debugtext.SetText(ssprintf("currentPos: %d scrlistPos: %d",currentPos,scrlistPos));
m_ScrollingList.Right(); m_ScrollingList.Right();
PlayMusicSample();
} }
MusicBannerWheel::~MusicBannerWheel() MusicBannerWheel::~MusicBannerWheel()
+8
View File
@@ -15,6 +15,8 @@
#include "Banner.h" #include "Banner.h"
#include "Sprite.h" #include "Sprite.h"
#include "ScrollingList.h" #include "ScrollingList.h"
#include "SongManager.h"
#include "BitmapText.h"
class MusicBannerWheel : public ActorFrame class MusicBannerWheel : public ActorFrame
{ {
@@ -27,9 +29,15 @@ public:
private: private:
void SetNewPos(int NewPos); void SetNewPos(int NewPos);
void PlayMusicSample(); void PlayMusicSample();
void LoadSongData();
BitmapText m_debugtext;
ScrollingList m_ScrollingList; ScrollingList m_ScrollingList;
int currentPos; int currentPos;
int scrlistPos;
CArray<Song*, Song*> arraySongs;
}; };
#endif #endif
+13 -3
View File
@@ -28,13 +28,23 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#define HELP_TEXT THEME->GetMetric("ScreenSelectMusic","HelpText")
#define TIMER_SECONDS THEME->GetMetricI("ScreenSelectMusic","TimerSeconds")
ScreenEz2SelectMusic::ScreenEz2SelectMusic() ScreenEz2SelectMusic::ScreenEz2SelectMusic()
{ {
MUSIC->Stop(); m_Menu.Load(
THEME->GetPathTo("BGAnimations","select music"),
THEME->GetPathTo("Graphics","select music top edge"),
HELP_TEXT, true, true, TIMER_SECONDS
);
this->AddChild( &m_Menu );
m_MusicBannerWheel.SetX(CENTER_X); m_MusicBannerWheel.SetX(CENTER_X);
m_MusicBannerWheel.SetY(CENTER_Y); m_MusicBannerWheel.SetY(CENTER_Y);
this->AddChild( &m_MusicBannerWheel ); this->AddChild( &m_MusicBannerWheel );
m_Menu.TweenOnScreenFromMenu( SM_None );
} }
void ScreenEz2SelectMusic::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) void ScreenEz2SelectMusic::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
@@ -83,9 +93,9 @@ void ScreenEz2SelectMusic::Update( float fDeltaTime )
void ScreenEz2SelectMusic::DrawPrimitives() void ScreenEz2SelectMusic::DrawPrimitives()
{ {
// m_Menu.DrawBottomLayer(); m_Menu.DrawBottomLayer();
Screen::DrawPrimitives(); Screen::DrawPrimitives();
// m_Menu.DrawTopLayer(); m_Menu.DrawTopLayer();
} }
+2 -1
View File
@@ -19,7 +19,7 @@
#include "TipDisplay.h" #include "TipDisplay.h"
#include "RageSoundStream.h" #include "RageSoundStream.h"
#include "MusicBannerWheel.h" #include "MusicBannerWheel.h"
#include "MenuElements.h"
class ScreenEz2SelectMusic : public Screen class ScreenEz2SelectMusic : public Screen
{ {
@@ -32,6 +32,7 @@ public:
virtual void HandleScreenMessage( const ScreenMessage SM ); virtual void HandleScreenMessage( const ScreenMessage SM );
protected: protected:
MusicBannerWheel m_MusicBannerWheel; MusicBannerWheel m_MusicBannerWheel;
MenuElements m_Menu;
}; };
+168 -35
View File
@@ -18,6 +18,26 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "Course.h" #include "Course.h"
#include "SongManager.h" #include "SongManager.h"
#include "ThemeManager.h"
enum BANNER_PREFS_TYPES
{
BANNERPREFS_DDRFLAT=0,
BANNERPREFS_DDRROT,
BANNERPREFS_EZ2,
BANNERPREFS_PUMP,
BANNERPREFS_PARA
};
#define BANNER_WIDTH THEME->GetMetricF("ScreenSelectMusic","BannerWidth")
#define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectMusic","BannerHeight")
#define EZ2_BANNER_WIDTH 92
#define EZ2_BANNER_HEIGHT 92
#define EZ2_BANNER_ZOOM 2.0
#define SPRITE_TYPE_SPRITE 0
#define SPRITE_TYPE_CROPPEDSPRITE 1
#define DDRROT_ROTATION 315
const int DEFAULT_VISIBLE_ELEMENTS = 9; const int DEFAULT_VISIBLE_ELEMENTS = 9;
const int DEFAULT_SPACING = 300; const int DEFAULT_SPACING = 300;
@@ -32,12 +52,19 @@ Initializes Variables for the ScrollingList
****************************************/ ****************************************/
ScrollingList::ScrollingList() ScrollingList::ScrollingList()
{ {
m_iBannerPrefs = BANNERPREFS_EZ2;
m_iSpriteType = SPRITE_TYPE_SPRITE;
m_iSelection = 0; m_iSelection = 0;
m_fSelectionLag = 0; m_fSelectionLag = 0;
m_iSpacing = DEFAULT_SPACING; m_iSpacing = DEFAULT_SPACING;
m_iNumVisible = DEFAULT_VISIBLE_ELEMENTS; m_iNumVisible = DEFAULT_VISIBLE_ELEMENTS;
} }
void ScrollingList::UseSpriteType(int NewSpriteType)
{
m_iSpriteType = NewSpriteType;
}
ScrollingList::~ScrollingList() ScrollingList::~ScrollingList()
{ {
Unload(); Unload();
@@ -45,9 +72,18 @@ ScrollingList::~ScrollingList()
void ScrollingList::Unload() void ScrollingList::Unload()
{ {
for( unsigned i=0; i<m_apSprites.size(); i++ ) if(m_iSpriteType == SPRITE_TYPE_SPRITE)
delete m_apSprites[i]; {
m_apSprites.clear(); for( unsigned i=0; i<m_apSprites.size(); i++ )
delete m_apSprites[i];
m_apSprites.clear();
}
else
{
for( unsigned i=0; i<m_apCSprites.size(); i++ )
delete m_apCSprites[i];
m_apCSprites.clear();
}
} }
/************************************ /************************************
@@ -56,12 +92,40 @@ in the scrolling list
*************************************/ *************************************/
void ScrollingList::Load( const CStringArray& asGraphicPaths ) void ScrollingList::Load( const CStringArray& asGraphicPaths )
{ {
RageTexturePrefs prefs;
Unload(); Unload();
for( unsigned i=0; i<asGraphicPaths.size(); i++ ) if(m_iSpriteType == SPRITE_TYPE_SPRITE)
{ {
Sprite* pNewSprite = new Sprite; for( unsigned i=0; i<asGraphicPaths.size(); i++ )
pNewSprite->Load( asGraphicPaths[i] ); {
m_apSprites.push_back( pNewSprite ); Sprite* pNewSprite = new Sprite;
pNewSprite->Load( asGraphicPaths[i] );
m_apSprites.push_back( pNewSprite );
}
}
else
{
for( unsigned i=0; i<asGraphicPaths.size(); i++ )
{
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( asGraphicPaths[i], prefs );
m_apCSprites.push_back( pNewCSprite );
}
} }
} }
@@ -73,10 +137,20 @@ Make the entire list shuffle left
**************************************/ **************************************/
void ScrollingList::Left() void ScrollingList::Left()
{ {
ASSERT( !m_apSprites.empty() ); // nothing loaded! if(m_iSpriteType == SPRITE_TYPE_SPRITE)
{
ASSERT( !m_apSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + m_apSprites.size() - 1) % m_apSprites.size(); // decrement with wrapping m_iSelection = (m_iSelection + m_apSprites.size() - 1) % m_apSprites.size(); // decrement with wrapping
m_fSelectionLag -= 1; m_fSelectionLag -= 1;
}
else
{
ASSERT( !m_apCSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + m_apCSprites.size() - 1) % m_apCSprites.size(); // decrement with wrapping
m_fSelectionLag -= 1;
}
} }
/************************************** /**************************************
@@ -86,10 +160,20 @@ Make the entire list shuffle right
**************************************/ **************************************/
void ScrollingList::Right() void ScrollingList::Right()
{ {
ASSERT( !m_apSprites.empty() ); // nothing loaded! if(m_iSpriteType == SPRITE_TYPE_SPRITE)
{
ASSERT( !m_apSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + 1) % m_apSprites.size(); // increment with wrapping m_iSelection = (m_iSelection + 1) % m_apSprites.size(); // increment with wrapping
m_fSelectionLag += 1; m_fSelectionLag += 1;
}
else
{
ASSERT( !m_apCSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + 1) % m_apCSprites.size(); // increment with wrapping
m_fSelectionLag += 1;
}
} }
/*********************************** /***********************************
@@ -132,9 +216,16 @@ Updates the actorframe
void ScrollingList::Update( float fDeltaTime ) void ScrollingList::Update( float fDeltaTime )
{ {
ActorFrame::Update( fDeltaTime ); ActorFrame::Update( fDeltaTime );
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
if( m_apSprites.empty() ) {
return; if( m_apSprites.empty() )
return;
}
else
{
if( m_apCSprites.empty() )
return;
}
// update m_fLaggingSelection // update m_fLaggingSelection
if( m_fSelectionLag != 0 ) if( m_fSelectionLag != 0 )
@@ -149,8 +240,16 @@ void ScrollingList::Update( float fDeltaTime )
m_fSelectionLag = 0; // snap m_fSelectionLag = 0; // snap
} }
for( unsigned i=0; i<m_apSprites.size(); i++ ) if(m_iSpriteType == SPRITE_TYPE_SPRITE)
m_apSprites[i]->Update( fDeltaTime ); {
for( unsigned i=0; i<m_apSprites.size(); i++ )
m_apSprites[i]->Update( fDeltaTime );
}
else
{
for( unsigned i=0; i<m_apCSprites.size(); i++ )
m_apCSprites[i]->Update( fDeltaTime );
}
} }
/******************************** /********************************
@@ -160,33 +259,67 @@ Draws the elements onto the screen
*********************************/ *********************************/
void ScrollingList::DrawPrimitives() void ScrollingList::DrawPrimitives()
{ {
ASSERT( !m_apSprites.empty() ); if(m_iSpriteType == SPRITE_TYPE_SPRITE)
{
ASSERT( !m_apSprites.empty() );
}
else
{
ASSERT( !m_apCSprites.empty() );
}
for( int i=(m_iNumVisible)/2; i>= 0; i-- ) // draw outside to inside for( int i=(m_iNumVisible)/2; i>= 0; i-- ) // draw outside to inside
{ {
int iIndexToDraw1 = m_iSelection - i; int iIndexToDraw1 = m_iSelection - i;
int iIndexToDraw2 = m_iSelection + i; int iIndexToDraw2 = m_iSelection + i;
// wrap IndexToDraw* if(m_iSpriteType == SPRITE_TYPE_SPRITE)
iIndexToDraw1 = (iIndexToDraw1 + m_apSprites.size()*300) % m_apSprites.size(); // make sure this is positive
iIndexToDraw2 = iIndexToDraw2 % m_apSprites.size();
ASSERT( iIndexToDraw1 >= 0 );
m_apSprites[iIndexToDraw1]->SetX( (-i+m_fSelectionLag) * m_iSpacing );
m_apSprites[iIndexToDraw2]->SetX( (+i+m_fSelectionLag) * m_iSpacing );
if( i==0 ) // so we don't draw 0 twice
{ {
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_SELECTED ); // wrap IndexToDraw*
m_apSprites[iIndexToDraw1]->Draw(); iIndexToDraw1 = (iIndexToDraw1 + m_apSprites.size()*300) % m_apSprites.size(); // make sure this is positive
iIndexToDraw2 = iIndexToDraw2 % m_apSprites.size();
ASSERT( iIndexToDraw1 >= 0 );
m_apSprites[iIndexToDraw1]->SetX( (-i+m_fSelectionLag) * m_iSpacing );
m_apSprites[iIndexToDraw2]->SetX( (+i+m_fSelectionLag) * m_iSpacing );
if( i==0 ) // so we don't draw 0 twice
{
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_SELECTED );
m_apSprites[iIndexToDraw1]->Draw();
}
else
{
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_NOT_SELECTED );
m_apSprites[iIndexToDraw2]->SetDiffuse( COLOR_NOT_SELECTED );
m_apSprites[iIndexToDraw1]->Draw();
m_apSprites[iIndexToDraw2]->Draw();
}
} }
else else
{ {
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_NOT_SELECTED ); // wrap IndexToDraw*
m_apSprites[iIndexToDraw2]->SetDiffuse( COLOR_NOT_SELECTED ); iIndexToDraw1 = (iIndexToDraw1 + m_apCSprites.size()*300) % m_apCSprites.size(); // make sure this is positive
m_apSprites[iIndexToDraw1]->Draw(); iIndexToDraw2 = iIndexToDraw2 % m_apCSprites.size();
m_apSprites[iIndexToDraw2]->Draw();
ASSERT( iIndexToDraw1 >= 0 );
m_apCSprites[iIndexToDraw1]->SetX( (-i+m_fSelectionLag) * m_iSpacing );
m_apCSprites[iIndexToDraw2]->SetX( (+i+m_fSelectionLag) * m_iSpacing );
if( i==0 ) // so we don't draw 0 twice
{
m_apCSprites[iIndexToDraw1]->SetDiffuse( COLOR_SELECTED );
m_apCSprites[iIndexToDraw1]->Draw();
}
else
{
m_apCSprites[iIndexToDraw1]->SetDiffuse( COLOR_NOT_SELECTED );
m_apCSprites[iIndexToDraw2]->SetDiffuse( COLOR_NOT_SELECTED );
m_apCSprites[iIndexToDraw1]->Draw();
m_apCSprites[iIndexToDraw2]->Draw();
}
} }
} }
} }
+5 -1
View File
@@ -13,6 +13,7 @@
#include "ActorFrame.h" #include "ActorFrame.h"
#include "Sprite.h" #include "Sprite.h"
#include "CroppedSprite.h"
class ScrollingList : public ActorFrame class ScrollingList : public ActorFrame
@@ -31,17 +32,20 @@ public:
int GetSelection(); int GetSelection();
void SetNumberVisible( int iNumVisibleElements ); void SetNumberVisible( int iNumVisibleElements );
void SetSpacing( int iSpacingInPixels ); void SetSpacing( int iSpacingInPixels );
void UseSpriteType(int NewSpriteType);
void Left(); void Left();
void Right(); void Right();
protected: protected:
int m_iBannerPrefs;
int m_iSpriteType;
int m_iSelection; int m_iSelection;
float m_fSelectionLag; float m_fSelectionLag;
int m_iSpacing; int m_iSpacing;
int m_iNumVisible; int m_iNumVisible;
CArray<Sprite*,Sprite*> m_apSprites; // stores the list of elements (left to right) CArray<Sprite*,Sprite*> m_apSprites; // stores the list of elements (left to right)
CArray<CroppedSprite*,CroppedSprite*> m_apCSprites; // stores the list of elements (left to right)
}; };
#endif #endif