Changed SongCriteria.m_sGroupName to a vector m_vsGroupNames, to allow for the potential to select a song from more than one group.
This commit is contained in:
+2
-2
@@ -56,8 +56,8 @@ RString CourseEntry::GetTextDescription() const
|
|||||||
vsEntryDescription.push_back( pSong->GetTranslitFullTitle() );
|
vsEntryDescription.push_back( pSong->GetTranslitFullTitle() );
|
||||||
else
|
else
|
||||||
vsEntryDescription.push_back( "Random" );
|
vsEntryDescription.push_back( "Random" );
|
||||||
if( !songCriteria.m_sGroupName.empty() )
|
if( !songCriteria.m_vsGroupNames.size() > 0 )
|
||||||
vsEntryDescription.push_back( songCriteria.m_sGroupName );
|
vsEntryDescription.push_back( join(",", songCriteria.m_vsGroupNames) );
|
||||||
if( songCriteria.m_bUseSongGenreAllowedList )
|
if( songCriteria.m_bUseSongGenreAllowedList )
|
||||||
vsEntryDescription.push_back( join(",",songCriteria.m_vsSongGenreAllowedList) );
|
vsEntryDescription.push_back( join(",",songCriteria.m_vsSongGenreAllowedList) );
|
||||||
if( stepsCriteria.m_difficulty != Difficulty_Invalid && stepsCriteria.m_difficulty != Difficulty_Medium )
|
if( stepsCriteria.m_difficulty != Difficulty_Invalid && stepsCriteria.m_difficulty != Difficulty_Medium )
|
||||||
|
|||||||
@@ -356,8 +356,6 @@ bool CourseLoaderCRS::ParseCourseMods( const MsdFile::value_t &sParams, AttackAr
|
|||||||
|
|
||||||
bool CourseLoaderCRS::ParseCourseSong( const MsdFile::value_t &sParams, CourseEntry &new_entry, const RString &sPath )
|
bool CourseLoaderCRS::ParseCourseSong( const MsdFile::value_t &sParams, CourseEntry &new_entry, const RString &sPath )
|
||||||
{
|
{
|
||||||
LOG->Trace("CourseLoaderCRS::ParseCourseSong parsing song %s", sPath.c_str());
|
|
||||||
LOG->Trace("CourseLoaderCRS::ParseCourseSong sParams[1] = %s", sParams[1].c_str());
|
|
||||||
// infer entry::Type from the first param
|
// infer entry::Type from the first param
|
||||||
// todo: make sure these aren't generating bogus entries due
|
// todo: make sure these aren't generating bogus entries due
|
||||||
// to a lack of songs. -aj
|
// to a lack of songs. -aj
|
||||||
@@ -443,7 +441,7 @@ bool CourseLoaderCRS::ParseCourseSong( const MsdFile::value_t &sParams, CourseEn
|
|||||||
split( sSong, "/", bits );
|
split( sSong, "/", bits );
|
||||||
if( bits.size() == 2 )
|
if( bits.size() == 2 )
|
||||||
{
|
{
|
||||||
new_entry.songCriteria.m_sGroupName = bits[0];
|
new_entry.songCriteria.m_vsGroupNames.push_back(bits[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -451,7 +449,7 @@ bool CourseLoaderCRS::ParseCourseSong( const MsdFile::value_t &sParams, CourseEn
|
|||||||
"Song should be in the format \"<group>/*\".", sSong.c_str() );
|
"Song should be in the format \"<group>/*\".", sSong.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !SONGMAN->DoesSongGroupExist(new_entry.songCriteria.m_sGroupName) )
|
if( !SONGMAN->DoesSongGroupExist(bits[0]) )
|
||||||
{
|
{
|
||||||
LOG->UserLog( "Course file", sPath, "random_within_group entry \"%s\" specifies a group that doesn't exist. "
|
LOG->UserLog( "Course file", sPath, "random_within_group entry \"%s\" specifies a group that doesn't exist. "
|
||||||
"This entry will be ignored.", sSong.c_str() );
|
"This entry will be ignored.", sSong.c_str() );
|
||||||
@@ -468,8 +466,8 @@ bool CourseLoaderCRS::ParseCourseSong( const MsdFile::value_t &sParams, CourseEn
|
|||||||
Song *pSong = nullptr;
|
Song *pSong = nullptr;
|
||||||
if( bits.size() == 2 )
|
if( bits.size() == 2 )
|
||||||
{
|
{
|
||||||
new_entry.songCriteria.m_sGroupName = bits[0];
|
new_entry.songCriteria.m_vsGroupNames.push_back(bits[0]);
|
||||||
pSong = SONGMAN->FindSong( bits[0], bits[1] );
|
pSong = SONGMAN->FindSong(bits[0], bits[1]);
|
||||||
}
|
}
|
||||||
else if( bits.size() == 1 )
|
else if( bits.size() == 1 )
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -255,7 +255,7 @@ void CourseUtil::AutogenEndlessFromGroup( const RString &sGroupName, Difficulty
|
|||||||
// gameplay. (We might still get a repeat at the repeat boundary,
|
// gameplay. (We might still get a repeat at the repeat boundary,
|
||||||
// but that'd be rare.) -glenn
|
// but that'd be rare.) -glenn
|
||||||
CourseEntry e;
|
CourseEntry e;
|
||||||
e.songCriteria.m_sGroupName = sGroupName;
|
e.songCriteria.m_vsGroupNames.push_back(sGroupName);
|
||||||
e.stepsCriteria.m_difficulty = diff;
|
e.stepsCriteria.m_difficulty = diff;
|
||||||
e.bSecret = true;
|
e.bSecret = true;
|
||||||
|
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
|
|||||||
const RString &sSong = Basename( pSong->GetSongDir() );
|
const RString &sSong = Basename( pSong->GetSongDir() );
|
||||||
|
|
||||||
f.Write( "#SONG:" );
|
f.Write( "#SONG:" );
|
||||||
if( !entry.songCriteria.m_sGroupName.empty() )
|
if( entry.songCriteria.m_vsGroupNames.size() > 0 )
|
||||||
f.Write( entry.songCriteria.m_sGroupName + '/' );
|
f.Write( entry.songCriteria.m_vsGroupNames[0] + '/' );
|
||||||
f.Write( sSong );
|
f.Write( sSong );
|
||||||
}
|
}
|
||||||
else if( !entry.songCriteria.m_sGroupName.empty() )
|
else if( entry.songCriteria.m_vsGroupNames.size() > 0 )
|
||||||
{
|
{
|
||||||
f.Write( ssprintf( "#SONG:%s/*", entry.songCriteria.m_sGroupName.c_str() ) );
|
f.Write( ssprintf( "#SONG:%s/*", entry.songCriteria.m_vsGroupNames[0].c_str() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-1
@@ -32,8 +32,10 @@ ThemeMetric<bool> SHOW_SECTIONS_IN_LENGTH_SORT ( "MusicWheel", "ShowSectionsInLe
|
|||||||
|
|
||||||
bool SongCriteria::Matches( const Song *pSong ) const
|
bool SongCriteria::Matches( const Song *pSong ) const
|
||||||
{
|
{
|
||||||
if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName )
|
if( !m_vsGroupNames.size() > 0 && std::find(m_vsGroupNames.begin(), m_vsGroupNames.end(), pSong->m_sGroupName) == m_vsGroupNames.end() )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( UNLOCKMAN->SongIsLocked(pSong) & LOCKED_DISABLED )
|
if( UNLOCKMAN->SongIsLocked(pSong) & LOCKED_DISABLED )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-3
@@ -25,7 +25,7 @@ public:
|
|||||||
* @brief What group name are we searching for for Songs?
|
* @brief What group name are we searching for for Songs?
|
||||||
*
|
*
|
||||||
* If an empty string, don't bother using this for searching. */
|
* If an empty string, don't bother using this for searching. */
|
||||||
RString m_sGroupName;
|
std::vector<RString> m_vsGroupNames;
|
||||||
bool m_bUseSongGenreAllowedList;
|
bool m_bUseSongGenreAllowedList;
|
||||||
std::vector<RString> m_vsSongGenreAllowedList;
|
std::vector<RString> m_vsSongGenreAllowedList;
|
||||||
enum Selectable { Selectable_Yes, Selectable_No, Selectable_DontCare } m_Selectable;
|
enum Selectable { Selectable_Yes, Selectable_No, Selectable_DontCare } m_Selectable;
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
} m_Locked;
|
} m_Locked;
|
||||||
|
|
||||||
/** @brief Set up some initial song criteria. */
|
/** @brief Set up some initial song criteria. */
|
||||||
SongCriteria(): m_sGroupName(""), m_bUseSongGenreAllowedList(false),
|
SongCriteria(): m_vsGroupNames(), m_bUseSongGenreAllowedList(false),
|
||||||
m_vsSongGenreAllowedList(), m_Selectable(Selectable_DontCare),
|
m_vsSongGenreAllowedList(), m_Selectable(Selectable_DontCare),
|
||||||
m_bUseSongAllowedList(false), m_vpSongAllowedList(),
|
m_bUseSongAllowedList(false), m_vpSongAllowedList(),
|
||||||
m_iMaxStagesForSong(-1), m_fMinBPM(-1), m_fMaxBPM(-1), m_Tutorial(Tutorial_DontCare),
|
m_iMaxStagesForSong(-1), m_fMinBPM(-1), m_fMaxBPM(-1), m_Tutorial(Tutorial_DontCare),
|
||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
/** @brief A quick way to match every part of the song criterium. */
|
/** @brief A quick way to match every part of the song criterium. */
|
||||||
#define X(x) (x == other.x)
|
#define X(x) (x == other.x)
|
||||||
return
|
return
|
||||||
X(m_sGroupName) &&
|
X(m_vsGroupNames) &&
|
||||||
X(m_bUseSongGenreAllowedList) &&
|
X(m_bUseSongGenreAllowedList) &&
|
||||||
X(m_vsSongGenreAllowedList) &&
|
X(m_vsSongGenreAllowedList) &&
|
||||||
X(m_Selectable) &&
|
X(m_Selectable) &&
|
||||||
|
|||||||
+23
-4
@@ -44,8 +44,18 @@ bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const
|
|||||||
|
|
||||||
void StepsUtil::GetAllMatching( const SongCriteria &soc, const StepsCriteria &stc, std::vector<SongAndSteps> &out )
|
void StepsUtil::GetAllMatching( const SongCriteria &soc, const StepsCriteria &stc, std::vector<SongAndSteps> &out )
|
||||||
{
|
{
|
||||||
const RString &sGroupName = soc.m_sGroupName.empty()? GROUP_ALL:soc.m_sGroupName;
|
|
||||||
const std::vector<Song*> &songs = SONGMAN->GetSongs( sGroupName );
|
std::vector<RString> groupNames = soc.m_vsGroupNames;
|
||||||
|
if( groupNames.size() == 0 )
|
||||||
|
{
|
||||||
|
groupNames.push_back(GROUP_ALL);
|
||||||
|
}
|
||||||
|
std::vector<Song *> songs;
|
||||||
|
for (unsigned i = 0; i < groupNames.size(); i++)
|
||||||
|
{
|
||||||
|
const std::vector<Song *> &groupSongs = SONGMAN->GetSongs(groupNames[i]);
|
||||||
|
songs.insert(songs.end(), groupSongs.begin(), groupSongs.end());
|
||||||
|
}
|
||||||
|
|
||||||
for (Song *so : songs)
|
for (Song *so : songs)
|
||||||
{
|
{
|
||||||
@@ -103,8 +113,17 @@ void StepsUtil::GetAllMatchingEndless( Song *pSong, const StepsCriteria &stc, st
|
|||||||
|
|
||||||
bool StepsUtil::HasMatching( const SongCriteria &soc, const StepsCriteria &stc )
|
bool StepsUtil::HasMatching( const SongCriteria &soc, const StepsCriteria &stc )
|
||||||
{
|
{
|
||||||
const RString &sGroupName = soc.m_sGroupName.empty()? GROUP_ALL:soc.m_sGroupName;
|
std::vector<RString> groupNames = soc.m_vsGroupNames;
|
||||||
const std::vector<Song*> &songs = SONGMAN->GetSongs( sGroupName );
|
if( groupNames.size() == 0 )
|
||||||
|
{
|
||||||
|
groupNames.push_back(GROUP_ALL);
|
||||||
|
}
|
||||||
|
std::vector<Song *> songs;
|
||||||
|
for (unsigned i = 0; i < groupNames.size(); i++)
|
||||||
|
{
|
||||||
|
const std::vector<Song *> &groupSongs = SONGMAN->GetSongs(groupNames[i]);
|
||||||
|
songs.insert(songs.end(), groupSongs.begin(), groupSongs.end());
|
||||||
|
}
|
||||||
|
|
||||||
return std::any_of(songs.begin(), songs.end(), [&](Song const *so) {
|
return std::any_of(songs.begin(), songs.end(), [&](Song const *so) {
|
||||||
return soc.Matches(so) && HasMatching(so, stc);
|
return soc.Matches(so) && HasMatching(so, stc);
|
||||||
|
|||||||
Reference in New Issue
Block a user