make EDIT_MODE less fragile by using switches

don't allow going past last beat in practice
This commit is contained in:
Chris Danford
2005-04-19 01:44:22 +00:00
parent ba1300dea5
commit 6053783a4c
4 changed files with 167 additions and 43 deletions
+54 -9
View File
@@ -58,14 +58,21 @@ static void GetSongsToShowForGroup( const CString &sGroup, vector<Song*> &vpSong
{
vpSongsOut.clear();
SONGMAN->GetSongs( vpSongsOut, sGroup );
if( EDIT_MODE < EDIT_MODE_FULL )
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
for( int i=vpSongsOut.size()-1; i>=0; i-- )
{
const Song* pSong = vpSongsOut[i];
if( UNLOCKMAN->SongIsLocked(pSong) )
vpSongsOut.erase( vpSongsOut.begin()+i );
}
break;
case EDIT_MODE_FULL:
break;
default:
ASSERT(0);
}
SongUtil::SortSongPointerArrayByTitle( vpSongsOut );
}
@@ -340,18 +347,38 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
FOREACH_CONST( Steps*, v, p )
m_vpSteps.push_back( StepsAndDifficulty(*p,dc) );
if( EDIT_MODE != EDIT_MODE_PRACTICE )
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
break;
case EDIT_MODE_HOME:
case EDIT_MODE_FULL:
m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit"
default:
ASSERT(0);
}
}
else
{
// don't allow selecting of non-edits in HomeMode
if( EDIT_MODE == EDIT_MODE_HOME )
continue;
Steps *pSteps = GetSelectedSong()->GetStepsByDifficulty( GetSelectedStepsType(), dc );
if( pSteps || EDIT_MODE != EDIT_MODE_PRACTICE )
switch( EDIT_MODE )
{
case EDIT_MODE_HOME:
// don't allow selecting of non-edits in HomeMode
break;
case EDIT_MODE_PRACTICE:
// only show this difficulty if steps exist
if( pSteps )
m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) );
break;
case EDIT_MODE_FULL:
// show this difficulty whether or not steps exist.
m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) );
break;
default:
ASSERT(0);
}
}
}
@@ -375,8 +402,17 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
s = DifficultyToThemedString(GetSelectedDifficulty());
// UGLY. "Edit" -> "New Edit"
if( EDIT_MODE == EDIT_MODE_HOME )
switch( EDIT_MODE )
{
case EDIT_MODE_HOME:
s = "New " + s;
break;
case EDIT_MODE_PRACTICE:
case EDIT_MODE_FULL:
break;
default:
ASSERT(0);
}
}
m_textValue[ROW_STEPS].SetText( s );
}
@@ -441,8 +477,17 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
if( GetSelectedSteps() )
{
m_Actions.push_back( EDIT_MENU_ACTION_EDIT );
if( EDIT_MODE != EDIT_MODE_PRACTICE )
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
break;
case EDIT_MODE_HOME:
case EDIT_MODE_FULL:
m_Actions.push_back( EDIT_MENU_ACTION_DELETE );
break;
default:
ASSERT(0);
}
}
else
{
+22 -13
View File
@@ -488,25 +488,34 @@ void NoteField::DrawPrimitives()
//
// BGChange text
//
if( EDIT_MODE == EDIT_MODE_FULL )
switch( EDIT_MODE )
{
vector<BackgroundChange> &aBackgroundChanges = GAMESTATE->m_pCurSong->m_BackgroundChanges;
for( unsigned i=0; i<aBackgroundChanges.size(); i++ )
case EDIT_MODE_HOME:
case EDIT_MODE_PRACTICE:
break;
case EDIT_MODE_FULL:
{
if(aBackgroundChanges[i].m_fStartBeat >= fFirstBeatToDraw &&
aBackgroundChanges[i].m_fStartBeat <= fLastBeatToDraw)
vector<BackgroundChange> &aBackgroundChanges = GAMESTATE->m_pCurSong->m_BackgroundChanges;
for( unsigned i=0; i<aBackgroundChanges.size(); i++ )
{
const BackgroundChange& change = aBackgroundChanges[i];
CString sChangeText = ssprintf("%s\n%.0f%%%s%s%s",
change.m_sBGName.c_str(),
change.m_fRate*100,
change.m_bFadeLast ? " Fade" : "",
change.m_bRewindMovie ? " Rewind" : "",
change.m_bLoop ? " Loop" : "" );
if(aBackgroundChanges[i].m_fStartBeat >= fFirstBeatToDraw &&
aBackgroundChanges[i].m_fStartBeat <= fLastBeatToDraw)
{
const BackgroundChange& change = aBackgroundChanges[i];
CString sChangeText = ssprintf("%s\n%.0f%%%s%s%s",
change.m_sBGName.c_str(),
change.m_fRate*100,
change.m_bFadeLast ? " Fade" : "",
change.m_bRewindMovie ? " Rewind" : "",
change.m_bLoop ? " Loop" : "" );
DrawBGChangeText( change.m_fStartBeat, sChangeText );
DrawBGChangeText( change.m_fStartBeat, sChangeText );
}
}
}
break;
default:
ASSERT(0);
}
//
+84 -20
View File
@@ -753,26 +753,49 @@ void ScreenEdit::UpdateTextInfo()
CString sText;
sText += ssprintf( "Current beat:\n %.3f\n", GAMESTATE->m_fSongBeat );
sText += ssprintf( "Current sec:\n %.3f\n", m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) );
if( EDIT_MODE >= EDIT_MODE_HOME )
sText += ssprintf( "Snap to:\n %s\n", sNoteType.c_str() );
sText += ssprintf( "Selection beat:\n %s\n %s\n", m_NoteFieldEdit.m_iBeginMarker==-1 ? "----" : ssprintf("%.3f",NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker)).c_str(), m_NoteFieldEdit.m_iEndMarker==-1 ? "----" : ssprintf("%.3f",NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker)).c_str() );
if( EDIT_MODE == EDIT_MODE_FULL )
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
break;
case EDIT_MODE_HOME:
case EDIT_MODE_FULL:
sText += ssprintf( "Snap to:\n %s\n", sNoteType.c_str() );
break;
default:
ASSERT(0);
}
sText += ssprintf( "Selection beat:\n %s\n %s\n", m_NoteFieldEdit.m_iBeginMarker==-1 ? "----" : ssprintf("%.3f",NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker)).c_str(), m_NoteFieldEdit.m_iEndMarker==-1 ? "----" : ssprintf("%.3f",NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker)).c_str() );
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
break;
case EDIT_MODE_FULL:
sText += ssprintf( "Difficulty:\n %s\n", DifficultyToString( m_pSteps->GetDifficulty() ).c_str() );
sText += ssprintf( "Description:\n %s\n", GAMESTATE->m_pCurSteps[PLAYER_1] ? GAMESTATE->m_pCurSteps[PLAYER_1]->GetDescription().c_str() : "no description" );
sText += ssprintf( "Main title:\n %s\n", m_pSong->m_sMainTitle.c_str() );
sText += ssprintf( "Sub title:\n %s\n", m_pSong->m_sSubTitle.c_str() );
break;
default:
ASSERT(0);
}
sText += ssprintf( "Tap steps:\n %d\n", iNumTaps );
sText += ssprintf( "Jumps:\n %d\n", iNumJumps );
sText += ssprintf( "Hands:\n %d\n", iNumHands );
sText += ssprintf( "Holds:\n %d\n", iNumHolds );
sText += ssprintf( "Mines:\n %d\n", iNumMines );
if( EDIT_MODE == EDIT_MODE_FULL )
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
break;
case EDIT_MODE_FULL:
sText += ssprintf( "Beat 0 Offset:\n %.3f secs\n", m_pSong->m_Timing.m_fBeat0OffsetInSeconds );
sText += ssprintf( "Preview Start:\n %.2f secs\n", m_pSong->m_fMusicSampleStartSeconds );
sText += ssprintf( "Preview Length:\n %.2f secs\n",m_pSong->m_fMusicSampleLengthSeconds );
break;
default:
ASSERT(0);
}
m_textInfo.SetText( sText );
@@ -1781,11 +1804,48 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
FOREACH_Difficulty( dc )
g_StepsInformation.rows[difficulty].choices.push_back( DifficultyToThemedString(pSteps->GetDifficulty()) );
g_StepsInformation.rows[difficulty].iDefaultChoice = pSteps->GetDifficulty();
g_StepsInformation.rows[difficulty].bEnabled = EDIT_MODE >= EDIT_MODE_FULL;
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
g_StepsInformation.rows[difficulty].bEnabled = false;
break;
case EDIT_MODE_FULL:
g_StepsInformation.rows[difficulty].bEnabled = true;
break;
default:
ASSERT(0);
}
g_StepsInformation.rows[meter].iDefaultChoice = clamp( pSteps->GetMeter()-1, 0, MAX_METER+1 );
g_StepsInformation.rows[meter].bEnabled = EDIT_MODE >= EDIT_MODE_HOME;
g_StepsInformation.rows[predict_meter].choices.resize(1);g_StepsInformation.rows[predict_meter].choices[0] = ssprintf("%.2f",pSteps->PredictMeter());
g_StepsInformation.rows[description].choices.resize(1); g_StepsInformation.rows[description].choices[0] = pSteps->GetDescription(); g_StepsInformation.rows[description].bEnabled = EDIT_MODE == EDIT_MODE_FULL;
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
g_StepsInformation.rows[meter].bEnabled = false;
break;
case EDIT_MODE_HOME:
case EDIT_MODE_FULL:
g_StepsInformation.rows[meter].bEnabled = true;
break;
default:
ASSERT(0);
}
g_StepsInformation.rows[predict_meter].choices.resize(1);
g_StepsInformation.rows[predict_meter].choices[0] = ssprintf("%.2f",pSteps->PredictMeter());
g_StepsInformation.rows[description].choices.resize(1);
g_StepsInformation.rows[description].choices[0] = pSteps->GetDescription();
switch( EDIT_MODE )
{
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
g_StepsInformation.rows[description].bEnabled = false;
break;
case EDIT_MODE_FULL:
g_StepsInformation.rows[description].bEnabled = true;
break;
default:
ASSERT(0);
}
g_StepsInformation.rows[description].choices.resize(1); g_StepsInformation.rows[description].choices[0] = pSteps->GetDescription();
g_StepsInformation.rows[tap_notes].choices.resize(1); g_StepsInformation.rows[tap_notes].choices[0] = ssprintf("%d", m_NoteDataEdit.GetNumTapNotes());
g_StepsInformation.rows[jumps].choices.resize(1); g_StepsInformation.rows[jumps].choices[0] = ssprintf("%d", m_NoteDataEdit.GetNumJumps());
g_StepsInformation.rows[hands].choices.resize(1); g_StepsInformation.rows[hands].choices[0] = ssprintf("%d", m_NoteDataEdit.GetNumHands());
@@ -2670,21 +2730,25 @@ void ScreenEdit::CheckNumberOfNotesAndUndo()
float ScreenEdit::GetMaximumBeatForNewNote() const
{
if( GAMESTATE->m_pCurSteps[0]->IsAnEdit() )
switch( EDIT_MODE )
{
float fEndBeat = GAMESTATE->m_pCurSong->m_fLastBeat;
case EDIT_MODE_PRACTICE:
case EDIT_MODE_HOME:
{
float fEndBeat = GAMESTATE->m_pCurSong->m_fLastBeat;
// Round up to the next measure end. Some songs end on weird beats
// mid-measure, and it's odd to have movement capped to these weird
// beats.
fEndBeat += BEATS_PER_MEASURE;
fEndBeat = ftruncf( fEndBeat, (float)BEATS_PER_MEASURE );
// Round up to the next measure end. Some songs end on weird beats
// mid-measure, and it's odd to have movement capped to these weird
// beats.
fEndBeat += BEATS_PER_MEASURE;
fEndBeat = ftruncf( fEndBeat, (float)BEATS_PER_MEASURE );
return fEndBeat;
}
else
{
return fEndBeat;
}
case EDIT_MODE_FULL:
return FLT_MAX;
default:
ASSERT(0); return 0;
}
}
+7 -1
View File
@@ -62,10 +62,16 @@ void DeleteCurSteps( void* pThrowAway )
Song* pSong = GAMESTATE->m_pCurSong;
Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1];
pSong->RemoveSteps( pStepsToDelete );
if( EDIT_MODE == EDIT_MODE_FULL )
switch( EDIT_MODE )
{
case EDIT_MODE_HOME:
break;
case EDIT_MODE_FULL:
pSong->Save();
SCREENMAN->ZeroNextUpdate();
break;
default:
ASSERT(0);
}
SCREENMAN->SendMessageToTopScreen( SM_RefreshSelector );
}