Add utility methods for step's #CREDIT tag.
This commit is contained in:
+41
-4
@@ -97,7 +97,8 @@ void SongUtil::GetSteps(
|
||||
Difficulty dc,
|
||||
int iMeterLow,
|
||||
int iMeterHigh,
|
||||
const RString &sDescription,
|
||||
const RString &sDescription,
|
||||
const RString &sCredit,
|
||||
bool bIncludeAutoGen,
|
||||
unsigned uHash,
|
||||
int iMaxToGet
|
||||
@@ -119,6 +120,8 @@ void SongUtil::GetSteps(
|
||||
continue;
|
||||
if( sDescription.size() && sDescription != pSteps->GetDescription() )
|
||||
continue;
|
||||
if( sCredit.size() && sCredit != pSteps->GetCredit() )
|
||||
continue;
|
||||
if( uHash != 0 && uHash != pSteps->GetHash() )
|
||||
continue;
|
||||
if( !bIncludeAutoGen && pSteps->IsAutogen() )
|
||||
@@ -141,13 +144,14 @@ Steps* SongUtil::GetOneSteps(
|
||||
Difficulty dc,
|
||||
int iMeterLow,
|
||||
int iMeterHigh,
|
||||
const RString &sDescription,
|
||||
const RString &sDescription,
|
||||
const RString &sCredit,
|
||||
unsigned uHash,
|
||||
bool bIncludeAutoGen
|
||||
)
|
||||
{
|
||||
vector<Steps*> vpSteps;
|
||||
GetSteps( pSong, vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, bIncludeAutoGen, uHash, 1 ); // get max 1
|
||||
GetSteps( pSong, vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, sCredit, bIncludeAutoGen, uHash, 1 ); // get max 1
|
||||
if( vpSteps.empty() )
|
||||
return NULL;
|
||||
else
|
||||
@@ -193,13 +197,23 @@ Steps* SongUtil::GetStepsByMeter( const Song *pSong, StepsType st, int iMeterLow
|
||||
Steps* SongUtil::GetStepsByDescription( const Song *pSong, StepsType st, RString sDescription )
|
||||
{
|
||||
vector<Steps*> vNotes;
|
||||
GetSteps( pSong, vNotes, st, Difficulty_Invalid, -1, -1, sDescription );
|
||||
GetSteps( pSong, vNotes, st, Difficulty_Invalid, -1, -1, sDescription, "" );
|
||||
if( vNotes.size() == 0 )
|
||||
return NULL;
|
||||
else
|
||||
return vNotes[0];
|
||||
}
|
||||
|
||||
Steps* SongUtil::GetStepsByCredit( const Song *pSong, StepsType st, RString sCredit )
|
||||
{
|
||||
vector<Steps*> vNotes;
|
||||
GetSteps(pSong, vNotes, st, Difficulty_Invalid, -1, -1, "", sCredit );
|
||||
if( vNotes.size() == 0 )
|
||||
return NULL;
|
||||
else
|
||||
return vNotes[0];
|
||||
}
|
||||
|
||||
|
||||
Steps* SongUtil::GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc, bool bIgnoreLocked )
|
||||
{
|
||||
@@ -803,6 +817,29 @@ bool SongUtil::ValidateCurrentStepsDescription( const RString &sAnswer, RString
|
||||
return true;
|
||||
}
|
||||
|
||||
static LocalizedString AUTHOR_NAME_CANNOT_CONTAIN( "SongUtil", "The step author's name cannot contain any of the following characters: %s" );
|
||||
|
||||
bool SongUtil::ValidateCurrentStepsCredit( const RString &sAnswer, RString &sErrorOut )
|
||||
{
|
||||
if( sAnswer.empty() )
|
||||
return true;
|
||||
|
||||
Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||
// If unchanged:
|
||||
if( pSteps->GetCredit() == sAnswer )
|
||||
return true;
|
||||
|
||||
// Borrow from EditDescription testing. Perhaps this should be abstracted? -Wolfman2000
|
||||
static const RString sInvalidChars = "\\/:*?\"<>|";
|
||||
if( strpbrk(sAnswer, sInvalidChars) != NULL )
|
||||
{
|
||||
sErrorOut = ssprintf( AUTHOR_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SongUtil::GetAllSongGenres( vector<RString> &vsOut )
|
||||
{
|
||||
set<RString> genres;
|
||||
|
||||
+7
-3
@@ -70,7 +70,8 @@ namespace SongUtil
|
||||
Difficulty dc = Difficulty_Invalid,
|
||||
int iMeterLow = -1,
|
||||
int iMeterHigh = -1,
|
||||
const RString &sDescription = "",
|
||||
const RString &sDescription = "",
|
||||
const RString &sCredit = "",
|
||||
bool bIncludeAutoGen = true,
|
||||
unsigned uHash = 0,
|
||||
int iMaxToGet = -1
|
||||
@@ -81,15 +82,17 @@ namespace SongUtil
|
||||
Difficulty dc = Difficulty_Invalid,
|
||||
int iMeterLow = -1,
|
||||
int iMeterHigh = -1,
|
||||
const RString &sDescription = "",
|
||||
const RString &sDescription = "",
|
||||
const RString &sCredit = "",
|
||||
unsigned uHash = 0,
|
||||
bool bIncludeAutoGen = true
|
||||
);
|
||||
Steps* GetStepsByDifficulty( const Song *pSong, StepsType st, Difficulty dc, bool bIncludeAutoGen = true );
|
||||
Steps* GetStepsByMeter( const Song *pSong, StepsType st, int iMeterLow, int iMeterHigh );
|
||||
Steps* GetStepsByDescription( const Song *pSong, StepsType st, RString sDescription );
|
||||
Steps* GetStepsByCredit( const Song *pSong, StepsType st, RString sCredit );
|
||||
Steps* GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc, bool bIgnoreLocked=false );
|
||||
|
||||
|
||||
void AdjustDuplicateSteps( Song *pSong ); // part of TidyUpData
|
||||
void DeleteDuplicateSteps( Song *pSong, vector<Steps*> &vSteps );
|
||||
|
||||
@@ -115,6 +118,7 @@ namespace SongUtil
|
||||
RString MakeUniqueEditDescription( const Song* pSong, StepsType st, const RString &sPreferredDescription );
|
||||
bool ValidateCurrentEditStepsDescription( const RString &sAnswer, RString &sErrorOut );
|
||||
bool ValidateCurrentStepsDescription( const RString &sAnswer, RString &sErrorOut );
|
||||
bool ValidateCurrentStepsCredit( const RString &sAnswer, RString &sErrorOut );
|
||||
|
||||
void GetAllSongGenres( vector<RString> &vsOut );
|
||||
void FilterSongs( const SongCriteria &sc, const vector<Song*> &in, vector<Song*> &out );
|
||||
|
||||
+2
-2
@@ -258,11 +258,11 @@ Steps *StepsID::ToSteps( const Song *p, bool bAllowNull ) const
|
||||
Steps *pRet = NULL;
|
||||
if( dc == Difficulty_Edit )
|
||||
{
|
||||
pRet = SongUtil::GetOneSteps( p, st, dc, -1, -1, sDescription, uHash, true );
|
||||
pRet = SongUtil::GetOneSteps( p, st, dc, -1, -1, sDescription, "", uHash, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
pRet = SongUtil::GetOneSteps( p, st, dc, -1, -1, "", 0, true );
|
||||
pRet = SongUtil::GetOneSteps( p, st, dc, -1, -1, "", "", 0, true );
|
||||
}
|
||||
|
||||
if( !bAllowNull && pRet == NULL )
|
||||
|
||||
Reference in New Issue
Block a user