Merge pull request #10 from petr666/feature/allow-to-hide-item-in-hand

Allow to hide item in hand
This commit is contained in:
Simon 2022-03-10 20:45:26 +00:00 committed by GitHub
commit 8bc72f8716
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 4 deletions

View file

@ -1429,8 +1429,10 @@ static void CG_DrawHoldableItem( void ) {
if ( value ) {
CG_RegisterItemVisuals( value );
//If we are two handing the weapon, move the item icon back to the HUD
if (trap_Cvar_VariableValue("vr_twoHandedWeapons") != 0.0f && vr->weapon_stabilised)
//If we are two handing the weapon or show in hand not enabled, move the item icon back to the HUD
qboolean show_in_hand_enabled = trap_Cvar_VariableValue( "vr_showItemInHand" ) != 0.0f;
qboolean two_handed_enabled = trap_Cvar_VariableValue("vr_twoHandedWeapons") != 0.0f;
if (!show_in_hand_enabled || (two_handed_enabled && vr->weapon_stabilised))
{
CG_DrawPic(640 - ICON_SIZE, (SCREEN_HEIGHT - ICON_SIZE) / 2, ICON_SIZE, ICON_SIZE,
cg_items[value].icon);

View file

@ -1642,7 +1642,9 @@ void CG_TrailItem( centity_t *cent, qhandle_t hModel, vec3_t offset, float scale
if (cent->currentState.clientNum == vr->clientNum)
{
if (trap_Cvar_VariableValue("vr_twoHandedWeapons") != 0.0f && vr->weapon_stabilised)
qboolean show_in_hand_enabled = trap_Cvar_VariableValue( "vr_showItemInHand" ) != 0.0f;
qboolean two_handed_enabled = trap_Cvar_VariableValue("vr_twoHandedWeapons") != 0.0f;
if (!show_in_hand_enabled || (two_handed_enabled && vr->weapon_stabilised))
{
return;
}

View file

@ -54,7 +54,8 @@ GAME OPTIONS MENU
#define ID_DRAWHUD 139
#define ID_HOLSTER2D 140
#define ID_GORE 141
#define ID_BACK 142
#define ID_SHOWINHAND 142
#define ID_BACK 143
#define NUM_CROSSHAIRS 10
#define NUM_GORE 4
@ -82,6 +83,7 @@ typedef struct {
menuradiobutton_s allowdownload;
menuradiobutton_s holster2d;
menulist_s gore;
menuradiobutton_s showinhand;
menubitmap_s back;
qhandle_t crosshairShader[NUM_CROSSHAIRS];
@ -130,6 +132,7 @@ static void Preferences_SetMenuItems( void ) {
s_preferences.gore.curvalue = level % NUM_GORE;
}
s_preferences.showinhand.curvalue = trap_Cvar_VariableValue( "vr_showItemInHand" ) != 0;
}
@ -225,6 +228,10 @@ static void Preferences_Event( void* ptr, int notification ) {
}
break;
case ID_SHOWINHAND:
trap_Cvar_SetValue( "vr_showItemInHand", s_preferences.showinhand.curvalue);
break;
case ID_BACK:
UI_PopMenu();
break;
@ -356,6 +363,15 @@ static void Preferences_MenuInit( void ) {
s_preferences.holster2d.generic.x = PREFERENCES_X_POS;
s_preferences.holster2d.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.showinhand.generic.type = MTYPE_RADIOBUTTON;
s_preferences.showinhand.generic.name = "Show Item In Hand:";
s_preferences.showinhand.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_preferences.showinhand.generic.callback = Preferences_Event;
s_preferences.showinhand.generic.id = ID_SHOWINHAND;
s_preferences.showinhand.generic.x = PREFERENCES_X_POS;
s_preferences.showinhand.generic.y = y;
y += BIGCHAR_HEIGHT+2;
s_preferences.wallmarks.generic.type = MTYPE_RADIOBUTTON;
s_preferences.wallmarks.generic.name = "Marks on Walls:";
@ -488,6 +504,7 @@ static void Preferences_MenuInit( void ) {
Menu_AddItem( &s_preferences.menu, &s_preferences.holster2d );
// Menu_AddItem( &s_preferences.menu, &s_preferences.allowdownload );
Menu_AddItem( &s_preferences.menu, &s_preferences.gore );
Menu_AddItem( &s_preferences.menu, &s_preferences.showinhand );
Menu_AddItem( &s_preferences.menu, &s_preferences.back );

View file

@ -28,6 +28,7 @@ cvar_t *vr_directionMode = NULL;
cvar_t *vr_weaponPitch = NULL;
cvar_t *vr_twoHandedWeapons = NULL;
cvar_t *vr_altKeyEnabled = NULL;
cvar_t *vr_showItemInHand = NULL;
cvar_t *vr_refreshrate = NULL;
cvar_t *vr_weaponScope = NULL;
cvar_t *vr_rollWhenHit = NULL;
@ -65,6 +66,7 @@ void VR_InitCvars( void )
vr_heightAdjust = Cvar_Get ("vr_heightAdjust", "0.0", CVAR_ARCHIVE);
vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE);
vr_altKeyEnabled = Cvar_Get ("vr_altKeyEnabled", "0", CVAR_ARCHIVE);
vr_showItemInHand = Cvar_Get ("vr_showItemInHand", "1", CVAR_ARCHIVE);
vr_refreshrate = Cvar_Get ("vr_refreshrate", "72", CVAR_ARCHIVE);
vr_weaponScope = Cvar_Get ("vr_weaponScope", "1", CVAR_ARCHIVE);
vr_rollWhenHit = Cvar_Get ("vr_rollWhenHit", "0", CVAR_ARCHIVE);