Fix options crashing when playing on 2P side.

This commit is contained in:
Glenn Maynard
2003-09-06 07:42:28 +00:00
parent 4ab3924122
commit cd2e095169
2 changed files with 26 additions and 9 deletions
+25 -9
View File
@@ -258,17 +258,33 @@ ScreenOptions::~ScreenOptions()
}
BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow )
{
const bool bExitRow = iRow == m_iNumOptionRows;
if( bExitRow )
return *m_textItems[iRow][0];
const bool bLotsOfOptions = m_bRowIsLong[iRow];
if( !bLotsOfOptions )
{
unsigned iOptionInRow = m_iSelectedOption[pn][iRow];
return *m_textItems[iRow][iOptionInRow];
}
const bool bOneChoice = m_OptionRow[iRow].bOneChoiceForAllPlayers;
if( bOneChoice )
return *m_textItems[iRow][0];
/* We have lots of options and this isn't a OneChoice row, which means
* each player has a separate item displayed. */
int iOptionInRow = min( (unsigned)pn, m_textItems[iRow].size()-1 );
return *m_textItems[iRow][iOptionInRow];
}
void ScreenOptions::GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut )
{
bool bExitRow = iRow == m_iNumOptionRows;
bool bLotsOfOptions = m_bRowIsLong[iRow];
bool bOneChoice = m_OptionRow[iRow].bOneChoiceForAllPlayers;
unsigned iOptionInRow = bExitRow? 0:
bLotsOfOptions? (bOneChoice? 0:pn):
m_iSelectedOption[pn][iRow];
BitmapText &text = *m_textItems[iRow][iOptionInRow];
BitmapText &text = GetTextItemForRow( pn, iRow );
iWidthOut = int(roundf( text.GetWidestLineWidthInSourcePixels() * text.GetZoomX() ));
iXOut = int(roundf( text.GetDestX() ));
+1
View File
@@ -64,6 +64,7 @@ protected:
virtual void ExportOptions() = 0;
void InitOptionsText();
void GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut );
BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow );
void PositionUnderlines();
void PositionIcons();
void RefreshIcons();