Merge pull request #213 from samisalreadytaken/vscript_vgui-patch

vscript vgui HUD visibility control
This commit is contained in:
Blixibon 2022-11-21 00:45:02 -06:00 committed by GitHub
commit 4cc1816b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 347 additions and 360 deletions

View File

@ -947,11 +947,6 @@ float CHud::GetFOVSensitivityAdjust()
{
return m_flFOVSensitivityAdjust;
}
#ifdef MAPBASE_VSCRIPT
extern int g_iVScriptHideHUD;
#endif
//-----------------------------------------------------------------------------
// Purpose: Return true if the passed in sections of the HUD shouldn't be drawn
//-----------------------------------------------------------------------------
@ -973,14 +968,6 @@ bool CHud::IsHidden( int iHudFlags )
iHideHud = hidehud.GetInt();
}
#ifdef MAPBASE_VSCRIPT
// Hide elements hidden by scripts
if ( g_iVScriptHideHUD )
{
iHideHud |= g_iVScriptHideHUD;
}
#endif
// Everything hidden?
if ( iHideHud & HIDEHUD_ALL )
return true;

View File

@ -58,6 +58,9 @@ public:
// Hidden bits.
// HIDEHUD_ flags that note when this element should be hidden in the HUD
virtual void SetHiddenBits( int iBits );
#ifdef MAPBASE_VSCRIPT
int GetHiddenBits() const { return m_iHiddenBits; }
#endif
bool IsParentedToClientDLLRootPanel() const;
void SetParentedToClientDLLRootPanel( bool parented );

View File

@ -58,70 +58,11 @@ bool C_FuncFakeWorldPortal::ShouldDraw()
}
//-----------------------------------------------------------------------------
// Do we have a fake world portal in view?
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane )
{
// Early out if no cameras
C_FuncFakeWorldPortal *pReflectiveGlass = GetFakeWorldPortalList();
if ( !pReflectiveGlass )
return NULL;
Frustum_t frustum;
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
cplane_t localPlane;
Vector vecOrigin, vecWorld, vecDelta, vecForward;
AngleVectors( view.angles, &vecForward, NULL, NULL );
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
{
if ( pReflectiveGlass->IsDormant() )
continue;
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
continue;
Vector vecMins, vecMaxs;
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
continue;
const model_t *pModel = pReflectiveGlass->GetModel();
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
for ( int i = 0; i < nCount; ++i )
{
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
VectorTransform( vecOrigin, mat, vecWorld );
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
continue;
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
if ( vecDelta.Dot( plane.normal ) >= 0 )
continue;
// Must have valid plane
if ( !pReflectiveGlass->m_hTargetPlane )
continue;
return pReflectiveGlass;
}
}
return NULL;
}
//-----------------------------------------------------------------------------
// Iterates through fake world portals instead of just picking one
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
cplane_t &plane, Vector &vecPlaneOrigin, const Frustum_t &frustum )
Vector &vecAbsPlaneNormal, float &flLocalPlaneDist, const Frustum_t &frustum )
{
// Early out if no cameras
C_FuncFakeWorldPortal *pReflectiveGlass = NULL;
@ -130,8 +71,9 @@ C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const
else
pReflectiveGlass = pStart->m_pNext;
cplane_t localPlane;
Vector vecOrigin, vecWorld, vecDelta;
cplane_t localPlane, worldPlane;
Vector vecMins, vecMaxs, vecLocalOrigin, vecAbsOrigin, vecDelta;
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
{
if ( pReflectiveGlass->IsDormant() )
@ -140,7 +82,10 @@ C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
continue;
Vector vecMins, vecMaxs;
// Must have valid plane
if ( !pReflectiveGlass->m_hTargetPlane )
continue;
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
continue;
@ -151,23 +96,22 @@ C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
for ( int i = 0; i < nCount; ++i )
{
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecLocalOrigin );
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
VectorTransform( vecOrigin, mat, vecWorld );
MatrixTransformPlane( mat, localPlane, worldPlane ); // Transform to world space
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
if ( view.origin.Dot( worldPlane.normal ) <= worldPlane.dist ) // Check for view behind plane
continue;
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
if ( vecDelta.Dot( plane.normal ) >= 0 )
VectorTransform( vecLocalOrigin, mat, vecAbsOrigin );
VectorSubtract( vecAbsOrigin, view.origin, vecDelta );
if ( vecDelta.Dot( worldPlane.normal ) >= 0 ) // Backface cull
continue;
// Must have valid plane
if ( !pReflectiveGlass->m_hTargetPlane )
continue;
flLocalPlaneDist = localPlane.dist;
vecAbsPlaneNormal = worldPlane.normal;
vecPlaneOrigin = vecOrigin;
return pReflectiveGlass;
}
}

View File

@ -53,10 +53,8 @@ public:
//-----------------------------------------------------------------------------
// Do we have reflective glass in view? If so, what's the reflection plane?
//-----------------------------------------------------------------------------
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane );
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view,
cplane_t &plane, Vector &vecPlaneOrigin, const Frustum_t &frustum );
Vector &vecAbsPlaneNormal, float &flLocalPlaneDist, const Frustum_t &frustum );
#endif // C_FUNC_FAKE_WORLDPORTAL

View File

