From 6df73d38391d406f24919570f6c89cfb5b79ffb0 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 21 Mar 2005 05:17:46 +0000 Subject: [PATCH] fix possible crash on row with no choices rename highlight -> cursor to avoid confusion with line highlight graphic --- stepmania/src/OptionRow.h | 2 ++ stepmania/src/ScreenOptions.cpp | 29 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 0e5721c791..aee529c0db 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -111,6 +111,8 @@ public: { if( m_RowDef.bOneChoiceForAllPlayers ) pn = PLAYER_1; + if( m_RowDef.choices.empty() ) + return -1; int iChoice = m_iChoiceInRowWithFocus[pn]; return iChoice; } diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index e6469d1103..737b94168d 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -171,7 +171,7 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v SET_XY_AND_ON_COMMAND( m_sprPage ); m_framePage.AddChild( m_sprPage ); - // init line highlights + // init line line highlights FOREACH_HumanPlayer( p ) { m_sprLineHighlight[p].Load( THEME->GetPathG(m_sName,"line highlight") ); @@ -181,7 +181,7 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v ON_COMMAND( m_sprLineHighlight[p] ); } - // init highlights + // init cursors FOREACH_HumanPlayer( p ) { m_Cursor[p].Load( m_sName, OptionsCursor::cursor ); @@ -371,28 +371,29 @@ void ScreenOptions::RefreshAllIcons() void ScreenOptions::PositionCursors() { - // Set the position of the highlight showing the current option the user is changing. - // Set the position of the underscores showing the current choice for each option line. + // Set the position of the cursor showing the current option the user is changing. + // Set the position of the underlines showing the current choice for each option line. FOREACH_HumanPlayer( pn ) { const int iRow = m_iCurrentRow[pn]; ASSERT_M( iRow < (int)m_Rows.size(), ssprintf("%i < %i", iRow, (int)m_Rows.size() ) ); OptionRow &OptionRow = *m_Rows[iRow]; - - OptionsCursor &highlight = m_Cursor[pn]; + OptionsCursor &cursor = m_Cursor[pn]; const int iChoiceWithFocus = OptionRow.GetChoiceInRowWithFocus(pn); + if( iChoiceWithFocus == -1 ) + continue; // skip int iWidth, iX, iY; GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY ); - highlight.SetBarWidth( iWidth ); - highlight.SetXY( (float)iX, (float)iY ); + cursor.SetBarWidth( iWidth ); + cursor.SetXY( (float)iX, (float)iY ); } } void ScreenOptions::TweenCursor( PlayerNumber pn ) { - // Set the position of the highlight showing the current option the user is changing. + // Set the position of the cursor showing the current option the user is changing. const int iRow = m_iCurrentRow[pn]; ASSERT_M( iRow < (int)m_Rows.size(), ssprintf("%i < %i", iRow, (int)m_Rows.size() ) ); @@ -402,11 +403,11 @@ void ScreenOptions::TweenCursor( PlayerNumber pn ) int iWidth, iX, iY; GetWidthXY( pn, iRow, iChoiceWithFocus, iWidth, iX, iY ); - OptionsCursor &highlight = m_Cursor[pn]; - highlight.StopTweening(); - highlight.BeginTweening( TWEEN_SECONDS ); - highlight.TweenBarWidth( iWidth ); - highlight.SetXY( (float)iX, (float)iY ); + OptionsCursor &cursor = m_Cursor[pn]; + cursor.StopTweening(); + cursor.BeginTweening( TWEEN_SECONDS ); + cursor.TweenBarWidth( iWidth ); + cursor.SetXY( (float)iX, (float)iY ); if( GAMESTATE->IsHumanPlayer(pn) ) {