Add GroupList.

(Group list from the group select screen, with no limit on song count.)
This commit is contained in:
Glenn Maynard
2002-08-24 20:36:29 +00:00
parent 849086a3ba
commit f54cb254a6
6 changed files with 253 additions and 107 deletions
+175
View File
@@ -0,0 +1,175 @@
#include "stdafx.h"
#include "GroupList.h"
#include "ThemeManager.h"
#include "SongManager.h"
#define BUTTON_X THEME->GetMetricF("SelectGroup","ButtonX")
#define BUTTON_START_Y THEME->GetMetricF("SelectGroup","ButtonStartY")
#define BUTTON_SPACING_Y THEME->GetMetricF("SelectGroup","ButtonSpacingY")
#define BUTTON_SELECTED_X THEME->GetMetricF("SelectGroup","ButtonSelectedX")
GroupList::GroupList()
{
m_iSelection = m_iTop = 0;
}
void GroupList::DoneAddingGroups()
{
int i;
for( i=0; i<min(m_textLabels.GetSize(), MAX_GROUPS_ONSCREEN); i++ )
{
m_sprButton[i].Load( THEME->GetPathTo("Graphics","select group button") );
m_sprButton[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y );
this->AddSubActor( &m_sprButton[i] );
this->AddSubActor( &m_screenLabels[i] );
}
for( i=0; i<min(m_textLabels.GetSize(), MAX_GROUPS_ONSCREEN); i++ )
{
m_screenLabels[i].LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_screenLabels[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y );
m_screenLabels[i].SetZoom( 0.8f );
m_screenLabels[i].SetShadowLength( 2 );
CString sGroupName = m_textLabels[i];
}
SetLabels();
AfterChange();
}
void GroupList::SetLabels()
{
for( int i=0; i<min(m_textLabels.GetSize(), MAX_GROUPS_ONSCREEN); i++ )
{
CString &label = m_textLabels[m_iTop+i];
m_screenLabels[i].SetText( SONGMAN->ShortenGroupName( label ) );
if( m_iTop+i == 0 ) m_screenLabels[i].TurnRainbowOn();
else {
m_screenLabels[i].TurnRainbowOff();
m_screenLabels[i].SetDiffuseColor( SONGMAN->GetGroupColor(label) );
}
}
}
void GroupList::BeforeChange()
{
int iSel = m_iSelection-m_iTop;
m_sprButton[iSel].BeginTweening( 0.2f );
m_sprButton[iSel].SetTweenX( BUTTON_X );
m_sprButton[iSel].SetEffectNone();
m_screenLabels[iSel].BeginTweening( 0.2f );
m_screenLabels[iSel].SetTweenX( BUTTON_X );
m_screenLabels[iSel].SetEffectNone();
}
void GroupList::AfterChange()
{
int iSel = m_iSelection-m_iTop;
m_sprButton[iSel].BeginTweening( 0.2f );
m_sprButton[iSel].SetTweenX( BUTTON_SELECTED_X );
m_sprButton[iSel].SetEffectGlowing();
m_screenLabels[iSel].BeginTweening( 0.2f );
m_screenLabels[iSel].SetTweenX( BUTTON_SELECTED_X );
m_screenLabels[iSel].SetEffectGlowing();
}
void GroupList::Up()
{
BeforeChange();
if( m_iSelection == 0 )
SetSelection(m_textLabels.GetSize()-1);
else
SetSelection(m_iSelection-1);
AfterChange();
}
void GroupList::Down()
{
BeforeChange();
SetSelection((m_iSelection+1) % m_textLabels.GetSize());
AfterChange();
}
void GroupList::AddGroup(CString name)
{
m_textLabels.Add(name);
}
void GroupList::SetSelection( int sel )
{
BeforeChange();
if( sel == m_iSelection ) ;
else if( sel == m_iSelection+1 ) {
if( m_iSelection >= MAX_GROUPS_ONSCREEN/2 )
m_iTop++;
} else if( sel == m_iSelection-1 ) {
if(m_iSelection < m_textLabels.GetSize() - MAX_GROUPS_ONSCREEN/2)
m_iTop--;
} else {
/* We're jumping somewhere else; just put the top somewhere
* reasonable. */
m_iTop = sel - MAX_GROUPS_ONSCREEN/2;
}
m_iSelection=sel;
m_iTop = clamp( m_iTop, 0, m_textLabels.GetSize()-MAX_GROUPS_ONSCREEN );
/* The current selection must always be visible. */
ASSERT( m_iTop <= m_iSelection );
ASSERT( m_iTop+MAX_GROUPS_ONSCREEN > m_iSelection );
SetLabels();
AfterChange();
}
void GroupList::TweenOnScreen()
{
for( int i=0; i<min(m_textLabels.GetSize(), MAX_GROUPS_ONSCREEN); i++ )
{
m_sprButton[i].SetX( BUTTON_X+400 );
m_sprButton[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_END );
m_sprButton[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_END );
m_sprButton[i].SetTweenX( BUTTON_X );
m_screenLabels[i].SetX( BUTTON_X+400 );
m_screenLabels[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_END );
m_screenLabels[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_END );
m_screenLabels[i].SetTweenX( BUTTON_X );
}
}
void GroupList::TweenOffScreen()
{
for( int i=0; i<min(m_textLabels.GetSize(), MAX_GROUPS_ONSCREEN); i++ )
{
if( i == m_iSelection )
m_sprButton[i].BeginTweeningQueued( 1.0f, TWEEN_BOUNCE_BEGIN );
else
m_sprButton[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_BEGIN );
m_sprButton[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_BEGIN );
m_sprButton[i].SetTweenX( BUTTON_X+400 );
if( i == m_iSelection )
m_screenLabels[i].BeginTweeningQueued( 1.0f, TWEEN_BOUNCE_BEGIN );
else
m_screenLabels[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_BEGIN );
m_screenLabels[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_BEGIN );
m_screenLabels[i].SetTweenX( BUTTON_X+400 );
}
}
+38
View File
@@ -0,0 +1,38 @@
#ifndef GROUPLIST_H
#define GROUPLIST_H
#include "ActorFrame.h"
#include "Sprite.h"
#include "BitmapText.h"
const int MAX_GROUPS_ONSCREEN = 8;
class GroupList: public ActorFrame {
Sprite m_sprButton[MAX_GROUPS_ONSCREEN];
BitmapText m_screenLabels[MAX_GROUPS_ONSCREEN];
CArray<CString,CString> m_textLabels;
/* Currently selected label. */
int m_iSelection;
/* Label that's currently at the top of the screen. */
int m_iTop;
void BeforeChange();
void AfterChange();
void SetLabels();
public:
GroupList();
void SetSelection(int sel);
int GetSelection() const { return m_iSelection; }
CString GetSelectionName() const { return m_textLabels[m_iSelection]; }
void Up();
void Down();
void AddGroup(CString name);
void DoneAddingGroups();
void TweenOffScreen();
void TweenOnScreen();
};
#endif
+23 -98
View File
@@ -34,10 +34,6 @@
#define NUMBER_Y THEME->GetMetricF("SelectGroup","NumberY")
#define EXPLANATION_X THEME->GetMetricF("SelectGroup","ExplanationX")
#define EXPLANATION_Y THEME->GetMetricF("SelectGroup","ExplanationY")
#define BUTTON_X THEME->GetMetricF("SelectGroup","ButtonX")
#define BUTTON_SELECTED_X THEME->GetMetricF("SelectGroup","ButtonSelectedX")
#define BUTTON_START_Y THEME->GetMetricF("SelectGroup","ButtonStartY")
#define BUTTON_SPACING_Y THEME->GetMetricF("SelectGroup","ButtonSpacingY")
#define CONTENTS_X THEME->GetMetricF("SelectGroup","ContentsX")
#define CONTENTS_Y THEME->GetMetricF("SelectGroup","ContentsY")
@@ -89,27 +85,27 @@ ScreenSelectGroup::ScreenSelectGroup()
for( i=0; i<aAllSongs.GetSize(); i++ ) // foreach Song
mapGroupToNothing[ aAllSongs[i]->m_sGroupName ] = "";
// Read group names back out into an m_asGroupNames
m_asGroupNames.Add( "ALL MUSIC" );
CStringArray asGroupNames;
// Read group names back out into asGroupNames
for( POSITION pos = mapGroupToNothing.GetStartPosition(); pos != NULL; )
{
CString sGroupName, sValue;
mapGroupToNothing.GetNextAssoc( pos, sGroupName, sValue );
m_asGroupNames.Add( sGroupName );
if( m_asGroupNames.GetSize() == MAX_GROUPS-1 )
break; // stop adding
asGroupNames.Add( sGroupName );
}
SortCStringArray( m_asGroupNames, true );
SortCStringArray( asGroupNames, true );
asGroupNames.InsertAt(0, "ALL MUSIC" );
// Add songs to the MusicList.
for( int j=0; j<min(m_asGroupNames.GetSize(), MAX_GROUPS); j++ ) /* for each group */
for( int j=0; j < asGroupNames.GetSize(); j++ ) /* for each group */
{
CArray<Song*,Song*> aSongsInGroup;
/* find all songs */
for( i=0; i<aAllSongs.GetSize(); i++ ) // foreach Song
{
if( j != 0 && aAllSongs[i]->m_sGroupName != m_asGroupNames[j] )
/* group 0 gets all songs */
if( j != 0 && aAllSongs[i]->m_sGroupName != asGroupNames[j] )
continue;
aSongsInGroup.Add( aAllSongs[i] );
@@ -121,7 +117,6 @@ ScreenSelectGroup::ScreenSelectGroup()
m_MusicList.AddSongsToGroup(aSongsInGroup);
}
m_iSelection = 0;
m_bChosen = false;
m_Menu.Load(
@@ -156,26 +151,12 @@ ScreenSelectGroup::ScreenSelectGroup()
this->AddSubActor( &m_sprContents );
this->AddSubActor( &m_MusicList );
for( i=0; i < asGroupNames.GetSize(); ++i )
m_GroupList.AddGroup( asGroupNames[i] );
m_GroupList.DoneAddingGroups();
this->AddSubActor( &m_GroupList );
for( i=0; i<min(m_asGroupNames.GetSize(), MAX_GROUPS); i++ )
{
CString sGroupName = m_asGroupNames[i];
m_sprButton[i].Load( THEME->GetPathTo("Graphics","select group button") );
m_sprButton[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y );
this->AddSubActor( &m_sprButton[i] );
m_textLabel[i].LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_textLabel[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y );
m_textLabel[i].SetText( SONGMAN->ShortenGroupName( sGroupName ) );
m_textLabel[i].SetZoom( 0.8f );
m_textLabel[i].SetShadowLength( 2 );
if( i == 0 ) m_textLabel[i].TurnRainbowOn();
else m_textLabel[i].SetDiffuseColor( SONGMAN->GetGroupColor(sGroupName) );
this->AddSubActor( &m_textLabel[i] );
}
m_soundChange.Load( THEME->GetPathTo("Sounds","select group change") );
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
@@ -192,6 +173,7 @@ ScreenSelectGroup::ScreenSelectGroup()
m_Menu.TweenOnScreenFromMenu( SM_None );
TweenOnScreen();
AfterChange();
m_GroupList.SetSelection(0);
}
@@ -238,34 +220,12 @@ void ScreenSelectGroup::HandleScreenMessage( const ScreenMessage SM )
}
}
void ScreenSelectGroup::BeforeChange()
{
int iSel = m_iSelection;
m_sprButton[iSel].BeginTweening( 0.2f );
m_sprButton[iSel].SetTweenX( BUTTON_X );
m_sprButton[iSel].SetEffectNone();
m_textLabel[iSel].BeginTweening( 0.2f );
m_textLabel[iSel].SetTweenX( BUTTON_X );
m_textLabel[iSel].SetEffectNone();
}
void ScreenSelectGroup::AfterChange()
{
int iSel = m_iSelection;
int sel = m_GroupList.GetSelection();
m_MusicList.SetGroupNo(sel);
m_sprButton[iSel].BeginTweening( 0.2f );
m_sprButton[iSel].SetTweenX( BUTTON_SELECTED_X );
m_sprButton[iSel].SetEffectGlowing();
m_textLabel[iSel].BeginTweening( 0.2f );
m_textLabel[iSel].SetTweenX( BUTTON_SELECTED_X );
m_textLabel[iSel].SetEffectGlowing();
m_MusicList.SetGroupNo(m_iSelection);
CString sSelectedGroupName = m_asGroupNames[m_iSelection];
CString sSelectedGroupName = m_GroupList.GetSelectionName();
CString sGroupBannerPath;
if( 0 == stricmp(sSelectedGroupName, "ALL MUSIC") )
@@ -297,11 +257,7 @@ void ScreenSelectGroup::MenuUp( const PlayerNumber p )
if( m_bChosen )
return;
BeforeChange();
m_iSelection = m_iSelection-1 % m_asGroupNames.GetSize();
if( m_iSelection < 0 )
m_iSelection += min( m_asGroupNames.GetSize(), MAX_GROUPS );
m_GroupList.Up();
AfterChange();
@@ -314,9 +270,7 @@ void ScreenSelectGroup::MenuDown( const PlayerNumber p )
if( m_bChosen )
return;
BeforeChange();
m_iSelection = (m_iSelection+1) % min( m_asGroupNames.GetSize(), MAX_GROUPS );
m_GroupList.Down();
AfterChange();
@@ -329,7 +283,7 @@ void ScreenSelectGroup::MenuStart( const PlayerNumber p )
m_bChosen = true;
GAMESTATE->m_pCurSong = NULL;
GAMESTATE->m_sPreferredGroup = m_asGroupNames[m_iSelection];
GAMESTATE->m_sPreferredGroup = m_GroupList.GetSelectionName();
if( 0 == stricmp(GAMESTATE->m_sPreferredGroup, "All Music") )
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_GROUP_COMMENT_ALL_MUSIC) );
@@ -366,26 +320,9 @@ void ScreenSelectGroup::TweenOffScreen()
m_sprContents.BeginTweeningQueued( 0.7f );
m_sprContents.BeginTweeningQueued( 0.5f, TWEEN_BIAS_END );
m_sprContents.SetTweenY( CONTENTS_Y+400 );
m_MusicList.TweenOffScreen();
for( i=0; i<min(m_asGroupNames.GetSize(), MAX_GROUPS); i++ )
{
if( i == m_iSelection )
m_sprButton[i].BeginTweeningQueued( 1.0f, TWEEN_BOUNCE_BEGIN );
else
m_sprButton[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_BEGIN );
m_sprButton[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_BEGIN );
m_sprButton[i].SetTweenX( BUTTON_X+400 );
if( i == m_iSelection )
m_textLabel[i].BeginTweeningQueued( 1.0f, TWEEN_BOUNCE_BEGIN );
else
m_textLabel[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_BEGIN );
m_textLabel[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_BEGIN );
m_textLabel[i].SetTweenX( BUTTON_X+400 );
}
m_GroupList.TweenOffScreen();
}
void ScreenSelectGroup::TweenOnScreen()
@@ -410,17 +347,5 @@ void ScreenSelectGroup::TweenOnScreen()
m_sprContents.SetTweenY( CONTENTS_Y );
m_MusicList.TweenOnScreen();
for( i=0; i<min(m_asGroupNames.GetSize(), MAX_GROUPS); i++ )
{
m_sprButton[i].SetX( BUTTON_X+400 );
m_sprButton[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_END );
m_sprButton[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_END );
m_sprButton[i].SetTweenX( BUTTON_X );
m_textLabel[i].SetX( BUTTON_X+400 );
m_textLabel[i].BeginTweeningQueued( 0.1f*i, TWEEN_BOUNCE_END );
m_textLabel[i].BeginTweeningQueued( 0.2f, TWEEN_BOUNCE_END );
m_textLabel[i].SetTweenX( BUTTON_X );
}
m_GroupList.TweenOnScreen();
}
+3 -9
View File
@@ -12,15 +12,12 @@
#include "Screen.h"
#include "Sprite.h"
#include "RandomSample.h"
#include "Screen.h"
#include "Quad.h"
#include "MenuElements.h"
#include "FadingBanner.h"
#include "MusicList.h"
#include "GroupList.h"
const int MAX_GROUPS = 15;
class ScreenSelectGroup : public Screen
{
public:
@@ -31,7 +28,6 @@ public:
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
void BeforeChange();
void AfterChange();
void MenuLeft( const PlayerNumber p );
@@ -52,16 +48,14 @@ private:
Sprite m_sprFrame;
FadingBanner m_Banner;
BitmapText m_textNumber;
Sprite m_sprButton[MAX_GROUPS];
BitmapText m_textLabel[MAX_GROUPS];
Sprite m_sprContents;
MusicList m_MusicList;
GroupList m_GroupList;
RandomSample m_soundChange;
RandomSample m_soundSelect;
CStringArray m_asGroupNames;
int m_iSelection;
bool m_bChosen;
};
+8
View File
@@ -636,6 +636,14 @@ SOURCE=.\GroupInfoFrame.h
# End Source File
# Begin Source File
SOURCE=.\GroupList.cpp
# End Source File
# Begin Source File
SOURCE=.\GroupList.h
# End Source File
# Begin Source File
SOURCE=.\MenuElements.cpp
# End Source File
# Begin Source File
+6
View File
@@ -628,6 +628,12 @@
<File
RelativePath="GrooveRadar.h">
</File>
<File
RelativePath="GroupList.cpp">
</File>
<File
RelativePath="GroupList.h">
</File>
<File
RelativePath="GroupInfoFrame.cpp">
</File>