@ -40,7 +40,9 @@
#include <vgui_controls/TextImage.h>
//#include <vgui_controls/Tooltip.h>
//#include "bitmap/tgaloader.h"
#if VGUI_TGA_IMAGE_PANEL
#include "bitmap/tgaloader.h"
#endif
#if !defined(NO_STEAM)
#include "steam/steam_api.h"
@ -48,6 +50,8 @@
#endif
#include "view.h"
#include "hudelement.h"
//#include "iclientmode.h" // g_pClientMode->GetViewport()
#include "vscript_vgui.h"
#include "vscript_vgui.nut"
@ -83,11 +87,16 @@
//=============================================================================
// When enabled, script panels will be parented to custom script root panels.
// When enabled, script panels will be parented to custom root panels.
// When disabled, script panels will be parented to engine root panels, and allow Z values for script panels to be interplaced amongst non-script panels.
// Changing this is not backwards compatible, as existing top level script panel depth would then change relative to non-script panels.
#define SCRIPT_ENGINE_ROOT_PANELS 1
// NOTE: causes rendering issues
#define ALLOW_SCRIPT_HUD_VIEWPORT_ROOT_PANEL 0
#define ALLOW_SCRIPT_GAMEUI_ROOT_PANEL 0
// On level transitions Restore is called up to 4 times in a row (due to .hl? client state files), each time
// trying to restore script panels from pre and post transitions, failing every time because script panels are
// destroyed on level shutdown but after client state files are written.
@ -100,6 +109,9 @@
// This code is left here for testing.
#define SCRIPT_VGUI_SAVERESTORE 0
#define SCRIPT_VGUI_SIGNAL_INTERFACE 0
#ifdef _DEBUG
#define DebugMsg(...) ConColorMsg( Color(196, 196, 156, 255), __VA_ARGS__ )
@ -117,15 +129,6 @@
using namespace vgui;
class IScriptVGUIObject;
struct FontData_t;
template< typename T > class CCopyableUtlVectorConservative;
// Aliases contain only one font definition unless 'yres' was defined
typedef CCopyableUtlVectorConservative< FontData_t > fontalias_t;
typedef CUtlDict< fontalias_t > CFontDict;
template< typename T >
class CCopyableUtlVectorConservative : public CUtlVectorConservative< T >
{
@ -137,16 +140,20 @@ public:
};
using namespace vgui;
class IScriptVGUIObject;
struct FontData_t;
// Aliases contain only one font definition unless 'yres' was defined
typedef CCopyableUtlVectorConservative< FontData_t > fontalias_t;
typedef CUtlDict< fontalias_t > CFontDict;
CFontDict g_ScriptFonts( k_eDictCompareTypeCaseSensitive );
CUtlVector< int > g_ScriptTextureIDs;
CUtlLinkedList< IScriptVGUIObject*, unsigned short > g_ScriptPanels;
// Used in hud.cpp to help scripts hide HUD elements
int g_iVScriptHideHUD = 0;
// Boundary is not checked in Surface, keep count manually to sanitise user input.
static int g_nFontCount = 0;
@ -317,7 +324,7 @@ public:
// Ideally script fonts would be loaded along with others in engine.
// In that case CScriptRootPanel would be removed, and
// g_pScriptRootPanel would be CScriptRootDLLPanel inside #if SCRIPT_ENGINE_ROOT_PANELS
void OnScreenSizeChanged( int, int )
void OnScreenSizeChanged( int w, int t )
{
// Reload fonts in the next vgui frame
ivgui()->AddTickSignal( GetVPanel() );
@ -326,6 +333,8 @@ public:
// Invalidate cached values
if ( g_pScriptVM )
g_pScriptVM->Run( "ISurface.__OnScreenSizeChanged()" );
Panel::OnScreenSizeChanged( w, t );
}
private:
@ -437,7 +446,6 @@ public:
void DrawOutlinedRect( int x0, int y0, int width, int height, int thickness );
void DrawLine( int x0, int y0, int x1, int y1 );
void DrawOutlinedCircle( int x, int y, int radius, int segments );
//void DrawColoredCircle( int x, int y, int radius, int r, int g, int b, int a );
void SetTextColor( int r, int g, int b, int a );
void SetTextPos( int x, int y );
@ -452,10 +460,10 @@ public:
void CreateFont( const char *customName, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int yresMin, int yresMax, bool proportional );
bool AddCustomFontFile( const char *fontFileName );
int GetTextureID( char const *filename );
int ValidateTexture( const char *filename, bool hardwareFilter, bool forceReload, bool procedural );
void SetTextureFile( int id, const char *filename, bool hardwareFilter );
//int ValidateMaterial( const char *materialName, const char *textureGroupName );
int GetTextureWide( int id );
int GetTextureTall( int id );
void SetTexture( int id );
@ -845,7 +853,34 @@ void CScriptSurface::SetTextureFile( int id, const char *filename, bool hardware
}
#endif
}
#if 0
void CScriptSurface::SetTextureMaterial( int id, HSCRIPT hMaterial )
{
IMaterial *pMaterial = (IMaterial*)HScriptToClass< IScriptMaterial >( hMaterial );
if ( !IsValid( pMaterial ) )
return;
if ( g_ScriptTextureIDs.HasElement(id) )
{
Assert( surface()->IsTextureIDValid(id) );
MatSystemSurface()->DrawSetTextureMaterial( id, pMaterial );
DebugMsg( "Set texture [%i]%s\n", id, pMaterial->GetName() );
}
#ifdef _DEBUG
if ( !g_ScriptTextureIDs.HasElement(id) && surface()->IsTextureIDValid(id) )
{
DebugWarning( "Tried to set non-script created texture! [%i]\n", id );
}
if ( !surface()->IsTextureIDValid(id) )
{
DebugWarning( "Tried to set invalid texture id! [%i]\n", id );
}
#endif
}
#endif
int CScriptSurface::GetTextureWide( int id )
{
int w, t;
@ -1308,7 +1343,7 @@ public:
g_ScriptPanels.AddToTail( this );
// Script specified engine root panel.
// Script specified root panel - a cheap alternative to registering uneditable panel instances.
// Match the values to vscript_vgui.nut.
//
// This parameter is hidden in script, and is defined by the return value of dummy functions.
@ -1326,6 +1361,14 @@ public:
case 2:
vparent = VGUI_GetScriptRootPanel( PANEL_CLIENTDLL );
break;
#if ALLOW_SCRIPT_HUD_VIEWPORT_ROOT_PANEL
// Hud viewport
case 10:
Assert( g_pClientMode && g_pClientMode->GetViewport() );
vparent = g_pClientMode->GetViewport()->GetVPanel();
break;
#endif
default: UNREACHABLE(); // Invalid parent panel
}
_base->SetParent( vparent );
@ -1357,7 +1400,7 @@ public:
{
ivgui()->AddTickSignal( this->GetVPanel(), i );
}
#if VGUI_SIGNAL_INTERFACE
#if SCRIPT_VGUI_SIGNAL_INTERFACE
void AddActionSignalTarget( HSCRIPT messageTarget )
{
IScriptVGUIObject *obj = ToScriptVGUIObj( messageTarget );
@ -1388,15 +1431,16 @@ public:
#ifdef _DEBUG
// Is my parent one of the root panels?
bool b = false;
bool bRootParent = false;
#if SCRIPT_ENGINE_ROOT_PANELS
if ( parent == g_pScriptRootPanel->GetVPanel() ||
#if ALLOW_SCRIPT_GAMEUI_ROOT_PANEL
(g_pScriptGameUIDLLPanel && parent == g_pScriptGameUIDLLPanel->GetVPanel()) ||
#endif
(g_pScriptClientDLLPanel && parent == g_pScriptClientDLLPanel->GetVPanel()) )
if ( ( parent == g_pScriptRootPanel->GetVPanel() )
#if ALLOW_SCRIPT_GAMEUI_ROOT_PANEL
|| ( g_pScriptGameUIDLLPanel && parent == g_pScriptGameUIDLLPanel->GetVPanel() )
#endif
|| ( g_pScriptClientDLLPanel && parent == g_pScriptClientDLLPanel->GetVPanel() )
)
{
b = true;
bRootParent = true;
}
else
#endif
@ -1404,13 +1448,16 @@ public:
{
if ( parent == enginevgui->GetPanel( (VGuiPanel_t)i ) )
{
b = true;
bRootParent = true;
break;
}
}
#if ALLOW_SCRIPT_HUD_VIEWPORT_ROOT_PANEL
if ( g_pClientMode && g_pClientMode->GetViewport() && ( parent == g_pClientMode->GetViewport()->GetVPanel() ) )
bRootParent = true;
#endif
// My parent wasn't registered.
AssertMsg1( b, "'%s'", ipanel()->GetName(parent) );
AssertMsg1( bRootParent, "'%s'", ipanel()->GetName(parent) );
#endif
return NULL;
@ -1449,8 +1496,7 @@ public:
{
g_pScriptVM->ArrayAppend( arr, obj->GetScriptInstance() );
}
// UNDONE: Register C++ created children of script created panels.
// It is safe to do so because their lifetime depends on their script parents.
// Beware of dangling pointers if C++ created children are to be registered
}
}
@ -1919,15 +1965,11 @@ public:
CLASS_HELPER_INTERFACE( Button, Label )
{
public:
// NOTE: This is used if DoClick() callback is not implemented in CScript_Button.
// This changes where and how button command is processed -
// whether in the button { DoClick() } or in an external panel { OnCommand(cmd) }.
// It is fine to always use DoClick() instead of vgui messages
// because of the dynamic nature of script closures.
#if VGUI_SIGNAL_INTERFACE
#if SCRIPT_VGUI_SIGNAL_INTERFACE
// Sets the command message to send to the action signal target when the button is pressed
void SetCommand( const char *command )
{
if ( !V_strncmp( command, "url ", 4 ) )
if ( !V_strnicmp( command, "url ", 4 ) )
{
__base()->SetCommand( (KeyValues*)NULL );
@ -1972,12 +2014,7 @@ public:
{
__base()->ForceDepressed(state);
}
#if 0
void SetBlink( bool state )
{
__base()->SetBlink(state);
}
#endif
void SetMouseClickEnabled( int code, bool state )
{
__base()->SetMouseClickEnabled( (MouseCode)code, state );
@ -2007,12 +2044,7 @@ public:
{
__base()->SetDepressedColor( Color(fr, fg, fb, fa), Color(br, bg, bb, ba) );
}
#if 0
void SetBlinkColor( int r, int g, int b, int a )
{
__base()->SetBlinkColor( Color(r, g, b, a) );
}
#endif
void SetArmedSound( const char *sound )
{
__base()->SetArmedSound( sound );
@ -2402,7 +2434,7 @@ public:
#endif
//--------------------------------------------------------------
//--------------------------------------------------------------
#if 0
#if VGUI_TGA_IMAGE_PANEL
CLASS_HELPER_INTERFACE( TGAImagePanel, Panel )
{
public:
@ -2439,10 +2471,12 @@ public:
//==============================================================
#define SetHScript( var, val ) \
if ( var && g_pScriptVM ) \
g_pScriptVM->ReleaseScript( var ); \
static inline void SetHScript( HSCRIPT &var, HSCRIPT val )
{
if ( var && g_pScriptVM )
g_pScriptVM->ReleaseScript( var );
var = val;
}
#define CheckCallback(s)\
if ( FStrEq( cb, #s ) )\
@ -2481,6 +2515,9 @@ private:
HSCRIPT m_hfnOnKeyCodePressed;
HSCRIPT m_hfnOnKeyCodeReleased;
HSCRIPT m_hfnOnKeyCodeTyped;
#if SCRIPT_VGUI_SIGNAL_INTERFACE
HSCRIPT m_hfnOnCommand;
#endif
public:
CScript_Panel( Panel *parent, const char *name ) :
@ -2506,6 +2543,10 @@ public:
m_hfnOnKeyCodePressed(NULL),
m_hfnOnKeyCodeReleased(NULL),
m_hfnOnKeyCodeTyped(NULL)
#if SCRIPT_VGUI_SIGNAL_INTERFACE
,
m_hfnOnCommand(NULL)
#endif
{}
void Shutdown()
@ -2532,6 +2573,9 @@ public:
SetHScript( m_hfnOnKeyCodePressed, NULL );
SetHScript( m_hfnOnKeyCodeReleased, NULL );
SetHScript( m_hfnOnKeyCodeTyped, NULL );
#if SCRIPT_VGUI_SIGNAL_INTERFACE
SetHScript( m_hfnOnCommand, NULL );
#endif
}
public:
@ -2582,7 +2626,7 @@ public:
g_pScriptVM->ExecuteFunction( m_hfnOnScreenSizeChanged, args, 2, NULL, NULL, true );
}
}
#if VGUI_SIGNAL_INTERFACE
#if SCRIPT_VGUI_SIGNAL_INTERFACE
void OnCommand( const char *command )
{
if ( m_hfnOnCommand )
@ -2707,6 +2751,7 @@ public:
BaseClass::OnKeyCodeTyped( code );
}
public:
void SetCallback( const char* cb, HSCRIPT fn )
{
@ -2730,6 +2775,9 @@ public:
CheckCallback( OnKeyCodePressed );
CheckCallback( OnKeyCodeReleased );
CheckCallback( OnKeyCodeTyped );
#if SCRIPT_VGUI_SIGNAL_INTERFACE
CheckCallback( OnCommand );
#endif
g_pScriptVM->RaiseException("invalid callback");
}
@ -2762,6 +2810,9 @@ private:
HSCRIPT m_hfnOnKeyCodePressed;
HSCRIPT m_hfnOnKeyCodeReleased;
HSCRIPT m_hfnOnKeyCodeTyped;
#if SCRIPT_VGUI_SIGNAL_INTERFACE
HSCRIPT m_hfnOnCommand;
#endif
public:
CScript_Frame( Panel *parent, const char *name ) :
@ -2788,6 +2839,10 @@ public:
m_hfnOnKeyCodePressed(NULL),
m_hfnOnKeyCodeReleased(NULL),
m_hfnOnKeyCodeTyped(NULL)
#if SCRIPT_VGUI_SIGNAL_INTERFACE
,
m_hfnOnCommand(NULL)
#endif
{
SetFadeEffectDisableOverride( true );
}
@ -2811,6 +2866,9 @@ public:
SetHScript( m_hfnOnKeyCodePressed, NULL );
SetHScript( m_hfnOnKeyCodeReleased, NULL );
SetHScript( m_hfnOnKeyCodeTyped, NULL );
#if SCRIPT_VGUI_SIGNAL_INTERFACE
SetHScript( m_hfnOnCommand, NULL );
#endif
}
public:
@ -2856,7 +2914,22 @@ public:
g_pScriptVM->ExecuteFunction( m_hfnOnScreenSizeChanged, args, 2, NULL, NULL, true );
}
}
#if SCRIPT_VGUI_SIGNAL_INTERFACE
void OnCommand( const char *command )
{
if ( m_hfnOnCommand )
{
ScriptVariant_t ret, arg = command;
g_pScriptVM->ExecuteFunction( m_hfnOnCommand, &arg, 1, &ret, NULL, true );
// Return true to swallow
if ( ret.m_type == FIELD_BOOLEAN && ret.m_bool )
return;
}
BaseClass::OnCommand( command );
}
#endif
void OnCursorEntered()
{
if ( m_hfnOnCursorEntered )
@ -2976,6 +3049,7 @@ public:
BaseClass::OnKeyCodeTyped( code );
}
}
public:
void SetCallback( const char* cb, HSCRIPT fn )
{
@ -2998,6 +3072,9 @@ public:
CheckCallback( OnKeyCodePressed );
CheckCallback( OnKeyCodeReleased );
CheckCallback( OnKeyCodeTyped );
#if SCRIPT_VGUI_SIGNAL_INTERFACE
CheckCallback( OnCommand );
#endif
g_pScriptVM->RaiseException("invalid callback");
}
@ -3146,7 +3223,7 @@ public:
#endif
//--------------------------------------------------------------
//--------------------------------------------------------------
#if 0
#if VGUI_TGA_IMAGE_PANEL
class CTGAImagePanel : public Panel
{
DECLARE_SCRIPTVGUI_CLASS_EX( CTGAImagePanel, Panel );
@ -3315,7 +3392,7 @@ END_SCRIPTDESC()
#endif
//--------------------------------------------------------------
//--------------------------------------------------------------
#if 0
#if VGUI_TGA_IMAGE_PANEL
BEGIN_VGUI_HELPER_EX( TGAImagePanel, CTGAImagePanel )
END_VGUI_HELPER()
@ -3333,6 +3410,18 @@ END_SCRIPTDESC()
//==============================================================
struct hudelementcache_t
{
CUtlConstString name;
int bits;
};
CUtlVector< hudelementcache_t > m_HudElementCache;
// Check if hud elements were changed in this level to shortcut on level shutdown
bool m_bHudVisiblityChangedThisLevel = false;
class CScriptVGUI : public CAutoGameSystem
{
public:
@ -3377,6 +3466,9 @@ HSCRIPT CScriptVGUI::CreatePanel( const char* panelClass, HSCRIPT parent, const
#if !defined(NO_STEAM)
Check( AvatarImage );
#endif
#if VGUI_TGA_IMAGE_PANEL
Check( TGAImagePanel );
#endif
g_pScriptVM->RaiseException("invalid vgui class");
return NULL;
@ -3408,8 +3500,25 @@ void CScriptVGUI::LevelShutdownPostEntity()
}
g_ScriptTextureIDs.Purge();
// Reset HUD hidden bits
g_iVScriptHideHUD = 0;
//
// Reset hud element visibility
//
if ( m_bHudVisiblityChangedThisLevel )
{
m_bHudVisiblityChangedThisLevel = false;
FOR_EACH_VEC( m_HudElementCache, i )
{
const hudelementcache_t &cache = m_HudElementCache[i];
Assert( !cache.name.IsEmpty() );
CHudElement *elem = gHUD.FindElement( cache.name );
Assert( elem );
if ( elem )
{
elem->SetHiddenBits( cache.bits );
}
}
}
}
void CScriptVGUI::Shutdown()
@ -3433,9 +3542,72 @@ void CScriptVGUI::Shutdown()
}
g_ScriptFonts.Purge();
m_HudElementCache.Purge();
}
void SetHudElementVisible( const char *name, bool state )
{
CHudElement *elem = gHUD.FindElement( name );
if ( !elem )
return;
int iOldBits = -2;
FOR_EACH_VEC( m_HudElementCache, i )
{
const hudelementcache_t &cache = m_HudElementCache[i];
if ( !V_stricmp( cache.name, name ) )
{
iOldBits = cache.bits;
break;
}
}
if ( iOldBits == -2 )
{
if ( state ) // no change
return;
// First time setting the visibility of this element, save the original bits
hudelementcache_t &cache = m_HudElementCache.Element( m_HudElementCache.AddToTail() );
cache.name.Set( name );
cache.bits = elem->GetHiddenBits();
}
elem->SetHiddenBits( state ? iOldBits : -1 );
m_bHudVisiblityChangedThisLevel = true;
}
#ifdef _DEBUG
CON_COMMAND( dump_hud_elements, "" )
{
int size = gHUD.m_HudList.Size();
CUtlVector< const char* > list( 0, size );
for ( int i = 0; i < size; i++ )
{
list.AddToTail( gHUD.m_HudList[i]->GetName() );
}
struct _cmp
{
static int __cdecl fn( const char * const *a, const char * const *b ) { return strcmp( *a, *b ); }
};
list.Sort( _cmp::fn );
for ( int i = 0; i < size; i++ )
{
Msg( "%s\n", list[i] );
}
}
#endif
class CScriptIInput
{
public:
@ -3697,32 +3869,11 @@ vgui::HFont GetScriptFont( const char *name, bool proportional )
return script_surface.GetFont( name, proportional, NULL );
}
//-----------------------------------------------------------------------------
// Control which HUD elements on the screen are hidden.
//-----------------------------------------------------------------------------
static int ScriptGetHUDHiddenBits()
{
return g_iVScriptHideHUD;
}
static void ScriptSetHUDHiddenBits( int iBits )
{
g_iVScriptHideHUD = iBits;
}
static void ScriptAddHUDHiddenBits( int iBits )
{
g_iVScriptHideHUD |= iBits;
}
static void ScriptClearHUDHiddenBits( int iBits )
{
g_iVScriptHideHUD &= ~(iBits);
}
void RegisterScriptVGUI()
{
ScriptRegisterFunction( g_pScriptVM, SetHudElementVisible, "" );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptXRES, "XRES", "" );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptYRES, "YRES", "" );
@ -3732,11 +3883,6 @@ void RegisterScriptVGUI()
ScriptRegisterFunction( g_pScriptVM, ScreenToRay, "Get a ray from screen pixel position to world space." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptScreenTransform, "ScreenTransform", "Get world position normalised in screen space. Return true if on screen." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptGetHUDHiddenBits, "GetHUDHiddenBits", "Use with 'HIDEHUD_' constants." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptSetHUDHiddenBits, "SetHUDHiddenBits", "Use with 'HIDEHUD_' constants." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptAddHUDHiddenBits, "AddHUDHiddenBits", "Use with 'HIDEHUD_' constants." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptClearHUDHiddenBits, "ClearHUDHiddenBits", "Use with 'HIDEHUD_' constants." );
g_pScriptVM->Run( g_Script_vgui_init );
g_pScriptVM->RegisterInstance( &script_surface, "surface" );

