diff --git a/engine/cl_ents_parse.cpp b/engine/cl_ents_parse.cpp index 9d96df85..03581216 100644 --- a/engine/cl_ents_parse.cpp +++ b/engine/cl_ents_parse.cpp @@ -451,7 +451,7 @@ void CL_PreserveExistingEntity( int nOldEntity ) return; } - pEnt->OnDataUnchangedInPVS(); +// pEnt->OnDataUnchangedInPVS(); } void CL_CopyExistingEntity( CEntityReadInfo &u ) diff --git a/engine/wscript b/engine/wscript index 161d1f4d..bcb28369 100755 --- a/engine/wscript +++ b/engine/wscript @@ -298,6 +298,7 @@ def build(bld): 'audio/private/voice_sound_engine_interface.cpp', #[!$X360] 'audio/private/voice_mixer_controls_openal.cpp', #[$OSXALL||$LINUXALL] 'audio/private/voice_record_openal.cpp', #[$OSXALL||$LINUXALL] + 'audio/private/voice_record_sdl.cpp', #[$OSXALL||$LINUXALL] '../public/vgui_controls/vgui_controls.cpp', '../common/vgui/vgui_basebudgetpanel.cpp', '../common/vgui/vgui_budgetbargraphpanel.cpp', diff --git a/game/client/NextBot/C_NextBot.cpp b/game/client/NextBot/C_NextBot.cpp deleted file mode 100644 index 13d55012..00000000 --- a/game/client/NextBot/C_NextBot.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// C_NextBot.cpp -// Client-side implementation of Next generation bot system -// Author: Michael Booth, April 2005 -//========= Copyright Valve Corporation, All rights reserved. ============// - -#include "cbase.h" -#include "C_NextBot.h" -#include "debugoverlay_shared.h" -#include -#include "viewrender.h" - -// memdbgon must be the last include file in a .cpp file!!! -#include "tier0/memdbgon.h" - -#undef NextBot - -ConVar NextBotShadowDist( "nb_shadow_dist", "400" ); - -//----------------------------------------------------------------------------- -IMPLEMENT_CLIENTCLASS_DT( C_NextBotCombatCharacter, DT_NextBot, NextBotCombatCharacter ) -END_RECV_TABLE() - - -//----------------------------------------------------------------------------- -C_NextBotCombatCharacter::C_NextBotCombatCharacter() -{ - // Left4Dead have surfaces too steep for IK to work properly - m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK; - - m_shadowType = SHADOWS_SIMPLE; - m_forcedShadowType = SHADOWS_NONE; - m_bForceShadowType = false; - - TheClientNextBots().Register( this ); -} - - -//----------------------------------------------------------------------------- -C_NextBotCombatCharacter::~C_NextBotCombatCharacter() -{ - TheClientNextBots().UnRegister( this ); -} - - -//----------------------------------------------------------------------------- -void C_NextBotCombatCharacter::Spawn( void ) -{ - BaseClass::Spawn(); -} - - -//----------------------------------------------------------------------------- -void C_NextBotCombatCharacter::UpdateClientSideAnimation() -{ - if (IsDormant()) - { - return; - } - - BaseClass::UpdateClientSideAnimation(); -} - - -//-------------------------------------------------------------------------------------------------------- -void C_NextBotCombatCharacter::UpdateShadowLOD( void ) -{ - ShadowType_t oldShadowType = m_shadowType; - - if ( m_bForceShadowType ) - { - m_shadowType = m_forcedShadowType; - } - else - { -#ifdef NEED_SPLITSCREEN_INTEGRATION - FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) - { - C_BasePlayer *pl = C_BasePlayer::GetLocalPlayer(hh); - if ( pl ) - { - Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer(hh)->GetAbsOrigin(); -#else - { - if ( C_BasePlayer::GetLocalPlayer() ) - { - Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer()->GetAbsOrigin(); -#endif - if ( delta.IsLengthLessThan( NextBotShadowDist.GetFloat() ) ) - { - m_shadowType = SHADOWS_RENDER_TO_TEXTURE_DYNAMIC; - } - else - { - m_shadowType = SHADOWS_SIMPLE; - } - } - else - { - m_shadowType = SHADOWS_SIMPLE; - } - } - } - - if ( oldShadowType != m_shadowType ) - { - DestroyShadow(); - } -} - - -//-------------------------------------------------------------------------------------------------------- -ShadowType_t C_NextBotCombatCharacter::ShadowCastType( void ) -{ - if ( !IsVisible() ) - return SHADOWS_NONE; - - if ( m_shadowTimer.IsElapsed() ) - { - m_shadowTimer.Start( 0.15f ); - UpdateShadowLOD(); - } - - return m_shadowType; -} - - -//-------------------------------------------------------------------------------------------------------- -bool C_NextBotCombatCharacter::GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const -{ - if ( pForcedShadowType ) - { - *pForcedShadowType = m_forcedShadowType; - } - return m_bForceShadowType; -} - -//-------------------------------------------------------------------------------------------------------- -/** - * Singleton accessor. - * By returning a reference, we guarantee construction of the - * instance before its first use. - */ -C_NextBotManager &TheClientNextBots( void ) -{ - static C_NextBotManager manager; - return manager; -} - - -//-------------------------------------------------------------------------------------------------------- -C_NextBotManager::C_NextBotManager( void ) -{ -} - - -//-------------------------------------------------------------------------------------------------------- -C_NextBotManager::~C_NextBotManager() -{ -} - - -//-------------------------------------------------------------------------------------------------------- -void C_NextBotManager::Register( C_NextBotCombatCharacter *bot ) -{ - m_botList.AddToTail( bot ); -} - - -//-------------------------------------------------------------------------------------------------------- -void C_NextBotManager::UnRegister( C_NextBotCombatCharacter *bot ) -{ - m_botList.FindAndRemove( bot ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -bool C_NextBotManager::SetupInFrustumData( void ) -{ -#ifdef ENABLE_AFTER_INTEGRATION - // Done already this frame. - if ( IsInFrustumDataValid() ) - return true; - - // Can we use the view data yet? - if ( !FrustumCache()->IsValid() ) - return false; - - // Get the number of active bots. - int nBotCount = m_botList.Count(); - - // Reset. - for ( int iBot = 0; iBot < nBotCount; ++iBot ) - { - // Get the current bot. - C_NextBotCombatCharacter *pBot = m_botList[iBot]; - if ( !pBot ) - continue; - - pBot->InitFrustumData(); - } - - FOR_EACH_VALID_SPLITSCREEN_PLAYER( iSlot ) - { - ACTIVE_SPLITSCREEN_PLAYER_GUARD( iSlot ); - // Get the active local player. - C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); - if ( !pPlayer ) - continue; - - for ( int iBot = 0; iBot < nBotCount; ++iBot ) - { - // Get the current bot. - C_NextBotCombatCharacter *pBot = m_botList[iBot]; - if ( !pBot ) - continue; - - // Are we in the view frustum? - Vector vecMin, vecMax; - pBot->CollisionProp()->WorldSpaceAABB( &vecMin, &vecMax ); - bool bInFrustum = !FrustumCache()->m_Frustums[iSlot].CullBox( vecMin, vecMax ); - - if ( bInFrustum ) - { - Vector vecSegment; - VectorSubtract( pBot->GetAbsOrigin(), pPlayer->GetAbsOrigin(), vecSegment ); - float flDistance = vecSegment.LengthSqr(); - if ( flDistance < pBot->GetInFrustumDistanceSqr() ) - { - pBot->SetInFrustumDistanceSqr( flDistance ); - } - - pBot->SetInFrustum( true ); - } - } - } - - // Mark as setup this frame. - m_nInFrustumFrame = gpGlobals->framecount; -#endif - - return true; -} - -//-------------------------------------------------------------------------------------------------------- diff --git a/game/client/NextBot/C_NextBot.h b/game/client/NextBot/C_NextBot.h deleted file mode 100644 index c26d7b9b..00000000 --- a/game/client/NextBot/C_NextBot.h +++ /dev/null @@ -1,134 +0,0 @@ -// C_NextBot.h -// Next generation bot system -// Author: Michael Booth, April 2005 -//========= Copyright Valve Corporation, All rights reserved. ============// - -#ifndef _C_NEXT_BOT_H_ -#define _C_NEXT_BOT_H_ - -#include "c_ai_basenpc.h" - -//---------------------------------------------------------------------------------------------------------------- -/** -* The interface holding IBody information -*/ -class IBodyClient -{ -public: - enum ActivityType - { - MOTION_CONTROLLED_XY = 0x0001, // XY position and orientation of the bot is driven by the animation. - MOTION_CONTROLLED_Z = 0x0002, // Z position of the bot is driven by the animation. - ACTIVITY_UNINTERRUPTIBLE= 0x0004, // activity can't be changed until animation finishes - ACTIVITY_TRANSITORY = 0x0008, // a short animation that takes over from the underlying animation momentarily, resuming it upon completion - ENTINDEX_PLAYBACK_RATE = 0x0010, // played back at different rates based on entindex - }; -}; - - -//-------------------------------------------------------------------------------------------------------- -/** - * The client-side implementation of the NextBot - */ -class C_NextBotCombatCharacter : public C_BaseCombatCharacter -{ -public: - DECLARE_CLASS( C_NextBotCombatCharacter, C_BaseCombatCharacter ); - DECLARE_CLIENTCLASS(); - - C_NextBotCombatCharacter(); - virtual ~C_NextBotCombatCharacter(); - -public: - virtual void Spawn( void ); - virtual void UpdateClientSideAnimation( void ); - virtual ShadowType_t ShadowCastType( void ); - virtual bool IsNextBot() { return true; } - void ForceShadowCastType( bool bForce, ShadowType_t forcedShadowType = SHADOWS_NONE ) { m_bForceShadowType = bForce; m_forcedShadowType = forcedShadowType; } - bool GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const; - - // Local In View Data. - void InitFrustumData( void ) { m_bInFrustum = false; m_flFrustumDistanceSqr = FLT_MAX; m_nInFrustumFrame = gpGlobals->framecount; } - bool IsInFrustumValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); } - void SetInFrustum( bool bInFrustum ) { m_bInFrustum = bInFrustum; } - bool IsInFrustum( void ) { return m_bInFrustum; } - void SetInFrustumDistanceSqr( float flDistance ) { m_flFrustumDistanceSqr = flDistance; } - float GetInFrustumDistanceSqr( void ) { return m_flFrustumDistanceSqr; } - -private: - ShadowType_t m_shadowType; // Are we LOD'd to simple shadows? - CountdownTimer m_shadowTimer; // Timer to throttle checks for shadow LOD - ShadowType_t m_forcedShadowType; - bool m_bForceShadowType; - void UpdateShadowLOD( void ); - - // Local In View Data. - int m_nInFrustumFrame; - bool m_bInFrustum; - float m_flFrustumDistanceSqr; - -private: - C_NextBotCombatCharacter( const C_NextBotCombatCharacter & ); // not defined, not accessible -}; - -//-------------------------------------------------------------------------------------------------------- -/** - * The C_NextBotManager manager - */ -class C_NextBotManager -{ -public: - C_NextBotManager( void ); - ~C_NextBotManager(); - - /** - * Execute functor for each NextBot in the system. - * If a functor returns false, stop iteration early - * and return false. - */ - template < typename Functor > - bool ForEachCombatCharacter( Functor &func ) - { - for( int i=0; i < m_botList.Count(); ++i ) - { - C_NextBotCombatCharacter *character = m_botList[i]; - if ( character->IsPlayer() ) - { - continue; - } - - if ( character->IsDormant() ) - { - continue; - } - - if ( !func( character ) ) - { - return false; - } - } - - return true; - } - - int GetActiveCount() { return m_botList.Count(); } - - bool SetupInFrustumData( void ); - bool IsInFrustumDataValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); } - -private: - friend class C_NextBotCombatCharacter; - - void Register( C_NextBotCombatCharacter *bot ); - void UnRegister( C_NextBotCombatCharacter *bot ); - - CUtlVector< C_NextBotCombatCharacter * > m_botList; ///< list of all active NextBots - - int m_nInFrustumFrame; -}; - -// singleton accessor -extern C_NextBotManager &TheClientNextBots( void ); - - -#endif // _C_NEXT_BOT_H_ diff --git a/game/client/abuse_report.cpp b/game/client/abuse_report.cpp deleted file mode 100644 index 285a633b..00000000 --- a/game/client/abuse_report.cpp +++ /dev/null @@ -1,720 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: Generic in-game abuse reporting -// -// $NoKeywords: $ -//=============================================================================// - -#include "cbase.h" -#include "abuse_report.h" -#include "abuse_report_ui.h" -#include "filesystem.h" -#include "imageutils.h" -#include "econ/confirm_dialog.h" -#include "econ/econ_notifications.h" - -inline bool IsLoggedOnToSteam() -{ - return steamapicontext != NULL && steamapicontext->SteamUser() != NULL && steamapicontext->SteamUser()->BLoggedOn(); -} - -const char CAbuseReportManager::k_rchScreenShotFilenameBase[] = "abuse_report"; -const char CAbuseReportManager::k_rchScreenShotFilename[] = "screenshots\\abuse_report.jpg"; - -//----------------------------------------------------------------------------- -class CEconNotification_AbuseReportReady : public CEconNotification -{ -public: - CEconNotification_AbuseReportReady() : CEconNotification() - { - m_bHasTriggered = false; - m_bShowInGame = false; - } - - ~CEconNotification_AbuseReportReady() - { - //if ( !m_bHasTriggered ) - //{ - // ReallyTrigger(); - //} - } - - virtual void MarkForDeletion() - { - m_bHasTriggered = true; - - CEconNotification::MarkForDeletion(); - } - - virtual bool BShowInGameElements() const { return m_bShowInGame; } - virtual EType NotificationType() { return eType_Trigger; } - virtual void Trigger() - { - ReallyTrigger(); - MarkForDeletion(); - } - - virtual const char *GetUnlocalizedHelpText() - { - return "#AbuseReport_Notification_Help"; - } - - static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast< CEconNotification_AbuseReportReady *>( pNotification ) != NULL; } - static bool IsInGameNotificationType( CEconNotification *pNotification ) - { - CEconNotification_AbuseReportReady *n = dynamic_cast< CEconNotification_AbuseReportReady *>( pNotification ); - return n != NULL && n->BShowInGameElements(); - } - - bool m_bShowInGame; - -private: - - void ReallyTrigger() - { - Assert( !m_bHasTriggered ); - m_bHasTriggered = true; - engine->ClientCmd_Unrestricted( "abuse_report_submit" ); - } - - bool m_bHasTriggered; -}; - -AbuseIncidentData_t::AbuseIncidentData_t() -{ - m_nScreenShotWaitFrames = 5; -} - -AbuseIncidentData_t::~AbuseIncidentData_t() -{ -} - -bool AbuseIncidentData_t::Poll() -{ - bool bReady = true; - - // Poll player data - for ( int i = 0 ; i < m_vecPlayers.Count() ; ++i ) - { - - // Make sure sure Steam knows we want the Avatar - PlayerData_t *p = &m_vecPlayers[i]; - if ( p->m_iSteamAvatarIndex < 0 ) - { - if ( steamapicontext && steamapicontext->SteamUser() ) - { - - p->m_iSteamAvatarIndex = steamapicontext->SteamFriends()->GetLargeFriendAvatar( p->m_steamID ); - if ( p->m_iSteamAvatarIndex < 0 ) - { - bReady = false; - } - } - else - { - p->m_iSteamAvatarIndex = 0; - } - } - } - - // Screenshot ready? - if ( !m_bitmapScreenshot.IsValid() && m_nScreenShotWaitFrames > 0 ) - { - --m_nScreenShotWaitFrames; - - // Just load the whole file into a memory buffer - char szFullPath[ MAX_PATH ] = ""; - if ( !g_pFullFileSystem->RelativePathToFullPath( CAbuseReportManager::k_rchScreenShotFilename, NULL, szFullPath, ARRAYSIZE(szFullPath) ) ) - { - Assert( false ); // ??? - } - - // Load it - - if ( g_pFullFileSystem->FileExists( szFullPath ) ) - { - - // Load the screenshot into a local buffer - if ( !g_pFullFileSystem->ReadFile( CAbuseReportManager::k_rchScreenShotFilename, NULL, m_bufScreenshotFileData ) ) - { - Warning( "Failed to read back %s\n", CAbuseReportManager::k_rchScreenShotFilename ); - m_nScreenShotWaitFrames = 0; - } - else - { - ConversionErrorType nErrorCode = ImgUtl_LoadBitmap( szFullPath, m_bitmapScreenshot ); - if ( nErrorCode != CE_SUCCESS ) - { - Warning( "Abuse report screenshot %s failed to load with error code %d\n", CAbuseReportManager::k_rchScreenShotFilename, nErrorCode ); - Assert( nErrorCode == CE_SUCCESS ); - m_nScreenShotWaitFrames = 0; - } - else - { - // !KLUDGE! Resize to power of two dimensions, since VGUI doesn't like odd sizes - ImgUtl_ResizeBitmap( m_bitmapScreenshot, 1024, 1024, &m_bitmapScreenshot ); - } - } - g_pFullFileSystem->RemoveFile( CAbuseReportManager::k_rchScreenShotFilename ); - } - } - - return bReady; -} - -CAbuseReportManager *g_AbuseReportMgr; - -CAbuseReportManager::CAbuseReportManager() -{ - m_pIncidentData = NULL; - m_bTestReport = false; - m_eIncidentDataStatus = k_EIncidentDataStatus_None; - m_bReportUIPending = false; - - // We're the singleton --- set global pointer - Assert( g_AbuseReportMgr == NULL ); - g_AbuseReportMgr = this; - m_timeLastReportReadyNotification = 0.0; - m_adrCurrentServer.Clear(); -} - -CAbuseReportManager::~CAbuseReportManager() -{ - Assert( m_pIncidentData == NULL ); -} - -char const *CAbuseReportManager::Name() -{ - return "AbuseRepotManager"; -} - -bool CAbuseReportManager::Init() -{ - // Clean out any temporary files - Assert( m_pIncidentData == NULL ); - DestroyIncidentData(); - - ListenForGameEvent( "teamplay_round_win" ); - ListenForGameEvent( "tf_game_over" ); - ListenForGameEvent( "player_death" ); - ListenForGameEvent( "server_spawn" ); - - return true; -} - -void CAbuseReportManager::LevelShutdownPreEntity() -{ - - // Don't keep the dialog open across a level transition. Don't discard their - // report data, but let's kill the dialog - if ( g_AbuseReportDlg.Get() != NULL ) - { - Warning( "Abuse report dialog open during level shutdown. Closing it.\n" ); - g_AbuseReportDlg.Get()->Close(); - } - - // And clear the 'pending' flag - m_bReportUIPending = false; -} - -void CAbuseReportManager::FireGameEvent( IGameEvent *event ) -{ - //C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); - - const char *eventname = event->GetName(); - - if ( !eventname || !eventname[0] ) - return; - - if ( - !Q_strcmp( "teamplay_round_win", eventname ) - || !Q_strcmp( "tf_game_over", eventname ) - ) { - // Periodically remind them that they have a report ready to file - CheckCreateReportReadyNotification( 60.0 * 5.0, true, 10.0f ); - } - else if ( !Q_strcmp( "player_death", eventname ) ) - { - // In some maps, the round just never ends. - // So make sure we do remind them every now and then about this. - // Just not too often - CheckCreateReportReadyNotification( 60.0 * 20.0, true, 5.0f ); - } - else if ( !Q_strcmp( "server_spawn", eventname ) ) - { - m_adrCurrentServer.Clear(); - m_adrCurrentServer.SetFromString( event->GetString( "address", "" ), false ); - m_adrCurrentServer.SetPort( event->GetInt( "port", 0 ) ); - - m_steamIDCurrentServer = CSteamID(); - if ( steamapicontext && steamapicontext->SteamUser() && GetUniverse() != k_EUniverseInvalid ) - { - m_steamIDCurrentServer.SetFromString( event->GetString( "steamid", "" ), GetUniverse() ); - } - } -} - -void CAbuseReportManager::Shutdown() -{ - // Close the dialog, if any - LevelShutdownPreEntity(); - - DestroyIncidentData(); - - // Clear global pointer - Assert( g_AbuseReportMgr == this ); - if ( g_AbuseReportMgr == this ) - { - g_AbuseReportMgr = NULL; - } -} - -void CAbuseReportManager::Update( float frametime ) -{ - - // if a dialog is already displayed, make sure we don't try to activate another - if ( g_AbuseReportDlg.Get() != NULL ) - { - m_bReportUIPending = false; - } - - // Poll report data, if any - if ( m_pIncidentData != NULL ) - { - if ( m_eIncidentDataStatus == k_EIncidentDataStatus_Preparing ) - { - if ( m_pIncidentData->Poll() ) - { - m_eIncidentDataStatus = k_EIncidentDataStatus_Ready; - CheckCreateReportReadyNotification( 1.0f, true, 7.0f ); - } - } - else - { - Assert( m_eIncidentDataStatus == k_EIncidentDataStatus_Ready ); - } - - if ( m_eIncidentDataStatus == k_EIncidentDataStatus_Ready && m_bReportUIPending ) - { - m_bReportUIPending = false; - ActivateSubmitReportUI(); - } - } - else - { - m_bReportUIPending = false; - } - - // Re-create notification constantly in the menu. - // While in game, we will only popup notifications - // periodically at round end or player death - CheckCreateReportReadyNotification( 10.0, false, 999.0f ); -} - -void CAbuseReportManager::SubmitReportUIRequested() -{ - if ( g_AbuseReportDlg.Get() != NULL ) - { - Assert( g_AbuseReportDlg.Get() == NULL ); - return; - } - - // If no report data already, then create some - if ( m_pIncidentData == NULL ) - { - QueueReport(); - if ( m_pIncidentData == NULL ) - { - // Failed - return; - } - } - - // Set flag to bring up the reporting UI at earliest opportunity, - // once all data has been fetched asynchronously - m_bReportUIPending = true; -} - -bool CAbuseReportManager::CreateAndPopulateIncident() -{ - Assert( m_pIncidentData == NULL ); - - // by default, just create the base class version - m_pIncidentData = new AbuseIncidentData_t; - - // And populate it - return PopulateIncident(); -} - -bool CAbuseReportManager::PopulateIncident() -{ - if ( m_pIncidentData == NULL ) - { - Assert( m_pIncidentData ); - return false; - } - - // Queue a screenshot - CUtlString cmd; - cmd.Format( "__screenshot_internal \"%s\"", k_rchScreenShotFilenameBase ); - engine->ClientCmd_Unrestricted( cmd ); - - // Set status as preparing - m_eIncidentDataStatus = k_EIncidentDataStatus_Preparing; - - m_pIncidentData->m_bCanReportGameServer = false; - - m_pIncidentData->m_adrGameServer.Clear(); - if ( - m_adrCurrentServer.IsValid() - && !m_adrCurrentServer.IsLocalhost() - && m_steamIDCurrentServer.IsValid() - && ( !m_adrCurrentServer.IsReservedAdr() || m_steamIDCurrentServer.GetEUniverse() != k_EUniversePublic ) - ) - { - m_pIncidentData->m_adrGameServer = m_adrCurrentServer; - m_pIncidentData->m_steamIDGameServer = m_steamIDCurrentServer; - m_pIncidentData->m_bCanReportGameServer = true; - } - - m_pIncidentData->m_matWorldToClip = engine->WorldToScreenMatrix(); - - // Add in players - for (int i = 1 ; i <= gpGlobals->maxClients ; ++i ) - { - CBasePlayer *player = UTIL_PlayerByIndex( i ); - - #ifndef _DEBUG - // Skip local players - if ( player != NULL && player->IsLocalPlayer() ) - { - continue; - } - #endif - - // Get player info from the engine. This works even if they haven't spawned yet. - player_info_t pi; - if ( !engine->GetPlayerInfo( i, &pi ) ) - { - continue; - } - - if ( pi.fakeplayer ) - { - continue; - } - if ( pi.friendsID == 0 ) - { - continue; - } - CSteamID steamID( pi.friendsID, 1, GetUniverse(), k_EAccountTypeIndividual ); - if ( !steamID.IsValid() ) - { - Assert( steamID.IsValid() ); - continue; - } - - int arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail(); - AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[ arrayIndex ]; - - p->m_iClientIndex = i; - p->m_steamID = steamID; - p->m_sPersona = pi.name; - p->m_bHasEntity = false; - p->m_bRenderBoundsValid = false; - p->m_screenBoundsMin.x = p->m_screenBoundsMin.y = 1.0f; - p->m_screenBoundsMax.x = p->m_screenBoundsMax.y = 0.0f; - - if ( player==NULL ) - { - continue; - } - - p->m_bHasEntity = true; - player->GetRenderBounds( p->m_vecRenderBoundsMin, p->m_vecRenderBoundsMax ); - p->m_matModelToWorld.CopyFrom3x4( player->RenderableToWorldTransform() ); - MatrixMultiply( m_pIncidentData->m_matWorldToClip, p->m_matModelToWorld, p->m_matModelToClip ); - - // Gather up screen extents - p->m_bRenderBoundsValid = false; - for ( int j = 0 ; j < 8 ; ++j ) - { - - // Get corner point in model space - Vector4D modelCorner( - ( j & 1 ) ? p->m_vecRenderBoundsMax.x : p->m_vecRenderBoundsMin.x, - ( j & 2 ) ? p->m_vecRenderBoundsMax.y : p->m_vecRenderBoundsMin.y, - ( j & 4 ) ? p->m_vecRenderBoundsMax.z : p->m_vecRenderBoundsMin.z, - 1.0f - ); - - // Transform to clip space - Vector4D clipCorner; - Vector4DMultiply( p->m_matModelToClip, modelCorner, clipCorner ); - - //Msg( "%6.3f, %6.3f, %6.3f, %6.3f\n", clipCorner[0], clipCorner[1], clipCorner[2], clipCorner[3] ); - - // If all points behind near clip plane, don't try to - // figure out screen space bounds - if ( clipCorner[3] > .1f ) - { - p->m_bRenderBoundsValid = true; - } - - // Push w forward to "near clip plane" - float w = MAX( clipCorner[3], .1f ); - - // Divide by w to project, and convert normalized device coordinates - // where the view volume is (-1...1), to normalized screen coords, where - // they are from 0...1 - float x = ( clipCorner[0] / w + 1.0f ) / 2.0f; - float y = ( -clipCorner[1] / w + 1.0f ) / 2.0f; - p->m_screenBoundsMin.x = MIN( p->m_screenBoundsMin.x, x ); - p->m_screenBoundsMax.x = MAX( p->m_screenBoundsMax.x, x ); - p->m_screenBoundsMin.y = MIN( p->m_screenBoundsMin.y, y ); - p->m_screenBoundsMax.y = MAX( p->m_screenBoundsMax.y, y ); - } - - // Clip projected rect to the screen - if ( p->m_bRenderBoundsValid ) - { - p->m_screenBoundsMin.x = MAX( p->m_screenBoundsMin.x, 0.0f ); - p->m_screenBoundsMax.x = MIN( p->m_screenBoundsMax.x, 1.0f ); - p->m_screenBoundsMin.y = MAX( p->m_screenBoundsMin.y, 0.0f ); - p->m_screenBoundsMax.y = MIN( p->m_screenBoundsMax.y, 1.0f ); - - p->m_bRenderBoundsValid = - p->m_screenBoundsMin.x + .01f < p->m_screenBoundsMax.x - && p->m_screenBoundsMin.y + .01f < p->m_screenBoundsMax.y; - } - - // Sanity check that we agree on what their steam ID is! - if ( player->GetSteamID( &steamID ) ) - { - Assert( p->m_steamID == steamID ); - } - } - - // Test harness: add in a handful of fake players - #ifdef _DEBUG - if ( m_bTestReport ) - { - int arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail(); - AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[ arrayIndex ]; - - p->m_iClientIndex = -1; - p->m_sPersona = "Lippencott"; - p->m_steamID.SetFromUint64( 148618791998333672 ); - - arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail(); - p = &m_pIncidentData->m_vecPlayers[ arrayIndex ]; - - p->m_iClientIndex = -1; - p->m_sPersona = "EricS"; - p->m_steamID.SetFromUint64( 148618791998195668 ); - - arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail(); - p = &m_pIncidentData->m_vecPlayers[ arrayIndex ]; - - p->m_iClientIndex = -1; - p->m_sPersona = "Sarenya"; - p->m_steamID.SetFromUint64( 148618791998429832 ); - - arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail(); - p = &m_pIncidentData->m_vecPlayers[ arrayIndex ]; - - - p->m_iClientIndex = -1; - p->m_sPersona = "fletch"; - p->m_steamID.SetFromUint64( 148618791998436114 ); - { - AbuseIncidentData_t::PlayerImage_t img; - img.m_eType = AbuseIncidentData_t::k_PlayerImageType_UGC; - img.m_hUGCHandle = 6978249415967519; - p->m_vecImages.AddToTail( img ); - } - - if ( !m_pIncidentData->m_bCanReportGameServer) - { - m_pIncidentData->m_adrGameServer.SetFromString( "123.45.67.89:27015", false ); - m_pIncidentData->m_steamIDGameServer = CSteamID( 12345, 0, GetUniverse(), k_EAccountTypeAnonGameServer ); - m_pIncidentData->m_bCanReportGameServer = true; - } - } - #endif - - // Make sure there is at least one other person we could file a report against! - if ( m_pIncidentData->m_vecPlayers.Count() < 1 ) - { - Warning( "No players to accuse of abuse, cannot file report\n" ); - return false; - } - - return true; -} - -void CAbuseReportManager::DestroyIncidentData() -{ - if ( m_pIncidentData != NULL ) - { - delete m_pIncidentData; - m_pIncidentData = NULL; - } - m_eIncidentDataStatus = k_EIncidentDataStatus_None; - - // Get rid of any existing screenshot file, both locally - // and in the cloud. We don't want this to count against - // our quota - if ( steamapicontext && steamapicontext->SteamRemoteStorage() && steamapicontext->SteamRemoteStorage()->FileExists( k_rchScreenShotFilename ) ) - { - steamapicontext->SteamRemoteStorage()->FileDelete( k_rchScreenShotFilename ); - } - - if ( g_pFullFileSystem->FileExists( k_rchScreenShotFilename ) ) // !KLUDGE! To prevent warning if the file doesn't exist! - { - g_pFullFileSystem->RemoveFile( k_rchScreenShotFilename ); - } - - m_timeLastReportReadyNotification = 0.0; - - // Make sure we don't have any notifications queued - NotificationQueue_Remove( &CEconNotification_AbuseReportReady::IsNotificationType ); -} - -void CAbuseReportManager::QueueReport() -{ - // Dialog is already active? - if ( g_AbuseReportDlg.Get() != NULL ) - { - Warning( "Cannot capture another incident report. Submission dialog is active.\n" ); - return; - } - - // Destroy any existing data - DestroyIncidentData(); - - // Make sure we're logged on to Steam - if ( !IsLoggedOnToSteam() ) - { - g_AbuseReportMgr->ShowNoSteamErrorMessage(); - return; - } - - if ( CreateAndPopulateIncident() ) - { - Msg( "Captured data for abuse report.\n"); - } - else - { - Warning( "Failed to captured data for abuse report.\n"); - DestroyIncidentData(); - } -} - -void CAbuseReportManager::ShowNoSteamErrorMessage() -{ - ShowMessageBox( "#AbuseReport_NoSteamTitle", "#AbuseReport_NoSteamMessage", "#GameUI_OK" ); -} - -void CAbuseReportManager::CheckCreateReportReadyNotification( float flMinSecondsSinceLastNotification, bool bInGame, float flLifetime ) -{ - // We have to have some data ready - if ( m_pIncidentData == NULL || m_eIncidentDataStatus != k_EIncidentDataStatus_Ready ) - { - return; - } - - // Don't pester them if they are already trying to do something about it - if ( g_AbuseReportDlg.Get() != NULL || m_bReportUIPending ) - { - return; - } - - // Already notified them too recently? - if ( m_timeLastReportReadyNotification != 0.0 && Plat_FloatTime() < m_timeLastReportReadyNotification + flMinSecondsSinceLastNotification ) - { - return; - } - - // Already a notification in the queue? - if ( bInGame ) - { - if ( NotificationQueue_Count( &CEconNotification_AbuseReportReady::IsInGameNotificationType ) > 0 ) - { - return; - } - } - else - { - if ( NotificationQueue_Count( &CEconNotification_AbuseReportReady::IsNotificationType ) > 0 ) - { - return; - } - } - - CreateReportReadyNotification( bInGame, flLifetime ); -} - -void CAbuseReportManager::CreateReportReadyNotification( bool bInGame, float flLifetime ) -{ - NotificationQueue_Remove( &CEconNotification_AbuseReportReady::IsNotificationType ); - CEconNotification_AbuseReportReady *pNotification = new CEconNotification_AbuseReportReady(); - pNotification->SetText( "AbuseReport_Notification" ); - pNotification->SetLifetime( flLifetime ); - pNotification->m_bShowInGame = bInGame; - NotificationQueue_Add( pNotification ); - - m_timeLastReportReadyNotification = Plat_FloatTime(); -} - -CON_COMMAND_F( abuse_report_queue, "Capture data for abuse report and queue for submission. Use abose_report_submit to activate UI to submit the report", FCVAR_DONTRECORD ) -{ - if ( !g_AbuseReportMgr ) - { - Warning( "abuse_report_queue: No abuse report manager, cannot create report.\n" ); - return; - } - - g_AbuseReportMgr->QueueReport(); -} - -CON_COMMAND_F( abuse_report_submit, "Activate UI to submit queued report. Use abuse_report_queue to capture data for the report the report", FCVAR_DONTRECORD ) -{ - if ( !g_AbuseReportMgr ) - { - Warning( "abuse_report_submit: No abuse report manager, cannot submit report.\n" ); - return; - } - - // Make sure we're logged on to Steam - if ( !IsLoggedOnToSteam() ) - { - g_AbuseReportMgr->ShowNoSteamErrorMessage(); - return; - } - - if ( g_AbuseReportDlg.Get() != NULL ) - { - // Dialog is already active - return; - } - g_AbuseReportMgr->SubmitReportUIRequested(); -} - -// Test harness -#ifdef _DEBUG - -CON_COMMAND_F( abuse_report_test, "Make a test abuse incident and activate UI", FCVAR_DONTRECORD ) -{ - if ( !g_AbuseReportMgr ) - { - Assert( g_AbuseReportMgr ); - return; - } - g_AbuseReportMgr->m_bTestReport = true; - g_AbuseReportMgr->QueueReport(); - g_AbuseReportMgr->m_bTestReport = false; - engine->ClientCmd_Unrestricted( "abuse_report_submit" ); -} - -#endif diff --git a/game/client/abuse_report.h b/game/client/abuse_report.h deleted file mode 100644 index 43410864..00000000 --- a/game/client/abuse_report.h +++ /dev/null @@ -1,274 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: Generic in-game abuse reporting -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef ABUSE_REPORT_H -#define ABUSE_REPORT_H -#ifdef _WIN32 -#pragma once -#endif - -#include -#include -#include -#include - -/// Different content types that can be reported as abusive. -/// -/// WARNING: These enum values MUST MATCH the values in Steam's -/// ECommunityContentType! -enum EAbuseReportContentType -{ - k_EAbuseReportContentNoSelection = -1, // dummy ilegal value: the user has not made a selection - k_EAbuseReportContentUnspecified = 0, // we use this to mean "other" - //k_EAbuseReportContentAll = 1, // reset all community content - k_EAbuseReportContentAvatarImage = 2, // clear avatar image - //k_EAbuseReportContentProfileText = 3, // reset profile text - //k_EAbuseReportContentWebLinks = 4, // delete web links - //k_EAbuseReportContentAnnouncement = 5, - //k_EAbuseReportContentEventText = 6, - //k_EAbuseReportContentCustomCSS = 7, - //k_EAbuseReportContentProfileURL = 8, // delete community URL ID - k_EAbuseReportContentComments = 9, // just comments this guy has written - k_EAbuseReportContentPersonaName = 10, // persona name - //k_EAbuseReportContentScreenshot = 11, // screenshot - //k_EAbuseReportContentVideo = 12, // videos - k_EAbuseReportContentCheating = 13, // cheating - k_EAbuseReportContentUGCImage = 14, // Image stored in UGC --- the report is accusing the image of being offensive - k_EAbuseReportContentActorUGCImage = 15, // Abuse report actor has uploaded a UGC image to server as supporting documentation of their claim -}; - - -/// Types of reasons why a violation report was issued -/// -/// WARNING: These enum values MUST MATCH the values in Steam's -/// EAbuseReportType! -enum EAbuseReportType -{ - k_EAbuseReportTypeNoSelection = -1, // dummy ilegal value: the user has not made a selection - k_EAbuseReportTypeUnspecified = 0, - k_EAbuseReportTypeInappropriate = 1, // just not ok to post - k_EAbuseReportTypeProhibited = 2, // prohibited by EULA or general law - k_EAbuseReportTypeSpamming = 3, // excessive spamming - k_EAbuseReportTypeAdvertisement = 4, // unwanted advertisement - //k_EAbuseReportTypeExploit = 5, // content data attempts to exploit code issue - k_EAbuseReportTypeSpoofing = 6, // user/group is impersonating an official contact - k_EAbuseReportTypeLanguage = 7, // bad language - k_EAbuseReportTypeAdultContent = 8, // any kind of adult material, references etc - k_EAbuseReportTypeHarassment = 9, // harassment, discrimination, racism etc - k_EAbuseReportTypeCheating = 10, // cheating -}; - -/// Container class that has everything we need to know in order to file -/// an abuse report, which is significantly more than the data we actually -/// include in a particular abuse report. It's everything we save off at the -/// time the user initiates the abuse reporting mechanism. Games can derive -/// their own report types and put game-specific data in here. -struct AbuseIncidentData_t -{ - AbuseIncidentData_t(); - virtual ~AbuseIncidentData_t(); - - enum EPlayerImageType - { - k_PlayerImageType_UGC, - k_PlayerImageType_Spray, - }; - - /// A custom image of the player's that could be considered offensive - struct PlayerImage_t - { - - /// What kind of image is it? - EPlayerImageType m_eType; - - /// For UGC images, what's the handle? - uint64 m_hUGCHandle; - }; - - /// Info we remember for one player. - struct PlayerData_t - { - PlayerData_t() - { - m_iClientIndex = -1; - m_iSteamAvatarIndex = -1; - } - - /// The client index. (See UTIL_PlayerByIndex). Note that this - /// index is really only valid at the time the incident is captured. - /// Because players can leave after the incident is captured. - int m_iClientIndex; - - /// The name they were going by at the time - CUtlString m_sPersona; - - /// Their steam ID. This is essential so we can file - /// an abuse report! - CSteamID m_steamID; - - /// Index of steam friends icon for their avatar. - /// 0 if they don't have one! - int m_iSteamAvatarIndex; - - /// Do we have an entity for this player? They might not have spawned, - /// or might be outside our PVS, etc. - bool m_bHasEntity; - - /// Model transform for the player's render stuff - VMatrix m_matModelToWorld; - - /// Model->clip matrix for the player's render stuff - VMatrix m_matModelToClip; - - /// True if the render bounds are approximately correct, false if not - bool m_bRenderBoundsValid; - - /// Bounds (in model space) of the player's renderable stuff - Vector m_vecRenderBoundsMin, m_vecRenderBoundsMax; - - /// Bounds (in normalized screen space coords 0...1) of the player's - /// renderable stuff - Vector2D m_screenBoundsMin, m_screenBoundsMax; - - /// List of his images - CUtlVector m_vecImages; - }; - - /// List of base player data. You got more data per player in your derived - /// incident type? Store it in a parallel array. - CUtlVector m_vecPlayers; - - /// Camera world -> clip matrix. - VMatrix m_matWorldToClip; - - /// Screenshot - Bitmap_t m_bitmapScreenshot; - - // Screenshot file data - CUtlBuffer m_bufScreenshotFileData; - - /// Number of frames we're willing to wait for the engine to write out a screenshot. - /// Zero if we already failed - int m_nScreenShotWaitFrames; - - /// Is it possible to report the game server itself for abuse? - bool m_bCanReportGameServer; - - /// What Game Server/IP are we on? Will be an invalid address if we don't know - netadr_t m_adrGameServer; - - /// Steam ID of the game server / IP we are on - CSteamID m_steamIDGameServer; - - /// Poll report (some data may have to be fetched asynchronously), - /// return true if everything is ready - virtual bool Poll(); -}; - -/// Generic abuse reporting panel. Your -class CAbuseReportManager : public CBaseGameSystemPerFrame, public CGameEventListener -{ -public: - CAbuseReportManager(); - virtual ~CAbuseReportManager(); - - // - // CAutoGameSystemPerFrame overrides - // - virtual char const *Name(); - virtual bool Init(); - virtual void Shutdown(); - virtual void LevelShutdownPreEntity(); - - // - // CGameEventListener overrides - // - virtual void FireGameEvent( IGameEvent *event ); - -// CAutoGameSystemPerFrame defines different stuff depending on which DLL we're building -#ifdef CLIENT_DLL - - // Do our frame-time processing - virtual void Update( float frametime ); - -#else - #error "Why is this being included?" -#endif - - /// Called when the console command is executed to capture data for a report - virtual void QueueReport(); - - /// Called when the console command is executed to submit data for a report - virtual void SubmitReportUIRequested(); - - /// Called to actually trigger the report UI, after all data is ready - virtual void ActivateSubmitReportUI() = 0; - - /// Fetch the incident that's queued to be reported - AbuseIncidentData_t *GetIncidentData() const { return m_pIncidentData; } - - /// Delete any current report incident. Also should clean - /// out any temporary files used by the incident system. - virtual void DestroyIncidentData(); - - /// Show a message box complaining about lack of steam - /// connection - virtual void ShowNoSteamErrorMessage(); - - /// Insert a a notification into the queue indicating that an unfiled report is ready - virtual void CreateReportReadyNotification( bool bInGame, float flLifetime ); - - /// Test harness. Set this to true, to generate fake data - bool m_bTestReport; - - static const char k_rchScreenShotFilenameBase[]; - static const char k_rchScreenShotFilename[]; - -protected: - - /// Your app will probably define its own abuse report types. - /// if so, you will need to override this function. - /// The base class just calls new to create an object, then calls - /// PopulateIncident() - virtual bool CreateAndPopulateIncident(); - - /// Fill in the details about the current incident. This just fills in the - /// base class data, and it should be called from CreateAndPopulateIncident - bool PopulateIncident(); - - /// Current incident that is pending to be reported or is being generated. - /// Might be NULL. - AbuseIncidentData_t *m_pIncidentData; - - /// Status of incident data. - enum EIncidentDataStatus - { - k_EIncidentDataStatus_None, - k_EIncidentDataStatus_Preparing, // we shuld call Poll() until it's ready - k_EIncidentDataStatus_Ready, // it's ready - }; - EIncidentDataStatus m_eIncidentDataStatus; - - /// Do we want to show the report UI as soon as the report is ready? - bool m_bReportUIPending; - - void CheckCreateReportReadyNotification( float flMinSecondsSinceLastNotification, bool bInGame, float flLifetime ); - - /// Time when we last pestered them about filing their report - double m_timeLastReportReadyNotification; - - /// Address of the lasts server we connected to - netadr_t m_adrCurrentServer; - CSteamID m_steamIDCurrentServer; - -}; - -/// Pointer to the app-specific instance. This pointer mght be NULL! Your -/// app should define set this pointer if it uses the system -extern CAbuseReportManager *g_AbuseReportMgr; - -#endif // ABUSE_REPORT_H diff --git a/game/client/abuse_report_ui.cpp b/game/client/abuse_report_ui.cpp deleted file mode 100644 index 0d1ab592..00000000 --- a/game/client/abuse_report_ui.cpp +++ /dev/null @@ -1,949 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: Generic in-game abuse reporting -// -// $NoKeywords: $ -//=============================================================================// - -#include "cbase.h" -#include "abuse_report_ui.h" -#include "econ/econ_controls.h" -#include "ienginevgui.h" -#include "vgui/ISurface.h" -#include -#include -#include -#include "vgui_bitmappanel.h" -#include "vgui_avatarimage.h" -#include "gc_clientsystem.h" -#include "econ/tool_items/tool_items.h" -#include "econ/econ_gcmessages.h" -#include "econ/confirm_dialog.h" -#include "tool_items/custom_texture_cache.h" - -vgui::DHANDLE g_AbuseReportDlg; - -CAbuseReportDlg::CAbuseReportDlg( vgui::Panel *parent, AbuseIncidentData_t *pIncidentData ) -: EditablePanel( parent, "AbuseReportSubmitDialog" ) -, m_pSubmitButton( NULL ) -, m_pScreenShot( NULL ) -, m_pScreenShotAttachCheckButton( NULL ) -, m_pOffensiveImage( NULL ) -, m_pDescriptionTextEntry( NULL ) -, m_pPlayerLabel( NULL ) -, m_pPlayerRadio( NULL ) -, m_pGameServerRadio( NULL ) -, m_pPlayerCombo( NULL ) -, m_pAbuseContentLabel( NULL ) -, m_pAbuseContentCombo( NULL ) -, m_pAbuseTypeLabel( NULL ) -, m_pAbuseTypeCombo( NULL ) -, m_pScreenShotBitmap( NULL ) -, m_pAvatarImage( NULL ) -, m_pNoAvatarLabel( NULL ) -, m_pCustomTextureImagePanel( NULL ) -, m_pNoCustomTexturesLabel( NULL ) -, m_pCustomTextureNextButton( NULL ) -, m_pCustomTexturePrevButton( NULL ) -, m_iUserImageIndex( 0 ) -, m_pIncidentData( pIncidentData ) -{ - vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ClientScheme.res", "ClientScheme" ); - SetScheme(scheme); - SetProportional( true ); - //m_pContainer = new vgui::EditablePanel( this, "Container" ); - - Assert( g_AbuseReportDlg.Get() == NULL ); - g_AbuseReportDlg.Set( this ); - - engine->ExecuteClientCmd("gameui_preventescape"); -} - -CAbuseReportDlg::~CAbuseReportDlg() -{ - Assert( g_AbuseReportDlg.Get() == this ); - if ( g_AbuseReportDlg.Get() == this ) - { - engine->ExecuteClientCmd("gameui_allowescape"); - g_AbuseReportDlg = NULL; - } -} - -void CAbuseReportDlg::OnCommand( const char *command ) -{ - if ( !Q_stricmp( command, "cancel" ) ) - { - Close(); - return; - } - if ( !Q_stricmp( command, "discard" ) ) - { - Close(); - g_AbuseReportMgr->DestroyIncidentData(); - return; - } - if ( !Q_stricmp( command, "submit" ) ) - { - OnSubmitReport(); - return; - } - if ( !Q_stricmp( command, "nextcustomtexture" ) ) - { - ++m_iUserImageIndex; - UpdateCustomTextures(); - return; - } - - if ( !Q_stricmp( command, "prevcustomtexture" ) ) - { - --m_iUserImageIndex; - UpdateCustomTextures(); - return; - } - -} - -void CAbuseReportDlg::MakeModal() -{ - TFModalStack()->PushModal( this ); - MakePopup(); - MoveToFront(); - SetKeyBoardInputEnabled( true ); - SetMouseInputEnabled( true ); - - // !KLUDGE! Initially set the dialog to be hidden, so we can take a screenshot! - SetEnabled( m_pIncidentData != NULL ); - //SetVisible( m_pIncidentData != NULL ); -} - -void CAbuseReportDlg::Close() -{ - TFModalStack()->PopModal( this ); - SetVisible( false ); - MarkForDeletion(); -} - -const char *CAbuseReportDlg::GetResFilename() -{ - return "Resource/UI/AbuseReportSubmitDialog.res"; - //return "Resource/UI/QuickplayDialog.res"; -} - -void CAbuseReportDlg::PerformLayout() -{ - BaseClass::PerformLayout(); - - // Center it, keeping requested size - int x, y, ww, wt, wide, tall; - vgui::surface()->GetWorkspaceBounds( x, y, ww, wt ); - GetSize(wide, tall); - SetPos(x + ((ww - wide) / 2), y + ((wt - tall) / 2)); - - // @todo setup -} - -class CCustomTextureImagePanel : public vgui::Panel -{ -public: - CCustomTextureImagePanel( Panel *parent, const char *panelName ) : vgui::Panel( parent, panelName ) - { - m_ugcHandle = 0; - } - - uint64 m_ugcHandle; - - virtual void Paint() - { - if ( m_ugcHandle == 0 ) - { - return; - } - int iTextureHandle = GetCustomTextureGuiHandle( m_ugcHandle ); - if ( iTextureHandle <= 0) - { - return; - } - - vgui::surface()->DrawSetColor(COLOR_WHITE); - vgui::surface()->DrawSetTexture( iTextureHandle ); - int iWide, iTall; - GetSize( iWide, iTall ); - - vgui::Vertex_t verts[4]; - verts[0].Init( Vector2D( 0, 0 ), Vector2D( 0.0f, 0.0f ) ); - verts[1].Init( Vector2D( iWide, 0 ), Vector2D( 1.0f, 0.0f ) ); - verts[2].Init( Vector2D( iWide, iTall ), Vector2D( 1.0f, 1.0f ) ); - verts[3].Init( Vector2D( 0, iTall ), Vector2D( 0.0f, 1.0f ) ); - - vgui::surface()->DrawTexturedPolygon( 4, verts ); - vgui::surface()->DrawSetColor(COLOR_WHITE); - } - -}; - -class CAbuseReportScreenShotPanel : public CBitmapPanel -{ -public: - CAbuseReportScreenShotPanel( CAbuseReportDlg *pDlg, const char *panelName ) - : CBitmapPanel( pDlg, panelName ) - , m_pDlg( pDlg ) - {} - - CAbuseReportDlg *m_pDlg; - - virtual void Paint() - { - CBitmapPanel::Paint(); - - const AbuseIncidentData_t::PlayerData_t *p = m_pDlg->GetAccusedPlayerPtr(); - if ( p == NULL || !p->m_bRenderBoundsValid ) - { - return; - } - int w, t; - GetSize( w, t ); - - int x0 = int( p->m_screenBoundsMin.x * (float)w ); - int y0 = int( p->m_screenBoundsMin.y * (float)t ); - int x1 = int( p->m_screenBoundsMax.x * (float)w ); - int y1 = int( p->m_screenBoundsMax.y * (float)t ); - - vgui::surface()->DrawSetColor( Color(200, 10, 10, 200 ) ); - vgui::surface()->DrawOutlinedRect( x0, y0, x1, y1 ); - vgui::surface()->DrawSetColor( COLOR_WHITE ); - } -}; - -void CAbuseReportDlg::ApplySchemeSettings( vgui::IScheme *pScheme ) -{ - EditablePanel::ApplySchemeSettings( pScheme ); - - m_pScreenShotBitmap = new CAbuseReportScreenShotPanel( this, "ScreenShotBitmap" ); - m_pCustomTextureImagePanel = new CCustomTextureImagePanel( this, "CustomTextureImage" ); - - LoadControlSettings( GetResFilename() ); - - m_pPlayerRadio = dynamic_cast(FindChildByName( "PlayerRadio", true )); - Assert( m_pPlayerRadio ); - if ( m_pPlayerRadio ) - { - m_pPlayerRadio->SetVisible( m_pIncidentData->m_bCanReportGameServer ); - } - - m_pGameServerRadio = dynamic_cast(FindChildByName( "GameServerRadio", true )); - Assert( m_pGameServerRadio ); - if ( m_pGameServerRadio ) - { - m_pGameServerRadio->SetVisible( m_pIncidentData->m_bCanReportGameServer ); - } - - m_pPlayerLabel = FindChildByName( "PlayerLabel", true ); - Assert( m_pPlayerLabel ); - - m_pScreenShotAttachCheckButton = dynamic_cast(FindChildByName( "ScreenShotAttachCheckButton", true )); - Assert( m_pScreenShotAttachCheckButton ); - if ( m_pScreenShotAttachCheckButton ) - { - m_pScreenShotAttachCheckButton->SetSelected( true ); - } - - m_pSubmitButton = dynamic_cast(FindChildByName( "SubmitButton", true )); - Assert( m_pSubmitButton ); - - m_pDescriptionTextEntry = dynamic_cast(FindChildByName( "DescriptionTextEntry", true )); - Assert( m_pDescriptionTextEntry ); - if ( m_pDescriptionTextEntry ) - { - m_pDescriptionTextEntry->SetMultiline( true ); - } - - m_pAvatarImage = dynamic_cast(FindChildByName( "AvatarImage", true )); - Assert( m_pAvatarImage ); - - m_pNoAvatarLabel = FindChildByName( "NoAvatarLabel", true ); - Assert( m_pNoAvatarLabel ); - - m_pNoCustomTexturesLabel = FindChildByName( "NoCustomTexturesLabel", true ); - Assert( m_pNoCustomTexturesLabel ); - - m_pCustomTextureNextButton = dynamic_cast(FindChildByName( "CustomTextureNextButton", true )); - Assert( m_pCustomTextureNextButton ); - - m_pCustomTexturePrevButton = dynamic_cast(FindChildByName( "CustomTexturePrevButton", true )); - Assert( m_pCustomTexturePrevButton ); - - m_pPlayerCombo = dynamic_cast(FindChildByName( "PlayerComboBox", true )); - Assert( m_pPlayerCombo ); - - m_pAbuseContentLabel = FindChildByName( "AbuseContentLabel", true ); - Assert( m_pAbuseContentLabel ); - - m_pAbuseContentCombo = dynamic_cast(FindChildByName( "AbuseContentComboBox", true )); - Assert( m_pAbuseContentCombo ); - if ( m_pAbuseContentCombo ) - { - m_pAbuseContentCombo->AddItem( "#AbuseReport_SelectOne", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentNoSelection ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentAvatarImage", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentAvatarImage ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentPlayerName", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentPersonaName ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentItemDecal", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentUGCImage ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentChatText", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentComments ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentCheating", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentCheating ) ); - m_pAbuseContentCombo->AddItem( "#AbuseReport_ContentOther", new KeyValues( "AbuseContent", "code", k_EAbuseReportContentUnspecified ) ); - m_pAbuseContentCombo->SilentActivateItemByRow( 0 ); - m_pAbuseContentCombo->SetNumberOfEditLines( m_pAbuseContentCombo->GetItemCount() ); - } - - m_pAbuseTypeLabel = FindChildByName( "AbuseTypeLabel", true ); - Assert( m_pAbuseTypeLabel ); - - m_pAbuseTypeCombo = dynamic_cast(FindChildByName( "AbuseTypeComboBox", true )); - Assert( m_pAbuseTypeCombo ); - - Assert( m_pScreenShotBitmap ); - if ( m_pScreenShotBitmap && m_pIncidentData->m_bitmapScreenshot.IsValid() ) - { - m_pScreenShotBitmap->SetBitmap( m_pIncidentData->m_bitmapScreenshot ); - } - - PopulatePlayerList(); - SetIsAccusingGameServer( false ); - - SetEnabled( true ); - SetVisible( true ); -} - -bool CAbuseReportDlg::IsAccusingGameServer() -{ - return m_pIncidentData && m_pIncidentData->m_bCanReportGameServer && m_pGameServerRadio && m_pGameServerRadio->IsSelected(); -} - -EAbuseReportContentType CAbuseReportDlg::GetAbuseContentType() -{ - if ( m_pAbuseContentCombo == NULL || IsAccusingGameServer() ) - { - Assert( m_pAbuseContentCombo ); - return k_EAbuseReportContentNoSelection; - } - KeyValues *pUserData = m_pAbuseContentCombo->GetActiveItemUserData(); - if ( pUserData == NULL ) - { - return k_EAbuseReportContentNoSelection; - } - return (EAbuseReportContentType)pUserData->GetInt( "code", k_EAbuseReportContentNoSelection ); -} - -EAbuseReportType CAbuseReportDlg::GetAbuseType() -{ - if ( m_pAbuseTypeCombo == NULL || IsAccusingGameServer() ) - { - Assert( m_pAbuseTypeCombo ); - return k_EAbuseReportTypeNoSelection; - } - KeyValues *pUserData = m_pAbuseTypeCombo->GetActiveItemUserData(); - if ( pUserData == NULL ) - { - return k_EAbuseReportTypeNoSelection; - } - return (EAbuseReportType)pUserData->GetInt( "code", k_EAbuseReportTypeNoSelection ); -} - -CUtlString CAbuseReportDlg::GetAbuseDescription() -{ - char buf[ 1024 ] = ""; - if ( m_pDescriptionTextEntry ) - { - m_pDescriptionTextEntry->GetText( buf, ARRAYSIZE(buf) ); - } - - return CUtlString( buf ); -} - -int CAbuseReportDlg::GetAccusedPlayerIndex() -{ - // If accusing a game server, then there's no player - if ( IsAccusingGameServer() ) - { - return -1; - } - - if ( m_pPlayerCombo == NULL ) - { - Assert( m_pPlayerCombo ); - return -1; - } - - // Item 0 is the "