We load lots of the same thing in OptionRows. Instead of loading each one
individually, just load one and copy it for the rest; this avoids doing the whole "search, read redir, find refcounted" code path for every option. Don't load data from OptionRow::AfterImportOptions.
This commit is contained in:
+10
-11
@@ -146,6 +146,11 @@ void OptionRow::LoadMetrics( const CString &sType )
|
|||||||
m_OptionIcons[p].Load( m_sType );
|
m_OptionIcons[p].Load( m_sType );
|
||||||
m_OptionIcons[p].RunCommands( ICONS_ON_COMMAND );
|
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 )
|
void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand, bool bFirstItemGoesDown )
|
||||||
@@ -278,11 +283,9 @@ void OptionRow::AfterImportOptions()
|
|||||||
LoadOptionIcon( p, "" );
|
LoadOptionIcon( p, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the items will go off the edge of the screen, then re-init with the "long row" style.
|
// If the items will go off the edge of the screen, then re-init with the "long row" style.
|
||||||
{
|
{
|
||||||
BitmapText bt;
|
BitmapText bt( m_textItemParent );
|
||||||
bt.LoadFromFont( THEME->GetPathF(m_sType,"item") );
|
|
||||||
bt.RunCommands( ITEMS_ON_COMMAND );
|
bt.RunCommands( ITEMS_ON_COMMAND );
|
||||||
|
|
||||||
float fX = ITEMS_START_X;
|
float fX = ITEMS_START_X;
|
||||||
@@ -315,12 +318,11 @@ void OptionRow::AfterImportOptions()
|
|||||||
// init text
|
// init text
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
{
|
||||||
BitmapText *bt = new BitmapText;
|
BitmapText *bt = new BitmapText( m_textItemParent );
|
||||||
m_textItems.push_back( bt );
|
m_textItems.push_back( bt );
|
||||||
|
|
||||||
const int iChoiceInRowWithFocus = m_iChoiceInRowWithFocus[p];
|
const int iChoiceInRowWithFocus = m_iChoiceInRowWithFocus[p];
|
||||||
|
|
||||||
bt->LoadFromFont( THEME->GetPathF(m_sType,"item") );
|
|
||||||
CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.m_vsChoices[iChoiceInRowWithFocus];
|
CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.m_vsChoices[iChoiceInRowWithFocus];
|
||||||
PrepareItemText( sText );
|
PrepareItemText( sText );
|
||||||
bt->SetText( sText );
|
bt->SetText( sText );
|
||||||
@@ -341,9 +343,9 @@ void OptionRow::AfterImportOptions()
|
|||||||
// init underlines
|
// init underlines
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
{
|
||||||
OptionsCursor *ul = new OptionsCursor;
|
OptionsCursor *ul = new OptionsCursor( m_UnderlineParent );
|
||||||
m_Underline[p].push_back( ul );
|
m_Underline[p].push_back( ul );
|
||||||
ul->Load( m_sType, OptionsCursor::underline );
|
|
||||||
ul->Set( p );
|
ul->Set( p );
|
||||||
int iWidth, iX, iY;
|
int iWidth, iX, iY;
|
||||||
GetWidthXY( p, 0, iWidth, iX, iY );
|
GetWidthXY( p, 0, iWidth, iX, iY );
|
||||||
@@ -375,9 +377,8 @@ void OptionRow::AfterImportOptions()
|
|||||||
// init underlines
|
// init underlines
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
{
|
||||||
OptionsCursor *ul = new OptionsCursor;
|
OptionsCursor *ul = new OptionsCursor( m_UnderlineParent );
|
||||||
m_Underline[p].push_back( ul );
|
m_Underline[p].push_back( ul );
|
||||||
ul->Load( m_sType, OptionsCursor::underline );
|
|
||||||
ul->Set( p );
|
ul->Set( p );
|
||||||
ul->SetX( fX );
|
ul->SetX( fX );
|
||||||
ul->SetWidth( truncf(fItemWidth) );
|
ul->SetWidth( truncf(fItemWidth) );
|
||||||
@@ -399,13 +400,11 @@ void OptionRow::AfterImportOptions()
|
|||||||
m_Frame.AddChild( m_Underline[p][c] );
|
m_Frame.AddChild( m_Underline[p][c] );
|
||||||
|
|
||||||
|
|
||||||
m_textTitle.LoadFromFont( THEME->GetPathF(m_sType,"title") );
|
|
||||||
CString sTitle = GetRowTitle();
|
CString sTitle = GetRowTitle();
|
||||||
m_textTitle.SetText( sTitle );
|
m_textTitle.SetText( sTitle );
|
||||||
m_textTitle.SetX( LABELS_X );
|
m_textTitle.SetX( LABELS_X );
|
||||||
m_textTitle.RunCommands( LABELS_ON_COMMAND );
|
m_textTitle.RunCommands( LABELS_ON_COMMAND );
|
||||||
|
|
||||||
m_sprBullet.Load( THEME->GetPathG(m_sType,"bullet") );
|
|
||||||
m_sprBullet.SetX( ARROWS_X );
|
m_sprBullet.SetX( ARROWS_X );
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -171,7 +171,9 @@ protected:
|
|||||||
RowType m_RowType;
|
RowType m_RowType;
|
||||||
OptionRowHandler* m_pHand;
|
OptionRowHandler* m_pHand;
|
||||||
ActorFrame m_Frame;
|
ActorFrame m_Frame;
|
||||||
|
BitmapText m_textItemParent;
|
||||||
vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined
|
vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined
|
||||||
|
OptionsCursor m_UnderlineParent;
|
||||||
vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined
|
vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined
|
||||||
Sprite m_sprBullet;
|
Sprite m_sprBullet;
|
||||||
BitmapText m_textTitle;
|
BitmapText m_textTitle;
|
||||||
|
|||||||
@@ -7,16 +7,26 @@
|
|||||||
|
|
||||||
OptionsCursor::OptionsCursor()
|
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 )
|
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") );
|
CString sPath = THEME->GetPathG( sType, ssprintf("%s 3x2",elem==cursor?"cursor":"underline") );
|
||||||
|
|
||||||
m_sprLeft.Load( sPath );
|
m_sprLeft.Load( sPath );
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class OptionsCursor : public ActorFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OptionsCursor();
|
OptionsCursor();
|
||||||
|
OptionsCursor( const OptionsCursor &cpy );
|
||||||
|
|
||||||
enum Element { cursor, underline };
|
enum Element { cursor, underline };
|
||||||
void Load( CString sType, Element elem );
|
void Load( CString sType, Element elem );
|
||||||
|
|||||||
Reference in New Issue
Block a user