pfnConditionsMet CInstructor::GetBaseConditions(const CUtlString& sConditions) { if (sConditions == "WhoCares") return WhoCaresConditions; else if (sConditions == "ValidPlayer") return ValidPlayerConditions; else if (sConditions == "PlayerAlive") return PlayerAliveConditions; else if (sConditions == "PlayerDead") return PlayerDeadConditions; else if (sConditions == "PlayerCanReload") return PlayerCanReloadConditions; else if (sConditions == "PlayerOutOfAmmoAndMultipleWeapons") return PlayerOutOfAmmoAndMultipleWeaponsConditions; else if (sConditions == "PlayerHasMultipleWeapons") return PlayerHasMultipleWeaponsConditions; else if (sConditions == "PlayerActiveWeaponHasAimIn") return PlayerActiveWeaponHasAimInConditions; else if (sConditions == "PlayerHasGrenades") return PlayerHasGrenadesConditions; else if (sConditions == "PlayerHasSlowMo") return PlayerHasSlowMoConditions; else if (sConditions == "PlayerInThirdPerson") return PlayerInThirdPersonConditions; Assert(false); Error(std::string("Couldn't find lesson condition '").append(sConditions.Get()).append("'\n").c_str()); return NULL; }
bool Unserialize( CUtlBuffer &buf, CUtlString &dest ) { int nLen = buf.PeekDelimitedStringLength( s_pConv ); dest.SetLength( nLen - 1 ); // -1 because the length returned includes space for \0 buf.GetDelimitedString( s_pConv, dest.Get(), nLen ); return buf.IsValid(); }
//============================================================================= void DownloadCampaign::OnCommand(const char *command) { if ( Q_stricmp( command, "Continue" ) == 0 ) { CUtlString dest; if ( V_strnicmp( "http:", m_webSite.Get(), 4 ) != 0 || V_strnicmp( "https:", m_webSite.Get(), 4 ) != 0 ) { dest = "http://"; dest += m_webSite; } else { dest = m_webSite; } system()->ShellExecute("open", dest.Get() ); NavigateBack(); } else if ( Q_stricmp( command, "Back" ) == 0 ) { CBaseModPanel::GetSingleton().PlayUISound( UISOUND_BACK ); NavigateBack(); } else { BaseClass::OnCommand( command ); } }
void C_HudMapInfo::LevelInitPostEntity() { KeyValuesAD mapInfo("MapInfo"); MapData *pData = g_pMapCache->GetCurrentMapData(); if (pData) { mapInfo->SetString("mapName", pData->m_szMapName); CUtlString authors; if (pData->GetCreditString(&authors, CREDIT_AUTHOR)) { mapInfo->SetString("authors", authors.Get()); m_pMapAuthorLabel->SetText(CConstructLocalizedString(m_wMapAuthors, (KeyValues*)mapInfo)); } mapInfo->SetInt("difficulty", pData->m_MainTrack.m_iDifficulty); m_pMapDifficultyLabel->SetText(CConstructLocalizedString(m_wMapDifficulty, (KeyValues*)mapInfo)); } else { mapInfo->SetString("mapName", g_pGameRules->MapName()); m_pMapAuthorLabel->SetText(""); m_pMapDifficultyLabel->SetText(""); } m_pMapNameLabel->SetText(CConstructLocalizedString(m_wMapName, (KeyValues*)mapInfo)); }
//----------------------------------------------------------------------------- // Paints the overlay text //----------------------------------------------------------------------------- void CMiniViewportEngineRenderArea::PaintOverlayText( ) { if ( !m_OverlayText.Length() ) return; int cw, ch; GetSize( cw, ch ); int nTextWidth, nTextHeight; int nBufLen = m_OverlayText.Length()+1; wchar_t *pTemp = (wchar_t*)_alloca( nBufLen * sizeof(wchar_t) ); ::MultiByteToWideChar( CP_UTF8, 0, m_OverlayText.Get(), -1, pTemp, nBufLen ); g_pMatSystemSurface->GetTextSize( m_OverlayTextFont, pTemp, nTextWidth, nTextHeight ); int lx = (cw - nTextWidth) / 2; if ( lx < 10 ) { lx = 10; } int ly = ch - 10 - nTextHeight; g_pMatSystemSurface->DrawColoredTextRect( m_OverlayTextFont, lx, ly, cw - lx, ch - ly, 255, 255, 255, 255, m_OverlayText.Get() ); }
static bool Str_LessFunc( CUtlString const &a, CUtlString const &b ) { return strcmp(a.Get(), b.Get()) < 0; }
static bool ModelNamesLessFunc( CUtlString const &pLHS, CUtlString const &pRHS ) { return CaselessStringLessThan( pLHS.Get(), pRHS.Get() ); }
CUtlString::CUtlString( const CUtlString& string ) { Set( string.Get() ); }
//----------------------------------------------------------------------------- // String attribute //----------------------------------------------------------------------------- bool Serialize( CUtlBuffer &buf, const CUtlString &src ) { buf.PutDelimitedString( s_pConv, src.Get() ); return buf.IsValid(); }
static bool ReslistLessFunc( CUtlString const &pLHS, CUtlString const &pRHS ) { return CaselessStringLessThan( pLHS.Get(), pRHS.Get() ); }
virtual void OnTick() { BaseClass::OnTick(); double ultotal = 0.0; double ulnow = 0.0; if ( YouTube_GetUploadProgress( m_uploadHandle, ultotal, ulnow ) == false ) { Close(); ShowMessageBox( "#YouTube_Upload_Title", "#YouTube_Upload_Failure", "#GameUI_OK" ); } else if ( YouTube_IsUploadFinished( m_uploadHandle ) ) { bool bSuccess = true; CUtlString strURLToVideo; CUtlString strURLToVideoStats; if ( YouTube_GetUploadResults( m_uploadHandle, bSuccess, strURLToVideo, strURLToVideoStats ) && bSuccess ) { // mark movie uploaded m_pMovie->SetUploaded( true ); m_pMovie->SetUploadURL( strURLToVideoStats.Get() ); g_pReplayMovieManager->FlagMovieForFlush( m_pMovie, true ); // update the UI CReplayDetailsPanel *pDetailsPanel = dynamic_cast< CReplayDetailsPanel *>( GetParent() ); if ( pDetailsPanel ) { pDetailsPanel->InvalidateLayout( true, false ); } ShowMessageBox( "#YouTube_Upload_Title", "#YouTube_Upload_Success", "#GameUI_OK", NULL, GetParent() ); // notify the GC uint64 uSessionId = g_pClientReplayContext->GetServerSessionId( m_pMovie->GetReplayHandle() ); if ( uSessionId != 0 ) { GCSDK::CProtoBufMsg< CMsgReplayUploadedToYouTube > msg( k_EMsgGCReplay_UploadedToYouTube ); msg.Body().set_youtube_url( strURLToVideoStats.Get() ); msg.Body().set_youtube_account_name( YouTube_GetLoginName() ); msg.Body().set_session_id( uSessionId ); GCClientSystem()->BSendMessage( msg ); } surface()->PlaySound( "replay\\youtube_uploadfinished.wav" ); UploadOgsData( m_pMovie, true, "completed" ); // share on Steam Community if ( steamapicontext && steamapicontext->SteamRemoteStorage() ) { CUtlString strPreviewFileName; AppId_t nConsumerAppId = steamapicontext->SteamUtils()->GetAppID(); ERemoteStoragePublishedFileVisibility eVisibility = k_ERemoteStoragePublishedFileVisibilityPublic; SteamParamStringArray_t tags; tags.m_ppStrings = NULL; tags.m_nNumStrings = 0; // don't bother waiting for result SteamAPICall_t hSteamAPICall = steamapicontext->SteamRemoteStorage()->PublishVideo( k_EWorkshopVideoProviderNone, "", strURLToVideo.Get(), strPreviewFileName.Get(), nConsumerAppId, m_strTitle.Get(), m_strDescription.Get(), eVisibility, &tags ); hSteamAPICall; } } else { ShowMessageBox( "#YouTube_Upload_Title", "#YouTube_Upload_Failure", "#GameUI_OK" ); surface()->PlaySound( "replay\\youtube_uploadfailed.wav" ); UploadOgsData( m_pMovie, true, "failed" ); } // close wait dialog YouTube_ClearUploadResults( m_uploadHandle ); Close(); } else { float flProgress = MIN( ulnow / MAX( ultotal, 1.0 ), 1.0f ); int iProgress = int( 100.0 * flProgress ); int ulnow_kb = uint32( ulnow / 1024 ); int ultotal_kb = uint32( ultotal / 1024 ); if ( ulnow_kb == ultotal_kb ) { // we tick at 500 ms, so this should be ok m_iTick = ( m_iTick + 1 ) % 4; switch ( m_iTick ) { case 0: SetDialogVariable( "duration", g_pVGuiLocalize->Find( "YouTube_UploadFinishing1" ) ); break; case 1: SetDialogVariable( "duration", g_pVGuiLocalize->Find( "YouTube_UploadFinishing2" ) ); break; case 2: SetDialogVariable( "duration", g_pVGuiLocalize->Find( "YouTube_UploadFinishing3" ) ); break; case 3: SetDialogVariable( "duration", g_pVGuiLocalize->Find( "YouTube_UploadFinishing4" ) ); break; } } else { wchar_t wszProgress[1024]; wchar_t wszPercentage[32]; wchar_t wszNow[32]; wchar_t wszTotal[32]; _snwprintf( wszPercentage, ARRAYSIZE( wszPercentage ), L"%u", iProgress ); _snwprintf( wszNow, ARRAYSIZE( wszNow ), L"%u", ulnow_kb ); _snwprintf( wszTotal, ARRAYSIZE( wszTotal ), L"%u", ultotal_kb ); g_pVGuiLocalize->ConstructString( wszProgress,sizeof( wszProgress ), g_pVGuiLocalize->Find( "#YouTube_UploadProgress" ), 3, wszPercentage, wszNow, wszTotal ); SetDialogVariable( "duration", wszProgress ); } if ( m_pProgressBar ) { m_pProgressBar->SetProgress( flProgress ); } } }