View File

@ -91,7 +91,7 @@ local _FontTall = {}
local DoGetFont = ISurface.DoGetFont <- ISurface.GetFont;
local DoGetFontTall = ISurface.GetFontTall;
ISurface.GetFont <- function( name, proportional = false, sch = "" )
ISurface.GetFont <- function( name, proportional, sch = "" )
{
if ( sch in _Schemes )
{
@ -101,6 +101,8 @@ ISurface.GetFont <- function( name, proportional = false, sch = "" )
}
else
{
if ( typeof sch != "string" )
throw "invalid parameter 'scheme'";
_Schemes[sch] <- [{}, {}];
}
@ -152,6 +154,7 @@ ISurface.GetTextureID <- function( name )
IVGui.GetRootPanel <- function() { return 1000 }
//IVGui.GetGameUIRootPanel <- function() { return 1001 }
IVGui.GetClientDLLRootPanel <- function() { return 1002 }
//IVGui.GetHudViewportPanel <- function() { return 1010 }
local CreatePanel = IVGui.CreatePanel;
IVGui.CreatePanel <- function( type, parent, name )
@ -169,10 +172,6 @@ IVGui.CreatePanel <- function( type, parent, name )
root = 0;
break;
case 1001:
root = 1;
break;
case 1002:
root = 2;
break;

View File

@ -409,10 +409,6 @@ protected:
void Enable3dSkyboxFog( void );
void DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget );
#ifdef MAPBASE
void CalculateSkyAngles( const QAngle &angAngles );
#endif
sky3dparams_t * PreRender3dSkyboxWorld( SkyboxVisibility_t nSkyboxVisible );
sky3dparams_t *m_pSky3dParams;
@ -2110,20 +2106,18 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
Frustum_t frustum;
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
cplane_t portalPlane;
Vector vecPlaneOrigin;
//C_FuncFakeWorldPortal *pPortalEnt = IsFakeWorldPortalInView( view, portalPlane );
//if ( pPortalEnt )
C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal( NULL, view, portalPlane, vecPlaneOrigin, frustum );
Vector vecAbsPlaneNormal;
float flLocalPlaneDist;
C_FuncFakeWorldPortal *pPortalEnt = NextFakeWorldPortal( NULL, view, vecAbsPlaneNormal, flLocalPlaneDist, frustum );
while ( pPortalEnt != NULL )
{
ITexture *pCameraTarget = pPortalEnt->RenderTarget();
int width = pCameraTarget->GetActualWidth();
int height = pCameraTarget->GetActualHeight();
DrawFakeWorldPortal( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer(), 0, 0, width, height, view, portalPlane, vecPlaneOrigin );
DrawFakeWorldPortal( pCameraTarget, pPortalEnt, viewMiddle, C_BasePlayer::GetLocalPlayer(), 0, 0, width, height, view, vecAbsPlaneNormal, flLocalPlaneDist );
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, portalPlane, vecPlaneOrigin, frustum );
pPortalEnt = NextFakeWorldPortal( pPortalEnt, view, vecAbsPlaneNormal, flLocalPlaneDist, frustum );
}
#endif
}
@ -3541,8 +3535,6 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
}
#ifdef MAPBASE
ConVar r_fakeworldportal_debug("r_fakeworldportal_debug", "0");
//-----------------------------------------------------------------------------
// Purpose: Sets up scene and renders WIP fake world portal view.
// Based on code from monitors, mirrors, and logic_measure_movement.
@ -3559,7 +3551,7 @@ ConVar r_fakeworldportal_debug("r_fakeworldportal_debug", "0");
//-----------------------------------------------------------------------------
bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
int x, int y, int width, int height,
const CViewSetup &mainView, cplane_t &ourPlane, const Vector &vecPlaneOrigin )
const CViewSetup &mainView, const Vector &vecAbsPlaneNormal, float flLocalPlaneDist )
{
#ifdef USE_MONITORS
VPROF_INCREMENT_COUNTER( "cameras rendered", 1 );
@ -3590,85 +3582,52 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
}
}
monitorView.width = width;
monitorView.height = height;
monitorView.x = x;
monitorView.y = y;
monitorView.origin = mainView.origin;
monitorView.angles = mainView.angles;
// Debug stuff
static float flLastDebugTime = 0.0f;
bool bDebug = r_fakeworldportal_debug.GetBool() && gpGlobals->curtime > flLastDebugTime;
//
// Calculate the angles for the fake portal plane
//
QAngle angTargetAngles = pCameraEnt->m_hTargetPlane->GetAbsAngles() - pCameraEnt->m_PlaneAngles;
QAngle angFakePortalAngles;
// Get vectors from our original angles.
Vector vOurForward, vOurRight, vOurUp;
AngleVectors( pCameraEnt->GetAbsAngles(), &vOurForward, &vOurRight, &vOurUp );
Quaternion quat;
BasisToQuaternion( ourPlane.normal, vOurRight, vOurUp, quat );
QuaternionAngles( quat, angFakePortalAngles );
if (bDebug)
{
// RED - Initial player origin
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 255, 0, 0, 128, 10.0f );
// YELLOW - Portal origin
debugoverlay->AddBoxOverlay( pCameraEnt->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), angFakePortalAngles, 255, 224, 0, 128, 10.0f );
}
//
// Translate the actual portal view position to be relative to the target
//
matrix3x4_t matPlayer, matPortal, matPlayerToPortal;
AngleIMatrix( monitorView.angles, monitorView.origin, matPlayer );
AngleMatrix( angFakePortalAngles, pCameraEnt->GetAbsOrigin(), matPortal );
ConcatTransforms( matPlayer, matPortal, matPlayerToPortal );
// Apply the scale factor
if ( pCameraEnt->m_flScale > 0 )
{
Vector vecTranslation;
MatrixGetColumn( matPlayerToPortal, 3, vecTranslation );
vecTranslation /= pCameraEnt->m_flScale;
MatrixSetColumn( vecTranslation, 3, matPlayerToPortal );
}
matrix3x4_t matTarget;
AngleMatrix( angTargetAngles, pCameraEnt->m_hTargetPlane->GetAbsOrigin(), matTarget );
// Now apply the new matrix to the new reference point
matrix3x4_t matPortalToPlayer, matNewPlayerPosition;
MatrixInvert( matPlayerToPortal, matPortalToPlayer );
ConcatTransforms( matTarget, matPortalToPlayer, matNewPlayerPosition );
MatrixAngles( matNewPlayerPosition, monitorView.angles, monitorView.origin );
if (bDebug)
{
// BLUE - Target origin
debugoverlay->AddBoxOverlay( pCameraEnt->m_hTargetPlane->GetAbsOrigin(), Vector(-32,-32,-32), Vector(32,32,32), angTargetAngles, 0, 0, 255, 128, 10.0f );
// GREEN - Final origin
debugoverlay->AddBoxOverlay( monitorView.origin, Vector(-32,-32,-32), Vector(32,32,32), monitorView.angles, 0, 255, 0, 128, 10.0f );
flLastDebugTime = gpGlobals->curtime + 5.0f;
}
monitorView.fov = mainView.fov;
monitorView.width = width;
monitorView.height = height;
monitorView.m_bOrtho = mainView.m_bOrtho;
monitorView.fov = mainView.fov;
monitorView.m_flAspectRatio = mainView.m_flAspectRatio;
monitorView.m_bViewToProjectionOverride = false;
matrix3x4_t worldToView;
AngleIMatrix( mainView.angles, mainView.origin, worldToView );
matrix3x4_t targetToWorld;
{
// NOTE: m_PlaneAngles is angle offset
QAngle targetAngles = pCameraEnt->m_hTargetPlane->GetAbsAngles() - pCameraEnt->m_PlaneAngles;
AngleMatrix( targetAngles, pCameraEnt->m_hTargetPlane->GetAbsOrigin(), targetToWorld );
}
matrix3x4_t portalToWorld;
{
Vector left, up;
VectorVectors( vecAbsPlaneNormal, left, up );
VectorNegate( left );
portalToWorld.Init( vecAbsPlaneNormal, left, up, pCameraEnt->GetAbsOrigin() );
}
matrix3x4_t portalToView;
ConcatTransforms( worldToView, portalToWorld, portalToView );
if ( pCameraEnt->m_flScale > 0.0f )
{
portalToView[0][3] /= pCameraEnt->m_flScale;
portalToView[1][3] /= pCameraEnt->m_flScale;
portalToView[2][3] /= pCameraEnt->m_flScale;
}
matrix3x4_t viewToPortal;
MatrixInvert( portalToView, viewToPortal );
matrix3x4_t newViewToWorld;
ConcatTransforms( targetToWorld, viewToPortal, newViewToWorld );
MatrixAngles( newViewToWorld, monitorView.angles, monitorView.origin );
// @MULTICORE (toml 8/11/2006): this should be a renderer....
int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR | VIEW_CLEAR_OBEY_STENCIL);
bool bDrew3dSkybox = false;
@ -3691,21 +3650,17 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
SafeRelease( pSkyView );
}
//
// Make a clipping plane for the target view
//
Vector4D plane;
Vector vecAnglesNormal;
AngleVectors( angTargetAngles, &vecAnglesNormal );
VectorNormalize( vecAnglesNormal );
VectorCopy( -vecAnglesNormal, plane.AsVector3D() );
// target direction
MatrixGetColumn( targetToWorld, 0, plane.AsVector3D() );
VectorNormalize( plane.AsVector3D() );
VectorNegate( plane.AsVector3D() );
// The portal plane's distance from the actual brush's origin
float flPlaneDist = vecPlaneOrigin.Length();
// The target's distance from world origin
plane.w = -((pCameraEnt->m_hTargetPlane->GetAbsOrigin() * vecAnglesNormal).Length() + flPlaneDist) + 0.1f;
plane.w =
MatrixColumnDotProduct( targetToWorld, 3, plane.AsVector3D() ) // target clip plane distance
- flLocalPlaneDist // portal plane distance on the brush. This distance needs to be accounted for while placing the exit target
- 0.1;
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->PushCustomClipPlane( plane.Base() );
@ -5400,10 +5355,16 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
// Re-use the x coordinate to determine if we shuld do this with angles
if (m_pSky3dParams->angles.GetX() != 0)
{
CalculateSkyAngles( m_pSky3dParams->skycamera->GetAbsAngles() );
const matrix3x4_t &matSky = m_pSky3dParams->skycamera->EntityToWorldTransform();
matrix3x4_t matView;
AngleMatrix( angles, origin, matView );
ConcatTransforms( matSky, matView, matView );
MatrixAngles( matView, angles, origin );
}
else
{
VectorAdd( origin, m_pSky3dParams->skycamera->GetAbsOrigin(), origin );
}
VectorAdd( origin, m_pSky3dParams->skycamera->GetAbsOrigin(), origin );
}
else
{
@ -5411,10 +5372,16 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
m_pSky3dParams->angles.GetY() != 0 ||
m_pSky3dParams->angles.GetZ() != 0)
{
CalculateSkyAngles( m_pSky3dParams->angles.Get() );
matrix3x4_t matSky, matView;
AngleMatrix( m_pSky3dParams->angles, m_pSky3dParams->origin, matSky );
AngleMatrix( angles, origin, matView );
ConcatTransforms( matSky, matView, matView );
MatrixAngles( matView, angles, origin );
}
else
{
VectorAdd( origin, m_pSky3dParams->origin, origin );
}
VectorAdd( origin, m_pSky3dParams->origin, origin );
}
#else
VectorAdd( origin, m_pSky3dParams->origin, origin );
@ -5531,55 +5498,6 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
#endif
}
#ifdef MAPBASE
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CSkyboxView::CalculateSkyAngles( const QAngle &angAngles )
{
// Unfortunately, it's not as simple as "angles += m_pSky3dParams->angles".
// This stuff took a long time to figure out. I'm glad I got it working.
// First, create a matrix for the sky's angles.
matrix3x4_t matSkyAngles;
AngleMatrix( angAngles, matSkyAngles );
// The code in between the lines below was mostly lifted from projected texture screenspace code and was a huge lifesaver.
// The comments are my attempt at explaining the little I understand of what's going on here.
// ----------------------------------------------------------------------
// These are the vectors that would eventually become our final angle directions.
Vector vecSkyForward, vecSkyRight, vecSkyUp;
// Get vectors from our original angles.
Vector vPlayerForward, vPlayerRight, vPlayerUp;
AngleVectors( angles, &vPlayerForward, &vPlayerRight, &vPlayerUp );
// Transform them from our sky angles matrix and put the results in those vectors we declared earlier.
VectorTransform( vPlayerForward, matSkyAngles, vecSkyForward );
VectorTransform( vPlayerRight, matSkyAngles, vecSkyRight );
VectorTransform( vPlayerUp, matSkyAngles, vecSkyUp );
// Normalize them.
VectorNormalize( vecSkyForward );
VectorNormalize( vecSkyRight );
VectorNormalize( vecSkyUp );
// Now do a bit of quaternion magic and apply that to our original angles.
// This works perfectly, so I'm not gonna touch it.
Quaternion quat;
BasisToQuaternion( vecSkyForward, vecSkyRight, vecSkyUp, quat );
QuaternionAngles( quat, angles );
// End of code mostly lifted from projected texture screenspace stuff
// ----------------------------------------------------------------------
// Now just rotate our origin with that matrix.
// We create a copy of the origin since VectorRotate doesn't want in1 to be the same variable as the destination.
VectorRotate(Vector(origin), matSkyAngles, origin);
}
#endif
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------

