//REGISTER_SCREEN_CLASS( ScreenOptions );	// can't be instantiated
ScreenOptions::ScreenOptions()
{
	// These can be overridden in a derived Init().
	switch( PREFSMAN->m_iArcadeOptionsNavigation )
	{
	case 0: SetNavigation( NAV_FIVE_KEY ); break;
	case 1: SetNavigation( NAV_THREE_KEY ); break;
	case 2: SetNavigation( NAV_THREE_KEY_ALT ); break;
	}
	m_InputMode = INPUTMODE_SHARE_CURSOR;
}
void ScreenOptionsManageProfiles::Init()
{
	ScreenOptions::Init();

	SetNavigation( NAV_THREE_KEY_MENU );
	SetInputMode( INPUTMODE_SHARE_CURSOR );
}
void ScreenMiniMenu::Init()
{
	if( PREFSMAN->m_iArcadeOptionsNavigation )
		SetNavigation( NAV_THREE_KEY_MENU );

	ScreenOptions::Init();
}
void ScreenOptionsMaster::Init()
{
	vector<RString> asLineNames;
	split( LINE_NAMES, ",", asLineNames );
	if( asLineNames.empty() )
	{
		LuaHelpers::ReportScriptErrorFmt("\"%s:LineNames\" is empty.", m_sName.c_str());
	}

	if( FORCE_ALL_PLAYERS )
	{
		FOREACH_PlayerNumber( pn )
			GAMESTATE->JoinPlayer( pn );
	}

	if( NAVIGATION_MODE == "toggle" )
		SetNavigation( PREFSMAN->m_iArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
	else if( NAVIGATION_MODE == "menu" )
		SetNavigation( NAV_THREE_KEY_MENU );

	SetInputMode( StringToInputMode(INPUT_MODE) );

	// Call this after enabling players, if any.
	ScreenOptions::Init();

	vector<OptionRowHandler*> OptionRowHandlers;
	for( unsigned i = 0; i < asLineNames.size(); ++i )
	{
		RString sLineName = asLineNames[i];
		RString sRowCommands = LINE(sLineName);
		
		Commands cmds;
		ParseCommands( sRowCommands, cmds, false );

		OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds );
		if( pHand == NULL )
		{
			LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s:Line:%s\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str());
		}
		else
		{
			OptionRowHandlers.push_back( pHand );
		}
	}
	InitMenu( OptionRowHandlers );
}
void ScreenOptionsMaster::Init()
{
	ScreenOptions::Init();

	// make sure volume is set to full in options, and menu lights are on
	ScreenAttract::SetAttractVolume( false );
	LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );

	CStringArray asLineNames;
	split( LINE_NAMES, ",", asLineNames );
	if( asLineNames.empty() )
		RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );


	CStringArray Flags;
	split( OPTION_MENU_FLAGS, ";", Flags, true );
	InputMode im = INPUTMODE_INDIVIDUAL;
	
	for( unsigned i = 0; i < Flags.size(); ++i )
	{
		CString sFlag = Flags[i];
		sFlag.MakeLower();

		if( sFlag == "together" )
			im = INPUTMODE_SHARE_CURSOR;
		else if( sFlag == "explanations" )
			;
		else if( sFlag == "forceallplayers" )
		{
			FOREACH_PlayerNumber( pn )
				GAMESTATE->m_bSideIsJoined[pn] = true;
			GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0);
		}
		else if( sFlag == "smnavigation" )
			SetNavigation( NAV_THREE_KEY_MENU );
		else if( sFlag == "toggle" || sFlag == "firstchoicegoesdown" )
			SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
		else
			RageException::Throw( "Unknown flag \"%s\"", sFlag.c_str() );
	}

	vector<OptionRowDefinition> OptionRowDefs;
	OptionRowDefs.resize( asLineNames.size() );
	OptionRowHandlers.resize( asLineNames.size() );
	for( unsigned i = 0; i < asLineNames.size(); ++i )
	{
		CString sLineName = asLineNames[i];
		OptionRowDefinition &def = OptionRowDefs[i];
		CString sRowCommands = LINE(sLineName);
		OptionRowHandler* &pHand = OptionRowHandlers[i];
		pHand = NULL;
		
		Commands vCommands;
		ParseCommands( sRowCommands, vCommands );
		if( vCommands.v.size() != 1 )
			RageException::Throw( "Parse error in %s::Line%s", m_sName.c_str(), sLineName.c_str() );

		Command& command = vCommands.v[0];
		pHand = OptionRowHandlerUtil::Make( command, def );
		if( pHand == NULL )
            RageException::Throw( "Invalid OptionRowHandler '%s' in %s::%s", command.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str() );
	}

	ASSERT( OptionRowHandlers.size() == asLineNames.size() );

	InitMenu( im, OptionRowDefs, OptionRowHandlers );
}
Exemple #6
0
CGUIAction::CGUIAction(int controlID)
{
  m_sendThreadMessages = false;
  SetNavigation(controlID);
}
ScreenOptionsMaster::ScreenOptionsMaster( const CString &sClassName ):
	ScreenOptions( sClassName )
{
	LOG->Trace("ScreenOptionsMaster::ScreenOptionsMaster(%s)", m_sName.c_str() );

	/* If this file doesn't exist, leave the music alone (eg. ScreenPlayerOptions music sample
	 * left over from ScreenSelectMusic).  If you really want to play no music, add a redir
	 * to _silent. */
	CString MusicPath = THEME->GetPathToS( ssprintf("%s music", m_sName.c_str()), true );
	if( MusicPath != "" )
		SOUND->PlayMusic( MusicPath );

	CStringArray asLineNames;
	split( LINE_NAMES, ",", asLineNames );
	if( asLineNames.empty() )
		RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );


	CStringArray Flags;
	split( OPTION_MENU_FLAGS, ";", Flags, true );
	InputMode im = INPUTMODE_INDIVIDUAL;
	bool Explanations = false;
	
	unsigned i;
	for( i = 0; i < Flags.size(); ++i )
	{
		CString &flag = Flags[i];
		flag.MakeLower();

		if( flag == "together" )
			im = INPUTMODE_SHARE_CURSOR;
		else if( flag == "explanations" )
			Explanations = true;
		else if( flag == "forceallplayers" )
		{
			FOREACH_PlayerNumber( pn )
				GAMESTATE->m_bSideIsJoined[pn] = true;
			GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0);
		}
		else if( flag == "smnavigation" )
			SetNavigation( NAV_THREE_KEY_MENU );
		else if( flag == "toggle" || flag == "firstchoicegoesdown" )
			SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
	}

	m_OptionRowAlloc = new OptionRowData[asLineNames.size()];
	for( i = 0; i < asLineNames.size(); ++i )
	{
		OptionRowData &row = m_OptionRowAlloc[i];
		
		vector<ParsedCommand> vCommands;
		ParseCommands( LINE(asLineNames[i]), vCommands );
		
		if( vCommands.size() < 1 )
			RageException::Throw( "Parse error in %s::Line%i", m_sName.c_str(), i+1 );

		OptionRowHandler hand;
		for( unsigned part = 0; part < vCommands.size(); ++part)
		{
			ParsedCommand& command = vCommands[part];

			HandleParams;

			const CString name = sParam(0);

			if( !name.CompareNoCase("list") )
			{
				SetList( row, hand, sParam(1), row.name );
			}
			else if( !name.CompareNoCase("steps") )
			{
				SetStep( row, hand );
				row.name = "Steps";
			}
			else if( !name.CompareNoCase("conf") )
			{
				SetConf( row, hand, sParam(1), row.name );
			}
			else if( !name.CompareNoCase("characters") )
			{
				SetCharacter( row, hand );
				row.name = "Characters";
			}
			else
				RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i );

			CheckHandledParams;
		}

		// TRICKY:  Insert a down arrow as the first choice in the row.
		if( m_OptionsNavigation == NAV_TOGGLE_THREE_KEY )
		{
			row.choices.insert( row.choices.begin(), ENTRY_NAME("NextRow") );
			hand.ListEntries.insert( hand.ListEntries.begin(), ModeChoice() );
		}

		OptionRowHandlers.push_back( hand );
	}

	ASSERT( OptionRowHandlers.size() == asLineNames.size() );

	Init( im, m_OptionRowAlloc, asLineNames.size() );
}