mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-12 23:07:55 +03:00
Added more convenient way to hide HUD elements from clientside VScript
This commit is contained in:
parent
2214301694
commit
6ceb808f93
@ -947,6 +947,11 @@ 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
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -968,6 +973,14 @@ 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;
|
||||
|
@ -143,6 +143,10 @@ 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;
|
||||
|
||||
@ -3403,6 +3407,9 @@ void CScriptVGUI::LevelShutdownPostEntity()
|
||||
surface()->DestroyTextureID( g_ScriptTextureIDs[i] );
|
||||
}
|
||||
g_ScriptTextureIDs.Purge();
|
||||
|
||||
// Reset HUD hidden bits
|
||||
g_iVScriptHideHUD = 0;
|
||||
}
|
||||
|
||||
void CScriptVGUI::Shutdown()
|
||||
@ -3690,6 +3697,29 @@ 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()
|
||||
{
|
||||
@ -3702,6 +3732,11 @@ 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" );
|
||||
|
@ -604,6 +604,25 @@ 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
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user