View File

@ -454,7 +454,7 @@ private:
#ifdef MAPBASE
bool DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
int x, int y, int width, int height,
const CViewSetup &mainView, cplane_t &ourPlane, const Vector &vecPlaneOrigin );
const CViewSetup &mainView, const Vector &vecAbsPlaneNormal, float flLocalPlaneDist );
#endif
// Drawing primitives

View File

@ -604,25 +604,6 @@ void RegisterSharedScriptConstants()
ScriptRegisterConstant( g_pScriptVM, D_NU, "Denotes a 'Neutral' relationship. Used by NPCs and players for relationship disposition." );
#endif
#ifdef CLIENT_DLL
//
// HUD
//
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_WEAPONSELECTION, "Hide ammo count & weapon selection" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_FLASHLIGHT, "" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_ALL, "" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_HEALTH, "Hide health & armor / suit battery" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_PLAYERDEAD, "Hide when local player's dead" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_NEEDSUIT, "Hide when the local player doesn't have the HEV suit" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_MISCSTATUS, "Hide miscellaneous status elements (trains, pickup history, death notices, etc)" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_CHAT, "Hide all communication elements (saytext, voice icon, etc)" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_CROSSHAIR, "Hide crosshairs" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_VEHICLE_CROSSHAIR, "Hide vehicle crosshair" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_INVEHICLE, "" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_BONUS_PROGRESS, "Hide bonus progress display (for bonus map challenges)" );
ScriptRegisterConstant( g_pScriptVM, HIDEHUD_BITCOUNT, "" );
#endif
//
// Misc. General
//

