From fb8ccf786d4a8bf2ee8cb6e28652aa8b5888ab43 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 31 Mar 2003 23:03:43 +0000 Subject: [PATCH] use alternate choice selection on ScreenOptions automatically if text runs off right edge of screen --- stepmania/src/ScreenOptions.cpp | 54 ++++++++++++++++++--------------- stepmania/src/ScreenOptions.h | 1 + 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index b365c4e843..cc30b1bca1 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -21,7 +21,6 @@ #include "GameState.h" #include "ThemeManager.h" -const int MAX_ITEMS_PER_ROW = 8; const float ITEM_X[NUM_PLAYERS] = { 260, 420 }; #define ICONS_X( p ) THEME->GetMetricF("ScreenOptions",ssprintf("IconsP%dX",p+1)) @@ -76,6 +75,7 @@ ScreenOptions::ScreenOptions( CString sClassName, bool bEnableTimer ) m_framePage.BeginTweening( 0.3f, Actor::TWEEN_DECELERATE ); m_framePage.SetTweenX( 0 ); memset(&m_OptionDim, 0, sizeof(m_OptionDim)); + memset(&m_bRowIsLong, 0, sizeof(m_bRowIsLong)); } void ScreenOptions::Init( InputMode im, OptionRow OptionRow[], int iNumOptionLines, bool bUseIcons, bool bLoadExplanations ) @@ -126,7 +126,7 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRow[], int iNumOptionLin m_framePage.AddChild( &m_textTitles[i] ); for( unsigned j=0; j=MAX_ITEMS_PER_ROW; + bool bLotsOfOptions = m_bRowIsLong[iRow]; int iOptionInRow = bExitRow ? 0 : bLotsOfOptions ? pn : m_iSelectedOption[pn][iRow]; BitmapText &text = m_textItems[iRow][iOptionInRow]; @@ -199,8 +199,31 @@ void ScreenOptions::InitOptionsText() // init all text in this line and count the width of the line - if( optline.choices.size() >= MAX_ITEMS_PER_ROW ) + float fX = ITEMS_START_X; // indent 70 pixels + for( unsigned j=0; jGetPathTo("Fonts","ScreenOptions item") ); + option.SetText( optline.choices[j] ); + option.SetZoom( ITEMS_ZOOM ); + option.EnableShadow( false ); + + // set the XY position of each item in the line + float fItemWidth = option.GetWidestLineWidthInSourcePixels() * option.GetZoomX(); + fX += fItemWidth/2; + option.SetXY( fX, fY ); + fX += fItemWidth/2 + ITEMS_GAP_X; + } + + m_bRowIsLong[i] = fX > SCREEN_RIGHT-40; // goes off edge of screen + + if( m_bRowIsLong[i] ) + { + // re-init with "long row" style + for( unsigned j=0; jIsPlayerEnabled(p) ) @@ -220,25 +243,6 @@ void ScreenOptions::InitOptionsText() } } } - else - { - float fX = ITEMS_START_X; // indent 70 pixels - for( unsigned j=0; jGetPathTo("Fonts","ScreenOptions item") ); - option.SetText( optline.choices[j] ); - option.SetZoom( ITEMS_ZOOM ); - option.EnableShadow( false ); - - // set the XY position of each item in the line - float fItemWidth = option.GetWidestLineWidthInSourcePixels() * option.GetZoomX(); - fX += fItemWidth/2; - option.SetXY( fX, fY ); - fX += fItemWidth/2 + ITEMS_GAP_X; - } - } } BitmapText &option = m_textItems[i][0]; @@ -365,7 +369,7 @@ void ScreenOptions::UpdateText( PlayerNumber player_no ) int iCurRow = m_iCurrentRow[player_no]; int iChoiceInRow = m_iSelectedOption[player_no][iCurRow]; - bool bLotsOfOptions = m_OptionRow[iCurRow].choices.size()>=MAX_ITEMS_PER_ROW; + bool bLotsOfOptions = m_bRowIsLong[iCurRow]; if( bLotsOfOptions ) m_textItems[iCurRow][player_no].SetText( m_OptionRow[iCurRow].choices[iChoiceInRow] ); @@ -389,7 +393,7 @@ void ScreenOptions::UpdateEnabledDisabled() m_textTitles[i].SetDiffuse( bThisRowIsSelected ? colorSelected : colorNotSelected ); - if( m_OptionRow[i].choices.size() >= MAX_ITEMS_PER_ROW ) + if( m_bRowIsLong[i] ) for( unsigned j=0; j