コード例 #1
0
ファイル: main.cpp プロジェクト: FelipeBudinich/greenworks
		static void steamReadFromFile(uv_work_t *req) {
			FileIOAsync *readData = (FileIOAsync*)req->data;
			ISteamRemoteStorage *pSteamRemoteStorage = SteamRemoteStorage();

			// Check if file exists
			if (!pSteamRemoteStorage->FileExists(readData->sFilename.c_str())) {
				readData->bSuccess = false;
				readData->sError = "File doesn't exist";
				return;
			}

			int32 nFileSize = pSteamRemoteStorage->GetFileSize(readData->sFilename.c_str());

			char *sFileContents = new char[nFileSize+1];
			int32 cubRead = pSteamRemoteStorage->FileRead( readData->sFilename.c_str(), sFileContents, nFileSize );
			sFileContents[cubRead] = 0; // null-terminate

			if (cubRead == 0 && nFileSize > 0) {
				readData->bSuccess = false;
				readData->sError = "Error loading file";
			}
			else {
				readData->bSuccess = true;
				readData->sContent = sFileContents;
			}

			delete sFileContents;
			return;
		}
コード例 #2
0
ファイル: main.cpp プロジェクト: FelipeBudinich/greenworks
		static void steamGetCloudQuota(uv_work_t *req) {
			CloudQuota *quotaData = (CloudQuota*)req->data;
			ISteamRemoteStorage *pSteamRemoteStorage = SteamRemoteStorage();

			int nTotal = -1, nAvailable = -1;

			if (!pSteamRemoteStorage->GetQuota(&nTotal, &nAvailable)) {
				quotaData->bSuccess = false;
				return;
			}

			quotaData->bSuccess = true;
			quotaData->nTotalBytes = nTotal;
			quotaData->nAvailableBytes = nAvailable;

			return;
		}
コード例 #3
0
ファイル: main.cpp プロジェクト: FelipeBudinich/greenworks
		static void steamWriteToFile(uv_work_t *req) {
			FileIOAsync *writeData = (FileIOAsync*)req->data;
			ISteamRemoteStorage *pSteamRemoteStorage = SteamRemoteStorage();

			// Checking quota (in the future we may need it)
			int nTotal = -1, nAvailable = -1;

			if (!pSteamRemoteStorage->GetQuota(&nTotal, &nAvailable)) {
				writeData->sError = "Error getting Cloud quota";
				writeData->bSuccess = false;
				return;
			}

			writeData->bSuccess = pSteamRemoteStorage->FileWrite(writeData->sFilename.c_str(), writeData->sContent.c_str(), (int)strlen(writeData->sContent.c_str()));
			if (!writeData->bSuccess)
				writeData->sError = "Error writing to file. ";

			return;
		}
