upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462900 additions and 495155 deletions
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
@@ -54,6 +54,7 @@ CClientScoreBoardDialog::CClientScoreBoardDialog(IViewPort *pViewPort) : Editabl
//memset(s_VoiceImage, 0x0, sizeof( s_VoiceImage ));
TrackerImage = 0;
m_pViewPort = pViewPort;
m_alignment = vgui::Label::a_center;
// initialize dialog
SetProportional(true);
@@ -75,12 +76,14 @@ CClientScoreBoardDialog::CClientScoreBoardDialog(IViewPort *pViewPort) : Editabl
// update scoreboard instantly if on of these events occure
ListenForGameEvent( "hltv_status" );
ListenForGameEvent( "replay_status" );
ListenForGameEvent( "server_spawn" );
m_pImageList = NULL;
m_mapAvatarsToImageList.SetLessFunc( DefLessFunc( CSteamID ) );
m_mapAvatarsToImageList.SetLessFunc( AvatarIndexLessFunc );
m_mapAvatarsToImageList.RemoveAll();
memset( &m_iImageAvatars, 0, sizeof(int) * (MAX_PLAYERS+1) );
}
//-----------------------------------------------------------------------------
@@ -122,7 +125,7 @@ void CClientScoreBoardDialog::OnThink()
if ( !g_pInputSystem->IsButtonDown( m_nCloseKey ) )
{
m_nCloseKey = BUTTON_CODE_INVALID;
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false );
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, false );
GetClientVoiceMgr()->StopSquelchMode();
}
}
@@ -158,6 +161,54 @@ void CClientScoreBoardDialog::InitScoreboardSections()
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CClientScoreBoardDialog::ApplySettings( KeyValues *inResourceData )
{
BaseClass::ApplySettings( inResourceData );
const char *alignmentString = inResourceData->GetString( "scoreboard_position", "" );
m_alignment = vgui::Label::a_center;
if ( !stricmp(alignmentString, "north-west") )
{
m_alignment = vgui::Label::a_northwest;
}
else if ( !stricmp(alignmentString, "north") )
{
m_alignment = vgui::Label::a_north;
}
else if ( !stricmp(alignmentString, "north-east") )
{
m_alignment = vgui::Label::a_northeast;
}
else if ( !stricmp(alignmentString, "west") )
{
m_alignment = vgui::Label::a_west;
}
else if ( !stricmp(alignmentString, "center") )
{
m_alignment = vgui::Label::a_center;
}
else if ( !stricmp(alignmentString, "east") )
{
m_alignment = vgui::Label::a_east;
}
else if ( !stricmp(alignmentString, "south-west") )
{
m_alignment = vgui::Label::a_southwest;
}
else if ( !stricmp(alignmentString, "south") )
{
m_alignment = vgui::Label::a_south;
}
else if ( !stricmp(alignmentString, "south-east") )
{
m_alignment = vgui::Label::a_southeast;
}
}
//-----------------------------------------------------------------------------
// Purpose: sets up screen
//-----------------------------------------------------------------------------
@@ -170,6 +221,7 @@ void CClientScoreBoardDialog::ApplySchemeSettings( IScheme *pScheme )
m_pImageList = new ImageList( false );
m_mapAvatarsToImageList.RemoveAll();
memset( &m_iImageAvatars, 0, sizeof(int) * (MAX_PLAYERS+1) );
PostApplySchemeSettings( pScheme );
}
@@ -239,6 +291,14 @@ void CClientScoreBoardDialog::FireGameEvent( IGameEvent *event )
m_HLTVSpectators = event->GetInt( "clients" );
m_HLTVSpectators -= event->GetInt( "proxies" );
}
else if ( Q_strcmp(type, "replay_status") == 0 )
{
// spectators = clients - proxies
m_ReplaySpectators = event->GetInt( "clients" );
m_ReplaySpectators -= event->GetInt( "proxies" );
}
else if ( Q_strcmp(type, "server_spawn") == 0 )
{
// We'll post the message ourselves instead of using SetControlString()
@@ -290,7 +350,7 @@ void CClientScoreBoardDialog::Update( void )
m_pPlayerList->SetSize(wide, m_iDesiredHeight);
}
MoveToCenterOfScreen();
PositionScoreboard();
// update every second
m_fNextUpdateTime = gpGlobals->curtime + 1.0f;
@@ -408,7 +468,7 @@ void CClientScoreBoardDialog::AddSection(int teamType, int teamNumber)
teamName = name;
}
g_pVGuiLocalize->ConstructString_safe( string1, g_pVGuiLocalize->Find("#Player"), 2, teamName );
g_pVGuiLocalize->ConstructString( string1, sizeof( string1 ), g_pVGuiLocalize->Find("#Player"), 2, teamName );
m_pPlayerList->AddSection(m_iSectionId, "", StaticPlayerSortFunc);
@@ -498,29 +558,36 @@ void CClientScoreBoardDialog::UpdatePlayerAvatar( int playerIndex, KeyValues *kv
{
if ( pi.friendsID )
{
CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
// See if we already have that avatar in our list
int iMapIndex = m_mapAvatarsToImageList.Find( steamIDForPlayer );
int iImageIndex;
if ( iMapIndex == m_mapAvatarsToImageList.InvalidIndex() )
// See if the avatar's changed
int iAvatar = steamapicontext->SteamFriends()->GetFriendAvatar( steamIDForPlayer, k_EAvatarSize32x32 );
if ( m_iImageAvatars[playerIndex] != iAvatar )
{
CAvatarImage *pImage = new CAvatarImage();
pImage->SetAvatarSteamID( steamIDForPlayer );
pImage->SetAvatarSize( 32, 32 ); // Deliberately non scaling
iImageIndex = m_pImageList->AddImage( pImage );
m_iImageAvatars[playerIndex] = iAvatar;
m_mapAvatarsToImageList.Insert( steamIDForPlayer, iImageIndex );
}
else
{
iImageIndex = m_mapAvatarsToImageList[ iMapIndex ];
// Now see if we already have that avatar in our list
int iIndex = m_mapAvatarsToImageList.Find( iAvatar );
if ( iIndex == m_mapAvatarsToImageList.InvalidIndex() )
{
CAvatarImage *pImage = new CAvatarImage();
pImage->SetAvatarSteamID( steamIDForPlayer );
pImage->SetAvatarSize( 32, 32 ); // Deliberately non scaling
int iImageIndex = m_pImageList->AddImage( pImage );
m_mapAvatarsToImageList.Insert( iAvatar, iImageIndex );
}
}
kv->SetInt( "avatar", iImageIndex );
int iIndex = m_mapAvatarsToImageList.Find( iAvatar );
CAvatarImage *pAvIm = (CAvatarImage *)m_pImageList->GetImage( iImageIndex );
pAvIm->UpdateFriendStatus();
if ( iIndex != m_mapAvatarsToImageList.InvalidIndex() )
{
kv->SetInt( "avatar", m_mapAvatarsToImageList[iIndex] );
CAvatarImage *pAvIm = (CAvatarImage *)m_pImageList->GetImage( m_mapAvatarsToImageList[iIndex] );
pAvIm->UpdateFriendStatus();
}
}
}
}
@@ -569,12 +636,53 @@ void CClientScoreBoardDialog::MoveLabelToFront(const char *textEntryName)
}
//-----------------------------------------------------------------------------
// Purpose: Center the dialog on the screen. (vgui has this method on
// Frame, but we're an EditablePanel, need to roll our own.)
// Purpose: Center the dialog on the screen.
//-----------------------------------------------------------------------------
void CClientScoreBoardDialog::MoveToCenterOfScreen()
void CClientScoreBoardDialog::PositionScoreboard()
{
int wx, wy, ww, wt;
surface()->GetWorkspaceBounds(wx, wy, ww, wt);
SetPos((ww - GetWide()) / 2, (wt - GetTall()) / 2);
ASSERT_LOCAL_PLAYER_RESOLVABLE();
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( GET_ACTIVE_SPLITSCREEN_SLOT() );
int wide, tall;
GetSize( wide, tall );
int hudWide, hudTall;
GetHudSize( hudWide, hudTall );
switch ( m_alignment )
{
case vgui::Label::a_northwest:
SetPos( 0, 0 );
break;
case vgui::Label::a_north:
SetPos( (hudWide - wide)/2, 0 );
break;
case vgui::Label::a_northeast:
SetPos( hudWide - wide, 0 );
break;
case vgui::Label::a_west:
SetPos( 0, (hudTall - tall)/2 );
break;
case vgui::Label::a_center:
SetPos( (hudWide - wide)/2, (hudTall - tall)/2 );
break;
case vgui::Label::a_east:
SetPos( hudWide - wide, (hudTall - tall)/2 );
break;
case vgui::Label::a_southwest:
SetPos( 0, hudTall - tall );
break;
case vgui::Label::a_south:
SetPos( (hudWide - wide)/2, hudTall - tall );
break;
case vgui::Label::a_southeast:
SetPos( hudWide - wide, hudTall - tall );
break;
}
}
+10 -6
View File
@@ -1,13 +1,17 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "IconPanel.h"
#include "iconpanel.h"
#include "KeyValues.h"
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
DECLARE_BUILD_FACTORY( CIconPanel );
CIconPanel::CIconPanel( vgui::Panel *parent, const char *name ) : vgui::Panel( parent, name )
@@ -21,9 +25,9 @@ void CIconPanel::ApplySettings( KeyValues *inResourceData )
{
Q_strncpy( m_szIcon, inResourceData->GetString( "icon", "" ), sizeof( m_szIcon ) );
m_icon = gHUD.GetIcon( m_szIcon );
m_icon = HudIcons().GetIcon( m_szIcon );
m_bScaleImage = inResourceData->GetInt("scaleImage", 0);
m_bScaleImage = inResourceData->GetBool( "scaleImage", false );
BaseClass::ApplySettings( inResourceData );
}
@@ -32,7 +36,7 @@ void CIconPanel::SetIcon( const char *szIcon )
{
Q_strncpy( m_szIcon, szIcon, sizeof(m_szIcon) );
m_icon = gHUD.GetIcon( m_szIcon );
m_icon = HudIcons().GetIcon( m_szIcon );
}
void CIconPanel::Paint()
@@ -61,7 +65,7 @@ void CIconPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
if ( m_szIcon[0] != '\0' )
{
m_icon = gHUD.GetIcon( m_szIcon );
m_icon = HudIcons().GetIcon( m_szIcon );
}
SetFgColor( pScheme->GetColor( "FgColor", Color( 255, 255, 255, 255 ) ) );
+1 -2
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -28,7 +28,6 @@ public:
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
void SetIcon( const char *szIcon );
void SetIconColor( Color cColor ) { m_IconColor = cColor; }
private:
CHudTexture *m_icon;
+74 -33
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: MapOverview.cpp: implementation of the CMapOverview class.
//
@@ -7,10 +7,10 @@
#include "cbase.h"
#include "mapoverview.h"
#include <vgui/ISurface.h>
#include <vgui/isurface.h>
#include <vgui/ILocalize.h>
#include <filesystem.h>
#include <KeyValues.h>
#include <keyvalues.h>
#include <convar.h>
#include "mathlib/mathlib.h"
#include <game/client/iviewport.h>
@@ -32,7 +32,18 @@ ConVar overview_tracks( "overview_tracks", "1", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_
ConVar overview_locked( "overview_locked", "1", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_CAN_EXECUTE, "Locks map angle, doesn't follow view angle.\n" );
ConVar overview_alpha( "overview_alpha", "1.0", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_CAN_EXECUTE, "Overview map translucency.\n" );
IMapOverviewPanel *g_pMapOverview = NULL; // we assume only one overview is created
static IMapOverviewPanel *g_pMapOverview[ MAX_SPLITSCREEN_PLAYERS ];
void SetMapOverView( int nSlot, IMapOverviewPanel *pPanel )
{
g_pMapOverview[ nSlot ] = pPanel;
}
IMapOverviewPanel *GetMapOverView()
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
return g_pMapOverview[ GET_ACTIVE_SPLITSCREEN_SLOT() ];
}
static int AdjustValue( int curValue, int targetValue, int amount )
{
@@ -56,7 +67,7 @@ static int AdjustValue( int curValue, int targetValue, int amount )
CON_COMMAND( overview_zoom, "Sets overview map zoom: <zoom> [<time>] [rel]" )
{
if ( !g_pMapOverview || args.ArgC() < 2 )
if ( !GetMapOverView() || args.ArgC() < 2 )
return;
float zoom = Q_atof( args[ 1 ] );
@@ -67,15 +78,15 @@ CON_COMMAND( overview_zoom, "Sets overview map zoom: <zoom> [<time>] [rel]" )
time = Q_atof( args[ 2 ] );
if ( args.ArgC() == 4 )
zoom *= g_pMapOverview->GetZoom();
zoom *= GetMapOverView()->GetZoom();
// We are going to store their zoom pick as the resultant overview size that it sees. This way, the value will remain
// correct even on a different map that has a different intrinsic zoom.
float desiredViewSize = 0.0f;
desiredViewSize = (zoom * OVERVIEW_MAP_SIZE * g_pMapOverview->GetFullZoom()) / g_pMapOverview->GetMapScale();
g_pMapOverview->SetPlayerPreferredViewSize( desiredViewSize );
desiredViewSize = (zoom * OVERVIEW_MAP_SIZE * GetMapOverView()->GetFullZoom()) / GetMapOverView()->GetMapScale();
GetMapOverView()->SetPlayerPreferredViewSize( desiredViewSize );
if( !g_pMapOverview->AllowConCommandsWhileAlive() )
if( !GetMapOverView()->AllowConCommandsWhileAlive() )
{
C_BasePlayer *localPlayer = CBasePlayer::GetLocalPlayer();
if( localPlayer && CBasePlayer::GetLocalPlayer()->IsAlive() )
@@ -84,12 +95,12 @@ CON_COMMAND( overview_zoom, "Sets overview map zoom: <zoom> [<time>] [rel]" )
return;// In the death cam spiral counts as alive
}
g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( g_pMapOverview->GetAsPanel(), "zoom", zoom, 0.0, time, vgui::AnimationController::INTERPOLATOR_LINEAR );
GetClientMode()->GetViewportAnimationController()->RunAnimationCommand( GetMapOverView()->GetAsPanel(), "zoom", zoom, 0.0, time, vgui::AnimationController::INTERPOLATOR_LINEAR );
}
CON_COMMAND( overview_mode, "Sets overview map mode off,small,large: <0|1|2>" )
{
if ( !g_pMapOverview )
if ( !GetMapOverView() )
return;
int mode;
@@ -97,7 +108,7 @@ CON_COMMAND( overview_mode, "Sets overview map mode off,small,large: <0|1|2>" )
if ( args.ArgC() < 2 )
{
// toggle modes
mode = g_pMapOverview->GetMode() + 1;
mode = GetMapOverView()->GetMode() + 1;
if ( mode > CMapOverview::MAP_MODE_FULL )
mode = CMapOverview::MAP_MODE_OFF;
@@ -109,9 +120,9 @@ CON_COMMAND( overview_mode, "Sets overview map mode off,small,large: <0|1|2>" )
}
if( mode != CMapOverview::MAP_MODE_RADAR )
g_pMapOverview->SetPlayerPreferredMode( mode );
GetMapOverView()->SetPlayerPreferredMode( mode );
if( !g_pMapOverview->AllowConCommandsWhileAlive() )
if( !GetMapOverView()->AllowConCommandsWhileAlive() )
{
C_BasePlayer *localPlayer = CBasePlayer::GetLocalPlayer();
if( localPlayer && CBasePlayer::GetLocalPlayer()->IsAlive() )
@@ -120,7 +131,7 @@ CON_COMMAND( overview_mode, "Sets overview map mode off,small,large: <0|1|2>" )
return;// In the death cam spiral counts as alive
}
g_pMapOverview->SetMode( mode );
GetMapOverView()->SetMode( mode );
}
//////////////////////////////////////////////////////////////////////
@@ -132,7 +143,7 @@ using namespace vgui;
CMapOverview::CMapOverview( const char *pElementName ) : BaseClass( NULL, pElementName ), CHudElement( pElementName )
{
SetParent( g_pClientMode->GetViewport()->GetVPanel() );
SetParent( GetClientMode()->GetViewport()->GetVPanel() );
SetBounds( 0,0, 256, 256 );
SetBgColor( Color( 0,0,0,100 ) );
@@ -173,7 +184,7 @@ CMapOverview::CMapOverview( const char *pElementName ) : BaseClass( NULL, pEleme
InitTeamColorsAndIcons();
g_pMapOverview = this; // for cvars access etc
SetMapOverView( GET_ACTIVE_SPLITSCREEN_SLOT(), this );
}
void CMapOverview::Init( void )
@@ -181,7 +192,7 @@ void CMapOverview::Init( void )
// register for events as client listener
ListenForGameEvent( "game_newmap" );
ListenForGameEvent( "round_start" );
ListenForGameEvent( "player_connect_client" );
ListenForGameEvent( "player_connect" );
ListenForGameEvent( "player_info" );
ListenForGameEvent( "player_team" );
ListenForGameEvent( "player_spawn" );
@@ -229,8 +240,7 @@ CMapOverview::~CMapOverview()
if ( m_MapKeyValues )
m_MapKeyValues->deleteThis();
g_pMapOverview = NULL;
SetMapOverView( GET_ACTIVE_SPLITSCREEN_SLOT(), NULL );
//TODO release Textures ? clear lists
}
@@ -320,7 +330,8 @@ void CMapOverview::UpdateFollowEntity()
if ( ent )
{
Vector position = MainViewOrigin(); // Use MainViewOrigin so SourceTV works in 3rd person
int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
Vector position = MainViewOrigin(nSlot); // Use MainViewOrigin so SourceTV works in 3rd person
QAngle angle = ent->EyeAngles();
if ( m_nFollowEntity <= MAX_PLAYERS )
@@ -564,15 +575,15 @@ void CMapOverview::DrawMapPlayerTrails()
player->trail[0] = WorldToMap ( player->position );
for ( int iTrail=0; iTrail<(MAX_TRAIL_LENGTH-1); iTrail++)
for ( int i=0; i<(MAX_TRAIL_LENGTH-1); i++)
{
if ( player->trail[iTrail +1].x == 0 && player->trail[iTrail +1].y == 0 )
if ( player->trail[i+1].x == 0 && player->trail[i+1].y == 0 )
break;
Vector2D pos1 = MapToPanel( player->trail[iTrail] );
Vector2D pos2 = MapToPanel( player->trail[iTrail +1] );
Vector2D pos1 = MapToPanel( player->trail[i] );
Vector2D pos2 = MapToPanel( player->trail[i+1] );
int intensity = 255 - float(255.0f * iTrail ) / MAX_TRAIL_LENGTH;
int intensity = 255 - float(255.0f * i) / MAX_TRAIL_LENGTH;
Vector2D dist = pos1 - pos2;
@@ -594,6 +605,9 @@ void CMapOverview::DrawObjects( )
{
MapObject_t *obj = &m_Objects[i];
if ( obj->flags & MAP_OBJECT_DONT_DRAW )
continue;
const char *text = NULL;
if ( Q_strlen(obj->name) > 0 )
@@ -663,7 +677,7 @@ bool CMapOverview::DrawIcon( MapObject_t *obj )
Vertex_t( MapToPanel ( pos4 ), Vector2D(0,1) )
};
surface()->DrawSetColor( 255, 255, 255, 255 );
surface()->DrawSetColor( obj->iconColor );
surface()->DrawSetTexture( textureID );
surface()->DrawTexturedPolygon( 4, points );
@@ -933,7 +947,7 @@ void CMapOverview::FireGameEvent( IGameEvent *event )
ResetRound();
}
else if ( Q_strcmp(type,"player_connect_client") == 0 )
else if ( Q_strcmp(type,"player_connect") == 0 )
{
int index = event->GetInt("index"); // = entity index - 1
@@ -1019,7 +1033,7 @@ void CMapOverview::SetMode(int mode)
{
ShowPanel( false );
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapOff" );
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence( "MapOff" );
}
else if ( mode == MAP_MODE_INSET )
{
@@ -1041,7 +1055,7 @@ void CMapOverview::SetMode(int mode)
if ( mode != m_nMode && RunHudAnimations() )
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToSmall" );
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToSmall" );
}
}
else if ( mode == MAP_MODE_FULL )
@@ -1061,7 +1075,7 @@ void CMapOverview::SetMode(int mode)
if ( mode != m_nMode && RunHudAnimations() )
{
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToLarge" );
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToLarge" );
}
}
@@ -1186,7 +1200,7 @@ bool CMapOverview::SetTeamColor(int team, Color color)
return true;
}
CMapOverview::MapObject_t* CMapOverview::FindObjectByID(int objectID)
MapObject_t* CMapOverview::FindObjectByID(int objectID)
{
for ( int i = 0; i < m_Objects.Count(); i++ )
{
@@ -1197,8 +1211,24 @@ CMapOverview::MapObject_t* CMapOverview::FindObjectByID(int objectID)
return NULL;
}
MapObject_t* CMapOverview::FindObjectByIndex(int objectIndex)
{
for ( int i = 0; i < m_Objects.Count(); i++ )
{
if ( m_Objects[i].index == objectIndex )
return &m_Objects[i];
}
return NULL;
}
int CMapOverview::AddObject( const char *icon, int entity, float timeToLive )
{
MapObject_t *pOldObject = FindObjectByIndex( entity );
if ( pOldObject )
return pOldObject->objectID;
MapObject_t obj; Q_memset( &obj, 0, sizeof(obj) );
obj.objectID = m_ObjectCounterID++;
@@ -1206,6 +1236,7 @@ int CMapOverview::AddObject( const char *icon, int entity, float timeToLive )
obj.icon = AddIconTexture( icon );
obj.size = m_flIconSize;
obj.status = -1;
obj.iconColor = Color( 255, 255, 255, 255 );
if ( timeToLive > 0 )
obj.endtime = gpGlobals->curtime + timeToLive;
@@ -1258,6 +1289,16 @@ void CMapOverview::SetObjectIcon( int objectID, const char *icon, float size )
obj->size = size;
}
void CMapOverview::SetObjectIconColor( int objectID, Color color )
{
MapObject_t* obj = FindObjectByID( objectID );
if ( !obj )
return;
obj->iconColor = color;
}
void CMapOverview::SetObjectPosition( int objectID, const Vector &position, const QAngle &angle )
{
MapObject_t* obj = FindObjectByID( objectID );
@@ -1337,4 +1378,4 @@ void CMapOverview::UpdateObjects()
obj->position = entity->GetAbsOrigin();
obj->angle = entity->GetAbsAngles();
}
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -11,7 +11,7 @@
#include <vgui/IScheme.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <KeyValues.h>
#include <convar.h>
@@ -25,7 +25,7 @@
using namespace vgui;
//--------------------------------------------------------------------------------------------------------------
CNavProgress::CNavProgress( IViewPort *pViewPort ) : Frame( NULL, PANEL_NAV_PROGRESS )
CNavProgress::CNavProgress( IViewPort *pViewPort ) : BaseClass( NULL, PANEL_NAV_PROGRESS )
{
// initialize dialog
m_pViewPort = pViewPort;
+2 -3
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
@@ -36,8 +36,7 @@ public:
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_NONE; }
virtual bool WantsBackgroundBlurred( void ) { return false; }
public:
+105 -70
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -27,7 +27,7 @@
#include "commandmenu.h"
#include "hltvcamera.h"
#if defined( REPLAY_ENABLED )
#include "replay/replaycamera.h"
#include "replaycamera.h"
#endif
#include <vgui_controls/TextEntry.h>
@@ -39,11 +39,6 @@
#include <shareddefs.h>
#include <igameresources.h>
#ifdef TF_CLIENT_DLL
#include "tf_gamerules.h"
void AddSubKeyNamed( KeyValues *pKeys, const char *pszName );
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -57,25 +52,14 @@ ConVar spec_scoreboard( "spec_scoreboard", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE
CSpectatorGUI *g_pSpectatorGUI = NULL;
// NB disconnect between localization text and observer mode enums
static const char *s_SpectatorModes[] =
{
"#Spec_Mode0", // OBS_MODE_NONE = 0,
"#Spec_Mode1", // OBS_MODE_DEATHCAM,
"", // OBS_MODE_FREEZECAM,
"#Spec_Mode2", // OBS_MODE_FIXED,
"#Spec_Mode3", // OBS_MODE_IN_EYE,
"#Spec_Mode4", // OBS_MODE_CHASE,
"#Spec_Mode5", // OBS_MODE_ROAMING,
};
static char *s_SpectatorModes[] = { "#Spec_Mode0", "#Spec_Mode1", "#Spec_Mode2", "#Spec_Mode3", "#Spec_Mode4", "#Spec_Mode5", "" };
using namespace vgui;
ConVar cl_spec_mode(
"cl_spec_mode",
"1",
FCVAR_ARCHIVE | FCVAR_USERINFO | FCVAR_SERVER_CAN_EXECUTE,
FCVAR_USERINFO | FCVAR_SERVER_CAN_EXECUTE,
"spectator mode" );
@@ -99,7 +83,7 @@ private:
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CSpectatorMenu::CSpectatorMenu( IViewPort *pViewPort ) : Frame( NULL, PANEL_SPECMENU )
CSpectatorMenu::CSpectatorMenu( IViewPort *pViewPort ) : BaseClass( NULL, PANEL_SPECMENU )
{
m_iDuckKey = BUTTON_CODE_INVALID;
@@ -138,12 +122,12 @@ CSpectatorMenu::CSpectatorMenu( IViewPort *pViewPort ) : Frame( NULL, PANEL_SPEC
m_pConfigSettings->SetOpenDirection( Menu::UP );
// create view config menu
CommandMenu * menu = new CommandMenu(m_pConfigSettings, "spectatormenu", gViewPortInterface);
CommandMenu * menu = new CommandMenu(m_pViewOptions, "spectatormenu", GetViewPortInterface());
menu->LoadFromFile( "Resource/spectatormenu.res" );
m_pConfigSettings->SetMenu( menu ); // attach menu to combo box
// create view mode menu
menu = new CommandMenu(m_pViewOptions, "spectatormodes", gViewPortInterface);
menu = new CommandMenu(m_pViewOptions, "spectatormodes", GetViewPortInterface());
menu->LoadFromFile("Resource/spectatormodes.res");
m_pViewOptions->SetMenu( menu ); // attach menu to combo box
@@ -294,7 +278,12 @@ void CSpectatorMenu::ShowPanel(bool bShow)
bool bIsEnabled = true;
if ( engine->IsHLTV() && HLTVCamera()->IsPVSLocked() )
#if defined( REPLAY_ENABLED )
if ( (g_bEngineIsHLTV && HLTVCamera()->IsPVSLocked()) ||
(engine->IsReplay() && ReplayCamera()->IsPVSLocked()) )
#else
if ( g_bEngineIsHLTV && HLTVCamera()->IsPVSLocked() )
#endif
{
// when watching HLTV or Replay with a locked PVS, some elements are disabled
bIsEnabled = false;
@@ -376,19 +365,6 @@ void CSpectatorMenu::Update( void )
break;
}
}
//=============================================================================
// HPE_BEGIN:
// [pfreese] make sure the view mode combo box is up to date - the spectator
// mode can be changed multiple ways
//=============================================================================
int specmode = GetSpectatorMode();
m_pViewOptions->SetText(s_SpectatorModes[specmode]);
//=============================================================================
// HPE_END
//=============================================================================
}
//-----------------------------------------------------------------------------
@@ -404,7 +380,6 @@ CSpectatorGUI::CSpectatorGUI(IViewPort *pViewPort) : EditablePanel( NULL, PANEL_
// m_bHelpShown = false;
// m_bInsetVisible = false;
// m_iDuckKey = KEY_NONE;
SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
m_bSpecScoreboard = false;
m_pViewPort = pViewPort;
@@ -455,23 +430,7 @@ CSpectatorGUI::~CSpectatorGUI()
//-----------------------------------------------------------------------------
void CSpectatorGUI::ApplySchemeSettings(IScheme *pScheme)
{
KeyValues *pConditions = NULL;
#ifdef TF_CLIENT_DLL
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() )
{
pConditions = new KeyValues( "conditions" );
AddSubKeyNamed( pConditions, "if_mvm" );
}
#endif
LoadControlSettings( GetResFile(), NULL, NULL, pConditions );
if ( pConditions )
{
pConditions->deleteThis();
}
LoadControlSettings("Resource/UI/Spectator.res");
m_pBottomBarBlank->SetVisible( true );
m_pTopBar->SetVisible( true );
@@ -484,9 +443,6 @@ void CSpectatorGUI::ApplySchemeSettings(IScheme *pScheme)
SetBorder( NULL );
#ifdef CSTRIKE_DLL
SetZPos(80); // guarantee it shows above the scope
#endif
}
//-----------------------------------------------------------------------------
@@ -516,10 +472,10 @@ void CSpectatorGUI::OnThink()
{
if ( m_bSpecScoreboard != spec_scoreboard.GetBool() )
{
if ( !spec_scoreboard.GetBool() || !gViewPortInterface->GetActivePanel() )
if ( !spec_scoreboard.GetBool() || !GetViewPortInterface()->GetActivePanel() )
{
m_bSpecScoreboard = spec_scoreboard.GetBool();
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, m_bSpecScoreboard );
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, m_bSpecScoreboard );
}
}
}
@@ -584,7 +540,7 @@ void CSpectatorGUI::ShowPanel(bool bShow)
SetVisible( bShow );
if ( !bShow && m_bSpecScoreboard )
{
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false );
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, false );
}
}
@@ -607,7 +563,7 @@ void CSpectatorGUI::Update()
int specmode = GetSpectatorMode();
int playernum = GetSpectatorTarget();
IViewPortPanel *overview = gViewPortInterface->FindPanelByName( PANEL_OVERVIEW );
IViewPortPanel *overview = GetViewPortInterface()->FindPanelByName( PANEL_OVERVIEW );
if ( overview && overview->IsVisible() )
{
@@ -648,14 +604,14 @@ void CSpectatorGUI::Update()
m_pPlayerLabel->SetFgColor( c );
wchar_t playerText[ 80 ], playerName[ 64 ], health[ 10 ];
V_wcsncpy( playerText, L"Unable to find #Spec_PlayerItem*", sizeof( playerText ) );
wcscpy( playerText, L"Unable to find #Spec_PlayerItem*" );
memset( playerName, 0x0, sizeof( playerName ) );
g_pVGuiLocalize->ConvertANSIToUnicode( UTIL_SafeName(gr->GetPlayerName( playernum )), playerName, sizeof( playerName ) );
int iHealth = gr->GetHealth( playernum );
if ( iHealth > 0 && gr->IsAlive(playernum) )
{
_snwprintf( health, ARRAYSIZE( health ), L"%i", iHealth );
_snwprintf( health, sizeof( health ), L"%i", iHealth );
g_pVGuiLocalize->ConstructString( playerText, sizeof( playerText ), g_pVGuiLocalize->Find( "#Spec_PlayerItem_Team" ), 2, playerName, health );
}
else
@@ -675,7 +631,7 @@ void CSpectatorGUI::Update()
wchar_t szTitleLabel[1024];
char tempstr[128];
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV )
{
// set spectator number and HLTV title
Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", HLTVCamera()->GetNumSpectators() );
@@ -684,6 +640,17 @@ void CSpectatorGUI::Update()
Q_strncpy( tempstr, HLTVCamera()->GetTitleText(), sizeof(tempstr) );
g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szTitleLabel,sizeof(szTitleLabel));
}
#if defined( REPLAY_ENABLED )
else if ( engine->IsReplay() )
{
// set spectator number and Replay title
Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", ReplayCamera()->GetNumSpectators() );
g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szEtxraInfo,sizeof(szEtxraInfo));
Q_strncpy( tempstr, ReplayCamera()->GetTitleText(), sizeof(tempstr) );
g_pVGuiLocalize->ConvertANSIToUnicode(tempstr,szTitleLabel,sizeof(szTitleLabel));
}
#endif
else
{
// otherwise show map name
@@ -709,7 +676,10 @@ void CSpectatorGUI::UpdateTimer()
int timer = 0;
V_swprintf_safe ( szText, L"%d:%02d\n", (timer / 60), (timer % 60) );
_snwprintf ( szText, sizeof( szText ), L"%d:%02d\n", (timer / 60), (timer % 60) );
szText[63] = 0;
SetLabelText("timerlabel", szText );
}
@@ -740,7 +710,7 @@ CON_COMMAND_F( spec_next, "Spectate next player", FCVAR_CLIENTCMD_CAN_EXECUTE )
if ( !pPlayer || !pPlayer->IsObserver() )
return;
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV )
{
// handle the command clientside
if ( !HLTVCamera()->IsPVSLocked() )
@@ -748,6 +718,16 @@ CON_COMMAND_F( spec_next, "Spectate next player", FCVAR_CLIENTCMD_CAN_EXECUTE )
HLTVCamera()->SpecNextPlayer( false );
}
}
#if defined( REPLAY_ENABLED )
else if ( engine->IsReplay() )
{
// handle the command clientside
if ( !ReplayCamera()->IsPVSLocked() )
{
ReplayCamera()->SpecNextPlayer( false );
}
}
#endif
else
{
ForwardSpecCmdToServer( args );
@@ -761,7 +741,7 @@ CON_COMMAND_F( spec_prev, "Spectate previous player", FCVAR_CLIENTCMD_CAN_EXECUT
if ( !pPlayer || !pPlayer->IsObserver() )
return;
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV )
{
// handle the command clientside
if ( !HLTVCamera()->IsPVSLocked() )
@@ -769,6 +749,16 @@ CON_COMMAND_F( spec_prev, "Spectate previous player", FCVAR_CLIENTCMD_CAN_EXECUT
HLTVCamera()->SpecNextPlayer( true );
}
}
#if defined( REPLAY_ENABLED )
else if ( engine->IsReplay() )
{
// handle the command clientside
if ( !ReplayCamera()->IsPVSLocked() )
{
ReplayCamera()->SpecNextPlayer( true );
}
}
#endif
else
{
ForwardSpecCmdToServer( args );
@@ -782,7 +772,7 @@ CON_COMMAND_F( spec_mode, "Set spectator mode", FCVAR_CLIENTCMD_CAN_EXECUTE )
if ( !pPlayer || !pPlayer->IsObserver() )
return;
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV )
{
if ( HLTVCamera()->IsPVSLocked() )
{
@@ -815,6 +805,41 @@ CON_COMMAND_F( spec_mode, "Set spectator mode", FCVAR_CLIENTCMD_CAN_EXECUTE )
// turn off auto director once user tried to change view settings
HLTVCamera()->SetAutoDirector( false );
}
#if defined( REPLAY_ENABLED )
else if ( engine->IsReplay() )
{
if ( ReplayCamera()->IsPVSLocked() )
{
// in locked mode we can only switch between first and 3rd person
ReplayCamera()->ToggleChaseAsFirstPerson();
}
else
{
// we can choose any mode, not loked to PVS
int mode;
if ( args.ArgC() == 2 )
{
// set specifc mode
mode = Q_atoi( args[1] );
}
else
{
// set next mode
mode = ReplayCamera()->GetMode()+1;
if ( mode > LAST_PLAYER_OBSERVERMODE )
mode = OBS_MODE_IN_EYE;
}
// handle the command clientside
ReplayCamera()->SetMode( mode );
}
// turn off auto director once user tried to change view settings
ReplayCamera()->SetAutoDirector( false );
}
#endif
else
{
// we spectate on a game server, forward command
@@ -832,7 +857,7 @@ CON_COMMAND_F( spec_player, "Spectate player by name", FCVAR_CLIENTCMD_CAN_EXECU
if ( args.ArgC() != 2 )
return;
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV )
{
// we can only switch primary spectator targets is PVS isnt locked by auto-director
if ( !HLTVCamera()->IsPVSLocked() )
@@ -840,6 +865,16 @@ CON_COMMAND_F( spec_player, "Spectate player by name", FCVAR_CLIENTCMD_CAN_EXECU
HLTVCamera()->SpecNamedPlayer( args[1] );
}
}
#if defined( REPLAY_ENABLED )
else if ( engine->IsReplay() )
{
// we can only switch primary spectator targets is PVS isnt locked by auto-director
if ( !ReplayCamera()->IsPVSLocked() )
{
ReplayCamera()->SpecNamedPlayer( args[1] );
}
}
#endif
else
{
ForwardSpecCmdToServer( args );
+55 -413
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
@@ -8,29 +8,22 @@
#include "basemodel_panel.h"
#include "activitylist.h"
#include "animation.h"
#include "vgui/IInput.h"
#include "vgui/iinput.h"
#include "matsys_controls/manipulator.h"
#include "bone_setup.h"
using namespace vgui;
extern float GetAutoPlayTime( void );
DECLARE_BUILD_FACTORY( CBaseModelPanel );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBaseModelPanel::CBaseModelPanel( vgui::Panel *pParent, const char *pName )
: BaseClass( pParent, pName )
, m_nActiveSequence( ACT_INVALID )
, m_flActiveSequenceDuration( 0.f )
CBaseModelPanel::CBaseModelPanel( vgui::Panel *pParent, const char *pName ): BaseClass( pParent, pName )
{
m_bForcePos = false;
m_bMousePressed = false;
m_bAllowRotation = false;
m_bAllowPitch = false;
m_bAllowFullManipulation = false;
m_bApplyManipulators = false;
m_bForcedCameraPosition = false;
vgui::SETUP_PANEL( this );
}
//-----------------------------------------------------------------------------
@@ -47,21 +40,13 @@ void CBaseModelPanel::ApplySettings( KeyValues *inResourceData )
{
BaseClass::ApplySettings( inResourceData );
// Set whether we render to texture
m_bRenderToTexture = inResourceData->GetBool( "render_texture", true );
m_bUseParticle = inResourceData->GetBool( "use_particle", false );
// Grab and set the camera FOV.
float flFOV = GetCameraFOV();
m_BMPResData.m_flFOV = inResourceData->GetInt( "fov", flFOV );
SetCameraFOV( m_BMPResData.m_flFOV );
// Do we allow rotation on these panels.
m_bAllowRotation = inResourceData->GetBool( "allow_rot", false );
m_bAllowPitch = inResourceData->GetBool( "allow_pitch", false );
// Do we allow full manipulation on these panels.
m_bAllowFullManipulation = inResourceData->GetBool( "allow_manip", false );
m_bAllowRotation = ( inResourceData->GetInt( "allow_rot", 0 ) == 1 );
// Parse our resource file and apply all necessary updates to the MDL.
for ( KeyValues *pData = inResourceData->GetFirstSubKey() ; pData != NULL ; pData = pData->GetNextKey() )
@@ -71,8 +56,6 @@ void CBaseModelPanel::ApplySettings( KeyValues *inResourceData )
ParseModelResInfo( pData );
}
}
SetMouseInputEnabled( m_bAllowFullManipulation || m_bAllowRotation || m_bAllowPitch );
}
//-----------------------------------------------------------------------------
@@ -105,8 +88,6 @@ void CBaseModelPanel::ParseModelResInfo( KeyValues *inResourceData )
ParseModelAttachInfo( pData );
}
}
SetupModelDefaults();
}
//-----------------------------------------------------------------------------
@@ -124,7 +105,7 @@ void CBaseModelPanel::ParseModelAnimInfo( KeyValues *inResourceData )
m_BMPResData.m_aAnimations[iAnim].m_pszName = ReadAndAllocStringValue( inResourceData, "name" );
m_BMPResData.m_aAnimations[iAnim].m_pszSequence = ReadAndAllocStringValue( inResourceData, "sequence" );
m_BMPResData.m_aAnimations[iAnim].m_pszActivity = ReadAndAllocStringValue( inResourceData, "activity" );
m_BMPResData.m_aAnimations[iAnim].m_bDefault = inResourceData->GetBool( "default" );
m_BMPResData.m_aAnimations[iAnim].m_bDefault = ( inResourceData->GetInt( "default", 0 ) == 1 );
for ( KeyValues *pAnimData = inResourceData->GetFirstSubKey(); pAnimData != NULL; pAnimData = pAnimData->GetNextKey() )
{
@@ -164,9 +145,6 @@ void CBaseModelPanel::SetupModelDefaults( void )
//-----------------------------------------------------------------------------
void CBaseModelPanel::SetupModelAnimDefaults( void )
{
// Set the move_x parameter so the run activity works
SetPoseParameterByName( "move_x", 1.0f );
// Verify that we have animations for this model.
int nAnimCount = m_BMPResData.m_aAnimations.Count();
if ( nAnimCount == 0 )
@@ -203,9 +181,7 @@ int CBaseModelPanel::FindDefaultAnim( void )
int CBaseModelPanel::FindAnimByName( const char *pszName )
{
int iIndex = -1;
if ( !pszName )
return iIndex;
int nAnimCount = m_BMPResData.m_aAnimations.Count();
for ( int iAnim = 0; iAnim < nAnimCount; ++iAnim )
{
@@ -227,7 +203,7 @@ int CBaseModelPanel::FindSequenceFromActivity( CStudioHdr *pStudioHdr, const cha
for ( int iSeq = 0; iSeq < pStudioHdr->GetNumSeq(); ++iSeq )
{
mstudioseqdesc_t &seqDesc = pStudioHdr->pSeqdesc( iSeq );
if ( !V_stricmp( seqDesc.pszActivityName(), pszActivity ) )
if ( !stricmp( seqDesc.pszActivityName(), pszActivity ) )
{
return iSeq;
}
@@ -245,6 +221,22 @@ void CBaseModelPanel::SetModelAnim( int iAnim )
if ( nAnimCount == 0 || !m_BMPResData.m_aAnimations.IsValidIndex( iAnim ) )
return;
// Do we have an activity or a sequence?
if ( m_BMPResData.m_aAnimations[iAnim].m_pszActivity && m_BMPResData.m_aAnimations[iAnim].m_pszActivity[0] )
{
SetModelAnim( m_BMPResData.m_aAnimations[iAnim].m_pszActivity );
}
else if ( m_BMPResData.m_aAnimations[iAnim].m_pszSequence && m_BMPResData.m_aAnimations[iAnim].m_pszSequence[0] )
{
SetModelAnim( m_BMPResData.m_aAnimations[iAnim].m_pszSequence );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::SetModelAnim( const char *pszName )
{
MDLCACHE_CRITICAL_SECTION();
// Get the studio header of the root model.
@@ -254,54 +246,27 @@ void CBaseModelPanel::SetModelAnim( int iAnim )
CStudioHdr studioHdr( pStudioHdr, g_pMDLCache );
// Do we have an activity or a sequence?
int iSequence = ACT_INVALID;
if ( m_BMPResData.m_aAnimations[iAnim].m_pszActivity && m_BMPResData.m_aAnimations[iAnim].m_pszActivity[0] )
iSequence = FindSequenceFromActivity( &studioHdr, pszName );
if ( iSequence == ACT_INVALID )
{
iSequence = FindSequenceFromActivity( &studioHdr, m_BMPResData.m_aAnimations[iAnim].m_pszActivity );
}
else if ( m_BMPResData.m_aAnimations[iAnim].m_pszSequence && m_BMPResData.m_aAnimations[iAnim].m_pszSequence[0] )
{
iSequence = LookupSequence( &studioHdr, m_BMPResData.m_aAnimations[iAnim].m_pszSequence );
iSequence = LookupSequence( &studioHdr, pszName );
}
if ( iSequence != ACT_INVALID )
{
SetSequence( iSequence, true );
SetSequence( iSequence );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::SetMDL( MDLHandle_t handle, void *pProxyData )
void CBaseModelPanel::SetMDL( MDLHandle_t handle )
{
MDLCACHE_CRITICAL_SECTION();
studiohdr_t *pHdr = g_pMDLCache->GetStudioHdr( handle );
if ( pHdr )
{
// SetMDL will cause the base CMdl code to set our localtoglobal indices if they aren't set.
// We set them up here so that they're left alone by that code.
CStudioHdr studioHdr( pHdr, g_pMDLCache );
if (studioHdr.numflexcontrollers() > 0 && studioHdr.pFlexcontroller( LocalFlexController_t(0) )->localToGlobal == -1)
{
for (LocalFlexController_t i = LocalFlexController_t(0); i < studioHdr.numflexcontrollers(); i++)
{
int j = C_BaseFlex::AddGlobalFlexController( studioHdr.pFlexcontroller( i )->pszName() );
studioHdr.pFlexcontroller( i )->localToGlobal = j;
}
}
}
else
{
handle = MDLHANDLE_INVALID;
}
// Clear our current sequence
SetSequence( ACT_IDLE );
BaseClass::SetMDL( handle, pProxyData );
BaseClass::SetMDL( handle );
SetupModelDefaults();
@@ -312,21 +277,11 @@ void CBaseModelPanel::SetMDL( MDLHandle_t handle, void *pProxyData )
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::SetModelAnglesAndPosition( const QAngle &angRot, const Vector &vecPos )
void CBaseModelPanel::SetMDL( const char *pMDLName )
{
BaseClass::SetModelAnglesAndPosition( angRot, vecPos );
SetSequence( 0 );
// Cache
m_vecPlayerPos = vecPos;
m_angPlayer = angRot;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::SetMDL( const char *pMDLName, void *pProxyData )
{
BaseClass::SetMDL( pMDLName, pProxyData );
BaseClass::SetMDL( pMDLName );
// Need to invalidate the layout so the panel will adjust is LookAt for the new model.
// InvalidateLayout();
@@ -339,38 +294,6 @@ void CBaseModelPanel::PerformLayout()
{
BaseClass::PerformLayout();
if ( m_bForcedCameraPosition )
{
return;
}
if ( m_bAllowFullManipulation )
{
// Set this to true if you want to keep the current rotation when changing models or poses
const bool bPreserveManipulation = false;
// Need to look at the target so we can rotate around it
const Vector kVecFocalPoint( 0.0f, 0.0f, 60.0f );
ResetCameraPivot();
SetCameraOffset( -(m_vecPlayerPos + kVecFocalPoint) );
SetCameraPositionAndAngles( kVecFocalPoint, vec3_angle, !bPreserveManipulation );
// We want to move the player to the origin and facing the correct way,
// but don't clobber m_angPlayer and m_vecPlayerPos, so use BaseClass.
BaseClass::SetModelAnglesAndPosition( m_angPlayer, vec3_origin );
// Once a manual transform has been done we want to apply it
if ( m_bApplyManipulators )
{
ApplyManipulation();
}
else
{
SyncManipulation();
}
return;
}
if ( m_bForcePos )
{
ResetCameraPivot();
@@ -390,72 +313,31 @@ void CBaseModelPanel::PerformLayout()
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnTick()
{
// Cycle stuff gets handled in mdlpanel::OnTick, so we want to fix up
// what our sequence is before it gets called.
// Check if we have a active sequence, and if it's expired and we need
// to run our default
if ( m_nActiveSequence != ACT_INVALID )
{
float flElapsedTime = GetAutoPlayTime() - m_RootMDL.m_flCycleStartTime;
if ( flElapsedTime >= m_flActiveSequenceDuration )
{
m_nActiveSequence = ACT_INVALID;
m_flActiveSequenceDuration = 0.f;
SetupModelDefaults();
}
}
BaseClass::OnTick();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnKeyCodePressed ( vgui::KeyCode code )
{
if ( m_bAllowFullManipulation )
{
BaseClass::OnKeyCodePressed( code );
return;
}
return;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnKeyCodeReleased( vgui::KeyCode code )
{
if ( m_bAllowFullManipulation )
{
BaseClass::OnKeyCodeReleased( code );
return;
}
return;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnMousePressed ( vgui::MouseCode code )
{
if ( m_bAllowFullManipulation )
{
BaseClass::OnMousePressed( code );
return;
}
if ( !m_bAllowRotation && !m_bAllowPitch )
if ( !m_bAllowRotation )
return;
RequestFocus();
EnableMouseCapture( true, code );
// Save where they clicked
input()->GetCursorPosition( m_nClickStartX, m_nClickStartY );
// Warp the mouse to the center of the screen
int width, height;
GetSize( width, height );
@@ -477,126 +359,42 @@ void CBaseModelPanel::OnMousePressed ( vgui::MouseCode code )
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnMouseReleased( vgui::MouseCode code )
{
if ( m_bAllowFullManipulation )
{
BaseClass::OnMouseReleased( code );
return;
}
if ( !m_bAllowRotation && !m_bAllowPitch )
if ( !m_bAllowRotation )
return;
EnableMouseCapture( false );
m_bMousePressed = false;
// Restore the cursor to where the clicked
input()->SetCursorPos( m_nClickStartX, m_nClickStartY );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnCursorMoved( int x, int y )
{
if ( m_bAllowFullManipulation )
{
if ( m_pCurrentManip )
{
m_bApplyManipulators = true;
}
BaseClass::OnCursorMoved( x, y );
return;
}
if ( !m_bAllowRotation && !m_bAllowPitch )
if ( !m_bAllowRotation )
return;
if ( m_bMousePressed )
{
WarpMouse( x, y );
int xpos, ypos;
input()->GetCursorPos( xpos, ypos );
if ( m_bAllowRotation )
// Only want the x delta.
float flDelta = xpos - m_nManipStartX;
// Apply the delta and rotate the player.
m_angPlayer.y += flDelta;
if ( m_angPlayer.y > 360.0f )
{
// Only want the x delta.
float flDelta = xpos - m_nManipStartX;
// Apply the delta and rotate the player.
RotateYaw( flDelta );
m_angPlayer.y = m_angPlayer.y - 360.0f;
}
else if ( m_angPlayer.y < -360.0f )
{
m_angPlayer.y = m_angPlayer.y + 360.0f;
}
if ( m_bAllowPitch )
{
// Only want the y delta.
float flDelta = ypos - m_nManipStartY;
// Apply the delta and rotate the player.
RotatePitch( flDelta );
}
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::RotateYaw( float flDelta )
{
m_angPlayer.y += flDelta;
if ( m_angPlayer.y > 360.0f )
{
m_angPlayer.y = m_angPlayer.y - 360.0f;
}
else if ( m_angPlayer.y < -360.0f )
{
m_angPlayer.y = m_angPlayer.y + 360.0f;
}
SetModelAnglesAndPosition( m_angPlayer, m_vecPlayerPos );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::RotatePitch( float flDelta )
{
m_angPlayer.x += flDelta;
if ( m_angPlayer.x > m_flMaxPitch )
{
m_angPlayer.x = m_flMaxPitch;
}
else if ( m_angPlayer.x < -m_flMaxPitch )
{
m_angPlayer.x = -m_flMaxPitch;
}
SetModelAnglesAndPosition( m_angPlayer, m_vecPlayerPos );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Vector CBaseModelPanel::GetPlayerPos() const
{
return m_vecPlayerPos;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
QAngle CBaseModelPanel::GetPlayerAngles() const
{
return m_angPlayer;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CBaseModelPanel::PlaySequence( const char *pszSequenceName )
{
CStudioHdr studioHDR( GetStudioHdr(), g_pMDLCache );
int iSeq = ::LookupSequence( &studioHDR, pszSequenceName );
if ( iSeq != ACT_INVALID )
{
m_nActiveSequence = iSeq;
m_flActiveSequenceDuration = Studio_Duration( &studioHDR, iSeq, NULL );
SetSequence( m_nActiveSequence, true );
SetModelAnglesAndPosition( m_angPlayer, m_vecPlayerPos );
}
}
@@ -604,11 +402,7 @@ void CBaseModelPanel::PlaySequence( const char *pszSequenceName )
//-----------------------------------------------------------------------------
void CBaseModelPanel::OnMouseWheeled( int delta )
{
if ( m_bAllowFullManipulation )
{
BaseClass::OnMouseWheeled( delta );
return;
}
return;
}
//-----------------------------------------------------------------------------
@@ -706,7 +500,6 @@ void CBaseModelPanel::LookAtBounds( const Vector &vecBoundsMin, const Vector &ve
vecModelPos.y = -vecXFormCenter.y;
vecModelPos.z = -vecXFormCenter.z;
SetModelAnglesAndPosition( m_BMPResData.m_angModelPoseRot, vecModelPos );
m_vecPlayerPos = vecModelPos;
// Back project to figure out the camera offset to center the model.
Vector2D vecPanelCenter( ( flW * 0.5f ), ( flH * 0.5f ) );
@@ -728,158 +521,7 @@ void CBaseModelPanel::LookAtBounds( const Vector &vecBoundsMin, const Vector &ve
// Clear the camera pivot and set position matrix.
ResetCameraPivot();
if (m_bAllowRotation || m_bAllowPitch )
{
vecCameraOffset.x = 0.0f;
}
SetCameraOffset( Vector( 0.0f, -vecCameraOffset.x, -vecCameraOffset.y ) );
UpdateCameraTransform();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBaseModelPanel::particle_data_t::~particle_data_t()
{
if ( m_pParticleSystem )
{
delete m_pParticleSystem;
m_pParticleSystem = NULL;
}
}
//-----------------------------------------------------------------------------
// Purpose: Allocate particle data
//-----------------------------------------------------------------------------
void CBaseModelPanel::particle_data_t::UpdateControlPoints( CStudioHdr *pStudioHdr, matrix3x4_t *pWorldMatrix, const CUtlVector< int >& vecAttachments, int iDefaultBone /*= 0*/, const Vector& vecParticleOffset /*= vec3_origin*/ )
{
if ( m_pParticleSystem )
{
// Update control points which is updating the position of the particles
matrix3x4_t matAttachToWorld;
Vector vecPosition, vecForward, vecRight, vecUp;
if ( vecAttachments.Count() )
{
for ( int i = 0; i < vecAttachments.Count(); ++i )
{
const mstudioattachment_t& attach = pStudioHdr->pAttachment( vecAttachments[i] );
MatrixMultiply( pWorldMatrix[ attach.localbone ], attach.local, matAttachToWorld );
MatrixVectors( matAttachToWorld, &vecForward, &vecRight, &vecUp );
MatrixPosition( matAttachToWorld, vecPosition );
m_pParticleSystem->SetControlPointOrientation( i, vecForward, vecRight, vecUp );
m_pParticleSystem->SetControlPoint( i, vecPosition + vecParticleOffset );
}
}
else
{
matAttachToWorld = pWorldMatrix[iDefaultBone];
MatrixVectors( matAttachToWorld, &vecForward, &vecRight, &vecUp );
MatrixPosition( matAttachToWorld, vecPosition );
m_pParticleSystem->SetControlPointOrientation( 0, vecForward, vecRight, vecUp );
m_pParticleSystem->SetControlPoint( 0, vecPosition + vecParticleOffset );
}
}
m_bIsUpdateToDate = true;
}
//-----------------------------------------------------------------------------
// Purpose: Allocate particle data
//-----------------------------------------------------------------------------
CBaseModelPanel::particle_data_t *CBaseModelPanel::CreateParticleData( const char *pszParticleName )
{
Assert( m_bUseParticle );
if ( !m_bUseParticle )
return NULL;
CParticleCollection *pParticle = g_pParticleSystemMgr->CreateParticleCollection( pszParticleName );
if ( !pParticle )
return NULL;
particle_data_t *pData = new particle_data_t;
pData->m_bIsUpdateToDate = false;
pData->m_pParticleSystem = pParticle;
m_particleList.AddToTail( pData );
return pData;
}
//-----------------------------------------------------------------------------
// Purpose: remove and delete particle data
//-----------------------------------------------------------------------------
bool CBaseModelPanel::SafeDeleteParticleData( particle_data_t **pData )
{
if ( !m_bUseParticle )
return false;
if ( *pData )
{
FOR_EACH_VEC( m_particleList, i )
{
if ( *pData == m_particleList[i] )
{
delete *pData;
*pData = NULL;
m_particleList.FastRemove( i );
return true;
}
}
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::PrePaint3D( IMatRenderContext *pRenderContext )
{
if ( !m_bUseParticle )
return;
// mark all effects need to be updated
FOR_EACH_VEC( m_particleList, i )
{
m_particleList[i]->m_bIsUpdateToDate = false;
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseModelPanel::PostPaint3D( IMatRenderContext *pRenderContext )
{
if ( !m_bUseParticle )
return;
// This needs calling to reset various counters.
g_pParticleSystemMgr->SetLastSimulationTime( gpGlobals->curtime );
// Render Particles
pRenderContext->MatrixMode( MATERIAL_MODEL );
pRenderContext->PushMatrix();
pRenderContext->LoadIdentity( );
FOR_EACH_VEC( m_particleList, i )
{
if ( m_particleList[i]->m_bIsUpdateToDate )
{
m_particleList[i]->m_pParticleSystem->Simulate( gpGlobals->frametime, false );
m_particleList[i]->m_pParticleSystem->Render( pRenderContext );
m_particleList[i]->m_bIsUpdateToDate = false;
}
}
pRenderContext->MatrixMode( MATERIAL_MODEL );
pRenderContext->PopMatrix();
}
+12 -56
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
@@ -158,19 +158,18 @@ public:
virtual ~CBaseModelPanel();
// Overridden mdlpanel.h
virtual void SetMDL( MDLHandle_t handle, void *pProxyData = NULL );
virtual void SetMDL( const char *pMDLName, void *pProxyData = NULL );
virtual void SetModelAnglesAndPosition( const QAngle &angRot, const Vector &vecPos );
virtual void SetMDL( MDLHandle_t handle );
virtual void SetMDL( const char *pMDLName );
// Overridden methods of vgui::Panel
virtual void ApplySettings( KeyValues *inResourceData );
virtual void PerformLayout();
virtual void OnTick() OVERRIDE;
// Animation.
// Animaiton.
int FindDefaultAnim( void );
int FindAnimByName( const char *pszName );
void SetModelAnim( int iAnim );
void SetModelAnim( const char *pszName );
// Manipulation.
virtual void OnKeyCodePressed ( vgui::KeyCode code );
@@ -180,25 +179,7 @@ public:
virtual void OnCursorMoved( int x, int y );
virtual void OnMouseWheeled( int delta );
studiohdr_t* GetStudioHdr( void ) { return m_RootMDL.m_MDL.GetStudioHdr(); }
void SetBody( unsigned int nBody ) { m_RootMDL.m_MDL.m_nBody = nBody; }
void RotateYaw( float flDelta );
void RotatePitch( float flDelta );
Vector GetPlayerPos() const;
QAngle GetPlayerAngles() const;
void PlaySequence( const char *pszSequenceName );
void LookAtBounds( const Vector &vecBoundsMin, const Vector &vecBoundsMax );
// Set to true if external code has set a specific camera position that shouldn't be clobbered by layout
void SetForcedCameraPosition( bool bForcedCameraPosition ) { m_bForcedCameraPosition = bForcedCameraPosition; }
int FindSequenceFromActivity( CStudioHdr *pStudioHdr, const char *pszActivity );
protected:
private:
// Resource file data.
void ParseModelResInfo( KeyValues *inResourceData );
@@ -208,47 +189,22 @@ protected:
void SetupModelDefaults( void );
void SetupModelAnimDefaults( void );
public:
void LookAtBounds( const Vector &vecBoundsMin, const Vector &vecBoundsMax );
int FindSequenceFromActivity( CStudioHdr *pStudioHdr, const char *pszActivity );
private:
BMPResData_t m_BMPResData; // Base model panel data set in the .res file.
QAngle m_angPlayer;
Vector m_vecPlayerPos;
protected:
bool m_bForcePos;
bool m_bMousePressed;
bool m_bAllowRotation;
bool m_bAllowPitch;
bool m_bAllowFullManipulation;
bool m_bApplyManipulators;
bool m_bForcedCameraPosition;
int m_nActiveSequence;
float m_flActiveSequenceDuration;
// VGUI script accessible variables.
CPanelAnimationVar( bool, m_bStartFramed, "start_framed", "0" );
CPanelAnimationVar( bool, m_bDisableManipulation, "disable_manipulation", "0" );
CPanelAnimationVar( bool, m_bUseParticle, "use_particle", "0" );
CPanelAnimationVar( float, m_flMaxPitch, "max_pitch", "90" );
struct particle_data_t
{
~particle_data_t();
void UpdateControlPoints( CStudioHdr *pStudioHdr, matrix3x4_t *pWorldMatrix, const CUtlVector< int >& vecAttachments, int iDefaultBone = 0, const Vector& vecParticleOffset = vec3_origin );
bool m_bIsUpdateToDate;
CParticleCollection *m_pParticleSystem;
};
CUtlVector< particle_data_t* > m_particleList;
particle_data_t *CreateParticleData( const char *pszParticleName );
bool SafeDeleteParticleData( particle_data_t **pData );
virtual void PrePaint3D( IMatRenderContext *pRenderContext ) OVERRIDE;
virtual void PostPaint3D( IMatRenderContext *pRenderContext ) OVERRIDE;
};
#endif // BASEMODEL_PANEL_H
+54 -93
View File
@@ -1,10 +1,9 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include <KeyValues.h>
#include <vgui/ISurface.h>
@@ -31,6 +30,11 @@
#include "activitylist.h"
#include "basemodelpanel.h"
#include "vgui_int.h"
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
bool UseHWMorphModels();
@@ -79,8 +83,8 @@ void CModelPanel::ApplySettings( KeyValues *inResourceData )
BaseClass::ApplySettings( inResourceData );
m_nFOV = inResourceData->GetInt( "fov", 54 );
m_bStartFramed = inResourceData->GetInt( "start_framed", false );
m_bAllowOffscreen = inResourceData->GetInt( "allow_offscreen", false );
m_bStartFramed = inResourceData->GetBool( "start_framed", false );
m_bAllowOffscreen = inResourceData->GetBool( "allow_offscreen", false );
// do we have a valid "model" section in the .res file?
for ( KeyValues *pData = inResourceData->GetFirstSubKey() ; pData != NULL ; pData = pData->GetNextKey() )
@@ -92,21 +96,6 @@ void CModelPanel::ApplySettings( KeyValues *inResourceData )
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CModelPanel::OnCommand( const char *command )
{
if (!Q_strnicmp("animation", command, 9))
{
UpdateModel();
SetSequence( command + 9 + 1 );
return;
}
BaseClass::OnCommand(command);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -291,13 +280,15 @@ void CModelPanel::SetupVCD( void )
if ( !pEnt )
return;
if ( pEnt->InitializeAsClientEntity( "", RENDER_GROUP_OTHER ) == false )
if ( pEnt->InitializeAsClientEntity( "", false ) == false )
{
// we failed to initialize this entity so just return gracefully
pEnt->Remove();
return;
}
g_pClientLeafSystem->EnableRendering( pEnt->RenderHandle(), false );
// setup the handle
m_hScene = pEnt;
@@ -364,23 +355,6 @@ const char *CModelPanel::GetModelName( void )
return m_pModelInfo->m_pszModelName;
}
void CModelPanel::SetBodyGroup( const char* pszBodyGroupName, int nGroup )
{
if ( !m_pModelInfo )
return;
if ( !m_hModel.Get() )
return;
int nBodyGroupNum = m_hModel->FindBodygroupByName( pszBodyGroupName );
if ( nBodyGroupNum == -1 )
return;
m_pModelInfo->m_mapBodygroupValues.InsertOrReplace( nBodyGroupNum, nGroup );
m_bPanelDirty = true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -404,7 +378,7 @@ void CModelPanel::SetupModel( void )
if ( !pEnt )
return;
if ( pEnt->InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
if ( pEnt->InitializeAsClientEntity( pszModelName, false ) == false )
{
// we failed to initialize this entity so just return gracefully
pEnt->Remove();
@@ -419,12 +393,7 @@ void CModelPanel::SetupModel( void )
if ( m_pModelInfo->m_nSkin >= 0 )
{
pEnt->m_nSkin = m_pModelInfo->m_nSkin;
}
FOR_EACH_MAP_FAST( m_pModelInfo->m_mapBodygroupValues, i )
{
pEnt->SetBodygroup( m_pModelInfo->m_mapBodygroupValues.Key( i ), m_pModelInfo->m_mapBodygroupValues[ i ] );
pEnt->SetSkin( m_pModelInfo->m_nSkin );
}
// do we have any animation information?
@@ -469,7 +438,7 @@ void CModelPanel::SetupModel( void )
if ( pTemp )
{
if ( pTemp->InitializeAsClientEntity( pInfo->m_pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
if ( pTemp->InitializeAsClientEntity( pInfo->m_pszModelName, false ) == false )
{
// we failed to initialize this model so just skip it
pTemp->Remove();
@@ -482,7 +451,7 @@ void CModelPanel::SetupModel( void )
if ( pInfo->m_nSkin >= 0 )
{
pTemp->m_nSkin = pInfo->m_nSkin;
pTemp->SetSkin( pInfo->m_nSkin );
}
pTemp->m_flAnimTime = gpGlobals->curtime;
@@ -513,28 +482,25 @@ void CModelPanel::InitCubeMaps()
}
}
//-----------------------------------------------------------------------------
// Purpose: If the panel is marked as dirty, update it and mark it as clean
//-----------------------------------------------------------------------------
void CModelPanel::UpdateModel()
void CModelPanel::UpdateIfDirty()
{
if ( m_bPanelDirty )
if ( !m_bPanelDirty )
{
InitCubeMaps();
SetupModel();
// are we trying to play a VCD?
if ( Q_strlen( m_pModelInfo->m_pszVCD ) > 0 )
{
SetupVCD();
}
m_bPanelDirty = false;
return;
}
}
InitCubeMaps();
SetupModel();
// are we trying to play a VCD?
if ( Q_strlen( m_pModelInfo->m_pszVCD ) > 0 )
{
SetupVCD();
}
m_bPanelDirty = false;
}
//-----------------------------------------------------------------------------
// Purpose:
@@ -543,14 +509,16 @@ void CModelPanel::Paint()
{
BaseClass::Paint();
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
ASSERT_LOCAL_PLAYER_RESOLVABLE();
VGUI_ABSPOS_SPLITSCREEN_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pLocalPlayer || !m_pModelInfo )
return;
MDLCACHE_CRITICAL_SECTION();
UpdateModel();
UpdateIfDirty();
if ( !m_hModel.Get() )
return;
@@ -559,7 +527,7 @@ void CModelPanel::Paint()
int x, y, w, h;
GetBounds( x, y, w, h );
ParentLocalToScreen( x, y );
// ParentLocalToScreen( x, y );
if ( !m_bAllowOffscreen && x < 0 )
{
@@ -569,7 +537,17 @@ void CModelPanel::Paint()
}
Vector vecExtraModelOffset( 0, 0, 0 );
float flWidthRatio = ((float)w / (float)h ) / ( 4.0f / 3.0f );
int dummyx, dummyy;
int sw, sh;
VGui_GetHudBounds( GET_ACTIVE_SPLITSCREEN_SLOT(), dummyx, dummyy, sw, sh );
x += dummyx;
y += dummyy;
float aspect = (float)sw/(float)sh;
float flWidthRatio = aspect / ( 4.0f / 3.0f );
// is this a player model?
if ( Q_strstr( GetModelName(), "models/player/" ) )
@@ -595,16 +573,10 @@ void CModelPanel::Paint()
m_hModel->FrameAdvance( gpGlobals->frametime );
}
CMatRenderContextPtr pRenderContext( materials );
// figure out what our viewport is right now
int viewportX, viewportY, viewportWidth, viewportHeight;
pRenderContext->GetViewport( viewportX, viewportY, viewportWidth, viewportHeight );
// Now draw it.
CViewSetup view;
view.x = x + m_pModelInfo->m_vecViewportOffset.x + viewportX; // we actually want to offset by the
view.y = y + m_pModelInfo->m_vecViewportOffset.y + viewportY; // viewport origin here because Push3DView expects global coords below
view.x = x + m_pModelInfo->m_vecViewportOffset.x;
view.y = y + m_pModelInfo->m_vecViewportOffset.y;
view.width = w;
view.height = h;
@@ -618,7 +590,7 @@ void CModelPanel::Paint()
view.zNear = VIEW_NEARZ;
view.zFar = 1000;
CMatRenderContextPtr pRenderContext( materials );
// Not supported by queued material system - doesn't appear to be necessary
// ITexture *pLocalCube = pRenderContext->GetLocalCubemap();
@@ -633,7 +605,6 @@ void CModelPanel::Paint()
}
pRenderContext->SetLightingOrigin( vec3_origin );
pRenderContext->SetAmbientLight( 0.4, 0.4, 0.4 );
static Vector white[6] =
{
@@ -663,13 +634,15 @@ void CModelPanel::Paint()
float color[3] = { 1.0f, 1.0f, 1.0f };
render->SetColorModulation( color );
render->SetBlend( 1.0f );
m_hModel->DrawModel( STUDIO_RENDER );
RenderableInstance_t instance;
instance.m_nAlpha = 255;
m_hModel->DrawModel( STUDIO_RENDER, instance );
for ( i = 0 ; i < m_AttachedModels.Count() ; i++ )
{
if ( m_AttachedModels[i].Get() )
{
m_AttachedModels[i]->DrawModel( STUDIO_RENDER );
m_AttachedModels[i]->DrawModel( STUDIO_RENDER, instance );
}
}
@@ -741,24 +714,12 @@ bool CModelPanel::SetSequence( const char *pszName )
return bRetVal;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CModelPanel::SetSkin( int nSkin )
{
if ( m_pModelInfo )
{
m_pModelInfo->m_nSkin = nSkin;
m_bPanelDirty = true;
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CModelPanel::OnSetAnimation( KeyValues *data )
{
UpdateModel();
UpdateIfDirty();
// If there's no model, these commands will be ignored.
Assert(m_hModel);
+3 -7
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -112,7 +112,6 @@ class CModelPanelModelInfo
{
public:
CModelPanelModelInfo()
: m_mapBodygroupValues( DefLessFunc( int ) )
{
m_pszModelName = NULL;
m_pszModelName_HWM = NULL;
@@ -157,7 +156,6 @@ public:
Vector2D m_vecViewportOffset;
Vector m_vecFramedOriginOffset;
bool m_bUseSpotlight;
CUtlMap< int, int > m_mapBodygroupValues;
CUtlVector<CModelPanelModelAnimation*> m_Animations;
CUtlVector<CModelPanelAttachedModelInfo*> m_AttachedModelsInfo;
@@ -176,15 +174,12 @@ public:
virtual void Paint();
virtual void ApplySettings( KeyValues *inResourceData );
virtual void OnCommand( const char *command ) OVERRIDE;
virtual void DeleteVCDData( void );
virtual void DeleteModelData( void );
virtual void SetFOV( int nFOV ){ m_nFOV = nFOV; }
virtual void SetPanelDirty( void ){ m_bPanelDirty = true; }
virtual bool SetSequence( const char *pszSequence );
virtual void SetSkin( int nSkin );
void SetBodyGroup( const char* pszBodyGroupName, int nGroup );
MESSAGE_FUNC_PARAMS( OnAddAnimation, "AddAnimation", data );
MESSAGE_FUNC_PARAMS( OnSetAnimation, "SetAnimation", data );
@@ -199,7 +194,6 @@ public:
void CalculateFrameDistance( void );
void ZoomToFrameDistance( void );
void UpdateModel();
public: // IGameEventListener:
virtual void FireGameEvent( IGameEvent * event );
@@ -213,6 +207,8 @@ private:
int FindAnimByName( const char *pszName );
void CalculateFrameDistanceInternal( const model_t *pModel );
void UpdateIfDirty();
public:
int m_nFOV;
float m_flFrameDistance;
+345 -204
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Client DLL VGUI2 Viewport
//
@@ -26,8 +26,8 @@
#include <vgui/IScheme.h>
#include <vgui/IVGui.h>
#include <vgui/ILocalize.h>
#include <vgui/IPanel.h>
#include <vgui_controls/Button.h>
#include <vgui/ipanel.h>
#include <vgui_controls/button.h>
#include <igameresources.h>
@@ -48,76 +48,74 @@
#include <convar.h>
#include "ienginevgui.h"
#include "iclientmode.h"
#include "vgui_int.h"
#include "tier0/etwprof.h"
#if defined( REPLAY_ENABLED )
#include "replay/ireplaysystem.h"
#include "replay/ienginereplay.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
IViewPort *gViewPortInterface = NULL;
static IViewPort *s_pFullscreenViewportInterface;
static IViewPort *s_pViewportInterfaces[ MAX_SPLITSCREEN_PLAYERS ];
IViewPort *GetViewPortInterface()
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
return s_pViewportInterfaces[ GET_ACTIVE_SPLITSCREEN_SLOT() ];
}
IViewPort *GetFullscreenViewPortInterface()
{
return s_pFullscreenViewportInterface;
}
vgui::Panel *g_lastPanel = NULL; // used for mouseover buttons, keeps track of the last active panel
vgui::Button *g_lastButton = NULL; // used for mouseover buttons, keeps track of the last active button
using namespace vgui;
void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue );
ConVar hud_autoreloadscript("hud_autoreloadscript", "0", FCVAR_NONE, "Automatically reloads the animation script each time one is ran", hud_autoreloadscript_callback);
void hud_autoreloadscript_callback( IConVar *var, const char *pOldValue, float flOldValue )
{
if ( g_pClientMode && g_pClientMode->GetViewportAnimationController() )
{
g_pClientMode->GetViewportAnimationController()->SetAutoReloadScript( hud_autoreloadscript.GetBool() );
}
}
ConVar hud_autoreloadscript("hud_autoreloadscript", "0", FCVAR_NONE, "Automatically reloads the animation script each time one is ran");
static ConVar cl_leveloverviewmarker( "cl_leveloverviewmarker", "0", FCVAR_CHEAT );
CON_COMMAND( showpanel, "Shows a viewport panel <name>" )
{
if ( !gViewPortInterface )
if ( !GetViewPortInterface() )
return;
if ( args.ArgC() != 2 )
return;
gViewPortInterface->ShowPanel( args[ 1 ], true );
GetViewPortInterface()->ShowPanel( args[ 1 ], true );
}
CON_COMMAND( hidepanel, "Hides a viewport panel <name>" )
{
if ( !gViewPortInterface )
if ( !GetViewPortInterface() )
return;
if ( args.ArgC() != 2 )
return;
gViewPortInterface->ShowPanel( args[ 1 ], false );
GetViewPortInterface()->ShowPanel( args[ 1 ], false );
}
/* global helper functions
bool Helper_LoadFile( IBaseFileSystem *pFileSystem, const char *pFilename, CUtlVector<char> &buf )
{
FileHandle_t hFile = pFileSystem->Open( pFilename, "rt" );
if ( hFile == FILESYSTEM_INVALID_HANDLE )
{
Warning( "Helper_LoadFile: missing %s\n", pFilename );
return false;
}
FileHandle_t hFile = pFileSystem->Open( pFilename, "rt" );
if ( hFile == FILESYSTEM_INVALID_HANDLE )
{
Warning( "Helper_LoadFile: missing %s\n", pFilename );
return false;
}
unsigned long len = pFileSystem->Size( hFile );
buf.SetSize( len );
pFileSystem->Read( buf.Base(), buf.Count(), hFile );
pFileSystem->Close( hFile );
unsigned long len = pFileSystem->Size( hFile );
buf.SetSize( len );
pFileSystem->Read( buf.Base(), buf.Count(), hFile );
pFileSystem->Close( hFile );
return true;
return true;
} */
//-----------------------------------------------------------------------------
@@ -157,11 +155,10 @@ bool CBaseViewport::LoadHudAnimations( void )
}
//================================================================
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
{
SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
gViewPortInterface = this;
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport" )
{
m_bInitialized = false;
m_bFullscreenViewport = false;
m_GameuiFuncs = NULL;
m_GameEventManager = NULL;
@@ -174,30 +171,18 @@ CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
m_bHasParent = false;
m_pActivePanel = NULL;
m_pLastActivePanel = NULL;
g_lastPanel = NULL;
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), "resource/ClientScheme.res", "ClientScheme");
SetScheme(scheme);
SetProportional( true );
m_pAnimController = new vgui::AnimationController(this);
// create our animation controller
m_pAnimController->SetScheme(scheme);
m_pAnimController->SetProportional(true);
// Attempt to load all hud animations
if ( LoadHudAnimations() == false )
{
// Fall back to just the main
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
{
Assert(0);
}
}
m_OldSize[ 0 ] = m_OldSize[ 1 ] = -1;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
vgui::VPANEL CBaseViewport::GetSchemeSizingVPanel( void )
{
return VGui_GetFullscreenRootVPANEL();
}
//-----------------------------------------------------------------------------
// Purpose: Updates hud to handle the new screen size
//-----------------------------------------------------------------------------
@@ -205,9 +190,6 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
{
BaseClass::OnScreenSizeChanged(iOldWide, iOldTall);
IViewPortPanel* pSpecGuiPanel = FindPanelByName(PANEL_SPECGUI);
bool bSpecGuiWasVisible = pSpecGuiPanel && pSpecGuiPanel->IsVisible();
// reload the script file, so the screen positions in it are correct for the new resolution
ReloadScheme( NULL );
@@ -218,7 +200,12 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
m_pBackGround->SetZPos( -20 ); // send it to the back
m_pBackGround->SetVisible( false );
#endif
CreateDefaultPanels();
if ( !IsFullscreenViewport() )
{
CreateDefaultPanels();
}
#ifndef _XBOX
vgui::ipanel()->MoveToBack( m_pBackGround->GetVPanel() ); // really send it to the back
#endif
@@ -226,8 +213,7 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
// hide all panels when reconnecting
ShowPanel( PANEL_ALL, false );
// re-enable the spectator gui if it was previously visible
if ( bSpecGuiWasVisible )
if ( g_bEngineIsHLTV || engine->IsReplay() )
{
ShowPanel( PANEL_SPECGUI, true );
}
@@ -235,24 +221,23 @@ void CBaseViewport::OnScreenSizeChanged(int iOldWide, int iOldTall)
void CBaseViewport::CreateDefaultPanels( void )
{
#ifndef _XBOX
AddNewPanel( CreatePanelByName( PANEL_SCOREBOARD ), "PANEL_SCOREBOARD" );
AddNewPanel( CreatePanelByName( PANEL_INFO ), "PANEL_INFO" );
AddNewPanel( CreatePanelByName( PANEL_SPECGUI ), "PANEL_SPECGUI" );
#if !defined( TF_CLIENT_DLL )
AddNewPanel( CreatePanelByName( PANEL_SPECMENU ), "PANEL_SPECMENU" );
AddNewPanel( CreatePanelByName( PANEL_NAV_PROGRESS ), "PANEL_NAV_PROGRESS" );
#endif // !TF_CLIENT_DLL
#endif // !_XBOX
}
void CBaseViewport::UpdateAllPanels( void )
{
int count = m_Panels.Count();
int nSlot = vgui::ipanel()->GetMessageContextId( GetVPanel() );
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( nSlot );
for (int i=0; i< count; i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *p = m_Panels[i];
IViewPortPanel *p = m_UnorderedPanels[i];
if ( p->IsVisible() )
{
@@ -261,43 +246,6 @@ void CBaseViewport::UpdateAllPanels( void )
}
}
// Check if we have any visible panel (that's not the MainMenuOverride or the Scoreboard)
bool CBaseViewport::IsAnyPanelVisibleExceptScores()
{
int count = m_Panels.Count();
for ( int i = 0; i < count; i++ )
{
IViewPortPanel *p = m_Panels[i];
if ( p->IsVisible() && Q_strcmp("MainMenuOverride", p->GetName()) && Q_strcmp("scores", p->GetName()) )
{
return true;
}
}
return false;
}
bool CBaseViewport::IsPanelVisible( const char* panel )
{
int count = m_Panels.Count();
for ( int i = 0; i < count; i++ )
{
IViewPortPanel *p = m_Panels[i];
if ( p->IsVisible() )
{
const char* panel_name = p->GetName();
if ( !Q_strcmp( panel, panel_name ) )
{
return true;
}
}
}
return false;
}
IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
IViewPortPanel* newpanel = NULL;
@@ -311,9 +259,9 @@ IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
newpanel = new CTextWindow( this );
}
/* else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
/* else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
{
newpanel = new CMapOverview( this );
newpanel = new CMapOverview( this );
}
*/
else if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
@@ -328,19 +276,19 @@ IViewPortPanel* CBaseViewport::CreatePanelByName(const char *szPanelName)
{
newpanel = new CSpectatorGUI( this );
}
#if !defined( TF_CLIENT_DLL )
else if ( Q_strcmp(PANEL_NAV_PROGRESS, szPanelName) == 0 )
{
newpanel = new CNavProgress( this );
}
#endif // TF_CLIENT_DLL
#endif
#endif // !XBOX
if ( Q_strcmp(PANEL_COMMENTARY_MODELVIEWER, szPanelName) == 0 )
{
newpanel = new CCommentaryModelViewer( this );
}
return newpanel;
}
@@ -349,7 +297,6 @@ bool CBaseViewport::AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugNam
{
if ( !pPanel )
{
DevMsg("CBaseViewport::AddNewPanel(%s): NULL panel.\n", pchDebugName );
return false;
}
@@ -360,23 +307,20 @@ bool CBaseViewport::AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugNam
return false;
}
m_Panels.AddToTail( pPanel );
m_Panels.Insert( pPanel->GetName(), pPanel );
pPanel->SetParent( GetVPanel() );
m_UnorderedPanels.AddToTail( pPanel );
return true;
}
IViewPortPanel* CBaseViewport::FindPanelByName(const char *szPanelName)
{
int count = m_Panels.Count();
int idx = m_Panels.Find( szPanelName );
if ( idx == m_Panels.InvalidIndex() )
return NULL;
for (int i=0; i< count; i++ )
{
if ( Q_strcmp(m_Panels[i]->GetName(), szPanelName) == 0 )
return m_Panels[i];
}
return NULL;
return m_Panels[ idx ];
}
void CBaseViewport::PostMessageToPanel( IViewPortPanel* pPanel, KeyValues *pKeyValues )
@@ -388,9 +332,10 @@ void CBaseViewport::PostMessageToPanel( const char *pName, KeyValues *pKeyValues
{
if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
{
for (int i=0; i< m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
PostMessageToPanel( m_Panels[i], pKeyValues );
IViewPortPanel *p = m_UnorderedPanels[i];
PostMessageToPanel( p, pKeyValues );
}
return;
@@ -414,13 +359,50 @@ void CBaseViewport::PostMessageToPanel( const char *pName, KeyValues *pKeyValues
}
void CBaseViewport::ShowPanel( const char *pName, bool state, KeyValues *data, bool autoDeleteData )
{
if ( !data )
{
ShowPanel( pName, state );
return;
}
// Also try to show the panel in the full screen viewport
if ( this != s_pFullscreenViewportInterface )
{
GetFullscreenViewPortInterface()->ShowPanel( pName, state, data, false );
}
IViewPortPanel *panel = FindPanelByName( pName );
if ( panel )
{
panel->SetData( data );
GetViewPortInterface()->ShowPanel( panel, state );
}
if ( autoDeleteData )
{
data->deleteThis();
}
}
void CBaseViewport::ShowPanel( const char *pName, bool state )
{
// Also try to show the panel in the full screen viewport
if ( this != s_pFullscreenViewportInterface )
{
GetFullscreenViewPortInterface()->ShowPanel( pName, state );
}
ASSERT_LOCAL_PLAYER_RESOLVABLE();
if ( Q_strcmp( pName, PANEL_ALL ) == 0 )
{
for (int i=0; i< m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
ShowPanel( m_Panels[i], state );
IViewPortPanel *p = m_UnorderedPanels[i];
ShowPanel( p, state );
}
return;
@@ -436,7 +418,7 @@ void CBaseViewport::ShowPanel( const char *pName, bool state )
{
panel = FindPanelByName( pName );
}
if ( !panel )
return;
@@ -445,26 +427,34 @@ void CBaseViewport::ShowPanel( const char *pName, bool state )
void CBaseViewport::ShowPanel( IViewPortPanel* pPanel, bool state )
{
// Extra guard to get layout stuff correct
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( GET_ACTIVE_SPLITSCREEN_SLOT() );
if ( state )
{
// if this is an 'active' panel, deactivate old active panel
if ( pPanel->HasInputElements() )
{
// don't show input panels during normal demo playback
#if defined( REPLAY_ENABLED )
if ( engine->IsPlayingDemo() && !engine->IsHLTV() && !g_pEngineClientReplay->IsPlayingReplayDemo() )
#else
if ( engine->IsPlayingDemo() && !engine->IsHLTV() )
#endif
if ( engine->IsPlayingDemo() && !g_bEngineIsHLTV && !engine->IsReplay() )
return;
if ( (m_pActivePanel != NULL) && (m_pActivePanel != pPanel) && (m_pActivePanel->IsVisible()) )
{
// store a pointer to the currently active panel
// so we can restore it later
m_pLastActivePanel = m_pActivePanel;
m_pActivePanel->ShowPanel( false );
if ( pPanel->CanReplace( m_pActivePanel->GetName() ) )
{
m_pLastActivePanel = m_pActivePanel;
m_pActivePanel->ShowPanel( false );
}
else
{
m_pLastActivePanel = pPanel;
return;
}
}
m_pActivePanel = pPanel;
}
}
@@ -498,12 +488,45 @@ IViewPortPanel* CBaseViewport::GetActivePanel( void )
return m_pActivePanel;
}
void CBaseViewport::RecreatePanel( const char *szPanelName )
{
IViewPortPanel *panel = FindPanelByName( szPanelName );
if ( panel )
{
m_Panels.Remove( szPanelName );
for ( int i = m_UnorderedPanels.Count() - 1; i >= 0; --i )
{
if ( m_UnorderedPanels[ i ] == panel )
{
m_UnorderedPanels.Remove( i );
break;
}
}
vgui::VPANEL vPanel = panel->GetVPanel();
vgui::ipanel()->DeletePanel( vPanel );
if ( m_pActivePanel == panel )
{
m_pActivePanel = NULL;
}
if ( m_pLastActivePanel == panel )
{
m_pLastActivePanel = NULL;
}
AddNewPanel( CreatePanelByName( szPanelName ), szPanelName );
}
}
void CBaseViewport::RemoveAllPanels( void)
{
g_lastPanel = NULL;
for ( int i=0; i < m_Panels.Count(); i++ )
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
vgui::VPANEL vPanel = m_Panels[i]->GetVPanel();
IViewPortPanel *p = m_UnorderedPanels[i];
vgui::VPANEL vPanel = p->GetVPanel();
vgui::ipanel()->DeletePanel( vPanel );
}
#ifndef _XBOX
@@ -513,7 +536,8 @@ void CBaseViewport::RemoveAllPanels( void)
m_pBackGround = NULL;
}
#endif
m_Panels.Purge();
m_Panels.RemoveAll();
m_UnorderedPanels.RemoveAll();
m_pActivePanel = NULL;
m_pLastActivePanel = NULL;
}
@@ -530,10 +554,13 @@ CBaseViewport::~CBaseViewport()
m_pBackGround = NULL;
#endif
RemoveAllPanels();
gameeventmanager->RemoveListener( this );
}
void CBaseViewport::InitViewportSingletons( void )
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
s_pViewportInterfaces[ GET_ACTIVE_SPLITSCREEN_SLOT() ] = this;
}
//-----------------------------------------------------------------------------
// Purpose: called when the VGUI subsystem starts up
@@ -541,6 +568,8 @@ CBaseViewport::~CBaseViewport()
//-----------------------------------------------------------------------------
void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager )
{
InitViewportSingletons();
m_GameuiFuncs = pGameUIFuncs;
m_GameEventManager = pGameEventManager;
#ifndef _XBOX
@@ -548,10 +577,32 @@ void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGam
m_pBackGround->SetZPos( -20 ); // send it to the back
m_pBackGround->SetVisible( false );
#endif
CreateDefaultPanels();
m_GameEventManager->AddListener( this, "game_newmap", false );
ListenForGameEvent( "game_newmap" );
SetScheme( "ClientScheme" );
SetProportional( true );
if ( !IsFullscreenViewport() )
{
CreateDefaultPanels();
}
m_pAnimController = new vgui::AnimationController(this);
// create our animation controller
m_pAnimController->SetScheme( GetScheme() );
m_pAnimController->SetProportional(true);
// Attempt to load all hud animations
if ( LoadHudAnimations() == false )
{
// Fall back to just the main
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
{
Assert(0);
}
}
m_bInitialized = true;
}
@@ -559,37 +610,37 @@ void CBaseViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGam
//-----------------------------------------------------------------------------
// Purpose: Updates the spectator panel with new player info
//-----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
void CBaseViewport::UpdateSpectatorPanel()
{
char bottomText[128];
int player = -1;
const char *name;
Q_snprintf(bottomText,sizeof( bottomText ), "#Spec_Mode%d", m_pClientDllInterface->SpectatorMode() );
char bottomText[128];
int player = -1;
const char *name;
Q_snprintf(bottomText,sizeof( bottomText ), "#Spec_Mode%d", m_pClientDllInterface->SpectatorMode() );
m_pClientDllInterface->CheckSettings();
// check if we're locked onto a target, show the player's name
if ( (m_pClientDllInterface->SpectatorTarget() > 0) && (m_pClientDllInterface->SpectatorTarget() <= m_pClientDllInterface->GetMaxPlayers()) && (m_pClientDllInterface->SpectatorMode() != OBS_ROAMING) )
{
player = m_pClientDllInterface->SpectatorTarget();
}
m_pClientDllInterface->CheckSettings();
// check if we're locked onto a target, show the player's name
if ( (m_pClientDllInterface->SpectatorTarget() > 0) && (m_pClientDllInterface->SpectatorTarget() <= m_pClientDllInterface->GetMaxPlayers()) && (m_pClientDllInterface->SpectatorMode() != OBS_ROAMING) )
{
player = m_pClientDllInterface->SpectatorTarget();
}
// special case in free map and inset off, don't show names
if ( ((m_pClientDllInterface->SpectatorMode() == OBS_MAP_FREE) && !m_pClientDllInterface->PipInsetOff()) || player == -1 )
name = NULL;
else
name = m_pClientDllInterface->GetPlayerInfo(player).name;
// special case in free map and inset off, don't show names
if ( ((m_pClientDllInterface->SpectatorMode() == OBS_MAP_FREE) && !m_pClientDllInterface->PipInsetOff()) || player == -1 )
name = NULL;
else
name = m_pClientDllInterface->GetPlayerInfo(player).name;
// create player & health string
if ( player && name )
{
Q_strncpy( bottomText, name, sizeof( bottomText ) );
}
char szMapName[64];
Q_FileBase( const_cast<char *>(m_pClientDllInterface->GetLevelName()), szMapName );
// create player & health string
if ( player && name )
{
Q_strncpy( bottomText, name, sizeof( bottomText ) );
}
char szMapName[64];
Q_FileBase( const_cast<char *>(m_pClientDllInterface->GetLevelName()), szMapName );
m_pSpectatorGUI->Update(bottomText, player, m_pClientDllInterface->SpectatorMode(), m_pClientDllInterface->IsSpectateOnly(), m_pClientDllInterface->SpectatorNumber(), szMapName );
m_pSpectatorGUI->UpdateSpectatorPlayerList();
m_pSpectatorGUI->Update(bottomText, player, m_pClientDllInterface->SpectatorMode(), m_pClientDllInterface->IsSpectateOnly(), m_pClientDllInterface->SpectatorNumber(), szMapName );
m_pSpectatorGUI->UpdateSpectatorPlayerList();
} */
// Return TRUE if the HUD's allowed to print text messages
@@ -598,7 +649,7 @@ bool CBaseViewport::AllowedToPrintText( void )
/* int iId = GetCurrentMenuID();
if ( iId == MENU_TEAM || iId == MENU_CLASS || iId == MENU_INTRO || iId == MENU_CLASSHELP )
return false; */
return false; */
// TODO ask every aktive elemet if it allows to draw text while visible
return ( m_pActivePanel == NULL);
@@ -606,6 +657,8 @@ bool CBaseViewport::AllowedToPrintText( void )
void CBaseViewport::OnThink()
{
ABS_QUERY_GUARD( true );
// Clear our active panel pointer if the panel has made
// itself invisible. Need this so we don't bring up dead panels
// if they are stored as the last active panel
@@ -613,39 +666,48 @@ void CBaseViewport::OnThink()
{
if( m_pLastActivePanel )
{
m_pActivePanel = m_pLastActivePanel;
ShowPanel( m_pActivePanel, true );
if ( m_pLastActivePanel->CanBeReopened() )
{
m_pActivePanel = m_pLastActivePanel;
ShowPanel( m_pActivePanel, true );
}
else
{
m_pActivePanel = NULL;
}
m_pLastActivePanel = NULL;
}
else
m_pActivePanel = NULL;
}
// TF does this in OnTick in TFViewport. This remains to preserve old
// behavior in other games
#if !defined( TF_CLIENT_DLL )
m_pAnimController->UpdateAnimations( gpGlobals->curtime );
#endif
int count = m_Panels.Count();
// check the auto-reload cvar
m_pAnimController->SetAutoReloadScript(hud_autoreloadscript.GetBool());
for (int i=0; i< count; i++ )
int nSlot = vgui::ipanel()->GetMessageContextId( GetVPanel() );
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( nSlot );
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *panel = m_Panels[i];
if ( panel->NeedsUpdate() && panel->IsVisible() )
IViewPortPanel *p = m_UnorderedPanels[i];
if ( p && p->NeedsUpdate() && p->IsVisible() )
{
panel->Update();
p->Update();
}
}
int w, h;
vgui::ipanel()->GetSize( enginevgui->GetPanel( PANEL_CLIENTDLL ), w, h );
vgui::ipanel()->GetSize( VGui_GetClientDLLRootPanel(), w, h );
if ( m_OldSize[ 0 ] != w || m_OldSize[ 1 ] != h )
{
m_OldSize[ 0 ] = w;
m_OldSize[ 1 ] = h;
g_pClientMode->Layout();
ASSERT_LOCAL_PLAYER_RESOLVABLE();
GetClientMode()->Layout();
}
BaseClass::OnThink();
@@ -661,7 +723,7 @@ void CBaseViewport::SetParent(vgui::VPANEL parent)
// parent happened to be non-proportional (such as the vgui root panel), we got
// slammed to be nonproportional
EditablePanel::SetProportional( true );
#ifndef _XBOX
m_pBackGround->SetParent( (vgui::VPANEL)parent );
#endif
@@ -698,7 +760,7 @@ void CBaseViewport::FireGameEvent( IGameEvent * event)
// hide all panels when reconnecting
ShowPanel( PANEL_ALL, false );
if ( engine->IsHLTV() )
if ( g_bEngineIsHLTV || engine->IsReplay() )
{
ShowPanel( PANEL_SPECGUI, true );
}
@@ -710,14 +772,13 @@ void CBaseViewport::FireGameEvent( IGameEvent * event)
//-----------------------------------------------------------------------------
void CBaseViewport::ReloadScheme(const char *fromFile)
{
CETWScope timer( "CBaseViewport::ReloadScheme" );
// See if scheme should change
if ( fromFile != NULL )
{
// "resource/ClientScheme.res"
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( enginevgui->GetPanel( PANEL_CLIENTDLL ), fromFile, "HudScheme" );
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx( GetSchemeSizingVPanel(), fromFile, "HudScheme" );
SetScheme(scheme);
SetProportional( true );
@@ -735,19 +796,88 @@ void CBaseViewport::ReloadScheme(const char *fromFile)
}
SetProportional( true );
KeyValuesAD pConditions( "conditions" );
g_pClientMode->ComputeVguiResConditions( pConditions );
// reload the .res file from disk
LoadControlSettings( "scripts/HudLayout.res", NULL, NULL, pConditions );
LoadHudLayout();
gHUD.RefreshHudTextures();
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
HudIcons().RefreshHudTextures();
}
InvalidateLayout( true, true );
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
{
IViewPortPanel *p = m_UnorderedPanels[i];
p->ReloadScheme();
}
// reset the hud
gHUD.ResetHUD();
GetHud().ResetHUD();
}
extern ConVar ss_verticalsplit;
void AddSubKeyNamed( KeyValues *pKeys, const char *pszName )
{
KeyValues *pNewKey = new KeyValues( pszName );
if ( pNewKey )
{
pKeys->AddSubKey( pNewKey );
}
}
void CBaseViewport::LoadHudLayout( void )
{
VGUI_ABSPOS_SPLITSCREEN_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
// reload the .res file from disk
KeyValues *pConditions = NULL;
if ( engine->IsSplitScreenActive() )
{
pConditions = new KeyValues( "conditions" );
if ( pConditions )
{
AddSubKeyNamed( pConditions, "if_split_screen_active" );
ConVarRef ss_verticalsplit( "ss_verticalsplit" );
if ( ss_verticalsplit.IsValid() && ss_verticalsplit.GetBool() )
{
AddSubKeyNamed( pConditions, "if_split_screen_vertical" );
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
AddSubKeyNamed( pConditions, "if_split_screen_left" );
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_right" );
}
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_horizontal" );
if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 )
{
AddSubKeyNamed( pConditions, "if_split_screen_top" );
}
else
{
AddSubKeyNamed( pConditions, "if_split_screen_bottom" );
}
}
}
}
LoadControlSettings( "scripts/HudLayout.res", NULL, NULL, pConditions );
if ( pConditions )
{
pConditions->deleteThis();
}
}
int CBaseViewport::GetDeathMessageStartHeight( void )
@@ -766,3 +896,14 @@ void CBaseViewport::Paint()
vgui::surface()->DrawLine( 0, size, size, size );
}
}
void CBaseViewport::SetAsFullscreenViewportInterface( void )
{
s_pFullscreenViewportInterface = this;
m_bFullscreenViewport = true;
}
bool CBaseViewport::IsFullscreenViewport() const
{
return m_bFullscreenViewport;
}
+27 -28
View File
@@ -1,22 +1,22 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef TEAMFORTRESSVIEWPORT_H
#define TEAMFORTRESSVIEWPORT_H
#ifndef BASEVIEWPORT_H
#define BASEVIEWPORT_H
// viewport interface for the rest of the dll
#include <game/client/iviewport.h>
#include "game/client/iviewport.h"
#include <utlqueue.h> // a vector based queue template to manage our VGUI menu queue
#include <vgui_controls/Frame.h>
#include "vgui_controls/Frame.h"
#include "vguitextwindow.h"
#include "vgui/ISurface.h"
#include "vgui/isurface.h"
#include "commandmenu.h"
#include <igameevents.h>
#include "igameevents.h"
using namespace vgui;
@@ -25,7 +25,7 @@ class IGameUIFuncs;
class IGameEventManager;
//==============================================================================
class CBaseViewport : public vgui::EditablePanel, public IViewPort, public IGameEventListener2
class CBaseViewport : public vgui::EditablePanel, public IViewPort, public CGameEventListener
{
DECLARE_CLASS_SIMPLE( CBaseViewport, vgui::EditablePanel );
@@ -37,7 +37,9 @@ public:
virtual IViewPortPanel* FindPanelByName(const char *szPanelName);
virtual IViewPortPanel* GetActivePanel( void );
virtual void RemoveAllPanels( void);
virtual void RecreatePanel( const char *szPanelName );
virtual void ShowPanel( const char *pName, bool state, KeyValues *data, bool autoDeleteData );
virtual void ShowPanel( const char *pName, bool state );
virtual void ShowPanel( IViewPortPanel* pPanel, bool state );
virtual bool AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugName );
@@ -52,7 +54,11 @@ public:
virtual void ActivateClientUI();
virtual void HideClientUI();
virtual bool AllowedToPrintText( void );
void LoadHudLayout( void );
virtual vgui::VPANEL GetSchemeSizingVPanel( void );
#ifndef _XBOX
virtual int GetViewPortScheme() { return m_pBackGround->GetScheme(); }
virtual VPANEL GetViewPortPanel() { return m_pBackGround->GetVParent(); }
@@ -70,21 +76,6 @@ public:
// virtual void ChatInputPosition( int *x, int *y );
// Check if any panel other than the scoreboard is visible
virtual bool IsAnyPanelVisibleExceptScores();
// Walk through all the panels. Handler should be an object taking an IViewPortPanel*
template<typename THandler> void ForEachPanel( THandler handler )
{
FOR_EACH_VEC( m_Panels, i )
{
handler( m_Panels[i] );
}
}
// Check if the named panel is visible
virtual bool IsPanelVisible( const char* panel );
public: // IGameEventListener:
virtual void FireGameEvent( IGameEvent * event);
@@ -130,7 +121,7 @@ protected:
virtual void OnMousePressed(MouseCode code) { }// don't respond to mouse clicks
virtual vgui::VPANEL IsWithinTraverse( int x, int y, bool traversePopups )
{
return ( vgui::VPANEL )0;
return NULL;
}
};
@@ -142,22 +133,30 @@ protected:
virtual void OnScreenSizeChanged(int iOldWide, int iOldTall);
void PostMessageToPanel( IViewPortPanel* pPanel, KeyValues *pKeyValues );
void SetAsFullscreenViewportInterface( void );
bool IsFullscreenViewport() const;
protected:
IGameUIFuncs* m_GameuiFuncs; // for key binding details
IGameEventManager2* m_GameEventManager;
#ifndef _XBOX
CBackGroundPanel *m_pBackGround;
#endif
CUtlVector<IViewPortPanel*> m_Panels;
CUtlDict<IViewPortPanel*,int> m_Panels;
CUtlVector< IViewPortPanel* > m_UnorderedPanels;
bool m_bHasParent; // Used to track if child windows have parents or not.
bool m_bInitialized;
bool m_bFullscreenViewport;
IViewPortPanel *m_pActivePanel;
IViewPortPanel *m_pLastActivePanel;
vgui::HCursor m_hCursorNone;
vgui::AnimationController *m_pAnimController;
int m_OldSize[2];
private:
virtual void InitViewportSingletons( void );
};
#endif
#endif // BASEVIEWPORT_H
+4 -64
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -6,9 +6,9 @@
//=============================================================================//
#include "cbase.h"
#include "buymenu.h"
#include "BuyMenu.h"
#include "buysubmenu.h"
#include "BuySubMenu.h"
using namespace vgui;
#include "mouseoverpanelbutton.h"
@@ -68,13 +68,9 @@ void CBuyMenu::ShowPanel(bool bShow)
Run( m_pMainMenu );
SetMouseInputEnabled( true );
engine->ClientCmd_Unrestricted( "gameui_preventescapetoshow\n" );
}
else
{
engine->ClientCmd_Unrestricted( "gameui_allowescapetoshow\n" );
SetVisible( false );
SetMouseInputEnabled( false );
}
@@ -86,66 +82,10 @@ void CBuyMenu::ShowPanel(bool bShow)
void CBuyMenu::Update()
{
//Don't need to do anything, but do need to implement this function as base is pure virtual
NULL;
}
void CBuyMenu::OnClose()
{
engine->ClientCmd_Unrestricted( "gameui_allowescapetoshow\n" );
BaseClass::OnClose();
ResetHistory();
}
void CBuyMenu::OnKeyCodePressed( vgui::KeyCode code )
{
int nDir = 0;
switch ( code )
{
case KEY_XBUTTON_UP:
case KEY_XSTICK1_UP:
case KEY_XSTICK2_UP:
case KEY_UP:
case STEAMCONTROLLER_DPAD_UP:
nDir = -1;
break;
case KEY_XBUTTON_DOWN:
case KEY_XSTICK1_DOWN:
case KEY_XSTICK2_DOWN:
case KEY_DOWN:
case STEAMCONTROLLER_DPAD_DOWN:
nDir = 1;
break;
}
if ( nDir != 0 )
{
Panel *pSubPanel = ( GetCurrentSubPanel() ? GetCurrentSubPanel() : m_pMainMenu );
CUtlSortVector< SortedPanel_t, CSortedPanelYLess > vecSortedButtons;
VguiPanelGetSortedChildButtonList( pSubPanel, (void*)&vecSortedButtons, "&", 0 );
if ( VguiPanelNavigateSortedChildButtonList( (void*)&vecSortedButtons, nDir ) != -1 )
{
// Handled!
return;
}
}
else
{
BaseClass::OnKeyCodePressed( code );
}
}
void CBuyMenu::OnKeyCodeTyped( KeyCode code )
{
if ( code == KEY_ESCAPE )
{
OnClose();
}
else
{
BaseClass::OnKeyCodeTyped( code );
}
}
+2 -7
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -13,7 +13,6 @@
#include <vgui_controls/WizardPanel.h>
#include <game/client/iviewport.h>
#include "vgui/KeyCode.h"
class CBuySubMenu;
@@ -46,11 +45,7 @@ public:
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual void OnKeyCodePressed( vgui::KeyCode code );
virtual void OnKeyCodeTyped( vgui::KeyCode code );
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_MENUCONTROLS; }
virtual bool WantsBackgroundBlurred( void ) { return false; }
public:
virtual void OnClose();
+5 -5
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -6,15 +6,15 @@
//=============================================================================//
#include "cbase.h"
#include "buysubmenu.h"
#include "BuySubMenu.h"
#include <KeyValues.h>
#include <vgui_controls/WizardPanel.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <game/client/iviewport.h>
#include <cdll_client_int.h>
#include "mouseoverpanelbutton.h"
#include "MouseOverPanelButton.h"
// #include "cs_gamerules.h"
// memdbgon must be the last include file in a .cpp file!!!
@@ -135,7 +135,7 @@ void CBuySubMenu::OnCommand( const char *command)
else
{
GetWizardPanel()->Close();
gViewPortInterface->ShowBackGround( false );
GetViewPortInterface()->ShowBackGround( false );
if ( Q_stricmp( command, "vguicancel" ) != 0 )
engine->ClientCmd( command );
+2 -2
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -13,7 +13,7 @@
#include <vgui_controls/WizardSubPanel.h>
#include <vgui_controls/Button.h>
#include <utlvector.h>
#include <UtlVector.h>
#include "mouseoverpanelbutton.h"
class CBuyMenu;
+15 -60
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -18,12 +18,11 @@
#include <vgui/ISurface.h>
#include <KeyValues.h>
#include <vgui_controls/ImageList.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <vgui_controls/TextEntry.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/Panel.h>
#include "inputsystem/iinputsystem.h"
#include "cdll_util.h"
#include "IGameUIFuncs.h" // for key bindings
@@ -32,6 +31,8 @@ extern IGameUIFuncs *gameuifuncs; // for key binding details
#endif
#include <game/client/iviewport.h>
#include <stdlib.h> // MAX_PATH define
// memdbgon must be the last include file in a .cpp file!!!
@@ -39,18 +40,16 @@ extern IGameUIFuncs *gameuifuncs; // for key binding details
using namespace vgui;
#ifdef TF_CLIENT_DLL
#define HUD_CLASSAUTOKILL_FLAGS ( FCVAR_CLIENTDLL | FCVAR_ARCHIVE | FCVAR_USERINFO )
#else
#define HUD_CLASSAUTOKILL_FLAGS ( FCVAR_CLIENTDLL | FCVAR_ARCHIVE )
#endif // !TF_CLIENT_DLL
ConVar hud_classautokill( "hud_classautokill", "1", HUD_CLASSAUTOKILL_FLAGS, "Automatically kill player after choosing a new playerclass." );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CClassMenu::CClassMenu(IViewPort *pViewPort) : Frame(NULL, PANEL_CLASS)
CClassMenu::CClassMenu(IViewPort *pViewPort) : BaseClass(NULL, PANEL_CLASS)
{
m_pViewPort = pViewPort;
m_iScoreBoardKey = BUTTON_CODE_INVALID; // this is looked up in Activate()
@@ -77,7 +76,7 @@ CClassMenu::CClassMenu(IViewPort *pViewPort) : Frame(NULL, PANEL_CLASS)
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CClassMenu::CClassMenu(IViewPort *pViewPort, const char *panelName) : Frame(NULL, panelName)
CClassMenu::CClassMenu(IViewPort *pViewPort, const char *panelName) : BaseClass(NULL, panelName)
{
m_pViewPort = pViewPort;
m_iScoreBoardKey = BUTTON_CODE_INVALID; // this is looked up in Activate()
@@ -167,21 +166,23 @@ void CClassMenu::OnCommand( const char *command )
{
if ( Q_stricmp( command, "vguicancel" ) )
{
engine->ClientCmd( const_cast<char *>( command ) );
#if !defined( CSTRIKE_DLL ) && !defined( TF_CLIENT_DLL )
// They entered a command to change their class, kill them so they spawn with
// the new class right away
if ( hud_classautokill.GetBool() )
{
engine->ClientCmd( "kill" );
}
#endif // !CSTRIKE_DLL && !TF_CLIENT_DLL
}
Close();
gViewPortInterface->ShowBackGround( false );
GetViewPortInterface()->ShowBackGround( false );
BaseClass::OnCommand( command );
}
@@ -255,56 +256,10 @@ void CClassMenu::SetVisibleButton(const char *textEntryName, bool state)
void CClassMenu::OnKeyCodePressed(KeyCode code)
{
int nDir = 0;
switch ( code )
{
case KEY_XBUTTON_UP:
case KEY_XSTICK1_UP:
case KEY_XSTICK2_UP:
case KEY_UP:
case KEY_XBUTTON_LEFT:
case KEY_XSTICK1_LEFT:
case KEY_XSTICK2_LEFT:
case KEY_LEFT:
case STEAMCONTROLLER_DPAD_LEFT:
nDir = -1;
break;
case KEY_XBUTTON_DOWN:
case KEY_XSTICK1_DOWN:
case KEY_XSTICK2_DOWN:
case KEY_DOWN:
case KEY_XBUTTON_RIGHT:
case KEY_XSTICK1_RIGHT:
case KEY_XSTICK2_RIGHT:
case KEY_RIGHT:
case STEAMCONTROLLER_DPAD_RIGHT:
nDir = 1;
break;
}
if ( m_iScoreBoardKey != BUTTON_CODE_INVALID && m_iScoreBoardKey == code )
{
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
gViewPortInterface->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
}
else if ( nDir != 0 )
{
CUtlSortVector< SortedPanel_t, CSortedPanelYLess > vecSortedButtons;
VguiPanelGetSortedChildButtonList( this, (void*)&vecSortedButtons, "&", 0 );
int nNewArmed = VguiPanelNavigateSortedChildButtonList( (void*)&vecSortedButtons, nDir );
if ( nNewArmed != -1 )
{
// Handled!
if ( nNewArmed < m_mouseoverButtons.Count() )
{
m_mouseoverButtons[ nNewArmed ]->OnCursorEntered();
}
return;
}
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, true );
GetViewPortInterface()->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
}
else
{
+3 -4
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -14,7 +14,7 @@
#include <vgui_controls/Frame.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/HTML.h>
#include <utlvector.h>
#include <UtlVector.h>
#include <vgui/ILocalize.h>
#include <vgui/KeyCode.h>
#include <game/client/iviewport.h>
@@ -51,8 +51,7 @@ public:
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_NONE; }
virtual bool WantsBackgroundBlurred( void ) { return false; }
protected:
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -12,6 +12,7 @@
#endif
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/Label.h>
#include <game/client/iviewport.h>
#include "GameEventListener.h"
@@ -47,25 +48,18 @@ public:
virtual bool HasInputElements( void ) { return true; }
virtual void ShowPanel( bool bShow );
virtual bool ShowAvatars()
{
#ifdef CSS_PERF_TEST
return false;
#endif
return IsPC();
}
virtual bool ShowAvatars() { return IsPC(); }
// both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual bool WantsBackgroundBlurred( void ) { return false; }
// IGameEventListener interface:
virtual void FireGameEvent( IGameEvent *event);
virtual void UpdatePlayerAvatar( int playerIndex, KeyValues *kv );
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_NONE; }
protected:
MESSAGE_FUNC_INT( OnPollHideCode, "PollHideCode", code );
@@ -84,6 +78,7 @@ protected:
static bool StaticPlayerSortFunc(vgui::SectionedListPanel *list, int itemID1, int itemID2);
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
virtual void ApplySettings(KeyValues *inResourceData);
virtual void PostApplySchemeSettings( vgui::IScheme *pScheme );
@@ -102,10 +97,11 @@ protected:
float m_fNextUpdateTime;
void MoveLabelToFront(const char *textEntryName);
void MoveToCenterOfScreen();
void PositionScoreboard();
vgui::ImageList *m_pImageList;
CUtlMap<CSteamID,int> m_mapAvatarsToImageList;
int m_iImageAvatars[MAX_PLAYERS+1];
CUtlMap<int,int> m_mapAvatarsToImageList;
CPanelAnimationVar( int, m_iAvatarWidth, "avatar_width", "34" ); // Avatar width doesn't scale with resolution
CPanelAnimationVarAliasType( int, m_iNameWidth, "name_width", "136", "proportional_int" );
@@ -120,6 +116,7 @@ private:
IViewPort *m_pViewPort;
ButtonCode_t m_nCloseKey;
vgui::Label::Alignment m_alignment;
// methods
void FillScoreBoard();
+2 -2
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
@@ -12,7 +12,7 @@
#include <icvar.h>
#include <filesystem.h>
#include "commandmenu.h"
#include "CommandMenu.h"
#include "vgui_controls/MenuItem.h"
// memdbgon must be the last include file in a .cpp file!!!
+3 -3
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@@ -12,8 +12,8 @@
#include <vgui_controls/Menu.h>
#include <game/client/iviewport.h>
#include <filesystem.h>
#include "utlstack.h"
#include "utlvector.h"
#include "UtlStack.h"
#include "UtlVector.h"
#include <KeyValues.h>
using namespace vgui;
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -8,8 +8,8 @@
#ifndef IMAGE_MOUSE_OVER_BUTTON_H
#define IMAGE_MOUSE_OVER_BUTTON_H
#include "vgui/ISurface.h"
#include "vgui/IScheme.h"
#include "vgui/isurface.h"
#include "vgui/ischeme.h"
#include "mouseoverpanelbutton.h"
//===============================================
@@ -64,7 +64,7 @@ CImageMouseOverButton<T>::CImageMouseOverButton( vgui::Panel *parent, const char
template <class T>
void CImageMouseOverButton<T>::ApplySettings( KeyValues *inResourceData )
{
m_bScaleImage = inResourceData->GetInt( "scaleImage", 0 );
m_bScaleImage = inResourceData->GetBool( "scaleImage", false );
// Active Image
delete [] m_pszActiveImageName;
@@ -111,10 +111,14 @@ void CImageMouseOverButton<T>::ApplySchemeSettings( vgui::IScheme *pScheme )
this->SetDepressedBorder( pBorder );
this->SetKeyFocusBorder( pBorder );
Color defaultFgColor = GetSchemeColor( "Button.TextColor", Color(255, 255, 255, 255), pScheme );
Color armedFgColor = GetSchemeColor( "Button.ArmedTextColor", Color(255, 255, 255, 255), pScheme );
Color depressedFgColor = GetSchemeColor( "Button.DepressedTextColor", Color(255, 255, 255, 255), pScheme );
Color blank(0,0,0,0);
this->SetDefaultColor( this->GetButtonFgColor(), blank );
this->SetArmedColor( this->GetButtonArmedFgColor(), blank );
this->SetDepressedColor( this->GetButtonDepressedFgColor(), blank );
this->SetDefaultColor( defaultFgColor, blank );
this->SetArmedColor( armedFgColor, blank );
this->SetDepressedColor( depressedFgColor, blank );
}
template <class T>
@@ -251,6 +255,9 @@ template <class T>
void CImageMouseOverButton<T>::HidePage( void )
{
MouseOverButton<T>::HidePage();
// send message to parent that we triggered something
this->PostActionSignal( new KeyValues( "ShowPage", "page", this->GetName() ) );
}
#endif //IMAGE_MOUSE_OVER_BUTTON_H
+3 -3
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
@@ -11,7 +11,7 @@
#include <vgui/IScheme.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <KeyValues.h>
#include <convar.h>
#include <game/client/iviewport.h>
@@ -26,7 +26,7 @@ using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CIntroMenu::CIntroMenu( IViewPort *pViewPort ) : Frame( NULL, PANEL_INTRO )
CIntroMenu::CIntroMenu( IViewPort *pViewPort ) : BaseClass( NULL, PANEL_INTRO )
{
// initialize dialog
m_pViewPort = pViewPort;
+2 -3
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
@@ -45,8 +45,7 @@ public:
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_IN_GAME_HUD; }
virtual bool WantsBackgroundBlurred( void ) { return false; }
protected:
// vgui overrides
+26 -20
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: MiniMap.h: interface for the CMiniMap class.
//
@@ -19,6 +19,23 @@
#include <const.h>
#include "hudelement.h"
typedef struct MapObject_s {
int objectID; // unique object ID
int index; // entity index if any
int icon; // players texture icon ID
Color color; // players team color
char name[MAX_PLAYER_NAME_LENGTH]; // show text under icon
Vector position; // current x,y pos
QAngle angle; // view origin 0..360
float endtime; // time stop showing object
float size; // object size
float status; // green status bar [0..1], -1 = disabled
Color statusColor; // color of status bar
int flags; // MAB_OBJECT_*
Color iconColor;
const char *text; // text to draw underneath the icon
} MapObject_t;
class IMapOverviewPanel
{
public:
@@ -91,23 +108,8 @@ protected: // private structures & types
Vector2D trail[MAX_TRAIL_LENGTH]; // save 1 footstep each second for 1 minute
} MapPlayer_t;
typedef struct MapObject_s {
int objectID; // unique object ID
int index; // entity index if any
int icon; // players texture icon ID
Color color; // players team color
char name[MAX_PLAYER_NAME_LENGTH]; // show text under icon
Vector position; // current x,y pos
QAngle angle; // view origin 0..360
float endtime; // time stop showing object
float size; // object size
float status; // green status bar [0..1], -1 = disabled
Color statusColor; // color of status bar
int flags; // MAB_OBJECT_*
const char *text; // text to draw underneath the icon
} MapObject_t;
#define MAP_OBJECT_ALIGN_TO_MAP (1<<0)
#define MAP_OBJECT_DONT_DRAW (1<<1)
public: // IViewPortPanel interface:
@@ -161,6 +163,7 @@ public:
virtual void SetCenter( const Vector2D &mappos);
virtual void SetAngle( float angle);
virtual Vector2D WorldToMap( const Vector &worldpos );
Vector2D MapToPanel( const Vector2D &mappos );
// Object settings
virtual int AddObject( const char *icon, int entity, float timeToLive ); // returns object ID, 0 = no entity, -1 = forever
@@ -168,6 +171,7 @@ public:
virtual void SetObjectText( int objectID, const char *text, Color color ); // text under icon
virtual void SetObjectStatus( int objectID, float value, Color statusColor ); // status bar under icon
virtual void SetObjectPosition( int objectID, const Vector &position, const QAngle &angle ); // world pos/angles
virtual void SetObjectIconColor( int objectID, Color color );
virtual void AddObjectFlags( int objectID, int flags );
virtual void SetObjectFlags( int objectID, int flags );
virtual void RemoveObject( int objectID );
@@ -185,6 +189,8 @@ public:
virtual int GetIconNumberFromTeamNumber( int teamNumber ){return teamNumber;}
MapObject_t* FindObjectByIndex(int objectIndex);
protected:
virtual void DrawCamera();
@@ -201,11 +207,10 @@ protected:
bool IsInPanel(Vector2D &pos);
MapPlayer_t* GetPlayerByUserID( int userID );
int AddIconTexture(const char *filename);
Vector2D MapToPanel( const Vector2D &mappos );
int GetPixelOffset( float height );
void UpdateFollowEntity();
virtual void UpdatePlayers();
void UpdateObjects(); // objects bound to entities
virtual void UpdateObjects(); // objects bound to entities
MapObject_t* FindObjectByID(int objectID);
virtual bool IsRadarLocked() {return false;}
@@ -270,6 +275,7 @@ protected:
};
extern IMapOverviewPanel *g_pMapOverview;
IMapOverviewPanel *GetMapOverView();
void SetMapOverView( int nSlot, IMapOverviewPanel *pPanel );
#endif //
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -88,12 +88,7 @@ private:
if ( m_bAddShortCut )
{
#ifdef WIN32
_snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %s", m_iIndex, localizeText);
#else
_snwprintf( newText, sizeof( newText )/ sizeof( wchar_t ), L"&%i %S", m_iIndex, localizeText);
#endif
}
else
{
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -1,324 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#include "cbase.h"
#include "game_controls/navigationpanel.h"
#include "econ/econ_controls.h"
#include "vgui_controls/Frame.h"
#include "vgui/IInput.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
using namespace vgui;
//-----------------------------------------------------------------------------
DECLARE_BUILD_FACTORY( CNavigationPanel );
//-----------------------------------------------------------------------------
class CNavButton : public CExImageButton
{
DECLARE_CLASS_SIMPLE( CNavButton, CExImageButton );
public:
CNavButton( Panel *parent, const char *name, const char *text = "", Panel *pActionSignalTarget = NULL, const char *cmd = NULL )
: CExImageButton( parent, name, text, pActionSignalTarget, cmd ), m_iUserData( -1 ) {}
CNavButton( Panel *parent, const char *name, const wchar_t *wszText = L"", Panel *pActionSignalTarget = NULL, const char *cmd = NULL )
: CExImageButton( parent, name, wszText, pActionSignalTarget, cmd ) , m_iUserData( -1 ) {}
virtual void ApplySettings( KeyValues *pInResourceData )
{
BaseClass::ApplySettings( pInResourceData );
if ( m_iUserData < 0 )
{
m_iUserData = pInResourceData->GetInt( "userdata", -1 ); AssertMsg( m_iUserData != -1, "Any messages sent for this button will have invalid user data!" );
}
}
int m_iUserData;
};
//-----------------------------------------------------------------------------
CNavigationPanel::CNavigationPanel( Panel *pParent, const char *pName, bool bAddParentAsActionSignalTarget/*=true*/ )
: BaseClass( pParent, pName ),
m_bAutoLayout( false ),
m_bAutoScale( true ),
m_bDisplayVertical( false ),
m_iSelectedButton( 0 ),
// m_nAlignment( ALIGN_CENTER ),
m_pKVButtonSettings( NULL )
{
if ( bAddParentAsActionSignalTarget && pParent )
{
AddActionSignalTarget( pParent );
}
}
CNavigationPanel::~CNavigationPanel()
{
}
void CNavigationPanel::AddButton( int iUserData, const char *pTextToken )
{
const int i = m_vecButtons.Count();
CNavButton *pNewButton = new CNavButton( this, CFmtStr( "button_%i", i ).Access(), pTextToken );
pNewButton->m_iUserData = iUserData;
pNewButton->InvalidateLayout( true, false );
pNewButton->SetCommand( CFmtStr( "select_%i", i ).Access() );
m_vecButtons.AddToTail( pNewButton );
}
CExImageButton *CNavigationPanel::GetButton( int index )
{
return m_vecButtons[ index ];
}
void CNavigationPanel::ApplySettings( KeyValues *pInResourceData )
{
BaseClass::ApplySettings( pInResourceData );
/*
const char *pAlignment = pInResourceData->GetString( "align", NULL );
if ( pAlignment )
{
if ( !V_strnicmp( pAlignment, "west", 4 ) )
{
m_nAlignment = ALIGN_WEST;
}
else if ( !V_strnicmp( pAlignment, "center", 6 ) )
{
m_nAlignment = ALIGN_CENTER;
}
else if ( !V_strnicmp( pAlignment, "east", 4 ) )
{
AssertMsg( 0, "This type of alignment is not supported." );
}
}
*/
m_bAutoLayout = pInResourceData->GetBool( "auto_layout", false );
m_bAutoScale = pInResourceData->GetBool( "auto_scale", true );
m_bDisplayVertical = pInResourceData->GetBool( "display_vertically", false );
KeyValues *pKVButtonSettings = pInResourceData->FindKey( "ButtonSettings" ); AssertMsg( pKVButtonSettings, "This is required" );
if ( !pKVButtonSettings )
{
AssertMsg( 0, "No button settings specified. CNavigationPanel is useless without this data." );
return;
}
// Cache this off for later
if ( m_pKVButtonSettings )
{
m_pKVButtonSettings->deleteThis();
m_pKVButtonSettings = NULL;
}
m_pKVButtonSettings = pKVButtonSettings->MakeCopy();
// Get individual button data and apply now
KeyValues *pKVButtons = pInResourceData->FindKey( "Buttons" );
if ( !pKVButtons )
return;
// Go through each image description and create a button
if ( m_vecButtons.Count() )
return;
int i = 0;
FOR_EACH_SUBKEY( pKVButtons, pKVCurButton )
{
CNavButton *pNewButton = new CNavButton( this, pKVCurButton->GetString( "FieldName", pKVCurButton->GetName() ), L"" );
pNewButton->ApplySettings( pKVCurButton );
pNewButton->InvalidateLayout( true, false );
pNewButton->SetCommand( CFmtStr( "select_%i", i ).Access() );
m_vecButtons.AddToTail( pNewButton );
++i;
}
if ( m_vecButtons.IsValidIndex( m_iSelectedButtonDefault ) )
{
UpdateButtonSelectionStates( m_iSelectedButtonDefault );
m_vecButtons[ m_iSelectedButtonDefault ]->InvalidateLayout( true );
const int iUserData = m_vecButtons[ m_iSelectedButtonDefault ]->m_iUserData;
PostActionSignal( new KeyValues( "NavButtonSelected", "userdata", iUserData ) );
}
}
void CNavigationPanel::ApplySchemeSettings( IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
}
void CNavigationPanel::PerformLayout()
{
if ( !m_vecButtons.Count() )
return;
if ( !m_pKVButtonSettings )
return;
BaseClass::PerformLayout();
// Get from settings
int nSettingWidth = m_pKVButtonSettings->GetInt( "wide" );
int nSettingHeight = m_pKVButtonSettings->GetInt( "tall" );
// Button dimensions for setting positions
int nButtonWidth = nSettingWidth;
int nButtonHeight = nSettingHeight;
if ( m_bAutoScale )
{
// Get image size
int nImageW, nImageH;
m_vecButtons[0]->GetImage()->GetSize( nImageW, nImageH );
int nWidth, nHeight;
if ( m_bDisplayVertical )
{
nWidth = GetWide();
nHeight = nSettingHeight * nWidth / ( nSettingWidth > 0 ? nSettingWidth : 1 );
}
else
{
nHeight = GetTall();
nWidth = nSettingWidth * nHeight / ( nSettingHeight > 0 ? nSettingHeight : 1 );
}
// Update button dimensions to scaled versions
nButtonWidth = nWidth;
nButtonHeight = nHeight;
}
FOR_EACH_VEC( m_vecButtons, i )
{
if ( m_vecButtons[i] && m_pKVButtonSettings )
{
// Apply generic settings
m_vecButtons[i]->ApplySettings( m_pKVButtonSettings );
}
if ( m_bAutoLayout )
{
// Display buttons vertically or horizontally?
if ( m_bDisplayVertical )
{
m_vecButtons[i]->SetPos( 0, i * ( nButtonHeight + m_nVerticalBuffer ) );
}
else
{
const int nStartX = 0;//0.5f * ( GetWide() - NumButtons() * ( nButtonWidth + m_nHorizontalBuffer ) );
m_vecButtons[i]->SetPos( nStartX + i * ( nButtonWidth + m_nHorizontalBuffer ), 0 );
}
}
if ( m_bAutoScale )
{
m_vecButtons[i]->SetSize( nButtonWidth, nButtonHeight );
m_vecButtons[i]->GetImage()->SetSize( nButtonWidth, nButtonHeight );
}
m_vecButtons[i]->SetVisible( true );
}
}
void CNavigationPanel::OnCommand( const char *pCommand )
{
if ( !V_strnicmp( pCommand, "select_", 7 ) )
{
const int iButton = atoi( pCommand + 7 ); AssertMsg( m_vecButtons.IsValidIndex( iButton ), "Button index out of range!" );
if ( !m_vecButtons.IsValidIndex( iButton ) )
return;
UpdateButtonSelectionStates( iButton );
const int iUserData = m_vecButtons[ iButton ]->m_iUserData;
PostActionSignal( new KeyValues( "NavButtonSelected", "userdata", iUserData ) );
}
else
{
BaseClass::OnCommand( pCommand );
}
}
void CNavigationPanel::OnThink()
{
BaseClass::OnThink();
// Make sure we only ever have one button in the selection state, since it's
// possible to do this if you select a button, then click and drag on another
// button, and release the mouse elsewhere.
if ( !vgui::input()->IsMouseDown( MOUSE_LEFT ) )
{
UpdateButtonSelectionStates( m_iSelectedButton );
}
}
void CNavigationPanel::UpdateButtonSelectionStates( int iButton )
{
if ( m_iSelectedButton != iButton )
{
m_iSelectedButton = iButton;
}
// Set the correct button as selected, all other buttons as not selected
for ( int i = 0; i < NumButtons(); ++i )
{
CNavButton *pCurButton = m_vecButtons[ i ];
if ( !pCurButton )
continue;
bool bShouldSelect = iButton == i;
pCurButton->SetSelected( bShouldSelect );
pCurButton->InvalidateLayout();
}
}
//-----------------------------------------------------------------------------
#ifdef _DEBUG
class CNavPanelTest : public Frame
{
DECLARE_CLASS_SIMPLE( CNavPanelTest, Frame );
public:
CNavPanelTest( vgui::Panel *pParent )
: Frame( pParent, "NavPanelTest" )
{
SetProportional( true );
LoadControlSettings( "Resource/UI/NavigationPanelTest.res" );
}
};
CON_COMMAND( open_navpanel_test, "" )
{
CNavPanelTest *pPanel = SETUP_PANEL( new CNavPanelTest( NULL ) );
pPanel->SetVisible( true );
pPanel->InvalidateLayout( false, true );
engine->ClientCmd_Unrestricted( "gameui_activate" );
const int nWidth = XRES( 300 );
const int nHeight = YRES( 300 );
pPanel->SetBounds(
( ScreenWidth() - nWidth ) / 2,
( ScreenHeight() - nHeight ) / 2,
nWidth,
nHeight
);
pPanel->Activate();
}
#endif // _DEBUG
@@ -1,79 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef NAVIGATIONPANEL_H
#define NAVIGATIONPANEL_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
#include "vgui_controls/EditablePanel.h"
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
class ImagePanel;
};
class CNavButton;
class CExImageButton;
//-----------------------------------------------------------------------------
//
// A generic panel containing a list of buttons which can be displayed vertically
// or horizontally. One button at a time can be selected, and messages are sent
// to the parent by default.
//
class CNavigationPanel : public vgui::EditablePanel
{
private:
DECLARE_CLASS_SIMPLE( CNavigationPanel, vgui::EditablePanel );
public:
CNavigationPanel( vgui::Panel *pParent, const char *pName, bool bAddParentAsActionSignalTarget = true );
virtual ~CNavigationPanel();
void AddButton( int iUserData, const char *pTextToken );
int NumButtons() const { return m_vecButtons.Count(); }
CExImageButton *GetButton( int index );
void UpdateButtonSelectionStates( int iButton );
protected:
virtual void PerformLayout();
virtual void ApplySettings( KeyValues *pInResourceData );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void OnCommand( const char *pCommand );
virtual void OnThink();
CUtlVector< CNavButton * > m_vecButtons;
bool m_bAutoLayout;
bool m_bAutoScale; // Auto-scale buttons to proportionally match height (for horizontal display) or width (for vertical display)
bool m_bDisplayVertical;
int m_iSelectedButton; // The currently selected button
KeyValues *m_pKVButtonSettings;
/*
enum Alignment_t
{
ALIGN_WEST, // left
ALIGN_CENTER,
};
Alignment_t m_nAlignment;
*/
// For auto-layout mode only
CPanelAnimationVarAliasType( int, m_nHorizontalBuffer, "auto_layout_horizontal_buffer", "5", "proportional_xpos" );
CPanelAnimationVarAliasType( int, m_nVerticalBuffer, "auto_layout_vertical_buffer", "5", "proportional_ypos" );
CPanelAnimationVar( int, m_iSelectedButtonDefault, "selected_button_default", "-1" );
};
//-----------------------------------------------------------------------------
#endif // NAVIGATIONPANEL_H
@@ -1,318 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#include "cbase.h"
#include "game_controls/slideshowpanel.h"
#include "vgui/IVGui.h"
#include "filesystem.h"
#include "fmtstr.h"
//-----------------------------------------------------------------------------
using namespace vgui;
//-----------------------------------------------------------------------------
DECLARE_BUILD_FACTORY( CCrossfadableImagePanel );
DECLARE_BUILD_FACTORY( CSlideshowPanel );
//-----------------------------------------------------------------------------
CCrossfadableImagePanel::CCrossfadableImagePanel( Panel* pParent, const char *pName )
: EditablePanel( pParent, pName ),
m_iSrcImg( 0 ),
m_flBlend( 0.0f ),
m_flBlendTime( 0.0f ),
m_flStartBlendTime( 0.0f ),
m_bBlending( false )
{
m_pImages[ 0 ] = new ImagePanel( this, "Image0" );
m_pImages[ 1 ] = new ImagePanel( this, "Image1" );
ivgui()->AddTickSignal( GetVPanel(), 10 );
}
CCrossfadableImagePanel::~CCrossfadableImagePanel()
{
ivgui()->RemoveTickSignal( GetVPanel() );
}
void CCrossfadableImagePanel::ApplySettings( KeyValues *pInResourceData )
{
BaseClass::ApplySettings( pInResourceData );
}
void CCrossfadableImagePanel::ApplySchemeSettings( IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
SrcImg()->SetTileImage( false );
DstImg()->SetTileImage( false );
}
void CCrossfadableImagePanel::PerformLayout()
{
BaseClass::PerformLayout();
for ( int i = 0; i < 2; ++i )
{
m_pImages[ i ]->SetBounds( 0, 0, GetWide(), GetTall() );
m_pImages[ i ]->SetVisible( true );
}
}
// Helper macro to perform a call on both images
#define CALL_FUNC_ON_BOTH_IMAGES( _call ) \
AssertMsg( m_pImages[ 0 ], "m_pImages[ 0 ] is NULL!" ); \
AssertMsg( m_pImages[ 1 ], "m_pImages[ 1 ] is NULL!" ); \
m_pImages[0]->_call; \
m_pImages[1]->_call;
void CCrossfadableImagePanel::SetShouldScaleImage( bool bState )
{
CALL_FUNC_ON_BOTH_IMAGES( SetShouldScaleImage( bState ) );
}
void CCrossfadableImagePanel::SetScaleAmount( float flScale )
{
CALL_FUNC_ON_BOTH_IMAGES( SetScaleAmount( flScale ) );
}
void CCrossfadableImagePanel::SetFillColor( Color c )
{
CALL_FUNC_ON_BOTH_IMAGES( SetFillColor( c ) );
}
void CCrossfadableImagePanel::SetDrawColor( Color clrDrawColor )
{
CALL_FUNC_ON_BOTH_IMAGES( SetDrawColor( clrDrawColor ) );
}
void CCrossfadableImagePanel::InstallMouseHandler( Panel *pHandler )
{
CALL_FUNC_ON_BOTH_IMAGES( InstallMouseHandler( pHandler ) );
}
IImage *CCrossfadableImagePanel::GetImage()
{
return SrcImg()->GetImage();
}
const char *CCrossfadableImagePanel::GetImageName()
{
return SrcImg()->GetImageName();
}
float CCrossfadableImagePanel::GetScaleAmount()
{
return SrcImg()->GetScaleAmount();
}
bool CCrossfadableImagePanel::GetShouldScaleImage()
{
return SrcImg()->GetShouldScaleImage();
}
Color CCrossfadableImagePanel::GetFillColor()
{
return SrcImg()->GetFillColor();
}
Color CCrossfadableImagePanel::GetDrawColor()
{
return SrcImg()->GetDrawColor();
}
void CCrossfadableImagePanel::SetImage( IImage *pImage, float flBlendTime/*=0.0f*/ )
{
DstImg()->SetImage( pImage );
SetupImageBlend( flBlendTime );
}
void CCrossfadableImagePanel::SetImage( const char *pImageName, float flBlendTime/*=0.0f*/ )
{
DstImg()->SetImage( pImageName );
SetupImageBlend( flBlendTime );
}
void CCrossfadableImagePanel::SetupImageBlend( float flBlendTime )
{
m_bBlending = true;
m_flBlendTime = flBlendTime;
m_flStartBlendTime = gpGlobals->realtime;
m_flBlend = 0.0f;
}
void CCrossfadableImagePanel::OnSizeChanged( int nWide, int nTall )
{
m_pImages[ 0 ]->SetSize( nWide, nTall );
m_pImages[ 1 ]->SetSize( nWide, nTall );
}
void CCrossfadableImagePanel::OnTick()
{
if ( m_bBlending )
{
// Compute current blend value
if ( m_flBlendTime == 0.0f )
{
m_flBlend = 1.0f;
}
else
{
float t = clamp( ( gpGlobals->realtime - m_flStartBlendTime ) / m_flBlendTime, 0.0f, 1.0f );
m_flBlend = clamp( t * t * (3 - 2*t), 0.0f, 1.0f ); // S-curve
}
// Set alpha channel on source image
Color clrDraw;
clrDraw = SrcImg()->GetDrawColor();
clrDraw[ 3 ] = ( int )( 255 * ( 1 - m_flBlend ) );
SrcImg()->SetDrawColor( clrDraw );
// Set alpha channel on destination image
clrDraw = DstImg()->GetDrawColor();
clrDraw[ 3 ] = ( int )( 255 * m_flBlend );
DstImg()->SetDrawColor( clrDraw );
// If we're done, don't blend next think
if ( m_flBlend >= 1.0f )
{
m_bBlending = false;
m_iSrcImg = !m_iSrcImg;
m_flBlend = 0.0f;
}
}
}
//-----------------------------------------------------------------------------
CSlideshowPanel::CSlideshowPanel( Panel *pParent, const char *pName )
: EditablePanel( pParent, pName ),
m_iCurImg( 0 ),
m_flInterval( 3.0f ),
m_flTransitionLength( 0.5f )
{
m_pImagePanel = new CCrossfadableImagePanel( this, "CrossfadableImage" );
// Setup the first transition time
UpdateNextTransitionTime();
// Add tick signal
ivgui()->AddTickSignal( GetVPanel(), 10 );
}
CSlideshowPanel::~CSlideshowPanel()
{
// Remove tick signal
ivgui()->RemoveTickSignal( GetVPanel() );
}
void CSlideshowPanel::SetInterval( float flInterval )
{
m_flInterval = flInterval;
UpdateNextTransitionTime();
}
void CSlideshowPanel::SetTransitionTime( float flTransitionLength )
{
m_flTransitionLength = flTransitionLength;
UpdateNextTransitionTime();
}
void CSlideshowPanel::UpdateNextTransitionTime()
{
m_flNextTransitionTime = gpGlobals->realtime + m_flInterval;
}
void CSlideshowPanel::AddImage( const char *pImageName )
{
if ( pImageName && strlen( pImageName ) > 0 )
{
AddImage( scheme()->GetImage( pImageName, m_pImagePanel->GetShouldScaleImage() ) );
}
}
void CSlideshowPanel::AddImage( IImage *pImage )
{
// Cache a pointer to the image
m_vecImages.AddToTail( pImage );
if ( m_vecImages.Count() == 1 )
{
GetImagePanel()->SetImage( pImage );
}
}
void CSlideshowPanel::FillWithImages( const char *pBasePath )
{
int i = 0;
while ( 1 )
{
CFmtStr fmtImagePath( "materials/vgui/%s%i.vmt", pBasePath, i );
V_FixDoubleSlashes( fmtImagePath.Access() );
if ( !g_pFullFileSystem->FileExists( fmtImagePath.Access() ) )
break;
fmtImagePath.sprintf( "%s%i.vmt", pBasePath, i );
AddImage( fmtImagePath.Access() );
++i;
}
}
void CSlideshowPanel::ApplySettings( KeyValues *pInResourceData )
{
BaseClass::ApplySettings( pInResourceData );
int iDefaultImage = pInResourceData->GetInt( "default_index", 0 );
int i = 0;
while ( 1 )
{
CFmtStr fmtImageKeyName( "image_%i", i );
const char *pImagePath = pInResourceData->GetString( fmtImageKeyName.Access(), NULL );
if ( !pImagePath )
break;
AddImage( pImagePath );
if ( iDefaultImage == i )
{
GetImagePanel()->SetImage( pImagePath );
}
++i;
}
GetImagePanel()->SetSize(
XRES( pInResourceData->GetInt( "wide" ) ),
YRES( pInResourceData->GetInt( "tall" ) )
);
GetImagePanel()->SetShouldScaleImage( pInResourceData->GetBool( "scaleImage" ) );
GetImagePanel()->SetScaleAmount( pInResourceData->GetFloat( "scaleAmount" ) );
}
void CSlideshowPanel::OnSizeChanged( int nWide, int nTall )
{
GetImagePanel()->SetSize( nWide, nTall );
}
void CSlideshowPanel::OnTick()
{
if ( GetImageCount() > 1 && gpGlobals->realtime >= m_flNextTransitionTime )
{
// Iterate to next image
m_iCurImg = ( m_iCurImg + 1 ) % GetImageCount();
// Setup new image
GetImagePanel()->SetImage( m_vecImages[ m_iCurImg ], m_flTransitionLength );
// Set transition time to be the end of the blend
m_flNextTransitionTime = gpGlobals->realtime + m_flInterval;
}
}
-105
View File
@@ -1,105 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef SLIDESHOWPANEL_H
#define SLIDESHOWPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/ProgressBar.h"
#include "vgui_controls/ImagePanel.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Allows fade from one image to another
//-----------------------------------------------------------------------------
class CCrossfadableImagePanel : public EditablePanel
{
DECLARE_CLASS_SIMPLE( CCrossfadableImagePanel, EditablePanel );
public:
CCrossfadableImagePanel( Panel* pParent, const char *pName );
~CCrossfadableImagePanel();
virtual void ApplySettings( KeyValues *pInResourceData );
virtual void ApplySchemeSettings( IScheme *pScheme );
virtual void PerformLayout();
// A duplicate of the ImagePanel interface - the only difference being that
// here we have blend times for SetImage().
void SetImage( IImage *pImage, float flBlendTime = 0.0f );
void SetImage( const char *pImageName, float flBlendTime = 0.0f );
void SetShouldScaleImage( bool bState );
void SetScaleAmount( float flScale );
void SetDrawColor( Color clrDrawColor );
IImage *GetImage();
const char *GetImageName();
void SetFillColor( Color c );
float GetScaleAmount();
bool GetShouldScaleImage();
Color GetFillColor();
Color GetDrawColor();
virtual void InstallMouseHandler( Panel *pHandler );
private:
virtual void OnSizeChanged( int nWide, int nTall );
virtual void OnTick();
inline ImagePanel *SrcImg() { return m_pImages[ m_iSrcImg ]; }
inline ImagePanel *DstImg() { return m_pImages[ !m_iSrcImg ]; }
void SetupImageBlend( float flBlendTime );
float m_flStartBlendTime; // the gpGlobals->realtime when we started blending
float m_flBlendTime; // amount of time to blend from one image to the next one
float m_flBlend; // blend value in [0,1] where 0 maps to the source image, and 1 maps to the dest image
bool m_bBlending; // are we currently transitioning/blending from one image to another?
ImagePanel* m_pImages[2];
int m_iSrcImg; // 0 or 1
};
//-----------------------------------------------------------------------------
// Purpose: Displays a slideshow of images at a set interval
//-----------------------------------------------------------------------------
class CSlideshowPanel : public EditablePanel
{
DECLARE_CLASS_SIMPLE( CSlideshowPanel, EditablePanel );
public:
CSlideshowPanel( Panel *pParent, const char *pName );
~CSlideshowPanel();
// Pass in a vgui-relative path, like "training/screenshots/cp_dustbowl_", and
// the slideshow panel will add "0.vmt", "1.vmt" etc. until it can't find anymore images.
void FillWithImages( const char *pBasePath );
void AddImage( const char *pImageName );
void AddImage( IImage *pImage );
void SetInterval( float flInterval );
void SetTransitionTime( float flTransitionLength );
CCrossfadableImagePanel *GetImagePanel() { return m_pImagePanel; }
int GetImageCount() const { return m_vecImages.Count(); }
private:
virtual void ApplySettings( KeyValues *pInResourceData );
virtual void OnSizeChanged( int nWide, int nTall );
virtual void OnTick();
void UpdateNextTransitionTime();
CCrossfadableImagePanel *m_pImagePanel;
CUtlVector< IImage * > m_vecImages;
float m_flNextTransitionTime; // gpGlobals->realtime of time when we should transition next
float m_flInterval; // Amount of time between blend begins to next image, in seconds
float m_flTransitionLength; // Length of each transition
int m_iCurImg; // Current image index
};
#endif // SLIDESHOWPANEL_H
+4 -8
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -12,7 +12,7 @@
#endif
#include <vgui/IScheme.h>
#include <vgui/KeyCode.h>
#include <vgui/keycode.h>
#include <vgui_controls/Frame.h>
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/Button.h>
@@ -60,6 +60,7 @@ public:
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
virtual bool WantsBackgroundBlurred( void ) { return false; }
virtual void OnThink();
virtual int GetTopBarHeight() { return m_pTopBar->GetTall(); }
@@ -68,10 +69,6 @@ public:
virtual bool ShouldShowPlayerLabel( int specmode );
virtual Color GetBlackBarColor( void ) { return BLACK_BAR_COLOR; }
virtual const char *GetResFile( void ) { return "Resource/UI/Spectator.res"; }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_SPECTATOR; }
protected:
@@ -128,8 +125,7 @@ public:
virtual bool IsVisible() { return BaseClass::IsVisible(); }
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_SPECTATOR; }
virtual bool WantsBackgroundBlurred( void ) { return false; }
private:
// VGUI2 overrides
+15 -59
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -15,7 +15,7 @@
#include <vgui/ISurface.h>
#include <KeyValues.h>
#include <vgui_controls/ImageList.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <vgui_controls/RichText.h>
#include <vgui_controls/Label.h>
@@ -28,6 +28,7 @@
#include <stdlib.h> // MAX_PATH define
#include <stdio.h>
#include "byteswap.h"
#include "vgui_int.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -67,7 +68,7 @@ const char *GetStringTeamColor( int i )
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTeamMenu::CTeamMenu(IViewPort *pViewPort) : Frame(NULL, PANEL_TEAM )
CTeamMenu::CTeamMenu(IViewPort *pViewPort) : BaseClass(NULL, PANEL_TEAM)
{
m_pViewPort = pViewPort;
m_iJumpKey = BUTTON_CODE_INVALID; // this is looked up in Activate()
@@ -90,6 +91,8 @@ CTeamMenu::CTeamMenu(IViewPort *pViewPort) : Frame(NULL, PANEL_TEAM )
#if defined( ENABLE_HTML_WINDOW )
m_pMapInfoHTML = new HTML( this, "MapInfoHTML");
#else
m_pMapInfoHTML = NULL;
#endif
LoadControlSettings("Resource/UI/TeamMenu.res");
@@ -190,7 +193,6 @@ void CTeamMenu::LoadMapPage( const char *mapName )
char mapRES[ MAX_PATH ];
char uilanguage[ 64 ];
uilanguage[0] = 0;
engine->GetUILanguage( uilanguage, sizeof( uilanguage ) );
Q_snprintf( mapRES, sizeof( mapRES ), "resource/maphtml/%s_%s.html", mapName, uilanguage );
@@ -224,7 +226,7 @@ void CTeamMenu::LoadMapPage( const char *mapName )
#if defined( ENABLE_HTML_WINDOW )
m_pMapInfoHTML->SetVisible( true );
m_pMapInfoHTML->OpenURL( localURL, NULL );
m_pMapInfoHTML->OpenURL( localURL );
#endif
InvalidateLayout();
Repaint();
@@ -275,20 +277,9 @@ void CTeamMenu::LoadMapPage( const char *mapName )
data[ bytesRead+1 ] = 0;
}
#ifndef WIN32
if ( ((ucs2 *)memBlock)[0] == 0xFEFF )
{
// convert the win32 ucs2 data to wchar_t
dataSize*=2;// need to *2 to account for ucs2 to wchar_t (4byte) growth
wchar_t *memBlockConverted = (wchar_t *)malloc(dataSize);
V_UCS2ToUnicode( (ucs2 *)memBlock, memBlockConverted, dataSize );
free(memBlock);
memBlock = memBlockConverted;
}
#else
// null-terminate the stream (redundant, since we memset & then trimmed the transformed buffer already)
memBlock[dataSize / sizeof(wchar_t) - 1] = 0x0000;
#endif
// ensure little-endian unicode reads correctly on all platforms
CByteswap byteSwap;
byteSwap.SetTargetBigEndian( false );
@@ -367,7 +358,7 @@ void CTeamMenu::OnTeamButton( int team )
else // next is spectate
{
// DuckMessage( "#Spec_Duck" );
gViewPortInterface->ShowBackGround( false );
GetViewPortInterface()->ShowBackGround( false );
}
}
else
@@ -395,53 +386,18 @@ void CTeamMenu::SetLabelText(const char *textEntryName, const char *text)
void CTeamMenu::OnKeyCodePressed(KeyCode code)
{
int nDir = 0;
switch ( code )
if( m_iJumpKey != BUTTON_CODE_INVALID && m_iJumpKey == code )
{
case KEY_XBUTTON_UP:
case KEY_XSTICK1_UP:
case KEY_XSTICK2_UP:
case KEY_UP:
case KEY_XBUTTON_LEFT:
case KEY_XSTICK1_LEFT:
case KEY_XSTICK2_LEFT:
case KEY_LEFT:
case STEAMCONTROLLER_DPAD_LEFT:
nDir = -1;
break;
case KEY_XBUTTON_DOWN:
case KEY_XSTICK1_DOWN:
case KEY_XSTICK2_DOWN:
case KEY_DOWN:
case KEY_XBUTTON_RIGHT:
case KEY_XSTICK1_RIGHT:
case KEY_XSTICK2_RIGHT:
case KEY_RIGHT:
case STEAMCONTROLLER_DPAD_RIGHT:
nDir = 1;
break;
AutoAssign();
}
if ( m_iScoreBoardKey != BUTTON_CODE_INVALID && m_iScoreBoardKey == code )
else if ( m_iScoreBoardKey != BUTTON_CODE_INVALID && m_iScoreBoardKey == code )
{
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
gViewPortInterface->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
}
else if ( nDir != 0 )
{
CUtlSortVector< SortedPanel_t, CSortedPanelYLess > vecSortedButtons;
VguiPanelGetSortedChildButtonList( this, (void*)&vecSortedButtons, "&", 0 );
if ( VguiPanelNavigateSortedChildButtonList( (void*)&vecSortedButtons, nDir ) != -1 )
{
// Handled!
return;
}
GetViewPortInterface()->ShowPanel( PANEL_SCOREBOARD, true );
GetViewPortInterface()->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
}
else
{
BaseClass::OnKeyCodePressed( code );
}
}
+7 -6
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -17,7 +17,7 @@
#include <game/client/iviewport.h>
#include <vgui/KeyCode.h>
#include <utlvector.h>
#include <UtlVector.h>
namespace vgui
{
@@ -26,7 +26,6 @@ namespace vgui
}
class TeamFortressViewport;
//-----------------------------------------------------------------------------
// Purpose: Displays the team menu
//-----------------------------------------------------------------------------
@@ -46,13 +45,15 @@ public:
virtual bool NeedsUpdate( void ) { return false; }
virtual bool HasInputElements( void ) { return true; }
virtual void ShowPanel( bool bShow );
virtual bool WantsBackgroundBlurred( void ) { return false; }
// both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_IN_GAME_HUD; }
virtual void SetParent( vgui::VPANEL parent )
{
BaseClass::SetParent( parent );
}
public:
+207 -187
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -9,12 +9,11 @@
#include "vguitextwindow.h"
#include <networkstringtabledefs.h>
#include <cdll_client_int.h>
#include <clientmode_shared.h>
#include <vgui/IScheme.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <filesystem.h>
#include <FileSystem.h>
#include <KeyValues.h>
#include <convar.h>
#include <vgui_controls/ImageList.h>
@@ -32,23 +31,19 @@ extern INetworkStringTable *g_pStringTableInfoPanel;
#define TEMP_HTML_FILE "textwindow_temp.html"
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "1", FCVAR_ARCHIVE, "Disable HTML motds." );
#define MINI_MOTD_FADE_TIME 2.5f
#define MINI_MOTD_HOLD_TIME 5.0f;
//=============================================================================
// HPE_BEGIN:
// [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
// of options. Passing a command string is dangerous and allowed a server network
// message to run arbitrary commands on the client.
//=============================================================================
CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command number>]" )
CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command>]" )
{
if ( !gViewPortInterface )
if ( !GetViewPortInterface() )
return;
if ( args.ArgC() < 4 )
return;
IViewPortPanel * panel = gViewPortInterface->FindPanelByName( PANEL_INFO );
IViewPortPanel * panel = GetViewPortInterface()->FindPanelByName( PANEL_INFO );
if ( panel )
{
@@ -62,7 +57,7 @@ CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command n
panel->SetData( kv );
gViewPortInterface->ShowPanel( panel, true );
GetViewPortInterface()->ShowPanel( panel, true );
kv->deleteThis();
}
@@ -71,14 +66,11 @@ CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command n
Msg("Couldn't find info panel.\n" );
}
}
//=============================================================================
// HPE_END
//=============================================================================
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CTextWindow::CTextWindow(IViewPort *pViewPort) : Frame(NULL, PANEL_INFO )
CTextWindow::CTextWindow(IViewPort *pViewPort) : BaseClass(NULL, PANEL_INFO )
{
// initialize dialog
m_pViewPort = pViewPort;
@@ -87,28 +79,30 @@ CTextWindow::CTextWindow(IViewPort *pViewPort) : Frame(NULL, PANEL_INFO )
m_szTitle[0] = '\0';
m_szMessage[0] = '\0';
m_szMessageFallback[0] = '\0';
m_nExitCommand = TEXTWINDOW_CMD_NONE;
m_bShownURL = false;
m_bUnloadOnDismissal = false;
m_szExitCommand[0] = '\0';
// load the new scheme early!!
SetScheme("ClientScheme");
SetMoveable(false);
SetSizeable(false);
SetProportional(true);
// hide the system buttons
SetTitleBarVisible( false );
m_pTextMessage = new TextEntry( this, "TextMessage" );
m_pHTMLMessage = new CMOTDHTML( this,"HTMLMessage" );
m_pTextMessage = new TextEntry(this, "TextMessage");
#if defined( ENABLE_HTMLWINDOW )
m_pHTMLMessage = new HTML(this,"HTMLMessage");;
#endif
m_pTitleLabel = new Label( this, "MessageTitle", "Message Title" );
m_pOK = new Button(this, "ok", "#PropertyDialog_OK");
m_pOK->SetCommand("okay");
m_pTextMessage->SetMultiline( true );
m_nContentType = TYPE_TEXT;
m_iFadeStatus = FADE_STATUS_IN;
m_bMiniMode = false;
ListenForGameEvent( "game_newmap" );
}
//-----------------------------------------------------------------------------
@@ -118,9 +112,15 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
LoadControlSettings("Resource/UI/TextWindow.res");
if ( !m_bMiniMode )
{
LoadControlSettings("Resource/UI/TextWindow.res");
}
else
{
LoadControlSettings("Resource/UI/MiniMOTD.res");
}
Reset();
}
//-----------------------------------------------------------------------------
@@ -129,72 +129,44 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
CTextWindow::~CTextWindow()
{
// remove temp file again
if (g_pFullFileSystem->FileExists(TEMP_HTML_FILE))
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
}
void CTextWindow::Reset( void )
{
//=============================================================================
// HPE_BEGIN:
// [Forrest] Replace strange hard-coded default message with hard-coded error message.
//=============================================================================
V_strcpy_safe( m_szTitle, "Error loading info message." );
V_strcpy_safe( m_szMessage, "" );
V_strcpy_safe( m_szMessageFallback, "" );
//=============================================================================
// HPE_END
//=============================================================================
Q_strcpy( m_szTitle, "This could be your Title." );
Q_strcpy( m_szMessage, "Just for 10 Euros a week!" );
m_szExitCommand[0] = 0;
m_nExitCommand = TEXTWINDOW_CMD_NONE;
m_nContentType = TYPE_TEXT;
m_bShownURL = false;
m_bUnloadOnDismissal = false;
Update();
if ( m_bMiniMode )
{
m_iFadeStatus = FADE_STATUS_OFF;
SetAlpha( 0 );
}
else
{
SetAlpha( 255 );
}
UpdateContents();
}
void CTextWindow::ShowText( const char *text )
void CTextWindow::ShowText( const char *text)
{
m_pTextMessage->SetVisible( true );
m_pTextMessage->SetText( text );
m_pTextMessage->GotoTextStart();
}
void CTextWindow::ShowURL( const char *URL, bool bAllowUserToDisable )
void CTextWindow::ShowURL( const char *URL)
{
#ifdef _DEBUG
Msg( "CTextWindow::ShowURL( %s )\n", URL );
#endif
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
if ( ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) || !mode->IsHTMLInfoPanelAllowed() )
{
Warning( "Blocking HTML info panel '%s'; Using plaintext instead.\n", URL );
// User has disabled HTML TextWindows. Show the fallback as text only.
if ( g_pStringTableInfoPanel )
{
int index = g_pStringTableInfoPanel->FindStringIndex( "motd_text" );
if ( index != ::INVALID_STRING_INDEX )
{
int length = 0;
const char *data = (const char *)g_pStringTableInfoPanel->GetStringUserData( index, &length );
if ( data && data[0] )
{
m_pHTMLMessage->SetVisible( false );
ShowText( data );
}
}
}
return;
}
#if defined( ENABLE_HTMLWINDOW )
m_pHTMLMessage->SetVisible( true );
m_pHTMLMessage->OpenURL( URL, NULL );
m_bShownURL = true;
m_pHTMLMessage->OpenURL( URL );
#endif
}
void CTextWindow::ShowIndex( const char *entry )
void CTextWindow::ShowIndex( const char *entry)
{
const char *data = NULL;
int length = 0;
@@ -211,7 +183,7 @@ void CTextWindow::ShowIndex( const char *entry )
return; // nothing to show
// is this a web URL ?
if ( !Q_strncmp( data, "http://", 7 ) || !Q_strncmp( data, "https://", 8 ) )
if ( !Q_strncmp( data, "http://", 7 ) )
{
ShowURL( data );
return;
@@ -251,6 +223,9 @@ void CTextWindow::ShowFile( const char *filename )
g_pFullFileSystem->GetLocalPath( filename, pPathData, sizeof(pPathData) );
Q_strncat( localURL, pPathData, sizeof( localURL ), COPY_ALL_CHARACTERS );
// force steam to dump a local copy
filesystem->GetLocalCopy( pPathData );
ShowURL( localURL );
}
else
@@ -275,14 +250,114 @@ void CTextWindow::ShowFile( const char *filename )
}
void CTextWindow::Update( void )
{
if ( IsVisible() == false )
return;
if ( m_bMiniMode )
{
if ( m_iFadeStatus == FADE_STATUS_IN )
{
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
SetAlpha ( MAX( 0, RemapValClamped( flDeltaTime, MINI_MOTD_FADE_TIME, 0, -128, 255 ) ) );
if ( flDeltaTime <= 0.0f )
{
m_iFadeStatus = FADE_STATUS_HOLD;
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_HOLD_TIME
}
}
else if ( m_iFadeStatus == FADE_STATUS_HOLD )
{
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
if ( flDeltaTime <= 0.0f )
{
m_iFadeStatus = FADE_STATUS_OUT;
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_FADE_TIME;
}
}
else if ( m_iFadeStatus == FADE_STATUS_OUT )
{
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
SetAlpha ( RemapValClamped( flDeltaTime, 0.0f, MINI_MOTD_FADE_TIME, 0, 255 ) );
if ( flDeltaTime <= 0.0f )
{
m_iFadeStatus = FADE_STATUS_OFF;
SetVisible( false );
}
}
}
}
void CTextWindow::OnCommand( const char *command)
{
if (!Q_strcmp(command, "okay"))
{
if ( m_szExitCommand[0] )
{
engine->ClientCmd( m_szExitCommand );
}
m_pViewPort->ShowPanel( this, false );
}
BaseClass::OnCommand(command);
}
void CTextWindow::SetData(KeyValues *data)
{
if ( IsVisible() == true )
return;
SetData( data->GetInt( "type" ), data->GetString( "title"), data->GetString( "msg" ), data->GetString( "cmd" ) );
}
void CTextWindow::SetData( int type, const char *title, const char *message, const char *command )
{
Q_strncpy( m_szTitle, title, sizeof( m_szTitle ) );
Q_strncpy( m_szMessage, message, sizeof( m_szMessage ) );
if ( command )
{
Q_strncpy( m_szExitCommand, command, sizeof(m_szExitCommand) );
}
else
{
m_szExitCommand[0]=0;
}
m_nContentType = type;
UpdateContents();
}
void CTextWindow::UpdateContents( void )
{
SetTitle( m_szTitle, false );
m_pTitleLabel->SetText( m_szTitle );
if ( m_pTitleLabel )
{
m_pTitleLabel->SetText( m_szTitle );
}
#if defined( ENABLE_HTMLWINDOW )
if ( m_pHTMLMessage )
{
m_pHTMLMessage->SetVisible( false );
m_pTextMessage->SetVisible( false );
}
#endif
if ( m_pTextMessage )
{
m_pTextMessage->SetVisible( false );
}
if ( m_bMiniMode )
return;
if ( m_nContentType == TYPE_INDEX )
{
@@ -290,15 +365,7 @@ void CTextWindow::Update( void )
}
else if ( m_nContentType == TYPE_URL )
{
if ( !Q_strncmp( m_szMessage, "http://", 7 ) || !Q_strncmp( m_szMessage, "https://", 8 ) || !Q_stricmp( m_szMessage, "about:blank" ) )
{
ShowURL( m_szMessage );
}
else
{
// We should have trapped this at a higher level
Assert( !"URL protocol is missing or blocked" );
}
ShowURL( m_szMessage );
}
else if ( m_nContentType == TYPE_FILE )
{
@@ -314,124 +381,77 @@ void CTextWindow::Update( void )
}
}
void CTextWindow::OnCommand( const char *command )
{
if (!Q_strcmp(command, "okay"))
{
//=============================================================================
// HPE_BEGIN:
// [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
// of options. Passing a command string is dangerous and allowed a server network
// message to run arbitrary commands on the client.
//=============================================================================
const char *pszCommand = NULL;
switch ( m_nExitCommand )
{
case TEXTWINDOW_CMD_NONE:
break;
case TEXTWINDOW_CMD_JOINGAME:
pszCommand = "joingame";
break;
case TEXTWINDOW_CMD_CHANGETEAM:
pszCommand = "changeteam";
break;
case TEXTWINDOW_CMD_IMPULSE101:
pszCommand = "impulse 101";
break;
case TEXTWINDOW_CMD_MAPINFO:
pszCommand = "mapinfo";
break;
case TEXTWINDOW_CMD_CLOSED_HTMLPAGE:
pszCommand = "closed_htmlpage";
break;
case TEXTWINDOW_CMD_CHOOSETEAM:
pszCommand = "chooseteam";
break;
default:
DevMsg("CTextWindow::OnCommand: unknown exit command value %i\n", m_nExitCommand );
break;
}
if ( pszCommand != NULL )
{
engine->ClientCmd_Unrestricted( pszCommand );
}
//=============================================================================
// HPE_END
//=============================================================================
m_pViewPort->ShowPanel( this, false );
}
BaseClass::OnCommand(command);
}
void CTextWindow::OnKeyCodePressed( vgui::KeyCode code )
{
if ( code == KEY_XBUTTON_A || code == KEY_XBUTTON_B || code == STEAMCONTROLLER_A || code == STEAMCONTROLLER_B )
{
OnCommand( "okay" );
return;
}
BaseClass::OnKeyCodePressed(code);
}
void CTextWindow::SetData(KeyValues *data)
{
SetData( data->GetInt( "type" ), data->GetString( "title" ), data->GetString( "msg" ), data->GetString( "msg_fallback" ), data->GetInt( "cmd" ), data->GetBool( "unload" ) );
}
void CTextWindow::SetData( int type, const char *title, const char *message, const char *message_fallback, int command, bool bUnload )
{
Q_strncpy( m_szTitle, title, sizeof( m_szTitle ) );
Q_strncpy( m_szMessage, message, sizeof( m_szMessage ) );
Q_strncpy( m_szMessageFallback, message_fallback, sizeof( m_szMessageFallback ) );
m_nExitCommand = command;
m_nContentType = type;
m_bUnloadOnDismissal = bUnload;
Update();
}
void CTextWindow::ShowPanel( bool bShow )
{
if ( IsX360() )
{
// Say no to MOTD from Xbox 360 clients!
bShow = false;
}
if ( BaseClass::IsVisible() == bShow )
return;
m_pViewPort->ShowBackGround( bShow );
m_bMiniMode = false;
if ( m_szMessage && m_szMessage[0] )
{
if ( !Q_strncmp( m_szMessage, "hostfile", 8 ) )
{
m_bMiniMode = true;
}
}
if ( bShow )
{
InvalidateLayout( true, true );
}
UpdateContents();
if ( bShow )
{
Activate();
SetMouseInputEnabled( true );
if ( !m_bMiniMode )
{
SetVisible( true );
SetMouseInputEnabled( true );
SetKeyBoardInputEnabled( true );
SetAlpha( 255 );
}
else
{
m_iFadeStatus = FADE_STATUS_IN;
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_FADE_TIME;
SetAlpha( 0 );
SetMouseInputEnabled( false );
SetKeyBoardInputEnabled( false );
}
}
else
{
SetVisible( false );
SetMouseInputEnabled( false );
if ( m_bUnloadOnDismissal && m_bShownURL && m_pHTMLMessage )
if ( !m_bMiniMode )
{
m_pHTMLMessage->OpenURL( "about:blank", NULL );
m_bShownURL = false;
SetMouseInputEnabled( false );
}
}
}
bool CTextWindow::CMOTDHTML::OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect )
void CTextWindow::FireGameEvent( IGameEvent *event )
{
if ( Q_strstr( url, "steam://" ) )
return false;
const char *name = event->GetName();
if ( Q_strcmp( name, "game_newmap" ) == 0 )
{
m_bIgnoreMultipleShowRequests = false;
}
}
return BaseClass::OnStartRequest( url, target, pchPostData, bIsRedirect );
bool CTextWindow::WantsBackgroundBlurred( void )
{
return (!m_bMiniMode);
}
+29 -38
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -17,17 +17,26 @@
#include <game/client/iviewport.h>
#include "shareddefs.h"
#include "GameEventListener.h"
namespace vgui
{
class TextEntry;
}
enum
{
FADE_STATUS_IN = 0,
FADE_STATUS_HOLD,
FADE_STATUS_OUT,
FADE_STATUS_OFF
};
//-----------------------------------------------------------------------------
// Purpose: displays the MOTD
//-----------------------------------------------------------------------------
class CTextWindow : public vgui::Frame, public IViewPortPanel
class CTextWindow : public vgui::Frame, public IViewPortPanel, public CGameEventListener
{
private:
DECLARE_CLASS_SIMPLE( CTextWindow, vgui::Frame );
@@ -40,7 +49,8 @@ public:
virtual void SetData(KeyValues *data);
virtual void Reset();
virtual void Update();
virtual bool NeedsUpdate( void ) { return false; }
virtual void UpdateContents( void );
virtual bool NeedsUpdate( void ) { return true; }
virtual bool HasInputElements( void ) { return true; }
virtual void ShowPanel( bool bShow );
@@ -49,57 +59,38 @@ public:
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
virtual void FireGameEvent( IGameEvent *event );
virtual bool WantsBackgroundBlurred( void );
public:
virtual void SetData( int type, const char *title, const char *message, const char *message_fallback, int command, bool bUnload );
virtual void ShowFile( const char *filename );
virtual void ShowText( const char *text );
virtual void ShowURL( const char *URL, bool bAllowUserToDisable = true );
virtual void ShowIndex( const char *entry );
virtual void SetData( int type, const char *title, const char *message, const char *command );
virtual void ShowFile( const char *filename);
virtual void ShowText( const char *text);
virtual void ShowURL( const char *URL);
virtual void ShowIndex( const char *entry);
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_IN_GAME_HUD; }
protected:
// vgui overrides
virtual void OnCommand( const char *command );
void OnKeyCodePressed( vgui::KeyCode code );
virtual void OnCommand( const char *command);
IViewPort *m_pViewPort;
char m_szTitle[255];
char m_szMessage[2048];
char m_szMessageFallback[2048];
//=============================================================================
// HPE_BEGIN:
// [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
// of options. Passing a command string is dangerous and allowed a server network
// message to run arbitrary commands on the client.
//=============================================================================
int m_nExitCommand;
//=============================================================================
// HPE_END
//=============================================================================
char m_szExitCommand[255];
int m_nContentType;
bool m_bShownURL;
bool m_bUnloadOnDismissal;
vgui::TextEntry *m_pTextMessage;
class CMOTDHTML : public vgui::HTML
{
private:
DECLARE_CLASS_SIMPLE( CMOTDHTML, vgui::HTML );
public:
CMOTDHTML( Panel *parent, const char *pchName ) : vgui::HTML( parent, pchName ) {}
virtual bool OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect ) OVERRIDE;
};
CMOTDHTML *m_pHTMLMessage;
vgui::HTML *m_pHTMLMessage;
vgui::Button *m_pOK;
vgui::Label *m_pTitleLabel;
float m_flNextFadeTime;
int m_iFadeStatus;
bool m_bMiniMode;
bool m_bIgnoreMultipleShowRequests;
};