fix "auto selection of last edited steps after saving in editor"
This commit is contained in:
@@ -125,17 +125,19 @@ EditMenu::EditMenu()
|
|||||||
OnRowValueChanged( ROW_SONG );
|
OnRowValueChanged( ROW_SONG );
|
||||||
|
|
||||||
// Select the current StepsType and difficulty if any
|
// Select the current StepsType and difficulty if any
|
||||||
if( GAMESTATE->m_pCurNotes )
|
if( GAMESTATE->m_pCurNotes && GAMESTATE->m_pCurNotes[PLAYER_1] )
|
||||||
{
|
{
|
||||||
for( i=0; i<m_StepsTypes.size(); i++ )
|
for( i=0; i<m_StepsTypes.size(); i++ )
|
||||||
|
{
|
||||||
if( m_StepsTypes[i] == GAMESTATE->m_pCurNotes[PLAYER_1]->m_StepsType )
|
if( m_StepsTypes[i] == GAMESTATE->m_pCurNotes[PLAYER_1]->m_StepsType )
|
||||||
{
|
{
|
||||||
m_iSelection[ROW_NOTES_TYPE] = i;
|
m_iSelection[ROW_NOTES_TYPE] = i;
|
||||||
OnRowValueChanged( ROW_NOTES_TYPE );
|
OnRowValueChanged( ROW_NOTES_TYPE );
|
||||||
}
|
|
||||||
|
|
||||||
m_iSelection[ROW_DIFFICULTY] = GAMESTATE->m_pCurNotes[PLAYER_1]->GetDifficulty();
|
m_iSelection[ROW_DIFFICULTY] = GAMESTATE->m_pCurNotes[PLAYER_1]->GetDifficulty();
|
||||||
OnRowValueChanged( ROW_DIFFICULTY );
|
OnRowValueChanged( ROW_DIFFICULTY );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-10
@@ -472,12 +472,23 @@ bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
|
|||||||
|
|
||||||
void Song::RevertFromDisk()
|
void Song::RevertFromDisk()
|
||||||
{
|
{
|
||||||
unsigned CurNoteIndex[NUM_PLAYERS];
|
// Ugly: When we re-load the song, the Steps* will change.
|
||||||
memset(CurNoteIndex, 0, sizeof(CurNoteIndex));
|
// Fix the GAMESTATE->m_CurNotes after reloading.
|
||||||
for( int pn = 0; pn < NUM_PLAYERS; ++pn )
|
StepsType st[NUM_PLAYERS];
|
||||||
for( unsigned n = 0; n < m_apNotes.size(); ++n )
|
Difficulty dc[NUM_PLAYERS];
|
||||||
if( m_apNotes[n] == GAMESTATE->m_pCurNotes[pn] )
|
for( int p = 0; p < NUM_PLAYERS; ++p )
|
||||||
CurNoteIndex[pn] = n;
|
{
|
||||||
|
if( GAMESTATE->m_pCurNotes[p] == NULL )
|
||||||
|
{
|
||||||
|
st[p] = STEPS_TYPE_INVALID;
|
||||||
|
dc[p] = DIFFICULTY_INVALID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
st[p] = GAMESTATE->m_pCurNotes[p]->m_StepsType;
|
||||||
|
dc[p] = GAMESTATE->m_pCurNotes[p]->GetDifficulty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CString dir = GetSongDir();
|
const CString dir = GetSongDir();
|
||||||
|
|
||||||
@@ -488,13 +499,15 @@ void Song::RevertFromDisk()
|
|||||||
// if they've saved in the editor.
|
// if they've saved in the editor.
|
||||||
LoadFromSongDir( dir, false );
|
LoadFromSongDir( dir, false );
|
||||||
|
|
||||||
|
|
||||||
if( GAMESTATE->m_pCurSong == this )
|
if( GAMESTATE->m_pCurSong == this )
|
||||||
{
|
{
|
||||||
/* m_pCurNotes points at notes that we just reloaded; fix it. */
|
for( int p = 0; p < NUM_PLAYERS; ++p )
|
||||||
for( int pn = 0; pn < NUM_PLAYERS; ++pn )
|
|
||||||
{
|
{
|
||||||
int ind = min(CurNoteIndex[pn], m_apNotes.size()-1);
|
if( st[p] == STEPS_TYPE_INVALID || dc[p] == DIFFICULTY_INVALID )
|
||||||
GAMESTATE->m_pCurNotes[pn] = m_apNotes[ind];
|
continue; // skip
|
||||||
|
GAMESTATE->m_pCurNotes[p] = this->GetStepsByDifficulty( st[p], dc[p], false );
|
||||||
|
ASSERT( GAMESTATE->m_pCurNotes[p] ); // we had something selected before reloading, so it better still be there after!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user