コード例 #4
0
//=============================================================================
void MainMenu::ApplySchemeSettings( IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	int screenWide, screenTall;
	surface()->GetScreenSize( screenWide, screenTall );
	float aspectRatio = (float)screenWide/(float)screenTall;
	bool bIsWidescreen = aspectRatio >= 1.5999f;

	DevMsg("Aspect Ratio: %f\n", aspectRatio);

	const char *pSettings = "Resource/UI/BaseModUI/MainMenu.res";

	if ( bIsWidescreen )
	{
		// use the widescreen version
		pSettings = "Resource/UI/BaseModUI/MainMenu_widescreen.res";
		Msg("Using widescreen scheme scheme file: %s\n", pSettings);
	}
	else
	{
		DevMsg("Using non-widescreen scheme file: %s\n", pSettings);
	}

	LoadControlSettings( pSettings );

/*	BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnPlaySolo" ) );
	if ( button )
	{

	}*/

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			bool bUsesCloud = false;

#ifdef IS_WINDOWS_PC
			ISteamRemoteStorage *pRemoteStorage = SteamClient()?(ISteamRemoteStorage *)SteamClient()->GetISteamGenericInterface(
				SteamAPI_GetHSteamUser(), SteamAPI_GetHSteamPipe(), STEAMREMOTESTORAGE_INTERFACE_VERSION ):NULL;
#else
			ISteamRemoteStorage *pRemoteStorage =  NULL; 
			AssertMsg( false, "This branch run on a PC build without IS_WINDOWS_PC defined." );
#endif

			int32 availableBytes, totalBytes = 0;
			if ( pRemoteStorage && pRemoteStorage->GetQuota( &totalBytes, &availableBytes ) )
			{
				if ( totalBytes > 0 )
				{
					bUsesCloud = true;
				}
			}

			pFlyout->SetControlEnabled( "BtnCloud", bUsesCloud );
		}
	}

	SetFooterState();

	if ( IsPC() )
	{
		vgui::Panel *firstPanel = FindChildByName( "BtnCoOp" );
		if ( firstPanel )
		{
			if ( m_ActiveControl )
			{
				m_ActiveControl->NavigateFrom( );
			}
			firstPanel->NavigateTo();
		}
	}
}
コード例 #5
0
ファイル: vmainmenu.cpp プロジェクト: Au-heppa/swarm-sdk
//=============================================================================
void MainMenu::ApplySchemeSettings( IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	const char *pSettings = "Resource/UI/BaseModUI/MainMenu.res";

#if !defined( _X360 )
	if ( !g_pMatchFramework->GetMatchSystem() )
	{
		Msg( "BAD!\n" );
	}
	if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager() )
	{
		Msg( "BAD PLAYER MANAGER!\n" );
	}
	if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( 0 ) )
	{
		pSettings = "Resource/UI/BaseModUI/MainMenuStub.res";
	}
#endif

	LoadControlSettings( pSettings );

	BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnPlaySolo" ) );
	if ( button )
	{
#ifdef _X360
		button->SetText( ( XBX_GetNumGameUsers() > 1 ) ? ( "#L4D360UI_MainMenu_PlaySplitscreen" ) : ( "#L4D360UI_MainMenu_PlaySolo" ) );
		button->SetHelpText( ( XBX_GetNumGameUsers() > 1 ) ? ( "#L4D360UI_MainMenu_OfflineCoOp_Tip" ) : ( "#L4D360UI_MainMenu_PlaySolo_Tip" ) );
#endif
	}

#ifdef _X360
	if ( !XBX_GetPrimaryUserIsGuest() )
	{
		wchar_t wszListText[ 128 ];
		wchar_t wszPlayerName[ 128 ];

		IPlayer *player1 = NULL;
		if ( XBX_GetNumGameUsers() > 0 )
		{
			player1 = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( 0 ) );
		}

		IPlayer *player2 = NULL;
		if ( XBX_GetNumGameUsers() > 1 )
		{
			player2 = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( 1 ) );
		}

		if ( player1 )
		{
			Label *pLblPlayer1GamerTag = dynamic_cast< Label* >( FindChildByName( "LblPlayer1GamerTag" ) );
			if ( pLblPlayer1GamerTag )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( player1->GetName(), wszPlayerName, sizeof( wszPlayerName ) );
				g_pVGuiLocalize->ConstructString( wszListText, sizeof( wszListText ), g_pVGuiLocalize->Find( "#L4D360UI_MainMenu_LocalProfilePlayer1" ), 1, wszPlayerName );

				pLblPlayer1GamerTag->SetVisible( true );
				pLblPlayer1GamerTag->SetText( wszListText );
			}
		}

		if ( player2 )
		{
			Label *pLblPlayer2GamerTag = dynamic_cast< Label* >( FindChildByName( "LblPlayer2GamerTag" ) );
			if ( pLblPlayer2GamerTag )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( player2->GetName(), wszPlayerName, sizeof( wszPlayerName ) );
				g_pVGuiLocalize->ConstructString( wszListText, sizeof( wszListText ), g_pVGuiLocalize->Find( "#L4D360UI_MainMenu_LocalProfilePlayer2" ), 1, wszPlayerName );

				pLblPlayer2GamerTag->SetVisible( true );
				pLblPlayer2GamerTag->SetText( wszListText );

				// in split screen, have player2 gamer tag instead of enable, and disable
				SetControlVisible( "LblPlayer2DisableIcon", true );
				SetControlVisible( "LblPlayer2Disable", true );
				SetControlVisible( "LblPlayer2Enable", false );
			}
		}
		else
		{
			SetControlVisible( "LblPlayer2DisableIcon", false );
			SetControlVisible( "LblPlayer2Disable", false );

			// not in split screen, no player2 gamertag, instead have enable
			SetControlVisible( "LblPlayer2GamerTag", false );
			SetControlVisible( "LblPlayer2Enable", true );
		}
	}