View File

@ -1277,9 +1277,11 @@ CNetMsgScriptHelper *g_ScriptNetMsg = &scriptnetmsg;
#ifdef _DEBUG
#ifdef GAME_DLL
#define DebugNetMsg( l, ... ) do { extern ConVar developer; if (developer.GetInt() >= l) ConColorMsg( Color(100, 225, 255, 255), __VA_ARGS__ ); } while (0);
ConVar script_net_debug("script_net_debug", "0");
#define DebugNetMsg( l, ... ) do { if (script_net_debug.GetInt() >= l) ConColorMsg( Color(100, 225, 255, 255), __VA_ARGS__ ); } while (0);
#else
#define DebugNetMsg( l, ... ) do { extern ConVar developer; if (developer.GetInt() >= l) ConColorMsg( Color(100, 225, 175, 255), __VA_ARGS__ ); } while (0);
ConVar script_net_debug("script_net_debug_client", "0");
#define DebugNetMsg( l, ... ) do { if (script_net_debug.GetInt() >= l) ConColorMsg( Color(100, 225, 175, 255), __VA_ARGS__ ); } while (0);
#endif
#define DebugWarning(...) Warning( __VA_ARGS__ )
#else
@ -1428,7 +1430,7 @@ void CNetMsgScriptHelper::ReceiveMessage( bf_read &msg )
m_MsgIn.StartReading( msg.m_pData, msg.m_nDataBytes );
#endif
DebugNetMsg( 2, DLL_LOC_STR " %s()", __FUNCTION__ );
DebugNetMsg( 2, DLL_LOC_STR " %s()\n", __FUNCTION__ );
// Don't do anything if there's no VM here. This can happen if a message from the server goes to a VM-less client, or vice versa.
if ( !g_pScriptVM )

