MusicWheel::JumpToNext/PrevGroup, functions tweaked (thanks juanelote)

Metric added, [MusicWheel]::HideSections, will restrict showing one group at time, it you want to see the other groups use the next/prev group code, defaulted to "false"
Also group changing is allowed via gamebuttons in case of those who wants to take advantage of the codedetector too, "false" as default
SongManager::GetSongGroupByIndex, gets groups by index (helpful in Jump to group functions, thanks to juanelote for this too).
This commit is contained in:
Alberto Ramos
2010-07-25 11:29:05 -06:00
parent e669aebd9b
commit 23a1cc37d4
7 changed files with 143 additions and 32 deletions
+9 -3
View File
@@ -724,7 +724,9 @@ UseSectionsWithPreferredGroup=false
RouletteSwitchSeconds=0.05 RouletteSwitchSeconds=0.05
RouletteSlowDownSwitches=5 RouletteSlowDownSwitches=5
LockedInitialVelocity=15 LockedInitialVelocity=15
#
HideSections=false
#
ScrollBarHeight=300 ScrollBarHeight=300
ScrollBarOnCommand=visible,false ScrollBarOnCommand=visible,false
# #
@@ -1764,8 +1766,12 @@ PreviousSongButton="MenuLeft"
NextSongButton="MenuRight" NextSongButton="MenuRight"
# #
ChangeStepsWithGameButtons=false ChangeStepsWithGameButtons=false
PreviousDifficultyButton="MenuUp" ;PreviousDifficultyButton="MenuUp"
NextDifficultyButton="MenuDown" ;NextDifficultyButton="MenuDown"
#
ChangeGroupsWithGameButtoms=false
;PreviousGroupButton="MenuUp"
;NextGroupButton="MenuDown"
# #
TwoPartSelection=false TwoPartSelection=false
TwoPartConfirmsOnly=false TwoPartConfirmsOnly=false
+45
View File
@@ -79,6 +79,7 @@ void MusicWheel::Load( RString sType )
SORT_ORDERS .Load(sType,"SortOrders"); SORT_ORDERS .Load(sType,"SortOrders");
SHOW_EASY_FLAG .Load(sType,"UseEasyMarkerFlag"); SHOW_EASY_FLAG .Load(sType,"UseEasyMarkerFlag");
USE_SECTIONS_WITH_PREFERRED_GROUP .Load(sType,"UseSectionsWithPreferredGroup"); USE_SECTIONS_WITH_PREFERRED_GROUP .Load(sType,"UseSectionsWithPreferredGroup");
HIDE_SECTIONS .Load(sType,"HideSections");
vector<RString> vsModeChoiceNames; vector<RString> vsModeChoiceNames;
split( MODE_MENU_CHOICE_NAMES, ",", vsModeChoiceNames ); split( MODE_MENU_CHOICE_NAMES, ",", vsModeChoiceNames );
CHOICE .Load(sType,CHOICE_NAME,vsModeChoiceNames); CHOICE .Load(sType,CHOICE_NAME,vsModeChoiceNames);
@@ -615,6 +616,8 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
// new section, make a section item // new section, make a section item
RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex); RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex);
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS; iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
// This restricts to show only one group at time (ever heard about exceed or zero?)
if( !HIDE_SECTIONS )
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection, iSectionCount) ); arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection, iSectionCount) );
sLastSection = sThisSection; sLastSection = sThisSection;
} }
@@ -1129,6 +1132,26 @@ void MusicWheel::SetOpenSection( RString group )
// sm-ssc additions: jump to group // sm-ssc additions: jump to group
RString MusicWheel::JumpToNextGroup() RString MusicWheel::JumpToNextGroup()
{ {
//Thanks to Juanelote for this small addition
if(HIDE_SECTIONS)
{
unsigned iNumGroups = SONGMAN->GetNumSongGroups();
for(unsigned i = 0 ; i < iNumGroups ; i++)
{
if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(i) )
{
if ( i < iNumGroups - 1 )
return SONGMAN->GetSongGroupByIndex(i+1);
else
{
//i = 0;
return SONGMAN->GetSongGroupByIndex(0);
}
}
}
}
else{
unsigned int iLastSelection = m_iSelection; unsigned int iLastSelection = m_iSelection;
for( unsigned int i = m_iSelection; i < m_CurWheelItemData.size(); ++i ) for( unsigned int i = m_iSelection; i < m_CurWheelItemData.size(); ++i )
{ {
@@ -1148,11 +1171,32 @@ RString MusicWheel::JumpToNextGroup()
return m_CurWheelItemData[i]->m_sText; return m_CurWheelItemData[i]->m_sText;
} }
} }
}
// and this would be el bad: // and this would be el bad:
return ""; return "";
} }
RString MusicWheel::JumpToPrevGroup() RString MusicWheel::JumpToPrevGroup()
{
if(HIDE_SECTIONS)
{
unsigned iNumGroups = SONGMAN->GetNumSongGroups();
for(unsigned i = 0 ; i < iNumGroups ; i++)
{
if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(i) )
{
if ( i > 0 )
return SONGMAN->GetSongGroupByIndex(i-1);
else
{
//i = iNumGroups - 1;
return SONGMAN->GetSongGroupByIndex(iNumGroups - 1);
}
}
}
}
else
{ {
for( unsigned int i = m_iSelection; i > 0; --i ) for( unsigned int i = m_iSelection; i > 0; --i )
{ {
@@ -1173,6 +1217,7 @@ RString MusicWheel::JumpToPrevGroup()
return m_CurWheelItemData[i]->m_sText; return m_CurWheelItemData[i]->m_sText;
} }
} }
}
// and this would be el bad: // and this would be el bad:
return ""; return "";
} }
+2
View File
@@ -85,6 +85,8 @@ protected:
ThemeMetric<LuaReference> SORT_ORDERS; ThemeMetric<LuaReference> SORT_ORDERS;
ThemeMetric<bool> SHOW_EASY_FLAG; ThemeMetric<bool> SHOW_EASY_FLAG;
ThemeMetric<bool> USE_SECTIONS_WITH_PREFERRED_GROUP; ThemeMetric<bool> USE_SECTIONS_WITH_PREFERRED_GROUP;
//sm-ssc additions -DaisuMaster
ThemeMetric<bool> HIDE_SECTIONS;
}; };
#endif #endif
+51 -2
View File
@@ -92,6 +92,7 @@ void ScreenSelectMusic::Init()
WRAP_CHANGE_STEPS.Load( m_sName, "WrapChangeSteps" ); WRAP_CHANGE_STEPS.Load( m_sName, "WrapChangeSteps" );
//To allow changing steps with gamebuttons -DaisuMaster //To allow changing steps with gamebuttons -DaisuMaster
CHANGE_STEPS_WITH_GAME_BUTTONS.Load( m_sName, "ChangeStepsWithGameButtons" ); CHANGE_STEPS_WITH_GAME_BUTTONS.Load( m_sName, "ChangeStepsWithGameButtons" );
CHANGE_GROUPS_WITH_GAME_BUTTONS.Load( m_sName, "ChangeGroupsWithGameButtoms" );
m_GameButtonPreviousSong = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"PreviousSongButton") ); m_GameButtonPreviousSong = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"PreviousSongButton") );
m_GameButtonNextSong = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"NextSongButton") ); m_GameButtonNextSong = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"NextSongButton") );
@@ -102,6 +103,12 @@ void ScreenSelectMusic::Init()
m_GameButtonPreviousDifficulty = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"PreviousDifficultyButton") ); m_GameButtonPreviousDifficulty = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"PreviousDifficultyButton") );
m_GameButtonNextDifficulty = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"NextDifficultyButton") ); m_GameButtonNextDifficulty = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"NextDifficultyButton") );
} }
//same here but for groups -DaisuMaster
if( CHANGE_GROUPS_WITH_GAME_BUTTONS )
{
m_GameButtonPreviousGroup = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"PreviousGroupButton") );
m_GameButtonNextGroup = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric(m_sName,"NextGroupButton") );
}
FOREACH_ENUM( PlayerNumber, p ) FOREACH_ENUM( PlayerNumber, p )
{ {
@@ -636,14 +643,56 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
{ {
if ( input.MenuI == m_GameButtonPreviousDifficulty ) if ( input.MenuI == m_GameButtonPreviousDifficulty )
{ {
// Oh! I forgot to restrict to switch if the selection is locked... -DaisuMaster
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
ChangeSteps( input.pn, -1 ); ChangeSteps( input.pn, -1 );
} }
else if( input.MenuI == m_GameButtonNextDifficulty ) else if( input.MenuI == m_GameButtonNextDifficulty )
{ {
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
ChangeSteps( input.pn, +1 ); ChangeSteps( input.pn, +1 );
} }
} }
} }
// Most likely a copypasta of the previous addition -DaisuMaster
if( CHANGE_GROUPS_WITH_GAME_BUTTONS )
{
if( input.type != IET_FIRST_PRESS)
return;
if( m_SelectionState == SelectionState_SelectingSong )
{
if(input.MenuI == m_GameButtonPreviousGroup )
{
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
{
//for real: copypasta
RString sNewGroup = m_MusicWheel.JumpToPrevGroup();
m_MusicWheel.SelectSection(sNewGroup);
m_MusicWheel.SetOpenSection(sNewGroup);
AfterMusicChange();
}
}
if(input.MenuI == m_GameButtonNextGroup )
{
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
{
RString sNewGroup = m_MusicWheel.JumpToNextGroup();
m_MusicWheel.SelectSection(sNewGroup);
m_MusicWheel.SetOpenSection(sNewGroup);
AfterMusicChange();
}
}
}
}
// two part confirms only means we can actually change songs here, // two part confirms only means we can actually change songs here,
// so we need some hackery. oops looks like this is never going into // so we need some hackery. oops looks like this is never going into
@@ -770,7 +819,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
MESSAGEMAN->Broadcast( "SongOptionsChanged" ); MESSAGEMAN->Broadcast( "SongOptionsChanged" );
} }
else if( CodeDetector::EnteredNextGroup(input.GameI.controller) ) else if( CodeDetector::EnteredNextGroup(input.GameI.controller) && !CHANGE_GROUPS_WITH_GAME_BUTTONS )
{ {
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play(); m_soundLocked.Play();
@@ -782,7 +831,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
AfterMusicChange(); AfterMusicChange();
} }
} }
else if( CodeDetector::EnteredPrevGroup(input.GameI.controller) ) else if( CodeDetector::EnteredPrevGroup(input.GameI.controller) && !CHANGE_GROUPS_WITH_GAME_BUTTONS )
{ {
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play(); m_soundLocked.Play();
+3
View File
@@ -89,6 +89,7 @@ protected:
ThemeMetric<float> TWO_PART_TIMER_SECONDS; ThemeMetric<float> TWO_PART_TIMER_SECONDS;
ThemeMetric<bool> WRAP_CHANGE_STEPS; ThemeMetric<bool> WRAP_CHANGE_STEPS;
ThemeMetric<bool> CHANGE_STEPS_WITH_GAME_BUTTONS; ThemeMetric<bool> CHANGE_STEPS_WITH_GAME_BUTTONS;
ThemeMetric<bool> CHANGE_GROUPS_WITH_GAME_BUTTONS;
bool CanChangeSong() const { return m_SelectionState == SelectionState_SelectingSong; } bool CanChangeSong() const { return m_SelectionState == SelectionState_SelectingSong; }
bool CanChangeSteps() const { return TWO_PART_SELECTION ? m_SelectionState == SelectionState_SelectingSteps : m_SelectionState == SelectionState_SelectingSong; } bool CanChangeSteps() const { return TWO_PART_SELECTION ? m_SelectionState == SelectionState_SelectingSteps : m_SelectionState == SelectionState_SelectingSong; }
@@ -108,6 +109,8 @@ protected:
GameButton m_GameButtonNextSong; GameButton m_GameButtonNextSong;
GameButton m_GameButtonPreviousDifficulty; GameButton m_GameButtonPreviousDifficulty;
GameButton m_GameButtonNextDifficulty; GameButton m_GameButtonNextDifficulty;
GameButton m_GameButtonPreviousGroup;
GameButton m_GameButtonNextGroup;
RString m_sSectionMusicPath; RString m_sSectionMusicPath;
RString m_sSortMusicPath; RString m_sSortMusicPath;
+5
View File
@@ -706,6 +706,11 @@ int SongManager::GetNumCourseGroups() const
return m_mapCourseGroupToInfo.size(); return m_mapCourseGroupToInfo.size();
} }
RString SongManager::GetSongGroupByIndex(unsigned index)
{
return m_sSongGroupNames[index];
}
RString SongManager::ShortenGroupName( RString sLongGroupName ) RString SongManager::ShortenGroupName( RString sLongGroupName )
{ {
static TitleSubst tsub("Groups"); static TitleSubst tsub("Groups");
+1
View File
@@ -98,6 +98,7 @@ public:
int GetNumCourses() const; int GetNumCourses() const;
int GetNumAdditionalCourses() const; int GetNumAdditionalCourses() const;
int GetNumCourseGroups() const; int GetNumCourseGroups() const;
RString GetSongGroupByIndex(unsigned index);
Song* GetRandomSong(); Song* GetRandomSong();
Course* GetRandomCourse(); Course* GetRandomCourse();