From 49b5375af86cfafc6a8f114958a2938726fcac66 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 19 Jan 2006 00:29:22 +0000 Subject: [PATCH] Split out ResetFocusFromSelection. Don't reset m_iChoiceInRowWithFocus in ResetFocusFromSelection for SELECT_MULTIPLE or SELECT_NONE. That's done by ChoicesChanged. --- stepmania/src/OptionRow.cpp | 37 +++++++++++++++++++++---------------- stepmania/src/OptionRow.h | 1 + 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index 1d64c86abb..cee6042ad9 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -483,28 +483,14 @@ void OptionRow::AfterImportOptions() { ASSERT( !m_vbSelected[p].empty() ); m_vbSelected[p][0] = true; - iSelection = 0; } - - m_iChoiceInRowWithFocus[p] = iSelection; // focus on the selection we just set } break; - case SELECT_MULTIPLE: - case SELECT_NONE: - m_iChoiceInRowWithFocus[p] = 0; - break; - default: - ASSERT(0); } } - - // - // HACK: Set focus to one item in the row, which is "go down" - // - if( m_bFirstItemGoesDown ) - FOREACH_PlayerNumber( p ) - m_iChoiceInRowWithFocus[p] = 0; + FOREACH_PlayerNumber( p ) + ResetFocusFromSelection( p ); UpdateText(); @@ -858,6 +844,25 @@ void OptionRow::SetChoiceInRowWithFocusShared( int iChoice ) SetChoiceInRowWithFocus( pn, iChoice ); } +void OptionRow::ResetFocusFromSelection( PlayerNumber pn ) +{ + switch( m_pHand->m_Def.m_selectType ) + { + case SELECT_ONE: + /* Import the focus from the selected option. */ + int iSelection = GetOneSelection( pn, true ); + m_iChoiceInRowWithFocus[pn] = iSelection; // focus on the selection we just set + break; + } + + // + // HACK: Set focus to one item in the row, which is "go down" + // + if( m_bFirstItemGoesDown ) + FOREACH_PlayerNumber( p ) + m_iChoiceInRowWithFocus[p] = 0; +} + bool OptionRow::GetSelected( PlayerNumber pn, int iChoice ) const { if( m_pHand->m_Def.m_bOneChoiceForAllPlayers ) diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 04be6124b5..8c6c3c9227 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -162,6 +162,7 @@ public: int GetChoiceInRowWithFocusShared() const; void SetChoiceInRowWithFocus( PlayerNumber pn, int iChoice ); void SetChoiceInRowWithFocusShared( int iChoice ); + void ResetFocusFromSelection( PlayerNumber pn ); bool GetSelected( PlayerNumber pn, int iChoice ) const; void SetSelected( PlayerNumber pn, int iChoice, bool b );