View File

@ -539,11 +539,12 @@ void RegisterBaseBindings( IScriptVM *pVM )
ScriptRegisterConstant( pVM, FCVAR_SPONLY, "If this convar flag is set, it can't be changed by clients connected to a multiplayer server." );
ScriptRegisterConstant( pVM, FCVAR_ARCHIVE, "If this convar flag is set, its value will be saved when the game is exited." );
ScriptRegisterConstant( pVM, FCVAR_NOTIFY, "If this convar flag is set, it will notify players when it is changed." );
ScriptRegisterConstant( pVM, FCVAR_CHEAT, "Only useable in singleplayer / debug / multiplayer & sv_cheats" );
ScriptRegisterConstant( pVM, FCVAR_USERINFO, "If this convar flag is set, it will be marked as info which plays a part in how the server identifies a client." );
ScriptRegisterConstant( pVM, FCVAR_PRINTABLEONLY, "If this convar flag is set, it cannot contain unprintable characters. Used for player name cvars, etc." );
ScriptRegisterConstant( pVM, FCVAR_UNLOGGED, "If this convar flag is set, it will not log its changes if a log is being created." );
ScriptRegisterConstant( pVM, FCVAR_NEVER_AS_STRING, "If this convar flag is set, it will never be printed as a string." );
ScriptRegisterConstant( pVM, FCVAR_REPLICATED, "If this convar flag is set, it will enforce a serverside value on any clientside counterparts. (also known as FCAR_SERVER)" );
ScriptRegisterConstant( pVM, FCVAR_REPLICATED, "If this convar flag is set, it will enforce a serverside value on any clientside counterparts. (also known as FCVAR_SERVER)" );
ScriptRegisterConstant( pVM, FCVAR_DEMO, "If this convar flag is set, it will be recorded when starting a demo file." );
ScriptRegisterConstant( pVM, FCVAR_DONTRECORD, "If this convar flag is set, it will NOT be recorded when starting a demo file." );
ScriptRegisterConstant( pVM, FCVAR_RELOAD_MATERIALS, "If this convar flag is set, it will force a material reload when it changes." );

View File

@ -2970,6 +2970,14 @@ int SquirrelVM::GetKeyValue(HSCRIPT hScope, int nIterator, ScriptVariant_t* pKey
bool SquirrelVM::GetValue(HSCRIPT hScope, const char* pszKey, ScriptVariant_t* pValue)
{
#ifdef _DEBUG
AssertMsg( pszKey, "FATAL: cannot get NULL" );
// Don't crash on debug
if ( !pszKey )
return GetValue( hScope, ScriptVariant_t(0), pValue );
#endif
SquirrelSafeCheck safeCheck(vm_);
Assert(pValue);