merge duplicate code

This commit is contained in:
Glenn Maynard
2003-11-08 02:46:12 +00:00
parent 555d12b49e
commit f810930dab
2 changed files with 13 additions and 21 deletions
+12 -21
View File
@@ -232,16 +232,7 @@ void ScreenOptions::Init( InputMode im, OptionRow OptionRows[], int iNumOptionLi
// poke once at all the explanation metrics so that we catch missing ones early // poke once at all the explanation metrics so that we catch missing ones early
for( r=0; r<m_iNumOptionRows; r++ ) // foreach line for( r=0; r<m_iNumOptionRows; r++ ) // foreach line
{ GetExplanationText( r );
CString sLineName = m_OptionRow[r].name;
if( sLineName=="" )
sLineName = m_OptionRow[r].choices[0];
sLineName.Replace("\n-","");
sLineName.Replace("\n","");
sLineName.Replace(" ","");
CString sExplanation = THEME->GetMetric(m_sName,sLineName);
}
CHECKPOINT; CHECKPOINT;
@@ -287,6 +278,16 @@ ScreenOptions::~ScreenOptions()
delete m_textItems[i][j]; delete m_textItems[i][j];
} }
CString ScreenOptions::GetExplanationText( int row ) const
{
CString sLineName = m_OptionRow[row].name;
if( sLineName=="" )
sLineName = m_OptionRow[row].choices[0];
sLineName.Replace("\n-","");
sLineName.Replace("\n","");
sLineName.Replace(" ","");
return THEME->GetMetric( m_sName,sLineName );
}
BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow ) BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow )
{ {
@@ -753,19 +754,9 @@ void ScreenOptions::OnChange( PlayerNumber pn )
} }
if( bIsExitRow ) if( bIsExitRow )
{
pText->SetText( "" ); pText->SetText( "" );
}
else else
{ pText->SetText( GetExplanationText(iCurRow) );
CString sLineName = m_OptionRow[iCurRow].name;
if( sLineName=="" )
sLineName = m_OptionRow[iCurRow].choices[0];
sLineName.Replace("\n-","");
sLineName.Replace("\n","");
sLineName.Replace(" ","");
pText->SetText( THEME->GetMetric(m_sName,sLineName) );
}
} }
+1
View File
@@ -67,6 +67,7 @@ protected:
virtual void ExportOptions() = 0; virtual void ExportOptions() = 0;
void InitOptionsText(); void InitOptionsText();
void GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut ); void GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut );
CString GetExplanationText( int row ) const;
BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow ); BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow );
void PositionUnderlines(); void PositionUnderlines();
void PositionIcons(); void PositionIcons();