示例#1
0
ScreenSelect::ScreenSelect( CString sClassName ) : ScreenWithMenuElements(sClassName)
{
	LOG->Trace( "ScreenSelect::ScreenSelect()" );

	m_sName = sClassName;

	//
	// Load choices
	//
	{
		// Instead of using NUM_CHOICES, use a comma-separated list of choices.  Each
		// element in the list is a choice name.  This level of indirection 
		// makes it easier to add or remove items without having to change a bunch
		// of indices.
		CStringArray asChoiceNames;
		split( CHOICE_NAMES, ",", asChoiceNames, true );

		for( unsigned c=0; c<asChoiceNames.size(); c++ )
		{
			CString sChoiceName = asChoiceNames[c];
			CString sChoice = CHOICE(sChoiceName);

			ModeChoice mc;
			mc.m_sName = sChoiceName;
			mc.Load( c, sChoice );
			m_aModeChoices.push_back( mc );
		
			CString sBGAnimationDir = THEME->GetPath(BGAnimations, m_sName, mc.m_sName, true);	// true="optional"
			if( sBGAnimationDir == "" )
				sBGAnimationDir = THEME->GetPathToB(m_sName+" background");
			BGAnimation *pBGA = new BGAnimation;
			m_vpBGAnimations.push_back( pBGA );
		}
	}

	//
	// Load codes
	//
	for( int c=0; c<NUM_CODES; c++ )
	{
		CodeItem code;
		if( !code.Load( CODE(c) ) )
			continue;

		m_aCodes.push_back( code );
		m_aCodeActions.push_back( CODE_ACTION(c) );
		ModeChoice mc;
		mc.Load( c, CODE_ACTION(c) );
		m_aCodeChoices.push_back( mc );
	}

	if( !m_aModeChoices.size() )
		RageException::Throw( "Screen \"%s\" does not set any choices", m_sName.c_str() );

	// derived classes can override if they want
	LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
}
/* Add the list named "ListName" to the given row/handler. */
void ScreenOptionsMaster::SetList( OptionRowData &row, OptionRowHandler &hand, const CString &ListName, CString &TitleOut )
{
	hand.type = ROW_LIST;

	TitleOut = ListName;
	if( !ListName.CompareNoCase("noteskins") )
	{
		hand.Default.Init(); /* none */
		row.bOneChoiceForAllPlayers = false;

		CStringArray arraySkinNames;
		NOTESKIN->GetNoteSkinNames( arraySkinNames );
		ModeChoice mc;
		for( unsigned skin=0; skin<arraySkinNames.size(); skin++ )
		{
			arraySkinNames[skin].MakeUpper();
			mc.m_sModifiers = arraySkinNames[skin];
			hand.ListEntries.push_back( mc );
			row.choices.push_back( arraySkinNames[skin] );
		}
		return;
	}

	hand.Default.Load( -1, ENTRY_DEFAULT(ListName) );

	/* Parse the basic configuration metric. */
	CStringArray asParts;
	split( ENTRY(ListName), ",", asParts );
	if( asParts.size() < 1 )
		RageException::Throw( "Parse error in ScreenOptionsMasterEntries::ListName%s", ListName.c_str() );

	row.bOneChoiceForAllPlayers = false;
	const int NumCols = atoi( asParts[0] );
	for( unsigned i=0; i<asParts.size(); i++ )
	{
		if( asParts[i].CompareNoCase("together") == 0 )
			row.bOneChoiceForAllPlayers = true;
		else if( asParts[i].CompareNoCase("multiselect") == 0 )
			row.bMultiSelect = true;
	}

	for( int col = 0; col < NumCols; ++col )
	{
		ModeChoice mc;
		mc.Load( 0, ENTRY_MODE(ListName, col) );
		if( mc.m_sName == "" )
			RageException::Throw( "List \"%s\", col %i has no name", ListName.c_str(), col );

		if( !mc.IsPlayable() )
			continue;

		hand.ListEntries.push_back( mc );

		CString sChoice = ENTRY_NAME(mc.m_sName);
		row.choices.push_back( sChoice );
	}
}
示例#3
0
void ScreenBranch::HandleScreenMessage( const ScreenMessage SM )
{
	switch( SM )
	{
	case SM_GoToNextScreen:
		{
			CString sNextScreen = NEXT_SCREEN(m_sChoice);
			LOG->Trace( "Branching to '%s'", sNextScreen.c_str() );

			ModeChoice mc;
			mc.Load( 0, sNextScreen );
			if( mc.m_sScreen == "" )
				RageException::Throw("Metric %s::%s must set \"screen\"",
					m_sName.c_str(), ("NextScreen"+m_sChoice).c_str() );
			mc.ApplyToAllPlayers();
		}
		break;
	}
}