From 1d2e3faefd23d89ed3cc99c8a054d42da4b031a0 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 24 Aug 2002 06:30:32 +0000 Subject: [PATCH] Add MusicList (move column display out of ScreenSelectGroup). Doesn't have a group limit (but ScreenSelectGroup still does) --- stepmania/src/MusicList.cpp | 99 ++++++++++++++++++++++++ stepmania/src/MusicList.h | 39 ++++++++++ stepmania/src/ScreenSelectGroup.cpp | 112 ++++++---------------------- stepmania/src/ScreenSelectGroup.h | 7 +- stepmania/src/StepMania.dsp | 8 ++ stepmania/src/StepMania.vcproj | 6 ++ 6 files changed, 175 insertions(+), 96 deletions(-) create mode 100644 stepmania/src/MusicList.cpp create mode 100644 stepmania/src/MusicList.h diff --git a/stepmania/src/MusicList.cpp b/stepmania/src/MusicList.cpp new file mode 100644 index 0000000000..54f4bc283e --- /dev/null +++ b/stepmania/src/MusicList.cpp @@ -0,0 +1,99 @@ +#include "stdafx.h" +#include "MusicList.h" +#include "ThemeManager.h" + +#define TITLES_START_X THEME->GetMetricF("SelectGroup","TitlesStartX") +#define TITLES_SPACING_X THEME->GetMetricF("SelectGroup","TitlesSpacingX") +#define TITLES_START_Y THEME->GetMetricF("SelectGroup","TitlesStartY") +#define TITLES_COLUMNS THEME->GetMetricI("SelectGroup","TitlesColumns") +#define TITLES_ROWS THEME->GetMetricI("SelectGroup","TitlesRows") + +MusicList::MusicList() +{ + CurGroup = 0; + + for( int i=0; iGetPathTo("Fonts","normal") ); + m_textTitles[i].SetXY( TITLES_START_X + i*TITLES_SPACING_X, TITLES_START_Y ); + m_textTitles[i].SetHorizAlign( Actor::align_left ); + m_textTitles[i].SetVertAlign( Actor::align_top ); + m_textTitles[i].SetZoom( 0.5f ); + m_textTitles[i].SetShadowLength( 2 ); + this->AddSubActor( &m_textTitles[i] ); + } +} + +void MusicList::AddGroup() +{ + m_ContentsText.Add(group()); +} + +void MusicList::AddSongsToGroup(const CArray &Songs) +{ + // Generate what text will show in the contents for each group + int group = m_ContentsText.GetSize()-1; + + m_ContentsText[group].m_iNumSongsInGroup = Songs.GetSize(); + + for( int c=0; c= Songs.GetSize() ) + continue; + + if( c == TITLES_COLUMNS-1 && r == TITLES_ROWS-1 ) + { + sText += ssprintf( "%d more.....", Songs.GetSize() - TITLES_COLUMNS * TITLES_ROWS - 1 ); + continue; + } + + CString sTitle = Songs[iIndex]->GetFullTitle(); + // TODO: Move this crop threshold into a theme metric or make automatic based on column width + if( sTitle.GetLength() > 40 ) + { + sTitle = sTitle.Left( 37 ); + sTitle += "..."; + } + sText += sTitle + "\n"; + } + m_ContentsText[m_ContentsText.GetSize()-1].ContentsText[c] = sText; + } + +} + +/* TODO: tween? */ +void MusicList::SetGroupNo(int group) +{ + CurGroup = group; + + for( int c=0; c m_ContentsText; + + int NumGroups, CurGroup; + +public: + MusicList(); + + /* Add a new group. */ + void AddGroup(); + + /* Add songs to the group that was just added. */ + void AddSongsToGroup(const CArray &songs); + + /* Set the displayed group number. */ + void SetGroupNo(int group); + + void TweenOnScreen(); + void TweenOffScreen(); + int GetNumSongs() const { return m_ContentsText[CurGroup].m_iNumSongsInGroup; } +}; + +#endif \ No newline at end of file diff --git a/stepmania/src/ScreenSelectGroup.cpp b/stepmania/src/ScreenSelectGroup.cpp index a57f0215e3..7c768fa70a 100644 --- a/stepmania/src/ScreenSelectGroup.cpp +++ b/stepmania/src/ScreenSelectGroup.cpp @@ -14,7 +14,6 @@ #include "ScreenSelectGroup.h" #include "ScreenManager.h" #include "PrefsManager.h" -#include "PrefsManager.h" #include "ScreenSelectMusic.h" #include "ScreenTitleMenu.h" #include "GameManager.h" @@ -41,11 +40,7 @@ #define BUTTON_SPACING_Y THEME->GetMetricF("SelectGroup","ButtonSpacingY") #define CONTENTS_X THEME->GetMetricF("SelectGroup","ContentsX") #define CONTENTS_Y THEME->GetMetricF("SelectGroup","ContentsY") -#define TITLES_START_X THEME->GetMetricF("SelectGroup","TitlesStartX") -#define TITLES_SPACING_X THEME->GetMetricF("SelectGroup","TitlesSpacingX") -#define TITLES_START_Y THEME->GetMetricF("SelectGroup","TitlesStartY") -#define TITLES_COLUMNS THEME->GetMetricI("SelectGroup","TitlesColumns") -#define TITLES_ROWS THEME->GetMetricI("SelectGroup","TitlesRows") + #define HELP_TEXT THEME->GetMetric("SelectGroup","HelpText") #define TIMER_SECONDS THEME->GetMetricI("SelectGroup","TimerSeconds") @@ -107,25 +102,24 @@ ScreenSelectGroup::ScreenSelectGroup() } SortCStringArray( m_asGroupNames, true ); - // Add songs to groups (this isn't very efficient, but oh well... - CArray aSongsInGroup[MAX_GROUPS]; - aSongsInGroup[0].Copy( aAllSongs ); // add to ALL MUSIC - for( i=0; i aSongsInGroup; + /* find all songs */ + for( i=0; im_sGroupName == m_asGroupNames[j] ) - { - aSongsInGroup[j].Add( pSong ); - break; - } + if( j != 0 && aAllSongs[i]->m_sGroupName != m_asGroupNames[j] ) + continue; + + aSongsInGroup.Add( aAllSongs[i] ); } + + SortSongPointerArrayByTitle( aSongsInGroup ); + + m_MusicList.AddGroup(); + m_MusicList.AddSongsToGroup(aSongsInGroup); } - - - m_iSelection = 0; m_bChosen = false; @@ -161,17 +155,7 @@ ScreenSelectGroup::ScreenSelectGroup() m_sprContents.SetXY( CONTENTS_X, CONTENTS_Y ); this->AddSubActor( &m_sprContents ); - for( i=0; iGetPathTo("Fonts","normal") ); - m_textTitles[i].SetXY( TITLES_START_X + i*TITLES_SPACING_X, TITLES_START_Y ); - m_textTitles[i].SetHorizAlign( Actor::align_left ); - m_textTitles[i].SetVertAlign( Actor::align_top ); - m_textTitles[i].SetZoom( 0.5f ); - m_textTitles[i].SetShadowLength( 2 ); - this->AddSubActor( &m_textTitles[i] ); - } - + this->AddSubActor( &m_MusicList ); for( i=0; iAddSubActor( &m_textLabel[i] ); } - - - // - // Generate what text will show in the contents for each group - // - for( i=0; i& aSongs = aSongsInGroup[i]; - m_iNumSongsInGroup[i] = aSongs.GetSize(); - SortSongPointerArrayByTitle( aSongs ); - - for( int c=0; c= aSongs.GetSize() ) - continue; - - if( c == TITLES_COLUMNS-1 && r == TITLES_ROWS-1 ) - { - sText += ssprintf( "%d more.....", aSongs.GetSize() - TITLES_COLUMNS * TITLES_ROWS - 1 ); - continue; - } - - CString sTitle = aSongs[iIndex]->GetFullTitle(); - // TODO: Move this crop threshold into a theme metric or make automatic based on column width - if( sTitle.GetLength() > 40 ) - { - sTitle = sTitle.Left( 37 ); - sTitle += "..."; - } - sText += sTitle + "\n"; - } - m_sContentsText[i][c] = sText; - } - } - m_soundChange.Load( THEME->GetPathTo("Sounds","select group change") ); m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") ); @@ -318,11 +263,7 @@ void ScreenSelectGroup::AfterChange() m_textLabel[iSel].SetTweenX( BUTTON_SELECTED_X ); m_textLabel[iSel].SetEffectGlowing(); - for( int c=0; cGetPathTo("Graphics","fallback banner"); - const int iNumSongs = m_iNumSongsInGroup[m_iSelection]; + const int iNumSongs = m_MusicList.GetNumSongs(); m_textNumber.SetText( ssprintf("%d", iNumSongs) ); m_Banner.SetFromGroup( sSelectedGroupName ); @@ -425,13 +366,9 @@ void ScreenSelectGroup::TweenOffScreen() m_sprContents.BeginTweeningQueued( 0.7f ); m_sprContents.BeginTweeningQueued( 0.5f, TWEEN_BIAS_END ); m_sprContents.SetTweenY( CONTENTS_Y+400 ); - for( i=0; i + + + +