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
RouletteSlowDownSwitches=5
LockedInitialVelocity=15
#
HideSections=false
#
ScrollBarHeight=300
ScrollBarOnCommand=visible,false
#
@@ -1764,8 +1766,12 @@ PreviousSongButton="MenuLeft"
NextSongButton="MenuRight"
#
ChangeStepsWithGameButtons=false
PreviousDifficultyButton="MenuUp"
NextDifficultyButton="MenuDown"
;PreviousDifficultyButton="MenuUp"
;NextDifficultyButton="MenuDown"
#
ChangeGroupsWithGameButtoms=false
;PreviousGroupButton="MenuUp"
;NextGroupButton="MenuDown"
#
TwoPartSelection=false
TwoPartConfirmsOnly=false
+69 -24
View File
@@ -79,6 +79,7 @@ void MusicWheel::Load( RString sType )
SORT_ORDERS .Load(sType,"SortOrders");
SHOW_EASY_FLAG .Load(sType,"UseEasyMarkerFlag");
USE_SECTIONS_WITH_PREFERRED_GROUP .Load(sType,"UseSectionsWithPreferredGroup");
HIDE_SECTIONS .Load(sType,"HideSections");
vector<RString> vsModeChoiceNames;
split( MODE_MENU_CHOICE_NAMES, ",", vsModeChoiceNames );
CHOICE .Load(sType,CHOICE_NAME,vsModeChoiceNames);
@@ -615,7 +616,9 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
// new section, make a section item
RageColor colorSection = (so==SORT_GROUP) ? SONGMAN->GetSongGroupColor(pSong->m_sGroupName) : SECTION_COLORS.GetValue(iSectionColorIndex);
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
arrayWheelItemDatas.push_back( new MusicWheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection, iSectionCount) );
// 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) );
sLastSection = sThisSection;
}
}
@@ -1129,23 +1132,44 @@ void MusicWheel::SetOpenSection( RString group )
// sm-ssc additions: jump to group
RString MusicWheel::JumpToNextGroup()
{
unsigned int iLastSelection = m_iSelection;
for( unsigned int i = m_iSelection; i < m_CurWheelItemData.size(); ++i )
//Thanks to Juanelote for this small addition
if(HIDE_SECTIONS)
{
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
unsigned iNumGroups = SONGMAN->GetNumSongGroups();
for(unsigned i = 0 ; i < iNumGroups ; i++)
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(i) )
{
if ( i < iNumGroups - 1 )
return SONGMAN->GetSongGroupByIndex(i+1);
else
{
//i = 0;
return SONGMAN->GetSongGroupByIndex(0);
}
}
}
}
// it should not get down here, but it might happen... only search up to
// the previous selection.
for( unsigned int i = 0; i < iLastSelection; ++i )
{
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
else{
unsigned int iLastSelection = m_iSelection;
for( unsigned int i = m_iSelection; i < m_CurWheelItemData.size(); ++i )
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
}
}
// it should not get down here, but it might happen... only search up to
// the previous selection.
for( unsigned int i = 0; i < iLastSelection; ++i )
{
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
}
}
}
// and this would be el bad:
@@ -1154,23 +1178,44 @@ RString MusicWheel::JumpToNextGroup()
RString MusicWheel::JumpToPrevGroup()
{
for( unsigned int i = m_iSelection; i > 0; --i )
if(HIDE_SECTIONS)
{
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
unsigned iNumGroups = SONGMAN->GetNumSongGroups();
for(unsigned i = 0 ; i < iNumGroups ; i++)
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(i) )
{
if ( i > 0 )
return SONGMAN->GetSongGroupByIndex(i-1);
else
{
//i = iNumGroups - 1;
return SONGMAN->GetSongGroupByIndex(iNumGroups - 1);
}
}
}
}
// in case it wasn't found above:
for( unsigned int i = m_CurWheelItemData.size()-1; i > 0; --i )
else
{
LOG->Trace( ssprintf("JumpToPrevGroup iteration 2 | i = %u",i) );
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION )
for( unsigned int i = m_iSelection; i > 0; --i )
{
m_iSelection = i;
LOG->Trace( ssprintf("finding it in #2 | i = %u | text = %s",i, m_CurWheelItemData[i]->m_sText.c_str()) );
return m_CurWheelItemData[i]->m_sText;
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection )
{
m_iSelection = i;
return m_CurWheelItemData[i]->m_sText;
}
}
// in case it wasn't found above:
for( unsigned int i = m_CurWheelItemData.size()-1; i > 0; --i )
{
LOG->Trace( ssprintf("JumpToPrevGroup iteration 2 | i = %u",i) );
if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION )
{
m_iSelection = i;
LOG->Trace( ssprintf("finding it in #2 | i = %u | text = %s",i, m_CurWheelItemData[i]->m_sText.c_str()) );
return m_CurWheelItemData[i]->m_sText;
}
}
}
// and this would be el bad:
+2
View File
@@ -85,6 +85,8 @@ protected:
ThemeMetric<LuaReference> SORT_ORDERS;
ThemeMetric<bool> SHOW_EASY_FLAG;
ThemeMetric<bool> USE_SECTIONS_WITH_PREFERRED_GROUP;
//sm-ssc additions -DaisuMaster
ThemeMetric<bool> HIDE_SECTIONS;
};
#endif
+54 -5
View File
@@ -92,6 +92,7 @@ void ScreenSelectMusic::Init()
WRAP_CHANGE_STEPS.Load( m_sName, "WrapChangeSteps" );
//To allow changing steps with gamebuttons -DaisuMaster
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_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_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 )
{
@@ -634,13 +641,55 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
if( m_SelectionState == SelectionState_SelectingSong )
{
if (input.MenuI == m_GameButtonPreviousDifficulty )
if ( input.MenuI == m_GameButtonPreviousDifficulty )
{
ChangeSteps( input.pn, -1 );
// Oh! I forgot to restrict to switch if the selection is locked... -DaisuMaster
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
ChangeSteps( input.pn, -1 );
}
else if( input.MenuI == m_GameButtonNextDifficulty )
{
ChangeSteps( input.pn, +1 );
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
else
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();
}
}
}
}
@@ -770,7 +819,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
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() )
m_soundLocked.Play();
@@ -782,7 +831,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
AfterMusicChange();
}
}
else if( CodeDetector::EnteredPrevGroup(input.GameI.controller) )
else if( CodeDetector::EnteredPrevGroup(input.GameI.controller) && !CHANGE_GROUPS_WITH_GAME_BUTTONS )
{
if( GAMESTATE->IsAnExtraStageAndSelectionLocked() )
m_soundLocked.Play();
+3
View File
@@ -89,6 +89,7 @@ protected:
ThemeMetric<float> TWO_PART_TIMER_SECONDS;
ThemeMetric<bool> WRAP_CHANGE_STEPS;
ThemeMetric<bool> CHANGE_STEPS_WITH_GAME_BUTTONS;
ThemeMetric<bool> CHANGE_GROUPS_WITH_GAME_BUTTONS;
bool CanChangeSong() const { return 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_GameButtonPreviousDifficulty;
GameButton m_GameButtonNextDifficulty;
GameButton m_GameButtonPreviousGroup;
GameButton m_GameButtonNextGroup;
RString m_sSectionMusicPath;
RString m_sSortMusicPath;
+5
View File
@@ -706,6 +706,11 @@ int SongManager::GetNumCourseGroups() const
return m_mapCourseGroupToInfo.size();
}
RString SongManager::GetSongGroupByIndex(unsigned index)
{
return m_sSongGroupNames[index];
}
RString SongManager::ShortenGroupName( RString sLongGroupName )
{
static TitleSubst tsub("Groups");
+1
View File
@@ -98,6 +98,7 @@ public:
int GetNumCourses() const;
int GetNumAdditionalCourses() const;
int GetNumCourseGroups() const;
RString GetSongGroupByIndex(unsigned index);
Song* GetRandomSong();
Course* GetRandomCourse();