Previously, OptionRowHandler was owned and freed by
ScreenOptionsMaster (and ScreenOptionsManageProfiles). Make it owned by OptionRow; the only pointer to them is where they're stored in the OptionRow. This eliminates the remaining association between m_OptionRowHandlers and m_pRows; that was confusing, because they're in different places, and aren't always the same size. It also simplifies using OptionRowHandlers.
This commit is contained in:
@@ -103,21 +103,16 @@ void OptionRow::Clear()
|
|||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
m_Underline[p].clear();
|
m_Underline[p].clear();
|
||||||
|
|
||||||
ASSERT( m_pHand == NULL );
|
|
||||||
|
|
||||||
m_bFirstItemGoesDown = false;
|
|
||||||
ZERO( m_bRowHasFocus );
|
|
||||||
ZERO( m_iChoiceInRowWithFocus );
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionRow::DetachHandler()
|
|
||||||
{
|
|
||||||
if( m_pHand )
|
if( m_pHand )
|
||||||
{
|
{
|
||||||
FOREACH_CONST( CString, m_pHand->m_vsReloadRowMessages, m )
|
FOREACH_CONST( CString, m_pHand->m_vsReloadRowMessages, m )
|
||||||
MESSAGEMAN->Unsubscribe( this, *m );
|
MESSAGEMAN->Unsubscribe( this, *m );
|
||||||
}
|
}
|
||||||
m_pHand = NULL;
|
SAFE_DELETE( m_pHand );
|
||||||
|
|
||||||
|
m_bFirstItemGoesDown = false;
|
||||||
|
ZERO( m_bRowHasFocus );
|
||||||
|
ZERO( m_iChoiceInRowWithFocus );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionRowType::Load( const CString &sType )
|
void OptionRowType::Load( const CString &sType )
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ public:
|
|||||||
|
|
||||||
void InitText();
|
void InitText();
|
||||||
void AfterImportOptions();
|
void AfterImportOptions();
|
||||||
void DetachHandler();
|
|
||||||
|
|
||||||
void PositionUnderlines( PlayerNumber pn );
|
void PositionUnderlines( PlayerNumber pn );
|
||||||
void PositionIcons();
|
void PositionIcons();
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ void ScreenOptions::InitMenu( const vector<OptionRowDefinition> &vDefs, const ve
|
|||||||
for( unsigned i=0; i<m_pRows.size(); i++ )
|
for( unsigned i=0; i<m_pRows.size(); i++ )
|
||||||
{
|
{
|
||||||
m_framePage.RemoveChild( m_pRows[i] );
|
m_framePage.RemoveChild( m_pRows[i] );
|
||||||
m_pRows[i]->DetachHandler();
|
|
||||||
SAFE_DELETE( m_pRows[i] );
|
SAFE_DELETE( m_pRows[i] );
|
||||||
}
|
}
|
||||||
m_pRows.clear();
|
m_pRows.clear();
|
||||||
|
|||||||
@@ -78,11 +78,6 @@ REGISTER_SCREEN_CLASS( ScreenOptionsManageProfiles );
|
|||||||
|
|
||||||
ScreenOptionsManageProfiles::~ScreenOptionsManageProfiles()
|
ScreenOptionsManageProfiles::~ScreenOptionsManageProfiles()
|
||||||
{
|
{
|
||||||
FOREACH( OptionRow*, m_pRows, r )
|
|
||||||
(*r)->DetachHandler();
|
|
||||||
FOREACH( OptionRowHandler*, m_OptionRowHandlers, h )
|
|
||||||
SAFE_DELETE( *h );
|
|
||||||
m_OptionRowHandlers.clear();
|
|
||||||
SAFE_DELETE( m_pContextMenu );
|
SAFE_DELETE( m_pContextMenu );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +96,6 @@ void ScreenOptionsManageProfiles::Init()
|
|||||||
|
|
||||||
void ScreenOptionsManageProfiles::BeginScreen()
|
void ScreenOptionsManageProfiles::BeginScreen()
|
||||||
{
|
{
|
||||||
FOREACH( OptionRow*, m_pRows, r )
|
|
||||||
(*r)->DetachHandler();
|
|
||||||
for( unsigned i = 0; i < m_OptionRowHandlers.size(); ++i )
|
|
||||||
delete m_OptionRowHandlers[i];
|
|
||||||
m_OptionRowHandlers.clear();
|
|
||||||
|
|
||||||
OptionRowDefinition def;
|
OptionRowDefinition def;
|
||||||
def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW;
|
def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW;
|
||||||
def.m_bAllowThemeTitle = false;
|
def.m_bAllowThemeTitle = false;
|
||||||
@@ -114,13 +103,14 @@ void ScreenOptionsManageProfiles::BeginScreen()
|
|||||||
|
|
||||||
int iIndex = 0;
|
int iIndex = 0;
|
||||||
vector<OptionRowDefinition> vDefs;
|
vector<OptionRowDefinition> vDefs;
|
||||||
|
vector<OptionRowHandler*> OptionRowHandlers;
|
||||||
|
|
||||||
if( SHOW_CREATE_NEW )
|
if( SHOW_CREATE_NEW )
|
||||||
{
|
{
|
||||||
OptionRowDefinition def;
|
OptionRowDefinition def;
|
||||||
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands("gamecommand;screen,ScreenOptionsEditProfile;name,Create New"), def );
|
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands("gamecommand;screen,ScreenOptionsEditProfile;name,Create New"), def );
|
||||||
vDefs.push_back( def );
|
vDefs.push_back( def );
|
||||||
m_OptionRowHandlers.push_back( pHand );
|
OptionRowHandlers.push_back( pHand );
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// gc.Load( iIndex++, );
|
// gc.Load( iIndex++, );
|
||||||
@@ -138,13 +128,13 @@ void ScreenOptionsManageProfiles::BeginScreen()
|
|||||||
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand), def );
|
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand), def );
|
||||||
def.m_sName = ssprintf( "%d", iIndex );
|
def.m_sName = ssprintf( "%d", iIndex );
|
||||||
vDefs.push_back( def );
|
vDefs.push_back( def );
|
||||||
m_OptionRowHandlers.push_back( pHand );
|
OptionRowHandlers.push_back( pHand );
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// gc.Load( iIndex++, );
|
// gc.Load( iIndex++, );
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenOptions::InitMenu( vDefs, m_OptionRowHandlers );
|
ScreenOptions::InitMenu( vDefs, OptionRowHandlers );
|
||||||
|
|
||||||
ScreenOptions::BeginScreen();
|
ScreenOptions::BeginScreen();
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ protected:
|
|||||||
|
|
||||||
vector<CString> m_vsLocalProfileID;
|
vector<CString> m_vsLocalProfileID;
|
||||||
|
|
||||||
vector<OptionRowHandler*> m_OptionRowHandlers;
|
|
||||||
|
|
||||||
ScreenMiniMenu *m_pContextMenu;
|
ScreenMiniMenu *m_pContextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ void ScreenOptionsMaster::Init()
|
|||||||
|
|
||||||
vector<OptionRowDefinition> OptionRowDefs;
|
vector<OptionRowDefinition> OptionRowDefs;
|
||||||
OptionRowDefs.resize( asLineNames.size() );
|
OptionRowDefs.resize( asLineNames.size() );
|
||||||
|
vector<OptionRowHandler*> OptionRowHandlers;
|
||||||
for( unsigned i = 0; i < asLineNames.size(); ++i )
|
for( unsigned i = 0; i < asLineNames.size(); ++i )
|
||||||
{
|
{
|
||||||
CString sLineName = asLineNames[i];
|
CString sLineName = asLineNames[i];
|
||||||
@@ -63,22 +64,17 @@ void ScreenOptionsMaster::Init()
|
|||||||
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds, def );
|
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds, def );
|
||||||
if( pHand == NULL )
|
if( pHand == NULL )
|
||||||
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%i", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), i );
|
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%i", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), i );
|
||||||
m_OptionRowHandlers.push_back( pHand );
|
OptionRowHandlers.push_back( pHand );
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT( m_OptionRowHandlers.size() == asLineNames.size() );
|
ASSERT( OptionRowHandlers.size() == asLineNames.size() );
|
||||||
|
|
||||||
|
|
||||||
InitMenu( OptionRowDefs, m_OptionRowHandlers );
|
InitMenu( OptionRowDefs, OptionRowHandlers );
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenOptionsMaster::~ScreenOptionsMaster()
|
ScreenOptionsMaster::~ScreenOptionsMaster()
|
||||||
{
|
{
|
||||||
FOREACH( OptionRow*, m_pRows, r )
|
|
||||||
(*r)->DetachHandler();
|
|
||||||
FOREACH( OptionRowHandler*, m_OptionRowHandlers, h )
|
|
||||||
SAFE_DELETE( *h );
|
|
||||||
m_OptionRowHandlers.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptionsMaster::ImportOptions( int r, const vector<PlayerNumber> &vpns )
|
void ScreenOptionsMaster::ImportOptions( int r, const vector<PlayerNumber> &vpns )
|
||||||
@@ -91,7 +87,7 @@ void ScreenOptionsMaster::ImportOptions( int r, const vector<PlayerNumber> &vpns
|
|||||||
|
|
||||||
void ScreenOptionsMaster::ExportOptions( int r, const vector<PlayerNumber> &vpns )
|
void ScreenOptionsMaster::ExportOptions( int r, const vector<PlayerNumber> &vpns )
|
||||||
{
|
{
|
||||||
CHECKPOINT_M( ssprintf("%i/%i", r, int(m_OptionRowHandlers.size())) );
|
CHECKPOINT_M( ssprintf("%i/%i", r, int(m_pRows.size())) );
|
||||||
|
|
||||||
OptionRow &row = *m_pRows[r];
|
OptionRow &row = *m_pRows[r];
|
||||||
bool bRowHasFocus[NUM_PLAYERS];
|
bool bRowHasFocus[NUM_PLAYERS];
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
int m_iChangeMask;
|
int m_iChangeMask;
|
||||||
|
|
||||||
vector<OptionRowHandler*> m_OptionRowHandlers;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user