From 7680cb1288a466a403e7b8a9be0ce39551f50e8b Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Wed, 12 Apr 2023 22:26:44 +0200 Subject: [PATCH] Fix use action when controlling droid; fix droid view help --- Projects/Android/jni/JKXR/VrInputDefault.cpp | 2 +- Projects/Android/jni/OpenJK/code/game/g_active.cpp | 8 ++++++-- Projects/Android/jni/OpenJK/code/game/g_trigger.cpp | 6 +++--- Projects/Android/jni/OpenJK/code/game/g_utils.cpp | 4 ++-- Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp | 8 ++++++-- Projects/Android/jni/OpenJK/codeJK2/game/g_trigger.cpp | 6 +++--- Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp | 4 ++-- z_vr_assets_jka/strings/english/vr_ingame.str | 3 +++ z_vr_assets_jka/strings/french/vr_ingame.str | 4 ++++ z_vr_assets_jka/strings/german/vr_ingame.str | 4 ++++ z_vr_assets_jka/strings/spanish/vr_ingame.str | 4 ++++ z_vr_assets_jko/strip/vr_ingame.sp | 7 ++++++- 12 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Projects/Android/jni/JKXR/VrInputDefault.cpp b/Projects/Android/jni/JKXR/VrInputDefault.cpp index 24ce518..807daa9 100644 --- a/Projects/Android/jni/JKXR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKXR/VrInputDefault.cpp @@ -346,7 +346,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, pOffTrackedRemoteOld->Buttons |= xrButton_Trigger; } } - else if (vr.misc_camera) + else if (vr.misc_camera && !vr.remote_droid) { if (between(-0.2f, primaryJoystickX, 0.2f)) { sendButtonAction("+use", pPrimaryJoystick->y < -0.8f || pPrimaryJoystick->y > 0.8f); diff --git a/Projects/Android/jni/OpenJK/code/game/g_active.cpp b/Projects/Android/jni/OpenJK/code/game/g_active.cpp index c360ae4..8b32ae1 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_active.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_active.cpp @@ -280,7 +280,11 @@ void G_SetViewEntity( gentity_t *self, gentity_t *viewEntity ) } if ( !self->s.number ) { - CG_CenterPrint( "@VR_INGAME_EXIT_CAMERA_VIEW", SCREEN_HEIGHT * 0.95 ); + if (viewEntity->client && viewEntity->client->NPC_class == CLASS_MOUSE) { + CG_CenterPrint( "@VR_INGAME_EXIT_DROID_VIEW", SCREEN_HEIGHT * 0.95 ); + } else { + CG_CenterPrint( "@VR_INGAME_EXIT_CAMERA_VIEW", SCREEN_HEIGHT * 0.95 ); + } } } @@ -1462,7 +1466,7 @@ void G_TouchTriggersLerped( gentity_t *ent ) { bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !(vr && vr->remote_droid); for ( curDist = 0; !done && ent->maxs[1]>0; curDist += (float)ent->maxs[1]/2.0f ) { diff --git a/Projects/Android/jni/OpenJK/code/game/g_trigger.cpp b/Projects/Android/jni/OpenJK/code/game/g_trigger.cpp index 4414004..9445bef 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_trigger.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_trigger.cpp @@ -256,7 +256,7 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !vr->remote_droid; if ( (self->spawnflags & 2) && ( !( self->spawnflags & 4 ) || ( ( self->spawnflags & 4) && !useGestureAllowed ) ) ) { // FACING and... ...is not USE_BUTTON or... ...is USE_BUTTON but use gestures are not active // In case of buttons activated by use gesture, we do not need to check if we are facing them as we are touching them by hand. @@ -264,9 +264,9 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) if ( other->client ) { - if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) && !thirdPersonActive ) + if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) && !thirdPersonActive && !vr->remote_droid ) { - // In case of USE_BUTTON, check facing by controller and not by head (if not in 3rd person) + // In case of USE_BUTTON, check facing by controller and not by head (if not in 3rd person or controlling droid) vec3_t origin, angles; BG_CalculateVRWeaponPosition(origin, angles); AngleVectors( angles, forward, NULL, NULL ); diff --git a/Projects/Android/jni/OpenJK/code/game/g_utils.cpp b/Projects/Android/jni/OpenJK/code/game/g_utils.cpp index e9f5fad..0b536df 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_utils.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_utils.cpp @@ -1784,7 +1784,7 @@ void TryUse_Internal( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) //extend to find end of use trace bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !vr->remote_droid; float useOffset = useGestureAllowed ? USE_OFFSET : 0.0f; float useDistance = useGestureAllowed ? USE_DISTANCE_GESTURE : USE_DISTANCE_BUTTON; VectorMA( src, useOffset, vf, src ); @@ -1881,7 +1881,7 @@ void TryUse( gentity_t *ent ) { bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; vec3_t src, angles, vf; - if (ent->client->ps.clientNum == 0) { + if (ent->client->ps.clientNum == 0 && !(vr && vr->remote_droid)) { if (thirdPersonActive) { VectorCopy(ent->currentOrigin, src); AngleVectors(ent->currentAngles, vf, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp index c7e646d..27ed013 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp @@ -237,7 +237,11 @@ void G_SetViewEntity( gentity_t *self, gentity_t *viewEntity ) } if ( !self->s.number ) { - CG_CenterPrint( "@VR_INGAME_EXIT_CAMERA_VIEW", SCREEN_HEIGHT * 0.95 ); + if (viewEntity->client && viewEntity->client->NPC_class == CLASS_MOUSE) { + CG_CenterPrint( "@VR_INGAME_EXIT_DROID_VIEW", SCREEN_HEIGHT * 0.95 ); + } else { + CG_CenterPrint( "@VR_INGAME_EXIT_CAMERA_VIEW", SCREEN_HEIGHT * 0.95 ); + } } } @@ -924,7 +928,7 @@ void G_TouchTriggersLerped( gentity_t *ent ) { bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !(vr && vr->remote_droid); for ( curDist = 0; !done && ent->maxs[1]>0; curDist += (float)ent->maxs[1]/2.0f ) { diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_trigger.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_trigger.cpp index 81c62b9..bb412ff 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_trigger.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_trigger.cpp @@ -226,7 +226,7 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !vr->remote_droid; if ( (self->spawnflags & 2) && ( !( self->spawnflags & 4 ) || ( ( self->spawnflags & 4) && !useGestureAllowed ) ) ) { // FACING and... ...is not USE_BUTTON or... ...is USE_BUTTON but use gestures are not active // In case of buttons activated by use gesture, we do not need to check if we are facing them as we are touching them by hand. @@ -234,9 +234,9 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) if ( other->client ) { - if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) && !thirdPersonActive ) + if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) && !thirdPersonActive && !vr->remote_droid ) { - // In case of USE_BUTTON, check facing by controller and not by head (if not in 3rd person) + // In case of USE_BUTTON, check facing by controller and not by head (if not in 3rd person or controlling droid) vec3_t origin, angles; BG_CalculateVRWeaponPosition(origin, angles); AngleVectors( angles, forward, NULL, NULL ); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp index cbe34dd..f43d22d 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp @@ -1549,7 +1549,7 @@ void TryUse_Internal( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) { //extend to find end of use trace bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h - bool useGestureAllowed = useGestureEnabled && !thirdPersonActive; + bool useGestureAllowed = useGestureEnabled && !thirdPersonActive && !vr->remote_droid; float useOffset = useGestureAllowed ? USE_OFFSET : 0.0f; float useDistance = useGestureAllowed ? USE_DISTANCE_GESTURE : USE_DISTANCE_BUTTON; VectorMA( src, useOffset, vf, src ); @@ -1627,7 +1627,7 @@ void TryUse( gentity_t *ent ) { bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; vec3_t src, angles, vf; - if (ent->client->ps.clientNum == 0) { + if (ent->client->ps.clientNum == 0 && !(vr && vr->remote_droid)) { if (thirdPersonActive) { VectorCopy(ent->currentOrigin, src); AngleVectors(ent->currentAngles, vf, NULL, NULL); diff --git a/z_vr_assets_jka/strings/english/vr_ingame.str b/z_vr_assets_jka/strings/english/vr_ingame.str index eaf76e9..2f4ecee 100644 --- a/z_vr_assets_jka/strings/english/vr_ingame.str +++ b/z_vr_assets_jka/strings/english/vr_ingame.str @@ -16,4 +16,7 @@ FILENOTES "" REFERENCE EXIT_CAMERA_VIEW LANG_ENGLISH "Press 'JUMP' to exit, thumbstick 'UP/DOWN' to switch view." +REFERENCE EXIT_DROID_VIEW +LANG_ENGLISH "Press 'JUMP' to exit, press 'USE' to activate buttons." + ENDMARKER diff --git a/z_vr_assets_jka/strings/french/vr_ingame.str b/z_vr_assets_jka/strings/french/vr_ingame.str index 74a3caa..e8c1c04 100644 --- a/z_vr_assets_jka/strings/french/vr_ingame.str +++ b/z_vr_assets_jka/strings/french/vr_ingame.str @@ -17,4 +17,8 @@ REFERENCE EXIT_CAMERA_VIEW LANG_ENGLISH "Press 'JUMP' to exit, thumbstick 'UP/DOWN' to switch view." LANG_FRENCH "#same" +REFERENCE EXIT_DROID_VIEW +LANG_ENGLISH "Press 'JUMP' to exit, press 'USE' to activate buttons." +LANG_FRENCH "#same" + ENDMARKER diff --git a/z_vr_assets_jka/strings/german/vr_ingame.str b/z_vr_assets_jka/strings/german/vr_ingame.str index 17c0a63..70902d8 100644 --- a/z_vr_assets_jka/strings/german/vr_ingame.str +++ b/z_vr_assets_jka/strings/german/vr_ingame.str @@ -17,4 +17,8 @@ REFERENCE EXIT_CAMERA_VIEW LANG_ENGLISH "Press 'JUMP' to exit, thumbstick 'UP/DOWN' to switch view." LANG_GERMAN "#same" +REFERENCE EXIT_DROID_VIEW +LANG_ENGLISH "Press 'JUMP' to exit, press 'USE' to activate buttons." +LANG_GERMAN "#same" + ENDMARKER diff --git a/z_vr_assets_jka/strings/spanish/vr_ingame.str b/z_vr_assets_jka/strings/spanish/vr_ingame.str index 6852d38..5d02fe7 100644 --- a/z_vr_assets_jka/strings/spanish/vr_ingame.str +++ b/z_vr_assets_jka/strings/spanish/vr_ingame.str @@ -17,4 +17,8 @@ REFERENCE EXIT_CAMERA_VIEW LANG_ENGLISH "Press 'JUMP' to exit, thumbstick 'UP/DOWN' to switch view." LANG_SPANISH "#same" +REFERENCE EXIT_DROID_VIEW +LANG_ENGLISH "Press 'JUMP' to exit, press 'USE' to activate buttons." +LANG_SPANISH "#same" + ENDMARKER diff --git a/z_vr_assets_jko/strip/vr_ingame.sp b/z_vr_assets_jko/strip/vr_ingame.sp index 33eceff..a5a7516 100644 --- a/z_vr_assets_jko/strip/vr_ingame.sp +++ b/z_vr_assets_jko/strip/vr_ingame.sp @@ -3,9 +3,14 @@ CONFIG W:\bin\striped.cfg ID 999 REFERENCE VR_INGAME DESCRIPTION "customized in game text for VR port" -COUNT 1 +COUNT 2 INDEX 0 { REFERENCE EXIT_CAMERA_VIEW TEXT_LANGUAGE1 "Press 'JUMP' to exit, thumbstick 'UP/DOWN' to switch view." } +INDEX 1 +{ + REFERENCE EXIT_DROID_VIEW + TEXT_LANGUAGE1 "Press 'JUMP' to exit, press 'USE' to activate buttons." +}