diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index eaaaff4a95..6458d0ba83 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -146,6 +146,11 @@ void OptionRow::LoadMetrics( const CString &sType ) m_OptionIcons[p].Load( m_sType ); m_OptionIcons[p].RunCommands( ICONS_ON_COMMAND ); } + + m_textItemParent.LoadFromFont( THEME->GetPathF(m_sType,"item") ); + m_UnderlineParent.Load( m_sType, OptionsCursor::underline ); + m_textTitle.LoadFromFont( THEME->GetPathF(m_sType,"title") ); + m_sprBullet.Load( THEME->GetPathG(m_sType,"bullet") ); } void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand, bool bFirstItemGoesDown ) @@ -278,11 +283,9 @@ void OptionRow::AfterImportOptions() LoadOptionIcon( p, "" ); } - // If the items will go off the edge of the screen, then re-init with the "long row" style. { - BitmapText bt; - bt.LoadFromFont( THEME->GetPathF(m_sType,"item") ); + BitmapText bt( m_textItemParent ); bt.RunCommands( ITEMS_ON_COMMAND ); float fX = ITEMS_START_X; @@ -315,12 +318,11 @@ void OptionRow::AfterImportOptions() // init text FOREACH_HumanPlayer( p ) { - BitmapText *bt = new BitmapText; + BitmapText *bt = new BitmapText( m_textItemParent ); m_textItems.push_back( bt ); const int iChoiceInRowWithFocus = m_iChoiceInRowWithFocus[p]; - bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.m_vsChoices[iChoiceInRowWithFocus]; PrepareItemText( sText ); bt->SetText( sText ); @@ -341,9 +343,9 @@ void OptionRow::AfterImportOptions() // init underlines FOREACH_HumanPlayer( p ) { - OptionsCursor *ul = new OptionsCursor; + OptionsCursor *ul = new OptionsCursor( m_UnderlineParent ); m_Underline[p].push_back( ul ); - ul->Load( m_sType, OptionsCursor::underline ); + ul->Set( p ); int iWidth, iX, iY; GetWidthXY( p, 0, iWidth, iX, iY ); @@ -375,9 +377,8 @@ void OptionRow::AfterImportOptions() // init underlines FOREACH_HumanPlayer( p ) { - OptionsCursor *ul = new OptionsCursor; + OptionsCursor *ul = new OptionsCursor( m_UnderlineParent ); m_Underline[p].push_back( ul ); - ul->Load( m_sType, OptionsCursor::underline ); ul->Set( p ); ul->SetX( fX ); ul->SetWidth( truncf(fItemWidth) ); @@ -399,13 +400,11 @@ void OptionRow::AfterImportOptions() m_Frame.AddChild( m_Underline[p][c] ); - m_textTitle.LoadFromFont( THEME->GetPathF(m_sType,"title") ); CString sTitle = GetRowTitle(); m_textTitle.SetText( sTitle ); m_textTitle.SetX( LABELS_X ); m_textTitle.RunCommands( LABELS_ON_COMMAND ); - m_sprBullet.Load( THEME->GetPathG(m_sType,"bullet") ); m_sprBullet.SetX( ARROWS_X ); // diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 0f7749f16c..e246d59fc6 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -171,7 +171,9 @@ protected: RowType m_RowType; OptionRowHandler* m_pHand; ActorFrame m_Frame; + BitmapText m_textItemParent; vector m_textItems; // size depends on m_bRowIsLong and which players are joined + OptionsCursor m_UnderlineParent; vector m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined Sprite m_sprBullet; BitmapText m_textTitle; diff --git a/stepmania/src/OptionsCursor.cpp b/stepmania/src/OptionsCursor.cpp index ff49e3c705..bd53a49f5f 100644 --- a/stepmania/src/OptionsCursor.cpp +++ b/stepmania/src/OptionsCursor.cpp @@ -7,16 +7,26 @@ OptionsCursor::OptionsCursor() { + this->AddChild( &m_sprMiddle ); + this->AddChild( &m_sprLeft ); + this->AddChild( &m_sprRight ); +} + +OptionsCursor::OptionsCursor( const OptionsCursor &cpy ): + ActorFrame( cpy ), + m_sprLeft( cpy.m_sprLeft ), + m_sprMiddle( cpy.m_sprMiddle ), + m_sprRight( cpy.m_sprRight ) +{ + /* Re-add children, or m_SubActors will point to cpy's children and not our own. */ + m_SubActors.clear(); + this->AddChild( &m_sprMiddle ); + this->AddChild( &m_sprLeft ); + this->AddChild( &m_sprRight ); } void OptionsCursor::Load( CString sType, Element elem ) { - ASSERT( m_SubActors.empty() ); // don't load twice - - this->AddChild( &m_sprMiddle ); - this->AddChild( &m_sprLeft ); - this->AddChild( &m_sprRight ); - CString sPath = THEME->GetPathG( sType, ssprintf("%s 3x2",elem==cursor?"cursor":"underline") ); m_sprLeft.Load( sPath ); diff --git a/stepmania/src/OptionsCursor.h b/stepmania/src/OptionsCursor.h index 16664c52fa..3e31ebcc71 100644 --- a/stepmania/src/OptionsCursor.h +++ b/stepmania/src/OptionsCursor.h @@ -12,6 +12,7 @@ class OptionsCursor : public ActorFrame { public: OptionsCursor(); + OptionsCursor( const OptionsCursor &cpy ); enum Element { cursor, underline }; void Load( CString sType, Element elem );