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