allocate GameCommand as needed

This commit is contained in:
Glenn Maynard
2006-10-01 20:13:27 +00:00
parent ca0f34d5a8
commit a31f76e9ad
4 changed files with 17 additions and 13 deletions
+2
View File
@@ -26,6 +26,8 @@
static LocalizedString COULD_NOT_LAUNCH_BROWSER( "GameCommand", "Could not launch web browser." );
REGISTER_CLASS_TRAITS( GameCommand, new GameCommand(*pCopy) );
void GameCommand::Init()
{
m_bApplyCommitsScreens = true;
+13 -10
View File
@@ -123,9 +123,10 @@ void MusicWheel::Load( RString sType )
const vector<WheelItemData *> &from = m_WheelItemDatas[SORT_MODE_MENU];
for( unsigned i=0; i<from.size(); i++ )
{
if( from[i]->m_Action.DescribesCurrentModeForAllPlayers() )
ASSERT( &*from[i]->m_pAction );
if( from[i]->m_pAction->DescribesCurrentModeForAllPlayers() )
{
m_sLastModeMenuItem = from[i]->m_Action.m_sName;
m_sLastModeMenuItem = from[i]->m_pAction->m_sName;
break;
}
}
@@ -285,11 +286,12 @@ bool MusicWheel::SelectCourse( const Course *p )
bool MusicWheel::SelectModeMenuItem()
{
/* Select the last-chosen option. */
ASSERT( GAMESTATE->m_SortOrder == SORT_MODE_MENU );
const vector<WheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
unsigned i;
for( i=0; i<from.size(); i++ )
{
const GameCommand &gc = from[i]->m_Action;
const GameCommand &gc = *from[i]->m_pAction;
if( gc.m_sName == m_sLastModeMenuItem )
break;
}
@@ -301,7 +303,7 @@ bool MusicWheel::SelectModeMenuItem()
for( i=0; i<m_CurWheelItemData.size(); i++ )
{
if( GetCurWheelItemData(i)->m_Action.m_sName != m_sLastModeMenuItem )
if( GetCurWheelItemData(i)->m_pAction->m_sName != m_sLastModeMenuItem )
continue;
m_iSelection = i; // select it
break;
@@ -391,11 +393,12 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData *> &arrayWheelItemDat
}
WheelItemData wid( TYPE_SORT, NULL, "", NULL, SORT_MENU_COLOR );
wid.m_Action.m_sName = vsNames[i];
wid.m_Action.Load( i, ParseCommands(CHOICE.GetValue(vsNames[i])) );
wid.m_pAction = HiddenPtr<GameCommand>( new GameCommand );
wid.m_pAction->m_sName = vsNames[i];
wid.m_pAction->Load( i, ParseCommands(CHOICE.GetValue(vsNames[i])) );
wid.m_sLabel = WHEEL_TEXT(vsNames[i]);
if( !wid.m_Action.IsPlayable() )
if( !wid.m_pAction->IsPlayable() )
continue;
arrayWheelItemDatas.push_back( new WheelItemData(wid) );
@@ -924,10 +927,10 @@ bool MusicWheel::Select() // return true if this selection ends the screen
case TYPE_SORT:
LOG->Trace("New sort order selected: %s - %s",
GetCurWheelItemData(m_iSelection)->m_sLabel.c_str(),
SortOrderToString(GetCurWheelItemData(m_iSelection)->m_Action.m_SortOrder).c_str() );
GetCurWheelItemData(m_iSelection)->m_Action.ApplyToAllPlayers();
SortOrderToString(GetCurWheelItemData(m_iSelection)->m_pAction->m_SortOrder).c_str() );
GetCurWheelItemData(m_iSelection)->m_pAction->ApplyToAllPlayers();
ChangeSort( GAMESTATE->m_PreferredSortOrder );
m_sLastModeMenuItem = GetCurWheelItemData(m_iSelection)->m_Action.m_sName;
m_sLastModeMenuItem = GetCurWheelItemData(m_iSelection)->m_pAction->m_sName;
break;
default:
break;
+1 -2
View File
@@ -29,7 +29,6 @@ WheelItemData::WheelItemData( WheelItemType wit, Song* pSong, RString sSectionNa
m_pCourse = pCourse;
}
MusicWheelItem::MusicWheelItem( RString sType ):
WheelItemBase( sType )
{
@@ -254,7 +253,7 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pWIBD )
m_sprSectionBar.SetHidden( false );
break;
case TYPE_SORT:
if( pWID->m_Action.m_pm != PlayMode_Invalid )
if( pWID->m_pAction->m_pm != PlayMode_Invalid )
m_sprModeBar.SetHidden( false );
else
m_sprSortBar.SetHidden( false );
+1 -1
View File
@@ -56,7 +56,7 @@ struct WheelItemData : public WheelItemBaseData
// for TYPE_SORT
RString m_sLabel;
GameCommand m_Action;
HiddenPtr<GameCommand> m_pAction;
};
#endif