From 786c5673ab36f854e176ad59a844558f21bbdc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A1=D1=83=D1=85=D0=BE=D0=B2?= <22411953+Vladislav4KZ@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:46:08 +0000 Subject: [PATCH] add: cscl_mapprefix cvar for menu scripts --- 3rdparty/cs16client-extras/touch/chooseteam.cfg | 4 +--- cl_dll/hud.cpp | 1 + cl_dll/hud.h | 1 + cl_dll/hud_msg.cpp | 11 +++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/3rdparty/cs16client-extras/touch/chooseteam.cfg b/3rdparty/cs16client-extras/touch/chooseteam.cfg index 6288391a..4f1ef82b 100644 --- a/3rdparty/cs16client-extras/touch/chooseteam.cfg +++ b/3rdparty/cs16client-extras/touch/chooseteam.cfg @@ -89,9 +89,7 @@ alias _menu_scores_show "teammenu_showscores 1; alias _menu_scores _menu_scores_ alias _menu_scores_hide "teammenu_showscores 0; alias _menu_scores _menu_scores_show; touch_settexture _menu_txt_slot9 \"#9 SHOW SCOREBOARD\"; touch_setcolor _menu_frame 0 0 0 200; touch_show _menu_frame_*; hidescoreboard2" _menu_vip_hide -if $cscl_currentmap == as_oilrig -:_menu_vip_show -if $cscl_currentmap == as_tundra +if $cscl_mapprefix == as_ :_menu_vip_show if $teammenu_showscores >= 1 diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index a4cdf83d..738eb6cc 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -238,6 +238,7 @@ void CHud :: Init( void ) CVAR_CREATE( "numericalmenu_clientonly", "1", FCVAR_ARCHIVE ); CVAR_CREATE( "checkscoreboard", "1", FCVAR_ARCHIVE ); cscl_currentmap = CVAR_CREATE( "cscl_currentmap", "", 0 ); + cscl_mapprefix = CVAR_CREATE( "cscl_mapprefix", "", 0 ); cscl_currentmoney = CVAR_CREATE( "cscl_currentmoney", "0", 0 ); CVAR_CREATE( "teammenu_showscores", "0", FCVAR_ARCHIVE ); CVAR_CREATE( "menu_bg_fill", "0", FCVAR_ARCHIVE ); diff --git a/cl_dll/hud.h b/cl_dll/hud.h index a5075f02..e2342c41 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -988,6 +988,7 @@ class CHud cvar_t *hud_scale; cvar_t *cscl_currentmoney; cvar_t *cscl_currentmap; + cvar_t *cscl_mapprefix; HSPRITE m_hGasPuff; diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 51699fc5..728fee3c 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -56,14 +56,25 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) // reset concussion effect m_iConcussionEffect = 0; + char szMapPrefix[64] = { 0 }; char szMapName[64] = { 0 }; const char *szFullMapName = gEngfuncs.pfnGetLevelName(); if ( szFullMapName && szFullMapName[0] ) { strncpy( szMapName, szFullMapName + 5, sizeof( szMapName ) ); szMapName[strlen( szMapName ) - 4] = '\0'; + + int i = 0; + while ( szMapName[i] != '_' && szMapName[i] != '\0' && i < sizeof( szMapPrefix ) - 1 ) + { + szMapPrefix[i] = szMapName[i]; + i++; + } + szMapPrefix[i] = '_'; + szMapPrefix[i + 1] = '\0'; } gEngfuncs.Cvar_Set( gHUD.cscl_currentmap->name, szMapName ); + gEngfuncs.Cvar_Set( gHUD.cscl_mapprefix->name, szMapPrefix ); return 1; }