mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-27 06:07:56 +03:00
Support for map-specific HUD animations and HUD layout scripts
This commit is contained in:
parent
e39e1e0cca
commit
8985ad2fe4
@ -146,6 +146,32 @@ bool CBaseViewport::LoadHudAnimations( void )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Reloads HUD animations after loading a map-specific HUD animations file.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CBaseViewport::ReloadHudAnimations( void )
|
||||||
|
{
|
||||||
|
// Force a reload
|
||||||
|
if ( LoadHudAnimations() == false )
|
||||||
|
{
|
||||||
|
// Fall back to just the main
|
||||||
|
if ( m_pAnimController->SetScriptFile( GetVPanel(), "scripts/HudAnimations.txt", true ) == false )
|
||||||
|
{
|
||||||
|
Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Loads a map-specific HUD animations file.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CBaseViewport::LoadCustomHudAnimations( const char *pszFile )
|
||||||
|
{
|
||||||
|
return m_pAnimController->SetScriptFile( GetVPanel(), pszFile, true );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
|
CBaseViewport::CBaseViewport() : vgui::EditablePanel( NULL, "CBaseViewport")
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,10 @@ public:
|
|||||||
public: // IGameEventListener:
|
public: // IGameEventListener:
|
||||||
virtual void FireGameEvent( IGameEvent * event);
|
virtual void FireGameEvent( IGameEvent * event);
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool LoadCustomHudAnimations( const char *pszFile );
|
||||||
|
void ReloadHudAnimations( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ ConVar mapbase_version_client( "mapbase_version_client", MAPBASE_VERSION, FCVAR_
|
|||||||
|
|
||||||
// This is from the vgui_controls library
|
// This is from the vgui_controls library
|
||||||
extern vgui::HScheme g_iCustomClientSchemeOverride;
|
extern vgui::HScheme g_iCustomClientSchemeOverride;
|
||||||
|
|
||||||
|
bool g_bUsingCustomHudAnimations = false;
|
||||||
|
bool g_bUsingCustomHudLayout = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void AddSurfacepropFile( const char *pFileName, IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem );
|
extern void AddSurfacepropFile( const char *pFileName, IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem );
|
||||||
@ -90,6 +93,8 @@ enum
|
|||||||
MANIFEST_CLOSECAPTION,
|
MANIFEST_CLOSECAPTION,
|
||||||
MANIFEST_VGUI,
|
MANIFEST_VGUI,
|
||||||
MANIFEST_CLIENTSCHEME,
|
MANIFEST_CLIENTSCHEME,
|
||||||
|
MANIFEST_HUDANIMATIONS,
|
||||||
|
MANIFEST_HUDLAYOUT,
|
||||||
#else
|
#else
|
||||||
MANIFEST_TALKER,
|
MANIFEST_TALKER,
|
||||||
//MANIFEST_SENTENCES,
|
//MANIFEST_SENTENCES,
|
||||||
@ -125,6 +130,8 @@ static const ManifestType_t gm_szManifestFileStrings[MANIFEST_NUM_TYPES] = {
|
|||||||
{ "closecaption", "mapbase_load_closecaption", "Should we load map-specific closed captioning? e.g. \"maps/<mapname>_closecaption_english.txt\" and \"maps/<mapname>_closecaption_english.dat\"" },
|
{ "closecaption", "mapbase_load_closecaption", "Should we load map-specific closed captioning? e.g. \"maps/<mapname>_closecaption_english.txt\" and \"maps/<mapname>_closecaption_english.dat\"" },
|
||||||
{ "vgui", "mapbase_load_vgui", "Should we load map-specific VGUI screens? e.g. \"maps/<mapname>_screens.txt\"" },
|
{ "vgui", "mapbase_load_vgui", "Should we load map-specific VGUI screens? e.g. \"maps/<mapname>_screens.txt\"" },
|
||||||
{ "clientscheme", "mapbase_load_clientscheme", "Should we load map-specific ClientScheme.res overrides? e.g. \"maps/<mapname>_clientscheme.res\"" },
|
{ "clientscheme", "mapbase_load_clientscheme", "Should we load map-specific ClientScheme.res overrides? e.g. \"maps/<mapname>_clientscheme.res\"" },
|
||||||
|
{ "hudanimations", "mapbase_load_hudanimations", "Should we load map-specific HUD animation overrides? e.g. \"maps/<mapname>_hudanimations.txt\"" },
|
||||||
|
{ "hudlayout", "mapbase_load_hudlayout", "Should we load map-specific HUD layout overrides? e.g. \"maps/<mapname>_hudlayout.res\"" },
|
||||||
#else
|
#else
|
||||||
{ "talker", "mapbase_load_talker", "Should we load map-specific talker files? e.g. \"maps/<mapname>_talker.txt\"" },
|
{ "talker", "mapbase_load_talker", "Should we load map-specific talker files? e.g. \"maps/<mapname>_talker.txt\"" },
|
||||||
//{ "sentences", "mapbase_load_sentences", "Should we load map-specific sentences? e.g. \"maps/<mapname>_sentences.txt\"" },
|
//{ "sentences", "mapbase_load_sentences", "Should we load map-specific sentences? e.g. \"maps/<mapname>_sentences.txt\"" },
|
||||||
@ -264,18 +271,36 @@ public:
|
|||||||
{
|
{
|
||||||
hudCloseCaption->RemoveCaptionDictionary( m_CloseCaptionFileNames[i] );
|
hudCloseCaption->RemoveCaptionDictionary( m_CloseCaptionFileNames[i] );
|
||||||
}
|
}
|
||||||
|
m_CloseCaptionFileNames.RemoveAll();
|
||||||
|
|
||||||
if (g_iCustomClientSchemeOverride != 0)
|
if (g_iCustomClientSchemeOverride != 0 || g_bUsingCustomHudAnimations || g_bUsingCustomHudLayout)
|
||||||
{
|
{
|
||||||
|
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Mapbase: Reloading client mode and viewport scheme\n" );
|
||||||
|
|
||||||
// TODO: We currently have no way of actually cleaning up custom schemes upon level unload.
|
// TODO: We currently have no way of actually cleaning up custom schemes upon level unload.
|
||||||
// That may or may not be sustainable if there's a ton of custom schemes loaded at once
|
// That may or may not be sustainable if there's a ton of custom schemes loaded at once
|
||||||
g_iCustomClientSchemeOverride = 0;
|
g_iCustomClientSchemeOverride = 0;
|
||||||
|
|
||||||
|
g_bUsingCustomHudAnimations = false;
|
||||||
|
g_bUsingCustomHudLayout = false;
|
||||||
|
|
||||||
// Reload scheme
|
// Reload scheme
|
||||||
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
|
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
|
||||||
if ( mode )
|
if ( mode )
|
||||||
{
|
{
|
||||||
mode->ReloadScheme();
|
mode->ReloadScheme();
|
||||||
|
|
||||||
|
// We need to reload default values, so load a special "hudlayout_mapbase.res" file that only contains
|
||||||
|
// default Mapbase definitions identical to the defaults in the code
|
||||||
|
CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>(g_pClientMode->GetViewport());
|
||||||
|
if (pViewport)
|
||||||
|
{
|
||||||
|
KeyValuesAD pConditions( "conditions" );
|
||||||
|
g_pClientMode->ComputeVguiResConditions( pConditions );
|
||||||
|
|
||||||
|
// reload the .res file from disk
|
||||||
|
pViewport->LoadControlSettings( "scripts/hudlayout_mapbase.res", NULL, NULL, pConditions );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -363,6 +388,42 @@ public:
|
|||||||
mode->ReloadScheme();
|
mode->ReloadScheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadCustomHudAnimations( const char *pszFile )
|
||||||
|
{
|
||||||
|
CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>(g_pClientMode->GetViewport());
|
||||||
|
if (pViewport)
|
||||||
|
{
|
||||||
|
g_bUsingCustomHudAnimations = true;
|
||||||
|
if (!pViewport->LoadCustomHudAnimations( pszFile ))
|
||||||
|
{
|
||||||
|
g_bUsingCustomHudAnimations = false;
|
||||||
|
CGWarning( 0, CON_GROUP_MAPBASE_MISC, "Custom HUD animations file \"%s\" failed to load\n", pszFile );
|
||||||
|
pViewport->ReloadHudAnimations();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Loaded custom HUD animations file \"%s\"\n", pszFile );;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadCustomHudLayout( const char *pszFile )
|
||||||
|
{
|
||||||
|
CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>(g_pClientMode->GetViewport());
|
||||||
|
if (pViewport)
|
||||||
|
{
|
||||||
|
g_bUsingCustomHudLayout = true;
|
||||||
|
|
||||||
|
KeyValuesAD pConditions( "conditions" );
|
||||||
|
g_pClientMode->ComputeVguiResConditions( pConditions );
|
||||||
|
|
||||||
|
// reload the .res file from disk
|
||||||
|
pViewport->LoadControlSettings( pszFile, NULL, NULL, pConditions );
|
||||||
|
|
||||||
|
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Loaded custom HUD layout file \"%s\"\n", pszFile );;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get a generic, hardcoded manifest with hardcoded names.
|
// Get a generic, hardcoded manifest with hardcoded names.
|
||||||
@ -422,6 +483,8 @@ public:
|
|||||||
} break;
|
} break;
|
||||||
case MANIFEST_VGUI: { PanelMetaClassMgr()->LoadMetaClassDefinitionFile( value ); } break;
|
case MANIFEST_VGUI: { PanelMetaClassMgr()->LoadMetaClassDefinitionFile( value ); } break;
|
||||||
case MANIFEST_CLIENTSCHEME: { LoadCustomScheme( value ); } break;
|
case MANIFEST_CLIENTSCHEME: { LoadCustomScheme( value ); } break;
|
||||||
|
case MANIFEST_HUDANIMATIONS: { LoadCustomHudAnimations( value ); } break;
|
||||||
|
case MANIFEST_HUDLAYOUT: { LoadCustomHudLayout( value ); } break;
|
||||||
//case MANIFEST_SOUNDSCAPES: { Soundscape_AddFile(value); } break;
|
//case MANIFEST_SOUNDSCAPES: { Soundscape_AddFile(value); } break;
|
||||||
#else
|
#else
|
||||||
case MANIFEST_TALKER: {
|
case MANIFEST_TALKER: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user