#endif

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			bool bUsesCloud = false;

#ifdef IS_WINDOWS_PC
			ISteamRemoteStorage *pRemoteStorage = SteamClient()?(ISteamRemoteStorage *)SteamClient()->GetISteamGenericInterface(
				SteamAPI_GetHSteamUser(), SteamAPI_GetHSteamPipe(), STEAMREMOTESTORAGE_INTERFACE_VERSION ):NULL;
#else
			ISteamRemoteStorage *pRemoteStorage =  NULL; 
			AssertMsg( false, "This branch run on a PC build without IS_WINDOWS_PC defined." );
#endif

			int32 availableBytes, totalBytes = 0;
			if ( pRemoteStorage && pRemoteStorage->GetQuota( &totalBytes, &availableBytes ) )
			{
				DevMsg("Accessing remote storage.  totalBytes = %i\n", totalBytes);
				if ( totalBytes > 0 )
				{
					DevMsg("Enabling cloud.\n");
					bUsesCloud = true;
				}
			}

			pFlyout->SetControlEnabled( "BtnCloud", bUsesCloud );
		}
	}

	SetFooterState();

	if ( IsX360() )
	{		
		GameModes *pGameModes =  dynamic_cast< GameModes* >( FindChildByName( "BtnGameModes" ) );	
		if ( pGameModes )
		{
			char lastActive[MAX_PATH];
			if ( pGameModes->GetLastActiveNameId( lastActive, sizeof( lastActive ) ) )
			{
				pGameModes->SetActive( lastActive, true );
			}
			else
			{
				pGameModes->SetActive( "BtnPlaySolo", true );
			}
			m_ActiveControl = pGameModes;
		}
	}

	if ( IsPC() )
	{
		vgui::Panel *firstPanel = FindChildByName( "BtnCoOp" );
		if ( firstPanel )
		{
			if ( m_ActiveControl )
			{
				m_ActiveControl->NavigateFrom( );
			}
			firstPanel->NavigateTo();
		}
	}

#if defined( _X360 ) && defined( _DEMO )
	SetControlVisible( "BtnExtras", !engine->IsDemoHostedFromShell() );
	SetControlVisible( "BtnQuit", engine->IsDemoHostedFromShell() );
#endif

	// CERT CATCH ALL JUST IN CASE!
#ifdef _X360
	bool bAllUsersCorrectlySignedIn = ( XBX_GetNumGameUsers() > 0 );
	for ( int k = 0; k < ( int ) XBX_GetNumGameUsers(); ++ k )
	{
		if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( k ) ) )
			bAllUsersCorrectlySignedIn = false;
	}
	if ( !bAllUsersCorrectlySignedIn )
	{
		Warning( "======= SIGNIN FAIL SIGNIN FAIL SIGNIN FAIL SIGNIN FAIL ==========\n" );
		Assert( 0 );
		CBaseModPanel::GetSingleton().CloseAllWindows( CBaseModPanel::CLOSE_POLICY_EVEN_MSGS );
		CAttractScreen::SetAttractMode( CAttractScreen::ATTRACT_GAMESTART );
		CBaseModPanel::GetSingleton().OpenWindow( WT_ATTRACTSCREEN, NULL, true );
		Warning( "======= SIGNIN RESET SIGNIN RESET SIGNIN RESET SIGNIN RESET ==========\n" );
	}
#endif
}