예제 #1
0
// Resume playing a savegame - launches to the campaign lobby with the specified save data loaded
void ASW_LaunchSaveGame(const char *szSaveName, bool bMultiplayer, bool bChangeLevel)
{
	IASW_Mission_Chooser_Source* pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if (!pSource)
		return;

	int iMissions = pSource->GetNumMissionsCompleted(szSaveName);
	if (iMissions == -1)	// invalid save
		return;

	// decide on lobby map (if singleplayer and no missions complete, we launch the intro)
	const char *szLobby = "Lobby";

	if (!bMultiplayer && iMissions == 0)	// if we're in singleplayer and starting the campaign, find the intro
	{
		szLobby = pSource->GetCampaignSaveIntroMap(szSaveName);
	}		

	// launch the campaign lobby map
	char buffer[512];
	if (bChangeLevel)		
		Q_snprintf(buffer, sizeof(buffer), "changelevel %s campaign %s\n", szLobby, szSaveName);
	else
		Q_snprintf(buffer, sizeof(buffer), "map %s campaign %s\n", szLobby, szSaveName);

#ifdef CLIENT_DLL
	engine->ClientCmd(buffer);
#else
	engine->ServerCommand(buffer);
#endif
}
void CNB_Select_Campaign_Entry::OnCommand( const char *command )
{
	if ( !Q_stricmp( "CampaignClicked", command ) )
	{
		IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
		if ( pSource )
		{
			ASW_Mission_Chooser_Mission *pCampaign = pSource->GetCampaign( m_nCampaignIndex );
			if ( pCampaign )
			{
				CNB_Select_Campaign_Panel *pPanel = dynamic_cast<CNB_Select_Campaign_Panel*>( GetParent()->GetParent()->GetParent() );
				if ( pPanel )
				{
					pPanel->CampaignSelected( pCampaign );
				}
			}
		}
	}
}
예제 #3
0
// con command for new campaign
void ASW_StartNewCampaign_cc( const CCommand &args )
{
	IASW_Mission_Chooser_Source* pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if (!pSource)
		return;

	if ( args.ArgC() < 4 )
	{
		Msg( "Usage: ASW_StartCampaign [CampaignName] [SaveName] [SP|MP]\n   Use 'auto' for SaveName to have an autonumbered save.\n" );
		return;
	}

	// create a new savegame at the start of the campaign
	char buffer[256];
	if (!Q_strnicmp( args[2], "auto", 4 ))
	{
		const char *pNewSaveName = GenerateNewSaveGameName();
		if (!pNewSaveName)
		{
			Msg("Error! No more room for autogenerated save names, delete some save games!\n");
			return;
		}
		Q_snprintf(buffer, sizeof(buffer), "%s", pNewSaveName);
	}
	else
		Q_snprintf(buffer, sizeof(buffer), "%s", args[2]);

	// Use an arg to detect MP (would be better to check maxplayers here, but we can't?)
	bool bMulti = (!Q_strnicmp( args[3], "MP", 2 ));
	if (!pSource->ASW_Campaign_CreateNewSaveGame(&buffer[0], sizeof(buffer), args[1], bMulti, NULL))
	{
		Msg( "Unable to create new save game.\n" );
		return;
	}

	// go to the load savegame code
	ASW_LaunchSaveGame(buffer, bMulti, args.ArgC() == 5);	// if 3rd parameter specified, do a changelevel instead of launching a new
}
예제 #4
0
void CASW_Voting_Missions::ScanThink()
{
	if (m_iListType == 0)		// if the player isn't looking at any particular list at the moment, don't bother updating our strings
	{
		SetThink( NULL );
		return;
	}

	if (!missionchooser || !missionchooser->LocalMissionSource())
		return;

	IASW_Mission_Chooser_Source* pMissionSource = missionchooser->LocalMissionSource();

	// let the source think, in case it needs to be scanning folders
	pMissionSource->Think();

	// player is looking at the list of missions
	if (m_iListType == 1)
	{
		if ( m_nCampaignIndex == -1 )
		{
			// make sure the source is setup to be looking at our page of missions (need to do this every time in case someone else is using the source too)
			pMissionSource->FindMissions(m_nOffset, m_iNumSlots, true);
			// copy them from the local source into our networked array
			ASW_Mission_Chooser_Mission* missions = pMissionSource->GetMissions();
			bool bChanged = false;
			for (int i=0;i<m_iNumSlots;i++)
			{
				if (i<ASW_SAVES_PER_PAGE && Q_strcmp(missions[i].m_szMissionName, STRING(m_iszMissionNames[i])))
				{
					bChanged = true;
					m_iszMissionNames.Set(i, AllocPooledString(missions[i].m_szMissionName));
					m_iszMissionNames.GetForModify(i);
				}
			}
			m_iNumMissions = pMissionSource->GetNumMissions(false);
			m_iNumOverviewMissions = pMissionSource->GetNumMissions(true);
		}
		else
		{
			// make sure the source is setup to be looking at our page of missions (need to do this every time in case someone else is using the source too)
			pMissionSource->FindMissionsInCampaign(m_nCampaignIndex, m_nOffset, m_iNumSlots);
			// copy them from the local source into our networked array
			ASW_Mission_Chooser_Mission* missions = pMissionSource->GetMissions();
			bool bChanged = false;
			for (int i=0;i<m_iNumSlots;i++)
			{
				if (i<ASW_SAVES_PER_PAGE && Q_strcmp(missions[i].m_szMissionName, STRING(m_iszMissionNames[i])))
				{
					bChanged = true;
					m_iszMissionNames.Set(i, AllocPooledString(missions[i].m_szMissionName));
					m_iszMissionNames.GetForModify(i);
				}
			}
			m_iNumMissions = pMissionSource->GetNumMissionsInCampaign( m_nCampaignIndex );
			m_iNumOverviewMissions = m_iNumMissions;
		}
	}
	else if (m_iListType == 2)	// player is looking at a list of campaigns
	{
		// make sure the source is setup to be looking at our page of campaign (need to do this every time in case someone else is using the source too)
		pMissionSource->FindCampaigns(m_nOffset, m_iNumSlots);
		// copy them from the local source into our networked array
		ASW_Mission_Chooser_Mission* campaigns = pMissionSource->GetCampaigns();
		for (int i=0;i<m_iNumSlots;i++)
		{
			if (i<ASW_CAMPAIGNS_PER_PAGE && Q_strcmp(campaigns[i].m_szMissionName, STRING(m_iszCampaignNames[i])))
			{
				m_iszCampaignNames.Set(i, AllocPooledString(campaigns[i].m_szMissionName));
			}
		}
		m_iNumCampaigns = pMissionSource->GetNumCampaigns();
	}
	else if (m_iListType == 3)	// player is looking at a list of saved campaign games
	{
		// make sure the source is setup to be looking at our page of saves (need to do this every time in case someone else is using the source too)
		bool bMulti = !( ASWGameResource() && ASWGameResource()->IsOfflineGame() );
		pMissionSource->FindSavedCampaigns(m_nOffset, m_iNumSlots, bMulti, (m_hPlayer.Get() && bMulti) ? m_hPlayer->GetASWNetworkID() : NULL);
		m_iNumSavedCampaigns = pMissionSource->GetNumSavedCampaigns(bMulti, (m_hPlayer.Get() && bMulti) ? m_hPlayer->GetASWNetworkID() : NULL);
		// copy them from the local source into our networked array
		ASW_Mission_Chooser_Saved_Campaign* saved = pMissionSource->GetSavedCampaigns();
		for (int i=0;i<m_iNumSlots;i++)
		{
			if (i<ASW_SAVES_PER_PAGE && Q_strcmp(saved[i].m_szSaveName, STRING(m_iszSaveNames[i])))
			{
				m_iszSaveNames.Set(i, AllocPooledString(saved[i].m_szSaveName));
				m_iszSaveCampaignNames.Set(i, AllocPooledString(saved[i].m_szCampaignName));
				m_iszSaveDateTimes.Set(i, AllocPooledString(saved[i].m_szDateTime));
				m_iszSavePlayerNames.Set(i, AllocPooledString(saved[i].m_szPlayerNames));
				m_iSaveMissionsComplete.Set(i, saved[i].m_iMissionsComplete);
			}
		}
	}
	
	SetThink( &CASW_Voting_Missions::ScanThink );
	SetNextThink(gpGlobals->curtime + 0.1f);
}
예제 #5
0
void GameSettings::UpdateMissionImage()
{	
	vgui::ImagePanel* imgLevelImage = dynamic_cast< vgui::ImagePanel* >( FindChildByName( "ImgLevelImage" ) );
	if( !imgLevelImage )
		return;

	vgui::Label *pMissionLabel = dynamic_cast< vgui::Label* >( FindChildByName( "MissionLabel" ) );


	DropDownMenu *menu = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpSelectMission", true ) );
#if 0
	IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if ( !pSource || !m_pSettings || !menu )
		return;

	const char *szGameType = m_pSettings->GetString( "game/mode", "campaign" );
	if ( !Q_stricmp( szGameType, "campaign" ) )
	{
		const char *szCampaign = m_pSettings->GetString( "game/campaign", NULL );
		if ( szCampaign )
		{
			KeyValues *pCampaignKeys = pSource->GetCampaignDetails( szCampaign );
			if ( pCampaignKeys )
			{
				//imgLevelImage->SetImage( pCampaignKeys->GetString( "ChooseCampaignTexture" ) );
				pMissionLabel->SetText( pCampaignKeys->GetString( "CampaignName" ) );
				menu->SetCurrentSelection( pCampaignKeys->GetString( "CampaignName" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( true );

			const char *szMission = m_pSettings->GetString( "game/mission", NULL );
			if ( szMission )
			{
				KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
				if ( pMissionKeys )
				{
					m_drpStartingMission->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
					imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				}
			}
		}
	}
	else if ( !Q_stricmp( szGameType, "single_mission" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
			if ( pMissionKeys )
			{
				// TODO: Handle missions without an image
				imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				pMissionLabel->SetText( pMissionKeys->GetString( "missiontitle" ) );
				menu->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
#else
	const char *szGameType = m_pSettings->GetString( "game/mode", "sdk" );
	if ( !Q_stricmp( szGameType, "sdk" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			pMissionLabel->SetText( szMission );
			menu->SetCurrentSelection( szMission );
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
	else if( !Q_stricmp( szGameType, "swarmkeeper" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			char path[256];
			Q_snprintf( path, 256, "maps/%s.res", szMission );
			KeyValues *pData = new KeyValues("Data");
			if( pData && pData->LoadFromFile( filesystem, path ) )
			{
				imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
				pMissionLabel->SetText( pData->GetString( "title" ) );
				menu->SetCurrentSelection( pData->GetString( "title" ) );
			}
			else
			{
				imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
				pMissionLabel->SetText( szMission );
				menu->SetCurrentSelection( szMission );
			}

			if( pData ) pData->deleteThis();
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
#endif // 0
}
void CNB_Select_Campaign_Entry::OnThink()
{
	BaseClass::OnThink();

	IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;

	// TODO: If voting, then use:
	//IASW_Mission_Chooser_Source *pSource = GetVotingMissionSource();

	if ( !pSource )
	{
		//Warning( "Unable to select a mission as couldn't find an IASW_Mission_Chooser_Source\n" );
		return;
	}

	color32 white;
	white.r = 255;
	white.g = 255;
	white.b = 255;
	white.a = 255;

	ASW_Mission_Chooser_Mission *pMission = pSource->GetCampaign( m_nCampaignIndex );
	if ( pMission )
	{
		if ( Q_strcmp( pMission->m_szMissionName, m_szCampaignName ) )
		{			
			Q_snprintf(m_szCampaignName, sizeof(m_szCampaignName), "%s", pMission->m_szMissionName);

			if (m_szCampaignName[0] == '\0')
			{
				m_pName->SetText( "" );
				m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED, "vgui/swarm/MissionPics/UnknownMissionPic", white );
				return;
			}

			KeyValues *pKeys = pSource->GetCampaignDetails( m_szCampaignName );

			if ( !pKeys )
			{
				m_pName->SetText( m_szCampaignName );
				if (m_pImage)
				{
					m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED, "vgui/swarm/MissionPics/UnknownMissionPic", white );
					m_pImage->SetVisible( true );
				}
			}
			else
			{
				const char *szTitle = pKeys->GetString("CampaignName");
				if (szTitle[0] == '\0')
					m_pName->SetText( m_szCampaignName );
				else
					m_pName->SetText( szTitle );
				if (m_pImage)
				{
					const char *szImage = pKeys->GetString("ChooseCampaignTexture");
					if (szImage[0] == '\0')
					{
						//Msg("setting image for %s to unknown pic\n", m_m_szMissionName);
						m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED, "vgui/swarm/MissionPics/UnknownMissionPic", white );
					}
					else
					{
						//Msg("setting image for %s to %s\n", m_m_szMissionName, szImage);
						char imagename[MAX_PATH];
						Q_snprintf( imagename, sizeof(imagename), "vgui/%s", szImage );
						m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED, imagename, white );
						m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, imagename, white );
						m_pImage->SetImage( CBitmapButton::BUTTON_PRESSED, imagename, white );
					}
					m_pImage->SetVisible(true);
				}
			}
		}
	}
	else
	{
		m_pName->SetText( "" );
		m_pImage->SetImage( CBitmapButton::BUTTON_ENABLED, "vgui/swarm/MissionPics/UnknownMissionPic", white );
	}
}
void LaunchMissionVotePanel(int iChooserType, bool bAvoidTranslucency)
{
    // close any chooser frame already open
    if (g_hChooserFrame!=NULL)
    {
        CASW_Mission_Chooser_Frame *pFrame = g_hChooserFrame;
        pFrame->SetVisible(false);
        pFrame->MarkForDeletion();
        g_hChooserFrame = NULL;
    }

    if (iChooserType == -1)
        return;

    IASW_Mission_Chooser_Source *pSource = GetVotingMissionSource(); //missionchooser ? missionchooser->LocalMissionSource() : NULL;
    if (!pSource)
        return;

    pSource->ResetCurrentPage();

    // since we're voting, this must be multiplayer, so make sure the server hosts the game
    int iHostType = ASW_HOST_TYPE_CALLVOTE;
    //CBaseViewport
    Msg("LaunchMissionVotePanel\n");
    // ASWTODO - check this works even though parent is null
    CASW_Mission_Chooser_Frame *pFrame = new CASW_Mission_Chooser_Frame( GetClientMode()->GetViewport(), "MissionChooserFrame", iHostType, iChooserType, pSource );

    vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx(0, "resource/SwarmFrameScheme.res", "SwarmFrameScheme");
    pFrame->SetScheme(scheme);

    pFrame->SetTitle("#asw_vote_server", true);

    //pFrame->LoadControlSettings("Resource/UI/ScoreBoard.res");
    pFrame->SetTitleBarVisible(true);
    pFrame->SetMoveable(false);
    pFrame->SetSizeable(false);
    pFrame->SetMenuButtonVisible(false);
    pFrame->SetMaximizeButtonVisible(false);
    pFrame->SetMinimizeToSysTrayButtonVisible(false);
    pFrame->SetMinimizeButtonVisible(false);
    pFrame->SetCloseButtonVisible(true);

    pFrame->RequestFocus();
    pFrame->SetVisible(true);
    pFrame->SetEnabled(true);

    // make sure it shows up on the client panel

    if (enginevgui)
    {
        //vgui::VPANEL rootpanel = enginevgui->GetPanel( PANEL_CLIENTDLL );
        //pFrame->SetParent( rootpanel );

        /*
        // if another frame is up, make sure we have no transparency, since it's bugged and shows the level behind
        vgui::Panel* pPanel = pFrame->GetParent();
        if (pPanel)
        {
        int iChildren = pPanel->GetChildCount();
        for (int i=0;i<iChildren;i++)
        {
        vgui::Panel *pChild = dynamic_cast<vgui::Frame*>(pPanel->GetChild(i));
        if (pChild && pChild != pFrame)
        {
        pFrame->RemoveTranslucency();
        break;
        }
        }
        }*/
    }

    if (bAvoidTranslucency)
        pFrame->RemoveTranslucency();

    g_hChooserFrame = pFrame;
}
void LaunchMissionChooser(int iHostType, int iChooserType)
{
    if (g_hChooserFrame!=NULL)
    {
        CASW_Mission_Chooser_Frame *pFrame = g_hChooserFrame;
        pFrame->SetVisible(false);
        pFrame->MarkForDeletion();
        g_hChooserFrame = NULL;
    }
    // close any difficulty panels we have up
    if (g_hDifficultyFrame != NULL)
    {
        CASW_Difficulty_Chooser *pFrame = g_hDifficultyFrame;
        pFrame->SetVisible(false);
        pFrame->MarkForDeletion();
        g_hDifficultyFrame = NULL;
    }

    IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
    if (!pSource)
        return;

    if (iChooserType == ASW_CHOOSER_SAVED_CAMPAIGN)
    {
        // refresh these each time we bring up the panel, since new saves get created during play
        pSource->RefreshSavedCampaigns();
    }

    Msg("LaunchMissionChooser\n");
    // ASWTODO - check this works even though parent is null
    CASW_Mission_Chooser_Frame *pFrame = new CASW_Mission_Chooser_Frame( NULL, "MissionChooserFrame", iHostType, iChooserType, pSource );
    vgui::VPANEL rootpanel = enginevgui->GetPanel( PANEL_GAMEUIDLL );
    pFrame->SetParent( rootpanel );

    vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx(0, "resource/SwarmFrameScheme.res", "SwarmFrameScheme");
    pFrame->SetScheme(scheme);

    if (iHostType == ASW_HOST_TYPE_SINGLEPLAYER)
        pFrame->SetTitle("#asw_menu_singleplayer", true );
    else if (iHostType == ASW_HOST_TYPE_CREATESERVER)
        pFrame->SetTitle("#asw_menu_create_server", true );
    else
    {
        char buffer[256];
        Q_snprintf(buffer, sizeof(buffer), "Host type: %d chooser: %d", iHostType, iChooserType);
        pFrame->SetTitle(buffer, true );
    }
    //pFrame->LoadControlSettings("Resource/UI/ScoreBoard.res");

    pFrame->SetTitleBarVisible(true);
    pFrame->SetMoveable(false);
    pFrame->SetSizeable(false);
    pFrame->SetMenuButtonVisible(false);
    pFrame->SetMaximizeButtonVisible(false);
    pFrame->SetMinimizeToSysTrayButtonVisible(false);
    pFrame->SetMinimizeButtonVisible(false);
    pFrame->SetCloseButtonVisible(true);

    pFrame->RequestFocus();
    pFrame->SetVisible(true);
    pFrame->SetEnabled(true);

    pFrame->InvalidateLayout(true, true);

    ///g_hChooserFrame = pFrame;
}
예제 #9
0
//=============================================================================
void GameSettings::OnCommand(const char *command)
{
	if( V_strcmp( command, "cmd_gametype_campaign" ) == 0 )
	{
		KeyValues *kvUpdate = new KeyValues( "update" );
		kvUpdate->SetString( "game/mode", "campaign" );
		KeyValues *kvModification = new KeyValues( "settings" );
		kvModification->AddSubKey( kvUpdate );
		UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) );
		UpdateSelectMissionButton();
		UpdateMissionImage();
	}
	else if( V_strcmp( command, "cmd_gametype_single_mission" ) == 0 )
	{
		KeyValues *kvUpdate = new KeyValues( "update" );
		kvUpdate->SetString( "game/mode", "single_mission" );
		KeyValues *kvModification = new KeyValues( "settings" );
		kvModification->AddSubKey( kvUpdate );
		UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) );
		UpdateSelectMissionButton();
		UpdateMissionImage();
	}
	else if( V_strcmp( command, "cmd_change_mission" ) == 0 )
	{
		ShowMissionSelect();
	}
	else if ( V_strcmp( command, "cmd_change_starting_mission" ) == 0 )
	{
		ShowStartingMissionSelect();
	}
	else if ( char const *szMissionSelected = StringAfterPrefix( command, "cmd_mission_selected_" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" mission asi-jac1-landingbay01"
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		char stripped[MAX_PATH];
		V_StripExtension( szMissionSelected, stripped, MAX_PATH );
		pSettings->SetString( "update/game/mission", stripped );

		UpdateSessionSettings( pSettings );
		UpdateMissionImage();
	}
	else if ( char const *szCampaignSelected = StringAfterPrefix( command, "cmd_campaign_selected_" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" campaign jacob"
			" mission asi-jac1-landingbay01"
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		char stripped[MAX_PATH];
		V_StripExtension( szCampaignSelected, stripped, MAX_PATH );
		pSettings->SetString( "update/game/campaign", stripped );

		// set the current mission to the first real mission in the campaign
		IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
		if ( pSource )
		{
			KeyValues *pCampaignDetails = pSource->GetCampaignDetails( szCampaignSelected );
			bool bSkippedFirst = false;
			for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
			{
				if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
				{
					if ( !bSkippedFirst )
					{
						bSkippedFirst = true;
					}
					else
					{
						pSettings->SetString( "update/game/mission", pMission->GetString( "MapName", "asi-jac1-landingbay01" ) );
						break;
					}
				}
			}
		}

		UpdateSessionSettings( pSettings );
		UpdateMissionImage();
	}
	else if( V_strcmp( command, "JoinAny" ) == 0 )	// Join game in progress
	{
		DoCustomMatch( "game" );
	}
	else if( V_strcmp( command, "StartGame" ) == 0 )
	{
		char const *szNetwork = m_pSettings->GetString( "system/network", "offline" );
		if ( !Q_stricmp( szNetwork, "offline" ) )
		{
			if ( IsCustomMatchSearchCriteria() )
			{
				DoCustomMatch( "lobby" );
			}
			else
			{
				Navigate();
			}
		}
		else
		{
			// safety check if we aren't on live
			if( !CUIGameData::Get()->SignedInToLive() )
				SelectNetworkAccess( "lan", "public" );

			char const *szNetwork = m_pSettings->GetString( "system/network", "offline" );
			char const *szAccess = m_pSettings->GetString( "system/access", "public" );

			if ( !Q_stricmp( "LIVE", szNetwork ) &&
				!Q_stricmp( "public", szAccess ) )
			{
				if ( ui_game_allow_create_public.GetBool() )
				{
					OnCommand( "Create" );
					return;
				}

				// Instead of creating a new public lobby we're going to search
				// for any existing public lobbies that match these params!
				// This way people who take this path to a public lobby will still
				// be matched with humans (they might not end up a lobby leader).
				DoCustomMatch( "lobby" );
			}
			else
			{
				Navigate();
			}
		}
	}
	else if ( !Q_strcmp( command, "Create" ) )
	{
		Assert( !IsEditingExistingLobby() );
		g_pMatchFramework->CreateSession( m_pSettings );
	}
	else if ( char const *szNetworkType = StringAfterPrefix( command, "GameNetwork_" ) )
	{
		SelectNetworkAccess( szNetworkType, "public" );
	}
	else if ( char const *szAccessType = StringAfterPrefix( command, "GameAccess_" ) )
	{
		SelectNetworkAccess( "LIVE", szAccessType );
	}
// 	else if( V_strcmp( command, "StartLobby" ) == 0 )
// 	{
// 		
// 	}
	else if( V_strcmp( command, "Back" ) == 0 )
	{
		// Act as though 360 back button was pressed
		OnKeyCodePressed( ButtonCodeToJoystickButtonCode( KEY_XBUTTON_B, CBaseModPanel::GetSingleton().GetLastActiveUserId() ) );
	}
	else if ( const char *szDifficultyValue = StringAfterPrefix( command, "#L4D360UI_Difficulty_" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
				" game { "
					" difficulty = "
				" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetString( "update/game/difficulty", szDifficultyValue );

		UpdateSessionSettings( pSettings );

		if( m_drpDifficulty )
		{
			if ( FlyoutMenu* pFlyout = m_drpDifficulty->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_RegularFF" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" hardcoreFF = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/hardcoreFF", 0 );

		UpdateSessionSettings( pSettings );

		if( m_drpFriendlyFire )
		{
			if ( FlyoutMenu* pFlyout = m_drpFriendlyFire->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_HardcoreFF" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" hardcoreFF = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/hardcoreFF", 1 );

		UpdateSessionSettings( pSettings );

		if( m_drpFriendlyFire )
		{
			if ( FlyoutMenu* pFlyout = m_drpFriendlyFire->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_OnslaughtDisabled" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" onslaught = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/onslaught", 0 );

		UpdateSessionSettings( pSettings );

		if( m_drpOnslaught )
		{
			if ( FlyoutMenu* pFlyout = m_drpOnslaught->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_OnslaughtEnabled" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" onslaught = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/onslaught", 1 );

		UpdateSessionSettings( pSettings );

		if( m_drpOnslaught )
		{
			if ( FlyoutMenu* pFlyout = m_drpOnslaught->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_EnergyWeaponsDisabled" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" energyweapons = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/energyweapons", 0 );

		UpdateSessionSettings( pSettings );

		if( m_drpEnergyWeapons )
		{
			if ( FlyoutMenu* pFlyout = m_drpEnergyWeapons->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( !Q_strcmp( command, "#L4D360UI_EnergyWeaponsEnabled" ) )
	{
		KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
			" game { "
			" energyweapons = "
			" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/energyweapons", 1 );

		UpdateSessionSettings( pSettings );

		if( m_drpEnergyWeapons )
		{
			if ( FlyoutMenu* pFlyout = m_drpEnergyWeapons->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else if ( const char *szRoundLimitValue = StringAfterPrefix( command, "#L4D360UI_RoundLimit_" ) )
	{
		KeyValues *pSettings = new KeyValues( "update" );
		KeyValues::AutoDelete autodelete( pSettings );

		pSettings->SetInt( "update/game/maxrounds", atoi( szRoundLimitValue ) );

		UpdateSessionSettings( pSettings );


	}
	else if ( const char *szServerTypeValue = StringAfterPrefix( command, "#L4D360UI_ServerType_" ) )
	{
	KeyValues *pSettings = KeyValues::FromString(
			"update",
			" update { "
				" options { "
					" server x "
				" } "
			" } "
			);
		KeyValues::AutoDelete autodelete( pSettings );

		char chBuffer[64];
		Q_snprintf( chBuffer, sizeof( chBuffer ), "%s", szServerTypeValue );
		for ( char *pszUpper = chBuffer; *pszUpper; ++ pszUpper )
		{
			if ( isupper( *pszUpper ) )
				*pszUpper = tolower( *pszUpper );
		}

		pSettings->SetString( "update/options/server", chBuffer );

		UpdateSessionSettings( pSettings );

		if ( m_drpServerType )
		{
			if ( FlyoutMenu *pFlyout = m_drpServerType->GetCurrentFlyout() )
				pFlyout->SetListener( this );
		}
	}
	else
	{
		BaseClass::OnCommand( command );
	}
}
예제 #10
0
void GameSettings::UpdateMissionImage()
{	
	vgui::ImagePanel* imgLevelImage = dynamic_cast< vgui::ImagePanel* >( FindChildByName( "ImgLevelImage" ) );
	if( !imgLevelImage )
		return;

	vgui::Label *pMissionLabel = dynamic_cast< vgui::Label* >( FindChildByName( "MissionLabel" ) );


	DropDownMenu *menu = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpSelectMission", true ) );

	IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if ( !pSource || !m_pSettings || !menu )
		return;

	const char *szGameType = m_pSettings->GetString( "game/mode", "campaign" );
	if ( !Q_stricmp( szGameType, "campaign" ) )
	{
		const char *szCampaign = m_pSettings->GetString( "game/campaign", NULL );
		if ( szCampaign )
		{
			KeyValues *pCampaignKeys = pSource->GetCampaignDetails( szCampaign );
			if ( pCampaignKeys )
			{
				//imgLevelImage->SetImage( pCampaignKeys->GetString( "ChooseCampaignTexture" ) );
				pMissionLabel->SetText( pCampaignKeys->GetString( "CampaignName" ) );
				menu->SetCurrentSelection( pCampaignKeys->GetString( "CampaignName" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( true );

			const char *szMission = m_pSettings->GetString( "game/mission", NULL );
			if ( szMission )
			{
				KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
				if ( pMissionKeys )
				{
					m_drpStartingMission->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
					imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				}
			}
		}
	}
	else if ( !Q_stricmp( szGameType, "single_mission" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
			if ( pMissionKeys )
			{
				// TODO: Handle missions without an image
				imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				pMissionLabel->SetText( pMissionKeys->GetString( "missiontitle" ) );
				menu->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
}
예제 #11
0
void CNB_Select_Mission_Panel::OnThink()
{
	BaseClass::OnThink();

	IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;

	// TODO: If voting, then use:
	//IASW_Mission_Chooser_Source *pSource = GetVotingMissionSource();

	if ( !pSource )
	{
		//Warning( "Unable to select a mission as couldn't find an IASW_Mission_Chooser_Source\n" );
		return;
	}

	pSource->Think();

	KeyValues *pCampaignDetails = NULL;
	if ( m_szCampaignFilter[0] )
	{
		pCampaignDetails = pSource->GetCampaignDetails( m_szCampaignFilter );
	}
	int nCount = 0;
	if ( pCampaignDetails )
	{
		bool bSkippedFirst = false;
		for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
		{
			if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
			{
				if ( !bSkippedFirst )
				{
					bSkippedFirst = true;
				}
				else
				{
					const char *szMapName = pMission->GetString( "MapName", "asi-jac1-landingbay01" );
					int nMissionIndex = GetMissionIndex( pSource, szMapName );
					if ( nMissionIndex == -1 )
						continue;
					
					if ( m_pHorizList->m_Entries.Count() < nCount + 1 )
					{
						CNB_Select_Mission_Entry *pEntry = new CNB_Select_Mission_Entry( NULL, "Select_Mission_Entry" );
						m_pHorizList->AddEntry( pEntry );
					}
					CNB_Select_Mission_Entry *pEntry = dynamic_cast<CNB_Select_Mission_Entry*>( m_pHorizList->m_Entries[nCount].Get() );
					if ( pEntry )
					{
						pEntry->m_nMissionIndex = nMissionIndex;
					}
					nCount++;
				}
			}
		}
	}
	else
	{
		int nMissions = pSource->GetNumMissions( true );
		for ( int i = 0; i < nMissions; i++ )
		{
			
			//ASW_Mission_Chooser_Mission* pMission = pSource->GetMission( i, true );
			//if ( pMission && pCampaignKeys && !CampaignContainsMission( pCampaignKeys, pMission->m_szMissionName ) )
				//continue;
			if ( m_pHorizList->m_Entries.Count() < nCount + 1 )
			{
				CNB_Select_Mission_Entry *pEntry = new CNB_Select_Mission_Entry( NULL, "Select_Mission_Entry" );
				m_pHorizList->AddEntry( pEntry );
			}
			CNB_Select_Mission_Entry *pEntry = dynamic_cast<CNB_Select_Mission_Entry*>( m_pHorizList->m_Entries[nCount].Get() );
			if ( pEntry )
			{
				pEntry->m_nMissionIndex = i;
			}
			nCount++;
		}
	}

	// empty out remaining slots
	for ( int i = nCount; i < m_pHorizList->m_Entries.Count(); i++ )
	{
		CNB_Select_Mission_Entry *pEntry = dynamic_cast<CNB_Select_Mission_Entry*>( m_pHorizList->m_Entries[i].Get() );
		if ( pEntry )
		{
			pEntry->m_nMissionIndex = -1;
		}
	}
	if ( nCount != m_nLastCount )
	{
		m_nLastCount = nCount;
		InvalidateLayout( true, true );
	}
}