Skip to content

Commit

Permalink
Merge pull request #93 from Vladislav4KZ/map-prefix-check
Browse files Browse the repository at this point in the history
add: cscl_mapprefix cvar for menu scripts
  • Loading branch information
Velaron authored Aug 16, 2024
2 parents 2395c66 + 786c567 commit e6df359
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions 3rdparty/cs16client-extras/touch/chooseteam.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions cl_dll/hud_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e6df359

Please sign in to comment.