Wheel selector

This commit is contained in:
Petr Bartos 2023-10-04 20:40:06 +02:00
parent e8e72601e5
commit 4000523483
27 changed files with 905 additions and 67 deletions

View file

@ -1522,6 +1522,8 @@ void RTCWVR_Init()
vr.teleportseek = qfalse;
vr.teleportenabled = qfalse;
vr.teleportready = qfalse;
vr.menu_right_handed = vr_control_scheme->integer == 0;
}

View file

@ -12,6 +12,7 @@ typedef struct {
float fov;
qboolean weapon_stabilised;
qboolean right_handed;
qboolean menu_right_handed;
qboolean player_moving;
qboolean visible_hud;
qboolean dualwield;
@ -73,7 +74,11 @@ typedef struct {
vec3_t teleportdest; // teleport destination
qboolean teleportexecute; // execute the teleport
int useGestureState;
int useGestureState;
int wheelSelectorEnabled;
qboolean binocularsActive;
qboolean useHoldableItem;
qboolean toggleMainMenu;
//////////////////////////////////////
// Test stuff for weapon alignment

View file

@ -133,19 +133,22 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
//Menu button
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
if (vr.toggleMainMenu) { // Menu toggled via wheel selector
vr.toggleMainMenu = qfalse;
Sys_QueEvent( 0, SE_KEY, K_ESCAPE, qtrue, 0, NULL );
}
static float menuYaw = 0;
static bool switchedMenuControls = qfalse;
if ( RTCWVR_useScreenLayer() )
{
bool controlsLeftHanded = vr_control_scheme->integer >= 10;
if ((controlsLeftHanded && !switchedMenuControls) || (!controlsLeftHanded && switchedMenuControls)) {
if (controlsLeftHanded == vr.menu_right_handed) {
interactWithTouchScreen(menuYaw, vr.offhandangles);
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton1, K_MOUSE1);
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
handleTrackedControllerButton(pOffTrackedRemoteNew, pOffTrackedRemoteOld, offButton2, K_ESCAPE);
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
switchedMenuControls = !switchedMenuControls;
vr.menu_right_handed = !vr.menu_right_handed;
}
} else {
interactWithTouchScreen(menuYaw, vr.dominanthandangles);
@ -153,7 +156,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton2, K_ESCAPE);
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) != (pOffTrackedRemoteOld->Buttons & ovrButton_Trigger) && (pOffTrackedRemoteNew->Buttons & ovrButton_Trigger)) {
switchedMenuControls = !switchedMenuControls;
vr.menu_right_handed = !vr.menu_right_handed;
}
}
}
@ -221,7 +224,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
static qboolean binocularstate = qfalse;
qboolean binocularsactive = (vr.hasbinoculars && vr.backpackitemactive == 3 &&
qboolean binocularsactive = (vr.hasbinoculars && (vr.backpackitemactive == 3 || vr.binocularsActive) &&
(distanceToHMD < BINOCULAR_ENGAGE_DISTANCE) &&
(pDominantTracking->Status & (VRAPI_TRACKING_STATUS_POSITION_TRACKED | VRAPI_TRACKING_STATUS_POSITION_VALID)));
if (binocularstate != binocularsactive)
@ -460,11 +463,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
if (dominantGripPushed) {
if (dominantGripPushTime == 0) {
dominantGripPushTime = GetTimeInMilliSeconds();
} else if (!handInBackpack && !vr.backpackitemactive && !vr.mountedgun && !vr.scopeengaged && !vr.weapon_stabilised &&
(GetTimeInMilliSeconds() - dominantGripPushTime) > vr_reloadtimeoutms->integer) {
vr.wheelSelectorEnabled = true;
}
}
else
{
if (vr.backpackitemactive == 1) {
if (vr.wheelSelectorEnabled) {
vr.wheelSelectorEnabled = false;
sendButtonActionSimple("wheelselectorselect");
}
else if (vr.backpackitemactive == 1) {
//Restores last used weapon if possible
char buffer[32];
sprintf(buffer, "weapon %i", vr.lastweaponid);
@ -598,7 +608,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
else
{
//Fire Primary
if (vr.backpackitemactive != 3 && // Can't fire while holding binoculars
if (vr.backpackitemactive != 3 && !vr.binocularsActive && // Can't fire while holding binoculars
!vr.velocitytriggered && // Don't fire velocity triggered weapons
(pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
@ -630,17 +640,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
//Weapon Chooser
static qboolean itemSwitched = false;
if (between(-0.2f, pPrimaryJoystick->x, 0.2f) &&
(between(0.8f, pPrimaryJoystick->y, 1.0f) ||
between(-1.0f, pPrimaryJoystick->y, -0.8f)))
if (!vr.wheelSelectorEnabled && between(-0.2f, pPrimaryJoystick->x, 0.2f) &&
(between(0.8f, pPrimaryJoystick->y, 1.0f) || between(-1.0f, pPrimaryJoystick->y, -0.8f)))
{
if (!itemSwitched) {
if (between(0.8f, pPrimaryJoystick->y, 1.0f))
{
vr.binocularsActive = false;
sendButtonActionSimple("weapprev");
}
else
{
vr.binocularsActive = false;
sendButtonActionSimple("weapnext");
}
itemSwitched = true;
@ -680,6 +691,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
static qboolean stopUseItemNextFrame = false;
static qboolean startUseItemNextFrame = false;
if (vr.useHoldableItem) // Item toggled via wheel selector
{
startUseItemNextFrame = true;
vr.useHoldableItem = false;
}
if (startUseItemNextFrame)
{
Cbuf_AddText("+useitem\n");
startUseItemNextFrame = qfalse;
stopUseItemNextFrame = qtrue;
}
if (stopUseItemNextFrame)
{
Cbuf_AddText("-useitem\n");
@ -752,62 +775,78 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
usingMountedGun = vr.mountedgun;
}
//No snap turn when using mounted gun
static int syncCount = 0;
static int increaseSnap = true;
if (!vr.mountedgun && !vr.scopeengaged) {
if (pPrimaryJoystick->x > 0.7f) {
if (increaseSnap) {
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f) : vr_turn_angle->value;
snapTurn -= turnAngle;
if (vr_turn_mode->integer == 0) {
increaseSnap = false;
}
if (snapTurn < -180.0f) {
snapTurn += 360.f;
}
RTCWVR_ResyncClientYawWithGameYaw();
if (vr.wheelSelectorEnabled) {
static int wheelSelectorSwitched = false;
if (between(0.8f, pPrimaryJoystick->x, 1.0f) || between(-1.0f, pPrimaryJoystick->x, -0.8f)) {
if (!wheelSelectorSwitched) {
if (between(0.8f, pPrimaryJoystick->x, 1.0f)) {
sendButtonActionSimple("wheelselectornext");
} else {
sendButtonActionSimple("wheelselectorprev");
}
wheelSelectorSwitched = true;
}
} else if (pPrimaryJoystick->x < 0.3f) {
increaseSnap = true;
} else {
wheelSelectorSwitched = false;
}
} else {
//No snap turn when using mounted gun
static int syncCount = 0;
static int increaseSnap = true;
if (!vr.mountedgun && !vr.scopeengaged) {
if (pPrimaryJoystick->x > 0.7f) {
if (increaseSnap) {
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f) : vr_turn_angle->value;
snapTurn -= turnAngle;
static int decreaseSnap = true;
if (pPrimaryJoystick->x < -0.7f) {
if (decreaseSnap) {
if (vr_turn_mode->integer == 0) {
increaseSnap = false;
}
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f) : vr_turn_angle->value;
snapTurn += turnAngle;
if (snapTurn < -180.0f) {
snapTurn += 360.f;
}
//If snap turn configured for less than 10 degrees
if (vr_turn_mode->integer == 0) {
decreaseSnap = false;
RTCWVR_ResyncClientYawWithGameYaw();
}
if (snapTurn > 180.0f) {
snapTurn -= 360.f;
}
RTCWVR_ResyncClientYawWithGameYaw();
} else if (pPrimaryJoystick->x < 0.3f) {
increaseSnap = true;
}
static int decreaseSnap = true;
if (pPrimaryJoystick->x < -0.7f) {
if (decreaseSnap) {
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f) : vr_turn_angle->value;
snapTurn += turnAngle;
//If snap turn configured for less than 10 degrees
if (vr_turn_mode->integer == 0) {
decreaseSnap = false;
}
if (snapTurn > 180.0f) {
snapTurn -= 360.f;
}
RTCWVR_ResyncClientYawWithGameYaw();
}
} else if (pPrimaryJoystick->x > -0.3f) {
decreaseSnap = true;
}
} else if (pPrimaryJoystick->x > -0.3f) {
decreaseSnap = true;
}
}
else {
if (fabs(pPrimaryJoystick->x) > 0.5f) {
if (increaseSnap)
else {
if (fabs(pPrimaryJoystick->x) > 0.5f) {
if (increaseSnap)
{
RTCWVR_ResyncClientYawWithGameYaw();
}
increaseSnap = false;
}
else
{
RTCWVR_ResyncClientYawWithGameYaw();
increaseSnap = true;
}
increaseSnap = false;
}
else
{
increaseSnap = true;
}
}
}
@ -818,7 +857,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
// Process "use" gesture
if (vr_gesture_triggered_use->integer) {
int thirdPersonActive = Cvar_VariableIntegerValue("cg_thirdPerson");
bool gestureUseAllowed = !vr.weapon_stabilised && !vr.mountedgun && !vr.scopeengaged && !thirdPersonActive;
bool gestureUseAllowed = !vr.weapon_stabilised && !vr.mountedgun && !vr.scopeengaged && !vr.wheelSelectorEnabled && !thirdPersonActive;
// Off-hand gesture
float distanceToBody = sqrt(vr.offhandoffset[0]*vr.offhandoffset[0] + vr.offhandoffset[2]*vr.offhandoffset[2]);
if (gestureUseAllowed && (distanceToBody > vr_use_gesture_boundary->value)) {

View file

@ -416,6 +416,10 @@ typedef struct {
void ( *function )( void );
} consoleCommand_t;
void CG_WheelSelectorSelect_f( void );
void CG_WheelSelectorNext_f( void );
void CG_WheelSelectorPrev_f( void );
static consoleCommand_t commands[] = {
{ "testgun", CG_TestGun_f },
{ "testmodel", CG_TestModel_f },
@ -453,6 +457,9 @@ static consoleCommand_t commands[] = {
{ "loaddeferred", CG_LoadDeferredPlayers }, // spelling fixed (SA)
{ "camera", CG_Camera_f }, // duffy
{ "fade", CG_Fade_f }, // duffy
{ "wheelselectorselect", CG_WheelSelectorSelect_f },
{ "wheelselectornext", CG_WheelSelectorNext_f },
{ "wheelselectorprev", CG_WheelSelectorPrev_f },
// NERVE - SMF
{ "mp_QuickMessage", CG_QuickMessage_f },

View file

@ -929,6 +929,12 @@ typedef struct {
int weaponAnimation;
int weaponAnimationTime;
int wheelSelectorType;
int wheelSelectorSelection;
int wheelSelectorTime;
vec3_t wheelSelectorOrigin;
vec3_t wheelSelectorOffset;
// blend blobs
viewDamage_t viewDamage[MAX_VIEWDAMAGE];
float damageTime; // last time any kind of damage was recieved
@ -1089,6 +1095,33 @@ typedef struct {
qhandle_t lagometerShader;
qhandle_t backTileShader;
qhandle_t noammoShader;
qhandle_t noammoIcon;
qhandle_t binocularsIcon;
qhandle_t binocularsIconSelect;
qhandle_t wine1Icon;
qhandle_t wine1IconSelect;
qhandle_t wine2Icon;
qhandle_t wine2IconSelect;
qhandle_t wine3Icon;
qhandle_t wine3IconSelect;
qhandle_t staminaIcon;
qhandle_t staminaIconSelect;
qhandle_t pbookIcon;
qhandle_t pbookIconSelect;
qhandle_t vbookIcon;
qhandle_t vbookIconSelect;
qhandle_t zbookIcon;
qhandle_t zbookIconSelect;
qhandle_t exitIcon;
qhandle_t exitIconSelect;
qhandle_t saveIcon;
qhandle_t saveIconSelect;
qhandle_t loadIcon;
qhandle_t loadIconSelect;
qhandle_t arrowIcon;
qhandle_t weaponIcons[SELECTABLE_WEAPONS_NUM];
qhandle_t weaponIconsSelect[SELECTABLE_WEAPONS_NUM];
qhandle_t reticleShader;
// qhandle_t reticleShaderSimple;
@ -2068,6 +2101,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
void CG_DrawWeaponSelect( void );
void CG_DrawHoldableSelect( void );
void CG_AddViewHand( playerState_t *ps );
void CG_DrawWheelSelector( void );
void CG_OutOfAmmoChange( void );
void CG_HoldableUsedupChange( void ); //----(SA) added

View file

@ -1283,6 +1283,61 @@ static void CG_RegisterGraphics( void ) {
cgs.media.backTileShader = trap_R_RegisterShader( "gfx/2d/backtile" );
cgs.media.noammoShader = trap_R_RegisterShader( "icons/noammo" );
cgs.media.arrowIcon = trap_R_RegisterShader( "icons/arrow" );
cgs.media.binocularsIcon = trap_R_RegisterShader( "icons/binoculars" );
cgs.media.wine1Icon = trap_R_RegisterShader( "icons/wine_notselect" );
cgs.media.wine2Icon = trap_R_RegisterShader( "icons/wine2_notselect" );
cgs.media.wine3Icon = trap_R_RegisterShader( "icons/wine3_notselect" );
cgs.media.staminaIcon = trap_R_RegisterShader( "icons/stamina_notselect" );
cgs.media.pbookIcon = trap_R_RegisterShader( "icons/icon_pbook_notselect" );
cgs.media.vbookIcon = trap_R_RegisterShader( "icons/icon_vbook_notselect" );
cgs.media.zbookIcon = trap_R_RegisterShader( "icons/icon_zbook_notselect" );
cgs.media.exitIcon = trap_R_RegisterShader( "icons/exit" );
cgs.media.loadIcon = trap_R_RegisterShader( "icons/load" );
cgs.media.saveIcon = trap_R_RegisterShader( "icons/save" );
cgs.media.binocularsIconSelect = trap_R_RegisterShader( "icons/binoculars_select" );
cgs.media.wine1IconSelect = trap_R_RegisterShader( "icons/wine" );
cgs.media.wine2IconSelect = trap_R_RegisterShader( "icons/wine2" );
cgs.media.wine3IconSelect = trap_R_RegisterShader( "icons/wine3" );
cgs.media.staminaIconSelect = trap_R_RegisterShader( "icons/stamina" );
cgs.media.pbookIconSelect = trap_R_RegisterShader( "icons/icon_pbook" );
cgs.media.vbookIconSelect = trap_R_RegisterShader( "icons/icon_vbook" );
cgs.media.zbookIconSelect = trap_R_RegisterShader( "icons/icon_zbook" );
cgs.media.exitIconSelect = trap_R_RegisterShader( "icons/exit_select" );
cgs.media.loadIconSelect = trap_R_RegisterShader( "icons/load_select" );
cgs.media.saveIconSelect = trap_R_RegisterShader( "icons/save_select" );
// Z-order of icon rendering is based on order they were registered, not based on depth
// they are rendered at. So we are registering weapon icons again so they are properly
// rendered on weapon wheel including no-ammo overlay icon
cgs.media.weaponIcons[0] = trap_R_RegisterShader( "icons/iconw_knife_1.tga" );
cgs.media.weaponIcons[1] = trap_R_RegisterShader( "icons/iconw_luger_1.tga" );
cgs.media.weaponIcons[2] = trap_R_RegisterShader( "icons/iconw_colt_1.tga" );
cgs.media.weaponIcons[3] = trap_R_RegisterShader( "icons/iconw_MP40_1.tga" );
cgs.media.weaponIcons[4] = trap_R_RegisterShader( "icons/iconw_thompson_1.tga" );
cgs.media.weaponIcons[5] = trap_R_RegisterShader( "icons/iconw_sten_1.tga" );
cgs.media.weaponIcons[6] = trap_R_RegisterShader( "icons/iconw_mauser_1.tga" );
cgs.media.weaponIcons[7] = trap_R_RegisterShader( "icons/iconw_garand_1.tga" );
cgs.media.weaponIcons[8] = trap_R_RegisterShader( "icons/iconw_fg42_1.tga" );
cgs.media.weaponIcons[9] = trap_R_RegisterShader( "icons/iconw_panzerfaust_1.tga" );
cgs.media.weaponIcons[10] = trap_R_RegisterShader( "icons/iconw_venom_1.tga" );
cgs.media.weaponIcons[11] = trap_R_RegisterShader( "icons/iconw_flamethrower_1.tga" );
cgs.media.weaponIcons[12] = trap_R_RegisterShader( "icons/iconw_tesla_1.tga" );
cgs.media.weaponIconsSelect[0] = trap_R_RegisterShader( "icons/iconw_knife_1_select.tga" );
cgs.media.weaponIconsSelect[1] = trap_R_RegisterShader( "icons/iconw_luger_1_select.tga" );
cgs.media.weaponIconsSelect[2] = trap_R_RegisterShader( "icons/iconw_colt_1_select.tga" );
cgs.media.weaponIconsSelect[3] = trap_R_RegisterShader( "icons/iconw_MP40_1_select.tga" );
cgs.media.weaponIconsSelect[4] = trap_R_RegisterShader( "icons/iconw_thompson_1_select.tga" );
cgs.media.weaponIconsSelect[5] = trap_R_RegisterShader( "icons/iconw_sten_1_select.tga" );
cgs.media.weaponIconsSelect[6] = trap_R_RegisterShader( "icons/iconw_mauser_1_select.tga" );
cgs.media.weaponIconsSelect[7] = trap_R_RegisterShader( "icons/iconw_garand_1_select.tga" );
cgs.media.weaponIconsSelect[8] = trap_R_RegisterShader( "icons/iconw_fg42_1_select.tga" );
cgs.media.weaponIconsSelect[9] = trap_R_RegisterShader( "icons/iconw_panzerfaust_1_select.tga" );
cgs.media.weaponIconsSelect[10] = trap_R_RegisterShader( "icons/iconw_venom_1_select.tga" );
cgs.media.weaponIconsSelect[11] = trap_R_RegisterShader( "icons/iconw_flamethrower_1_select.tga" );
cgs.media.weaponIconsSelect[12] = trap_R_RegisterShader( "icons/iconw_tesla_1_select.tga" );
cgs.media.noammoIcon = trap_R_RegisterShader( "icons/noammo2" );
// powerup shaders
// cgs.media.quadShader = trap_R_RegisterShader("powerups/quad" );
// cgs.media.quadWeaponShader = trap_R_RegisterShader("powerups/quadWeapon" );

View file

@ -1603,11 +1603,13 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
DEBUGTIME
}
CG_AddViewWeapon( &cg.predictedPlayerState );
if (trap_Cvar_VariableIntegerValue("vr_gesture_triggered_use") && !cgVR->weapon_stabilised && !cg.renderingThirdPerson) {
CG_AddViewHand( &cg.predictedPlayerState);
if (cgVR->wheelSelectorEnabled) {
CG_DrawWheelSelector();
} else {
CG_AddViewWeapon( &cg.predictedPlayerState );
if (trap_Cvar_VariableIntegerValue("vr_gesture_triggered_use") && !cgVR->weapon_stabilised && !cg.renderingThirdPerson) {
CG_AddViewHand( &cg.predictedPlayerState);
}
}
DEBUGTIME

View file

@ -2001,6 +2001,14 @@ void CG_CalculateVRWeaponPosition( int weaponNum, vec3_t origin, vec3_t angles )
angles[YAW] += cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW];
}
void CG_CalculateVRDominantHandPosition( vec3_t origin, vec3_t angles ) {
convertFromVR(cgVR->calculated_weaponoffset, cg.refdef.vieworg, origin);
origin[2] -= 64;
origin[2] += (cgVR->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value;
VectorCopy(cgVR->dominanthandangles, angles);
angles[YAW] += cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW];
}
void CG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ) {
convertFromVR(cgVR->offhandoffset, cg.refdef.vieworg, origin);
origin[2] -= 64;
@ -2009,6 +2017,18 @@ void CG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ) {
angles[YAW] += cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW];
}
void CG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles )
{
vec3_t offset;
VectorCopy(in_offset, offset);
offset[1] = 0; // up/down is index 1 in this case
convertFromVR(offset, cg.refdef.vieworg, origin);
origin[2] -= 64;
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
VectorCopy(in_orientation, angles);
angles[YAW] += (cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW]);
}
/*
==============
CG_CalculateWeaponPositionAndScale
@ -2040,7 +2060,7 @@ static float CG_CalculateWeaponPositionAndScale( playerState_t *ps, vec3_t origi
CG_CenterPrint( cgVR->test_name, SCREEN_HEIGHT * 0.45, SMALLCHAR_WIDTH );
} else {
if (cgVR->backpackitemactive == 3)
if (cgVR->backpackitemactive == 3 || cgVR->binocularsActive)
{
scale = 0.5f;
VectorSet(offset, 1, -3, 0);
@ -2993,7 +3013,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
}
if ( ps ) {
if (cgVR->backpackitemactive == 3)
if (cgVR->backpackitemactive == 3 || cgVR->binocularsActive)
{
gun.hModel = binocularModel;
CG_PositionEntityOnTag( &gun, parent, "tag_weapon", 0, NULL );
@ -3464,7 +3484,7 @@ void CG_AddPlayerFoot( refEntity_t *parent, playerState_t *ps, centity_t *cent )
void CG_LaserSight(const playerState_t *ps) {
if (trap_Cvar_VariableIntegerValue("vr_lasersight") != 0 &&
cgVR->backpackitemactive == 0 &&
cgVR->backpackitemactive == 0 && !cgVR->binocularsActive &&
cg.predictedPlayerState.stats[STAT_HEALTH] > 0 &&
!cgVR->screen &&
!cgVR->scopeengaged)
@ -3622,7 +3642,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
CG_WeaponAnimation( ps, weapon, &hand.oldframe, &hand.frame, &hand.backlerp ); //----(SA) changed
}
if (cgVR->backpackitemactive != 3)
if (cgVR->backpackitemactive != 3 && !cgVR->binocularsActive)
{
hand.hModel = weapon->handsModel;
}
@ -3993,6 +4013,19 @@ static qboolean CG_WeaponHasAmmo( int i ) {
return qtrue;
}
/*
==============
CG_WeaponAvailable
check if player has weapon
==============
*/
static qboolean CG_WeaponAvailable( int i ) {
if ( !( COM_BitCheck( cg.predictedPlayerState.weapons, i ) ) ) {
return qfalse;
}
return qtrue;
}
/*
===============
@ -4363,6 +4396,614 @@ void CG_WeaponSuggest( int weap ) {
}
void GC_HandleWheelSelector(vec3_t beamColor, selectorWheelEntity_t selectorWheelItems[] , int selectorWheelItemNum )
{
if (cg.wheelSelectorTime == 0)
{
cg.wheelSelectorTime = cg.time;
convertFromVR(cgVR->calculated_weaponoffset, cg.refdef.vieworg, cg.wheelSelectorOrigin);
VectorCopy(cgVR->calculated_weaponoffset, cg.wheelSelectorOffset);
}
float dist = 10.0f;
float radius = 4.4f;
float scale = 0.05f;
float frac = (cg.time - cg.wheelSelectorTime) / 20.0f;
if (frac > 1.0f)
{
frac = 1.0f;
}
trap_Cvar_Set("timescale", "0.22");
vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin, weaponPosition;
CG_CalculateVRDominantHandPosition(controllerOrigin, controllerAngles);
convertFromVR(cgVR->calculated_weaponoffset, cg.refdef.vieworg, weaponPosition);
VectorSubtract(weaponPosition, cg.wheelSelectorOrigin, controllerOffset);
vec3_t wheelAngles, wheelOrigin, beamOrigin, wheelForward, wheelRight, wheelUp;
vec3_t angles;
VectorClear(angles);
angles[YAW] = cgVR->hmdorientation[YAW];
CG_CalculateVRPositionInWorld(cg.wheelSelectorOrigin, cg.wheelSelectorOffset, angles, wheelOrigin, wheelAngles);
AngleVectors(wheelAngles, wheelForward, wheelRight, wheelUp);
VectorCopy(controllerOrigin, wheelOrigin);
VectorCopy(wheelOrigin, beamOrigin);
VectorMA(wheelOrigin, (dist * frac), wheelForward, wheelOrigin);
VectorCopy(wheelOrigin, selectorOrigin);
vec3_t pos;
memset(&pos, 0, sizeof pos);
{
pos[0] = (sinf(DEG2RAD(wheelAngles[YAW] - controllerAngles[YAW])) / sinf(DEG2RAD(22.5f)));
pos[1] = ((wheelAngles[PITCH] - controllerAngles[PITCH]) / 22.5f);
float len = VectorLength(pos);
if (len > 1.0f)
{
pos[0] *= (1.0f / len);
pos[1] *= (1.0f / len);
}
}
VectorMA(selectorOrigin, radius * pos[0], wheelRight, selectorOrigin);
VectorMA(selectorOrigin, radius * pos[1], wheelUp, selectorOrigin);
for (int s = -1; s < 2; s += 2) {
refEntity_t arrowIcon;
memset(&arrowIcon, 0, sizeof(arrowIcon));
vec3_t right;
AngleVectors(wheelAngles, NULL, right, NULL);
float offset = ((float) s * 7.0f) + (((float) s * 0.3f) *
sinf(DEG2RAD(AngleNormalize360(cg.time - cg.wheelSelectorTime))));
VectorMA(wheelOrigin, offset, right, arrowIcon.origin);
arrowIcon.reType = RT_SPRITE;
arrowIcon.customShader = cgs.media.arrowIcon;
arrowIcon.radius = 0.3f;
arrowIcon.rotation = 180.0f * ((s - 1.0f) / 2.0f);
memset(arrowIcon.shaderRGBA, 0xff, 4);
trap_R_AddRefEntityToScene(&arrowIcon);
}
clientInfo_t ci;
ci.health = 1;
ci.handicap = 96; // value out of 255 for alpha channel
VectorSet(ci.color, beamColor[0], beamColor[1], beamColor[2]);
CG_RailTrail2(&ci, beamOrigin, selectorOrigin);
if (selectorWheelItemNum == 0) {
cg.wheelSelectorSelection = WP_NONE;
return;
}
qboolean selected = qfalse;
for (int i = 0; i < selectorWheelItemNum; i++) {
selectorWheelEntity_t item = selectorWheelItems[i];
//first calculate wheel slot position
vec3_t angles, iconOrigin, notSelectableLabelOrigin, selectorFrameOrigin, selectedIconOrigin;
VectorClear(angles);
angles[YAW] = wheelAngles[YAW];
angles[PITCH] = wheelAngles[PITCH];
angles[ROLL] = (float)(360 / selectorWheelItemNum) * i;
vec3_t forward, up;
AngleVectors(angles, forward, NULL, up);
VectorMA(wheelOrigin, (radius * frac), up, iconOrigin);
VectorMA(iconOrigin, -0.2f, forward, notSelectableLabelOrigin);
VectorMA(iconOrigin, -0.2f, forward, selectorFrameOrigin);
VectorMA(iconOrigin, -0.4f, forward, selectedIconOrigin);
vec3_t diff;
VectorSubtract(selectorOrigin, iconOrigin, diff);
float length = VectorLength(diff);
if (length <= 1.0f && frac == 1.0f && !item.notSelectable) {
selected = qtrue;
cg.wheelSelectorSelection = item.itemId;
refEntity_t selectorFrame;
memset(&selectorFrame, 0, sizeof(selectorFrame));
selectorFrame.reType = RT_SPRITE;
selectorFrame.customShader = cgs.media.selectShader;
float radius = 1.4f + (0.2f * sinf(DEG2RAD(AngleNormalize360(cg.time - cg.wheelSelectorTime))));
selectorFrame.radius = radius;
memset(selectorFrame.shaderRGBA, 0xff, 4);
VectorCopy(selectorFrameOrigin, selectorFrame.origin);
trap_R_AddRefEntityToScene(&selectorFrame);
VectorCopy(selectedIconOrigin, item.iconSelected.origin);
trap_R_AddRefEntityToScene(&item.iconSelected);
trap_Haptic(1, cgVR->right_handed ? 1 : 0, 0.7f, "switch_weapon", 0.0f, 0.0f);
} else {
VectorCopy(iconOrigin, item.icon.origin);
trap_R_AddRefEntityToScene(&item.icon);
if (item.notSelectable) {
VectorCopy(notSelectableLabelOrigin, item.labelNotSelectable.origin);
trap_R_AddRefEntityToScene(&item.labelNotSelectable);
}
}
}
if (!selected)
{
cg.wheelSelectorSelection = -1;
}
}
void CG_DrawWheelSelector( void )
{
if (cg.predictedPlayerState.stats[STAT_HEALTH] <= 0)
{
return;
}
vec3_t beamColor;
selectorWheelEntity_t selectorWheelItems[32];
int selectorWheelItemNum = 0;
if (cg.wheelSelectorType == WST_WEAPON) {
beamColor[0] = 1.0f;
beamColor[1] = 0.8f;
beamColor[2] = 0.2f;
int availableWeapons[SELECTABLE_WEAPONS_NUM];
int weaponCount = 0;
for (int i = 0; i < SELECTABLE_WEAPONS_NUM; i++) {
int weaponNum = SELECTABLE_WEAPONS[i];
if (CG_WeaponAvailable(weaponNum)) {
CG_RegisterWeapon(weaponNum);
selectorWheelEntity_t item;
memset(&item, 0, sizeof(item));
if (weaponNum == WP_LUGER && CG_WeaponAvailable(WP_SILENCER)) {
item.itemId = WP_SILENCER;
} else {
item.itemId = weaponNum;
}
refEntity_t icon;
memset(&icon, 0, sizeof(icon));
icon.reType = RT_SPRITE;
icon.customShader = cgs.media.weaponIcons[i];
icon.radius = 0.8f;
memset(icon.shaderRGBA, 0xff, 4);
item.icon = icon;
refEntity_t iconSelected;
memset(&iconSelected, 0, sizeof(iconSelected));
iconSelected.reType = RT_SPRITE;
iconSelected.customShader = cgs.media.weaponIconsSelect[i];
iconSelected.radius = 1.3f;
memset(iconSelected.shaderRGBA, 0xff, 4);
item.iconSelected = iconSelected;
if (!CG_WeaponHasAmmo(weaponNum)) {
item.notSelectable = qtrue;
refEntity_t labelNotSelectable;
memset(&labelNotSelectable, 0, sizeof(labelNotSelectable));
labelNotSelectable.reType = RT_SPRITE;
labelNotSelectable.customShader = cgs.media.noammoIcon;
labelNotSelectable.radius = 0.5f;
memset(labelNotSelectable.shaderRGBA, 0xff, 4);
item.labelNotSelectable = labelNotSelectable;
}
selectorWheelItems[selectorWheelItemNum++] = item;
}
}
} else if (cg.wheelSelectorType == WST_ITEM) {
beamColor[0] = 0.0f;
beamColor[1] = 1.0f;
beamColor[2] = 0.0f;
if (cgVR->hasbinoculars) {
selectorWheelEntity_t binocularsItem;
memset(&binocularsItem, 0, sizeof(binocularsItem));
binocularsItem.itemId = WSI_BINOCULARS;
refEntity_t binocularsIcon;
memset(&binocularsIcon, 0, sizeof(binocularsIcon));
binocularsIcon.reType = RT_SPRITE;
binocularsIcon.customShader = cgs.media.binocularsIcon;
binocularsIcon.radius = 0.6f;
memset(binocularsIcon.shaderRGBA, 0xff, 4);
binocularsItem.icon = binocularsIcon;
refEntity_t binocularsIconSelected;
memset(&binocularsIconSelected, 0, sizeof(binocularsIconSelected));
binocularsIconSelected.reType = RT_SPRITE;
binocularsIconSelected.customShader = cgs.media.binocularsIconSelect;
binocularsIconSelected.radius = 1.3f;
memset(binocularsIconSelected.shaderRGBA, 0xff, 4);
binocularsItem.iconSelected = binocularsIconSelected;
selectorWheelItems[selectorWheelItemNum++] = binocularsItem;
}
if (CG_WeaponAvailable(WP_GRENADE_LAUNCHER) && CG_WeaponHasAmmo(WP_GRENADE_LAUNCHER)) {
selectorWheelEntity_t grenadeItem;
memset(&grenadeItem, 0, sizeof(grenadeItem));
grenadeItem.itemId = WSI_GRENADE;
refEntity_t grenadeIcon;
memset(&grenadeIcon, 0, sizeof(grenadeIcon));
grenadeIcon.reType = RT_SPRITE;
grenadeIcon.customShader = cg_weapons[WP_GRENADE_LAUNCHER].weaponIcon[0];
grenadeIcon.radius = 0.8f;
memset(grenadeIcon.shaderRGBA, 0xff, 4);
grenadeItem.icon = grenadeIcon;
refEntity_t grenadeIconSelected;
memset(&grenadeIconSelected, 0, sizeof(grenadeIconSelected));
grenadeIconSelected.reType = RT_SPRITE;
grenadeIconSelected.customShader = cg_weapons[WP_GRENADE_LAUNCHER].weaponIcon[1];
grenadeIconSelected.radius = 1.3f;
memset(grenadeIconSelected.shaderRGBA, 0xff, 4);
grenadeItem.iconSelected = grenadeIconSelected;
selectorWheelItems[selectorWheelItemNum++] = grenadeItem;
}
if (CG_WeaponAvailable(WP_GRENADE_PINEAPPLE) && CG_WeaponHasAmmo(WP_GRENADE_PINEAPPLE)) {
selectorWheelEntity_t pineappleItem;
memset(&pineappleItem, 0, sizeof(pineappleItem));
pineappleItem.itemId = WSI_PINEAPPLE;
refEntity_t pineappleIcon;
memset(&pineappleIcon, 0, sizeof(pineappleIcon));
pineappleIcon.reType = RT_SPRITE;
pineappleIcon.customShader = cg_weapons[WP_GRENADE_PINEAPPLE].weaponIcon[0];
pineappleIcon.radius = 0.8f;
memset(pineappleIcon.shaderRGBA, 0xff, 4);
pineappleItem.icon = pineappleIcon;
refEntity_t pineappleIconSelected;
memset(&pineappleIconSelected, 0, sizeof(pineappleIconSelected));
pineappleIconSelected.reType = RT_SPRITE;
pineappleIconSelected.customShader = cg_weapons[WP_GRENADE_PINEAPPLE].weaponIcon[1];
pineappleIconSelected.radius = 1.3f;
memset(pineappleIconSelected.shaderRGBA, 0xff, 4);
pineappleItem.iconSelected = pineappleIconSelected;
selectorWheelItems[selectorWheelItemNum++] = pineappleItem;
}
if (CG_WeaponAvailable(WP_DYNAMITE) && CG_WeaponHasAmmo(WP_DYNAMITE)) {
selectorWheelEntity_t dynamiteItem;
memset(&dynamiteItem, 0, sizeof(dynamiteItem));
dynamiteItem.itemId = WSI_DYNAMITE;
refEntity_t dynamiteIcon;
memset(&dynamiteIcon, 0, sizeof(dynamiteIcon));
dynamiteIcon.reType = RT_SPRITE;
dynamiteIcon.customShader = cg_weapons[WP_DYNAMITE].weaponIcon[0];
dynamiteIcon.radius = 0.8f;
memset(dynamiteIcon.shaderRGBA, 0xff, 4);
dynamiteItem.icon = dynamiteIcon;
refEntity_t dynamiteIconSelected;
memset(&dynamiteIconSelected, 0, sizeof(dynamiteIconSelected));
dynamiteIconSelected.reType = RT_SPRITE;
dynamiteIconSelected.customShader = cg_weapons[WP_DYNAMITE].weaponIcon[1];
dynamiteIconSelected.radius = 1.3f;
memset(dynamiteIconSelected.shaderRGBA, 0xff, 4);
dynamiteItem.iconSelected = dynamiteIconSelected;
selectorWheelItems[selectorWheelItemNum++] = dynamiteItem;
}
gitem_t *wine = BG_FindItemForHoldable(HI_WINE);
if (wine) {
int quantity = cg.predictedPlayerState.holdable[HI_WINE];
if (quantity) {
selectorWheelEntity_t wineItem;
memset(&wineItem, 0, sizeof(wineItem));
wineItem.itemId = WSI_WINE;
refEntity_t wineIcon;
memset(&wineIcon, 0, sizeof(wineIcon));
wineIcon.reType = RT_SPRITE;
if (quantity >= 3) {
wineIcon.customShader = cgs.media.wine1Icon;
} else if (quantity == 2) {
wineIcon.customShader = cgs.media.wine2Icon;
} else {
wineIcon.customShader = cgs.media.wine3Icon;
}
wineIcon.radius = 0.8f;
memset(wineIcon.shaderRGBA, 0xff, 4);
wineItem.icon = wineIcon;
refEntity_t wineIconSelected;
memset(&wineIconSelected, 0, sizeof(wineIconSelected));
wineIconSelected.reType = RT_SPRITE;
if (quantity >= 3) {
wineIconSelected.customShader = cgs.media.wine1IconSelect;
} else if (quantity == 2) {
wineIconSelected.customShader = cgs.media.wine2IconSelect;
} else {
wineIconSelected.customShader = cgs.media.wine3IconSelect;
}
wineIconSelected.radius = 1.3f;
memset(wineIconSelected.shaderRGBA, 0xff, 4);
wineItem.iconSelected = wineIconSelected;
selectorWheelItems[selectorWheelItemNum++] = wineItem;
}
}
gitem_t *stamina = BG_FindItemForHoldable(HI_STAMINA);
if (stamina) {
int quantity = cg.predictedPlayerState.holdable[HI_STAMINA];
if (quantity) {
selectorWheelEntity_t staminaItem;
memset(&staminaItem, 0, sizeof(staminaItem));
staminaItem.itemId = WSI_STAMINA;
refEntity_t staminaIcon;
memset(&staminaIcon, 0, sizeof(staminaIcon));
staminaIcon.reType = RT_SPRITE;
staminaIcon.customShader = cgs.media.staminaIcon;
staminaIcon.radius = 0.8f;
memset(staminaIcon.shaderRGBA, 0xff, 4);
staminaItem.icon = staminaIcon;
refEntity_t staminaIconSelected;
memset(&staminaIconSelected, 0, sizeof(staminaIconSelected));
staminaIconSelected.reType = RT_SPRITE;
staminaIconSelected.customShader = cgs.media.staminaIconSelect;
staminaIconSelected.radius = 1.3f;
memset(staminaIconSelected.shaderRGBA, 0xff, 4);
staminaItem.iconSelected = staminaIconSelected;
selectorWheelItems[selectorWheelItemNum++] = staminaItem;
}
}
gitem_t *vbook = BG_FindItemForHoldable(HI_BOOK1);
if (vbook) {
int quantity = cg.predictedPlayerState.holdable[HI_BOOK1];
if (quantity) {
selectorWheelEntity_t vbookItem;
memset(&vbookItem, 0, sizeof(vbookItem));
vbookItem.itemId = WSI_VBOOK;
refEntity_t vbookIcon;
memset(&vbookIcon, 0, sizeof(vbookIcon));
vbookIcon.reType = RT_SPRITE;
vbookIcon.customShader = cgs.media.vbookIcon;
vbookIcon.radius = 0.8f;
memset(vbookIcon.shaderRGBA, 0xff, 4);
vbookItem.icon = vbookIcon;
refEntity_t vbookIconSelected;
memset(&vbookIconSelected, 0, sizeof(vbookIconSelected));
vbookIconSelected.reType = RT_SPRITE;
vbookIconSelected.customShader = cgs.media.vbookIconSelect;
vbookIconSelected.radius = 1.3f;
memset(vbookIconSelected.shaderRGBA, 0xff, 4);
vbookItem.iconSelected = vbookIconSelected;
selectorWheelItems[selectorWheelItemNum++] = vbookItem;
}
}
gitem_t *pbook = BG_FindItemForHoldable(HI_BOOK2);
if (pbook) {
int quantity = cg.predictedPlayerState.holdable[HI_BOOK2];
if (quantity) {
selectorWheelEntity_t pbookItem;
memset(&pbookItem, 0, sizeof(pbookItem));
pbookItem.itemId = WSI_PBOOK;
refEntity_t pbookIcon;
memset(&pbookIcon, 0, sizeof(pbookIcon));
pbookIcon.reType = RT_SPRITE;
pbookIcon.customShader = cgs.media.pbookIcon;
pbookIcon.radius = 0.8f;
memset(pbookIcon.shaderRGBA, 0xff, 4);
pbookItem.icon = pbookIcon;
refEntity_t pbookIconSelected;
memset(&pbookIconSelected, 0, sizeof(pbookIconSelected));
pbookIconSelected.reType = RT_SPRITE;
pbookIconSelected.customShader = cgs.media.pbookIconSelect;
pbookIconSelected.radius = 1.3f;
memset(pbookIconSelected.shaderRGBA, 0xff, 4);
pbookItem.iconSelected = pbookIconSelected;
selectorWheelItems[selectorWheelItemNum++] = pbookItem;
}
}
gitem_t *zbook = BG_FindItemForHoldable(HI_BOOK3);
if (zbook) {
int quantity = cg.predictedPlayerState.holdable[HI_BOOK3];
if (quantity) {
selectorWheelEntity_t zbookItem;
memset(&zbookItem, 0, sizeof(zbookItem));
zbookItem.itemId = WSI_ZBOOK;
refEntity_t zbookIcon;
memset(&zbookIcon, 0, sizeof(zbookIcon));
zbookIcon.reType = RT_SPRITE;
zbookIcon.customShader = cgs.media.zbookIcon;
zbookIcon.radius = 0.8f;
memset(zbookIcon.shaderRGBA, 0xff, 4);
zbookItem.icon = zbookIcon;
refEntity_t zbookIconSelected;
memset(&zbookIconSelected, 0, sizeof(zbookIconSelected));
zbookIconSelected.reType = RT_SPRITE;
zbookIconSelected.customShader = cgs.media.zbookIconSelect;
zbookIconSelected.radius = 1.3f;
memset(zbookIconSelected.shaderRGBA, 0xff, 4);
zbookItem.iconSelected = zbookIconSelected;
selectorWheelItems[selectorWheelItemNum++] = zbookItem;
}
}
} else if (cg.wheelSelectorType == WST_SYSTEM) {
beamColor[0] = 1.0f;
beamColor[1] = 1.0f;
beamColor[2] = 1.0f;
selectorWheelEntity_t exitItem;
memset(&exitItem, 0, sizeof(exitItem));
exitItem.itemId = WSI_EXIT_MENU;
refEntity_t exitIcon;
memset(&exitIcon, 0, sizeof(exitIcon));
exitIcon.reType = RT_SPRITE;
exitIcon.customShader = cgs.media.exitIcon;
exitIcon.radius = 0.6f;
memset(exitIcon.shaderRGBA, 0xff, 4);
exitItem.icon = exitIcon;
refEntity_t exitIconSelected;
memset(&exitIconSelected, 0, sizeof(exitIconSelected));
exitIconSelected.reType = RT_SPRITE;
exitIconSelected.customShader = cgs.media.exitIconSelect;
exitIconSelected.radius = 1.3f;
memset(exitIconSelected.shaderRGBA, 0xff, 4);
exitItem.iconSelected = exitIconSelected;
selectorWheelItems[selectorWheelItemNum++] = exitItem;
selectorWheelEntity_t loadItem;
memset(&loadItem, 0, sizeof(loadItem));
loadItem.itemId = WSI_QUICK_LOAD;
refEntity_t loadIcon;
memset(&loadIcon, 0, sizeof(loadIcon));
loadIcon.reType = RT_SPRITE;
loadIcon.customShader = cgs.media.loadIcon;
loadIcon.radius = 0.6f;
memset(loadIcon.shaderRGBA, 0xff, 4);
loadItem.icon = loadIcon;
refEntity_t loadIconSelected;
memset(&loadIconSelected, 0, sizeof(loadIconSelected));
loadIconSelected.reType = RT_SPRITE;
loadIconSelected.customShader = cgs.media.loadIconSelect;
loadIconSelected.radius = 1.3f;
memset(loadIconSelected.shaderRGBA, 0xff, 4);
loadItem.iconSelected = loadIconSelected;
selectorWheelItems[selectorWheelItemNum++] = loadItem;
selectorWheelEntity_t saveItem;
memset(&saveItem, 0, sizeof(saveItem));
saveItem.itemId = WSI_QUICK_SAVE;
refEntity_t saveIcon;
memset(&saveIcon, 0, sizeof(saveIcon));
saveIcon.reType = RT_SPRITE;
saveIcon.customShader = cgs.media.saveIcon;
saveIcon.radius = 0.6f;
memset(saveIcon.shaderRGBA, 0xff, 4);
saveItem.icon = saveIcon;
refEntity_t saveIconSelected;
memset(&saveIconSelected, 0, sizeof(saveIconSelected));
saveIconSelected.reType = RT_SPRITE;
saveIconSelected.customShader = cgs.media.saveIconSelect;
saveIconSelected.radius = 1.3f;
memset(saveIconSelected.shaderRGBA, 0xff, 4);
saveItem.iconSelected = saveIconSelected;
selectorWheelItems[selectorWheelItemNum++] = saveItem;
}
GC_HandleWheelSelector(beamColor, selectorWheelItems, selectorWheelItemNum);
}
void CG_WheelSelectorSelect_f( void )
{
trap_Cvar_Set("timescale", "1.0");
if (cg.wheelSelectorSelection != -1) {
if (cg.wheelSelectorType == WST_WEAPON) {
cgVR->binocularsActive = qfalse;
if (cg.wheelSelectorSelection != cg.weaponSelect) {
cg.weaponSelectTime = cg.time;
cg.weaponSelect = cg.wheelSelectorSelection;
}
}
else if (cg.wheelSelectorType == WST_ITEM) {
if (cg.wheelSelectorSelection == WSI_BINOCULARS) {
cgVR->binocularsActive = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_GRENADE) {
cgVR->binocularsActive = qfalse;
cg.weaponSelectTime = cg.time;
cg.weaponSelect = WP_GRENADE_LAUNCHER;
}
else if (cg.wheelSelectorSelection == WSI_PINEAPPLE) {
cgVR->binocularsActive = qfalse;
cg.weaponSelectTime = cg.time;
cg.weaponSelect = WP_GRENADE_PINEAPPLE;
}
else if (cg.wheelSelectorSelection == WSI_DYNAMITE) {
cgVR->binocularsActive = qfalse;
cg.weaponSelectTime = cg.time;
cg.weaponSelect = WP_DYNAMITE;
}
else if (cg.wheelSelectorSelection == WSI_WINE) {
cg.holdableSelectTime = cg.time;
cg.holdableSelect = HI_WINE;
cgVR->useHoldableItem = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_STAMINA) {
cg.holdableSelectTime = cg.time;
cg.holdableSelect = HI_STAMINA;
cgVR->useHoldableItem = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_VBOOK) {
cg.holdableSelectTime = cg.time;
cg.holdableSelect = HI_BOOK1;
cgVR->useHoldableItem = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_PBOOK) {
cg.holdableSelectTime = cg.time;
cg.holdableSelect = HI_BOOK2;
cgVR->useHoldableItem = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_ZBOOK) {
cg.holdableSelectTime = cg.time;
cg.holdableSelect = HI_BOOK3;
cgVR->useHoldableItem = qtrue;
}
}
else if (cg.wheelSelectorType == WST_SYSTEM) {
if (cg.wheelSelectorSelection == WSI_EXIT_MENU) {
// TODO Why this does not work?
// trap_SendConsoleCommand("togglemenu\n");
cgVR->toggleMainMenu = qtrue;
}
else if (cg.wheelSelectorSelection == WSI_QUICK_SAVE) {
trap_SendConsoleCommand("savegame quicksave\n");
}
else if (cg.wheelSelectorSelection == WSI_QUICK_LOAD) {
trap_SendConsoleCommand("loadgame quicksave\n");
}
}
}
//reset ready for next time
cg.wheelSelectorSelection = -1;
cg.wheelSelectorType = 0;
cg.wheelSelectorTime = 0;
}
void CG_WheelSelectorNext_f( void )
{
cg.wheelSelectorType++;
if (cg.wheelSelectorType >= NUM_WST) {
cg.wheelSelectorType = 0;
}
cg.wheelSelectorTime = cg.time;
cg.wheelSelectorSelection = -1;
}
void CG_WheelSelectorPrev_f( void )
{
cg.wheelSelectorType--;
if (cg.wheelSelectorType < 0) {
cg.wheelSelectorType = NUM_WST - 1;
}
cg.wheelSelectorTime = cg.time;
cg.wheelSelectorSelection = -1;
}
/*
==============

View file

@ -160,6 +160,14 @@ typedef struct {
} refEntity_t;
typedef struct {
int itemId;
refEntity_t icon;
refEntity_t iconSelected;
qboolean notSelectable;
refEntity_t labelNotSelectable;
} selectorWheelEntity_t;
//----(SA)
// //

View file

@ -615,6 +615,51 @@ typedef struct ammotable_s {
extern ammotable_t ammoTable[]; // defined in bg_misc.c
extern int weapAlts[]; // defined in bg_misc.c
static const int SELECTABLE_WEAPONS_NUM = 13;
static const int SELECTABLE_WEAPONS[] = {
// order matches prev/next selector
WP_KNIFE,
WP_LUGER,
WP_COLT,
WP_MP40,
WP_THOMPSON,
WP_STEN,
WP_MAUSER,
WP_GARAND,
WP_FG42,
WP_PANZERFAUST,
WP_VENOM,
WP_FLAMETHROWER,
WP_TESLA
};
typedef enum
{
WST_WEAPON,
WST_ITEM,
WST_SYSTEM,
NUM_WST
} wheelSelectorType_t;
typedef enum
{
WSI_BINOCULARS,
WSI_GRENADE,
WSI_PINEAPPLE,
WSI_DYNAMITE,
WSI_WINE,
WSI_STAMINA,
WSI_VBOOK,
WSI_PBOOK,
WSI_ZBOOK
} itemSelectorItems_t;
typedef enum
{
WSI_EXIT_MENU,
WSI_QUICK_SAVE,
WSI_QUICK_LOAD
} systemSelectorItems_t;
//----(SA)
// for routines that need to check if a WP_ is </=/> a given set of weapons

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB