Allow editing #DISPLAYBPM traits in the editor.

Look in Edit Song Info to find it.
This commit is contained in:
Jason Felds
2011-04-05 22:40:33 -04:00
parent 047cec8182
commit 5d98f47fc3
15 changed files with 87 additions and 32 deletions
+3 -3
View File
@@ -180,8 +180,8 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong )
ASSERT( pSong );
switch( pSong->m_DisplayBPMType )
{
case Song::DISPLAY_ACTUAL:
case Song::DISPLAY_SPECIFIED:
case DISPLAY_BPM_ACTUAL:
case DISPLAY_BPM_SPECIFIED:
{
DisplayBpms bpms;
pSong->GetDisplayBpms( bpms );
@@ -189,7 +189,7 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong )
m_fCycleTime = 1.0f;
}
break;
case Song::DISPLAY_RANDOM:
case DISPLAY_BPM_RANDOM:
CycleRandomly();
break;
default:
+3 -3
View File
@@ -500,18 +500,18 @@ bool DWILoader::LoadFromDir( const RString &sPath_, Song &out, set<RString> &Bla
* worth bothering with since we don't display fractional BPM anyway.) */
if( sscanf( sParams[1], "%i..%i", &iMin, &iMax ) == 2 )
{
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
out.m_fSpecifiedBPMMin = (float) iMin;
out.m_fSpecifiedBPMMax = (float) iMax;
}
else if( sscanf( sParams[1], "%i", &iMin ) == 1 )
{
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
out.m_fSpecifiedBPMMin = out.m_fSpecifiedBPMMax = (float) iMin;
}
else
{
out.m_DisplayBPMType = Song::DISPLAY_RANDOM;
out.m_DisplayBPMType = DISPLAY_BPM_RANDOM;
}
}
+2 -2
View File
@@ -581,10 +581,10 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
{
// #DISPLAYBPM:[xxx][xxx:xxx]|[*];
if( sParams[1] == "*" )
out.m_DisplayBPMType = Song::DISPLAY_RANDOM;
out.m_DisplayBPMType = DISPLAY_BPM_RANDOM;
else
{
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
out.m_fSpecifiedBPMMin = StringToFloat( sParams[1] );
if( sParams[2].empty() )
out.m_fSpecifiedBPMMax = out.m_fSpecifiedBPMMin;
+2 -2
View File
@@ -230,10 +230,10 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out )
{
// #DISPLAYBPM:[xxx][xxx:xxx]|[*];
if( sParams[1] == "*" )
out.m_DisplayBPMType = Song::DISPLAY_RANDOM;
out.m_DisplayBPMType = DISPLAY_BPM_RANDOM;
else
{
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
out.m_fSpecifiedBPMMin = StringToFloat( sParams[1] );
if( sParams[2].empty() )
out.m_fSpecifiedBPMMax = out.m_fSpecifiedBPMMin;
+2 -2
View File
@@ -256,10 +256,10 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
{
// #DISPLAYBPM:[xxx][xxx:xxx]|[*];
if( sParams[1] == "*" )
out.m_DisplayBPMType = Song::DISPLAY_RANDOM;
out.m_DisplayBPMType = DISPLAY_BPM_RANDOM;
else
{
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
out.m_fSpecifiedBPMMin = StringToFloat( sParams[1] );
if( sParams[2].empty() )
out.m_fSpecifiedBPMMax = out.m_fSpecifiedBPMMin;
+3 -3
View File
@@ -360,16 +360,16 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
f.PutLine( ssprintf("#CDTITLE:%s;", DwiEscape(out.m_sCDTitleFile).c_str()) );
switch( out.m_DisplayBPMType )
{
case Song::DISPLAY_ACTUAL:
case DISPLAY_BPM_ACTUAL:
// write nothing
break;
case Song::DISPLAY_SPECIFIED:
case DISPLAY_BPM_SPECIFIED:
if( out.m_fSpecifiedBPMMin == out.m_fSpecifiedBPMMax )
f.PutLine( ssprintf("#DISPLAYBPM:%i;\n", (int) out.m_fSpecifiedBPMMin) );
else
f.PutLine( ssprintf("#DISPLAYBPM:%i..%i;\n", (int) out.m_fSpecifiedBPMMin, (int) out.m_fSpecifiedBPMMax) );
break;
case Song::DISPLAY_RANDOM:
case DISPLAY_BPM_RANDOM:
f.PutLine( "#DISPLAYBPM:*" );
break;
}
+3 -3
View File
@@ -94,17 +94,17 @@ static void WriteGlobalTags( RageFile &f, const Song &out )
switch( out.m_DisplayBPMType )
{
case Song::DISPLAY_ACTUAL:
case DISPLAY_BPM_ACTUAL:
// write nothing
break;
case Song::DISPLAY_SPECIFIED:
case DISPLAY_BPM_SPECIFIED:
if( out.m_fSpecifiedBPMMin == out.m_fSpecifiedBPMMax )
f.PutLine( ssprintf( "#DISPLAYBPM:%.3f;", out.m_fSpecifiedBPMMin ) );
else
f.PutLine( ssprintf( "#DISPLAYBPM:%.3f:%.3f;",
out.m_fSpecifiedBPMMin, out.m_fSpecifiedBPMMax ) );
break;
case Song::DISPLAY_RANDOM:
case DISPLAY_BPM_RANDOM:
f.PutLine( ssprintf( "#DISPLAYBPM:*;" ) );
break;
}
+3 -3
View File
@@ -91,16 +91,16 @@ static void WriteGlobalTags( RageFile &f, const Song &out )
switch( out.m_DisplayBPMType )
{
case Song::DISPLAY_ACTUAL:
case DISPLAY_BPM_ACTUAL:
// write nothing
break;
case Song::DISPLAY_SPECIFIED:
case DISPLAY_BPM_SPECIFIED:
if( out.m_fSpecifiedBPMMin == out.m_fSpecifiedBPMMax )
f.PutLine( ssprintf( "#DISPLAYBPM:%.6f;", out.m_fSpecifiedBPMMin ) );
else
f.PutLine( ssprintf( "#DISPLAYBPM:%.6f:%.6f;", out.m_fSpecifiedBPMMin, out.m_fSpecifiedBPMMax ) );
break;
case Song::DISPLAY_RANDOM:
case DISPLAY_BPM_RANDOM:
f.PutLine( ssprintf( "#DISPLAYBPM:*;" ) );
break;
}
+34 -3
View File
@@ -539,7 +539,10 @@ static MenuDef g_SongInformation(
MenuRowDef( ScreenEdit::main_title_transliteration, "Main title transliteration", true, EditMode_Practice, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::sub_title_transliteration, "Sub title transliteration", true, EditMode_Practice, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::artist_transliteration, "Artist transliteration", true, EditMode_Practice, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::last_beat_hint, "Last beat hint", true, EditMode_Full, true, true, 0, NULL )
MenuRowDef( ScreenEdit::last_beat_hint, "Last beat hint", true, EditMode_Full, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::display_bpm, "Display BPM", true, EditMode_Full, true, true, 0, "Actual", "Specified", "Random" ),
MenuRowDef( ScreenEdit::min_bpm, "Min BPM", true, EditMode_Full, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::min_bpm, "Max BPM", true, EditMode_Full, true, true, 0, NULL )
);
static MenuDef g_TimingDataInformation(
@@ -2980,6 +2983,16 @@ static void ChangeLastBeatHint( const RString &sNew )
GAMESTATE->m_pCurSong->m_fSpecifiedLastBeat = StringToFloat( sNew );
}
static void ChangeMinBPM( const RString &sNew )
{
GAMESTATE->m_pCurSong->m_fSpecifiedBPMMin = StringToFloat( sNew );
}
static void ChangeMaxBPM( const RString &sNew )
{
GAMESTATE->m_pCurSong->m_fSpecifiedBPMMax = StringToFloat( sNew );
}
// End helper functions
static LocalizedString REVERT_LAST_SAVE ( "ScreenEdit", "Do you want to revert to your last save?" );
@@ -3171,6 +3184,9 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
g_SongInformation.rows[sub_title_transliteration].SetOneUnthemedChoice( pSong->m_sSubTitleTranslit );
g_SongInformation.rows[artist_transliteration].SetOneUnthemedChoice( pSong->m_sArtistTranslit );
g_SongInformation.rows[last_beat_hint].SetOneUnthemedChoice( ssprintf("%.5f", pSong->m_fSpecifiedLastBeat) );
g_SongInformation.rows[display_bpm].iDefaultChoice = pSong->m_DisplayBPMType;
g_SongInformation.rows[min_bpm].SetOneUnthemedChoice( ssprintf("%.5f", pSong->m_fSpecifiedBPMMin) );
g_SongInformation.rows[max_bpm].SetOneUnthemedChoice( ssprintf("%.5f", pSong->m_fSpecifiedBPMMax) );
EditMiniMenu( &g_SongInformation, SM_BackFromSongInformation );
}
@@ -3575,13 +3591,15 @@ static LocalizedString ENTER_MAIN_TITLE_TRANSLIT ("ScreenEdit","Enter a new main
static LocalizedString ENTER_SUB_TITLE_TRANSLIT ("ScreenEdit","Enter a new sub title transliteration.");
static LocalizedString ENTER_ARTIST_TRANSLIT ("ScreenEdit","Enter a new artist transliteration.");
static LocalizedString ENTER_LAST_BEAT_HINT ("ScreenEdit","Enter a new last beat hint.");
static LocalizedString ENTER_MIN_BPM ("ScreenEdit","Enter a new min BPM.");
static LocalizedString ENTER_MAX_BPM ("ScreenEdit","Enter a new max BPM.");
void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vector<int> &iAnswers )
{
Song* pSong = GAMESTATE->m_pCurSong;
pSong->m_DisplayBPMType = static_cast<DisplayBPM>(iAnswers[display_bpm]);
switch( c )
{
DEFAULT_FAIL(c);
case main_title:
ScreenTextEntry::TextEntry( SM_None, ENTER_MAIN_TITLE, pSong->m_sMainTitle, 100, NULL, ChangeMainTitle, NULL );
break;
@@ -3607,7 +3625,20 @@ void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vec
ScreenTextEntry::TextEntry( SM_None, ENTER_ARTIST_TRANSLIT, pSong->m_sArtistTranslit, 100, NULL, ChangeArtistTranslit, NULL );
break;
case last_beat_hint:
ScreenTextEntry::TextEntry( SM_None, ENTER_LAST_BEAT_HINT, ssprintf("%.5f", pSong->m_fSpecifiedLastBeat), 20, ScreenTextEntry::FloatValidate, ChangeLastBeatHint, NULL );
ScreenTextEntry::TextEntry( SM_None, ENTER_LAST_BEAT_HINT,
ssprintf("%.5f", pSong->m_fSpecifiedLastBeat), 20,
ScreenTextEntry::FloatValidate, ChangeLastBeatHint, NULL );
break;
case min_bpm:
ScreenTextEntry::TextEntry( SM_None, ENTER_MIN_BPM,
ssprintf("%.5f", pSong->m_fSpecifiedBPMMin), 20,
ScreenTextEntry::FloatValidate, ChangeMinBPM, NULL );
break;
case max_bpm:
ScreenTextEntry::TextEntry( SM_None, ENTER_MAX_BPM,
ssprintf("%.5f", pSong->m_fSpecifiedBPMMax), 20,
ScreenTextEntry::FloatValidate, ChangeMaxBPM, NULL );
break;
};
}
+3
View File
@@ -442,6 +442,9 @@ public:
sub_title_transliteration,
artist_transliteration,
last_beat_hint,
display_bpm,
min_bpm,
max_bpm,
NUM_SONG_INFORMATION_CHOICES
};
void HandleSongInformationChoice( SongInformationChoice c, const vector<int> &iAnswers );
+4 -4
View File
@@ -74,7 +74,7 @@ Song::Song()
m_fSpecifiedLastBeat = -1;
m_SelectionDisplay = SHOW_ALWAYS;
m_bEnabled = true;
m_DisplayBPMType = DISPLAY_ACTUAL;
m_DisplayBPMType = DISPLAY_BPM_ACTUAL;
m_fSpecifiedBPMMin = 0;
m_fSpecifiedBPMMax = 0;
m_bIsSymLink = false;
@@ -147,7 +147,7 @@ void Song::AddLyricSegment( LyricSegment seg )
void Song::GetDisplayBpms( DisplayBpms &AddTo ) const
{
if( m_DisplayBPMType == DISPLAY_SPECIFIED )
if( m_DisplayBPMType == DISPLAY_BPM_SPECIFIED )
{
AddTo.Add( m_fSpecifiedBPMMin );
AddTo.Add( m_fSpecifiedBPMMax );
@@ -1458,7 +1458,7 @@ bool Song::HasSignificantBpmChangesOrStops() const
// Don't consider BPM changes that only are only for maintaining sync as
// a real BpmChange.
if( m_DisplayBPMType == DISPLAY_SPECIFIED )
if( m_DisplayBPMType == DISPLAY_BPM_SPECIFIED )
{
if( m_fSpecifiedBPMMin != m_fSpecifiedBPMMax )
return true;
@@ -1612,7 +1612,7 @@ public:
}
static int IsDisplayBpmRandom( T* p, lua_State *L )
{
lua_pushboolean( L, p->m_DisplayBPMType == Song::DISPLAY_RANDOM );
lua_pushboolean( L, p->m_DisplayBPMType == DISPLAY_BPM_RANDOM );
return 1;
}
+10 -1
View File
@@ -35,6 +35,15 @@ enum BackgroundLayer
NUM_BackgroundLayer,
BACKGROUND_LAYER_Invalid
};
/** @brief The different ways of displaying the BPM. */
enum DisplayBPM
{
DISPLAY_BPM_ACTUAL, /**< Display the song's actual BPM. */
DISPLAY_BPM_SPECIFIED, /**< Display a specified value or values. */
DISPLAY_BPM_RANDOM /**< Display a random selection of BPMs. */
};
/** @brief A custom foreach loop for the different background layers. */
#define FOREACH_BackgroundLayer( bl ) FOREACH_ENUM( BackgroundLayer, bl )
@@ -222,7 +231,7 @@ public:
float m_fSpecifiedLastBeat; // specified last beat of the song
float m_fMusicSampleStartSeconds;
float m_fMusicSampleLengthSeconds;
enum { DISPLAY_ACTUAL, DISPLAY_SPECIFIED, DISPLAY_RANDOM } m_DisplayBPMType;
DisplayBPM m_DisplayBPMType;
float m_fSpecifiedBPMMin;
float m_fSpecifiedBPMMax; // if a range, then Min != Max
+3 -3
View File
@@ -189,11 +189,11 @@ void Trail::GetDisplayBpms( DisplayBpms &AddTo ) const
ASSERT( pSong );
switch( pSong->m_DisplayBPMType )
{
case Song::DISPLAY_ACTUAL:
case Song::DISPLAY_SPECIFIED:
case DISPLAY_BPM_ACTUAL:
case DISPLAY_BPM_SPECIFIED:
pSong->GetDisplayBpms( AddTo );
break;
case Song::DISPLAY_RANDOM:
case DISPLAY_BPM_RANDOM:
AddTo.Add( -1 );
break;
DEFAULT_FAIL( pSong->m_DisplayBPMType );