fix multiselect + options icon crash

This commit is contained in:
Chris Danford
2004-01-11 02:28:10 +00:00
parent 028e5bd6c8
commit dc863c8f31
3 changed files with 35 additions and 22 deletions
+2 -1
View File
@@ -58,7 +58,8 @@ void OptionIcon::Load( PlayerNumber pn, CString sText, bool bHeader )
sText.Replace( " ", "\n" ); sText.Replace( " ", "\n" );
bool bVacant = (sText==""); bool bVacant = (sText=="");
m_spr.SetState( pn*3 + (bHeader?0:(bVacant?1:2)) ); int iState = pn*3 + (bHeader?0:(bVacant?1:2));
m_spr.SetState( iState );
m_text.SetText( bHeader ? "" : sText ); m_text.SetText( bHeader ? "" : sText );
m_text.SetZoom( TEXT_ZOOM ); m_text.SetZoom( TEXT_ZOOM );
+2
View File
@@ -1113,6 +1113,8 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType type )
m_SoundToggleOn.Play(); m_SoundToggleOn.Play();
else else
m_SoundToggleOff.Play(); m_SoundToggleOff.Play();
PositionUnderlines();
RefreshIcons();
} }
else else
{ {
+22 -12
View File
@@ -598,35 +598,45 @@ void ScreenOptionsMaster::RefreshIcons()
Row &row = *m_Rows[i]; Row &row = *m_Rows[i];
const OptionRowData &data = row.m_RowDef; const OptionRowData &data = row.m_RowDef;
int iSelection = row.GetOneSelection((PlayerNumber)p); // find first selection and whether multiple are selected
if( iSelection >= (int)data.choices.size() ) int iFirstSelection = -1;
bool bMultipleSelected = false;
for( int j=0; j<row.m_vbSelected[p].size(); j++ )
{ {
/* Invalid selection. Send debug output, to aid debugging. */ if( row.m_vbSelected[p][j] )
CString error = ssprintf("Option row with name '%s' selects item %i, but there are only %i items:\n", {
data.name.c_str(), if( iFirstSelection != -1 )
iSelection, (int) data.choices.size() ); bMultipleSelected = true;
else
iFirstSelection = j;
}
for( unsigned j = 0; j < data.choices.size(); ++j )
error += ssprintf(" %s\n", data.choices[j].c_str());
RageException::Throw( "%s", error.c_str() );
} }
// set icon name // set icon name
CString sIcon; CString sIcon;
if( bMultipleSelected )
{
sIcon = "Multiple";
}
else if( iFirstSelection != -1 )
{
const OptionRowHandler &handler = OptionRowHandlers[i]; const OptionRowHandler &handler = OptionRowHandlers[i];
switch( handler.type ) switch( handler.type )
{ {
case ROW_LIST: case ROW_LIST:
sIcon = handler.ListEntries[iSelection].m_sModifiers; sIcon = handler.ListEntries[iFirstSelection].m_sModifiers;
break; break;
case ROW_STEP: case ROW_STEP:
case ROW_CHARACTER: case ROW_CHARACTER:
sIcon = data.choices[iSelection]; sIcon = data.choices[iFirstSelection];
break; break;
case ROW_CONFIG: case ROW_CONFIG:
break; break;
} }
}
/* XXX: hack to not display text in the song options menu */ /* XXX: hack to not display text in the song options menu */
if( data.bOneChoiceForAllPlayers ) if( data.bOneChoiceForAllPlayers )