From 42cf81a1786ad12c2f8700bc075d9943f6e6fdf7 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 20 Jul 2019 00:04:47 +0100 Subject: [PATCH] Some HUD stuff.. --- .../src/Xash3D/xash3d/engine/client/cl_main.c | 4 + .../jni/src/hlsdk-xash3d/cl_dll/ammo.cpp | 8 +- .../hlsdk-xash3d/cl_dll/ammo_secondary.cpp | 4 +- .../src/hlsdk-xash3d/cl_dll/flashlight.cpp | 8 +- .../jni/src/hlsdk-xash3d/cl_dll/train.cpp | 2 +- assets/config.cfg | 85 +++++++++++++++++++ .../drbeef/lambda1vr/GLES3JNIActivity.java | 34 ++++---- 7 files changed, 119 insertions(+), 26 deletions(-) create mode 100644 assets/config.cfg diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c index feb5aa5..362a5d0 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c @@ -2143,7 +2143,11 @@ void CL_InitLocal( void ) r_bmodelinterp = Cvar_Get( "r_bmodelinterp", "1", 0, "enable bmodel interpolation" ); cl_nat = Cvar_Get( "cl_nat", "0", 0, "Show servers running under nat" ); +#ifdef VR + hud_scale = Cvar_Get( "hud_scale", "1.3", CVAR_ARCHIVE|CVAR_LATCH, "scale hud at current resolution" ); +#else hud_scale = Cvar_Get( "hud_scale", "0", CVAR_ARCHIVE|CVAR_LATCH, "scale hud at current resolution" ); +#endif hud_utf8 = Cvar_Get( "hud_utf8", "0", CVAR_ARCHIVE, "Use utf-8 encoding for hud text" ); ui_renderworld = Cvar_Get( "ui_renderworld", "0", CVAR_ARCHIVE, "render world when UI is visible" ); diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo.cpp index 4104acf..c1cd925 100644 --- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo.cpp +++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo.cpp @@ -871,7 +871,7 @@ int CHudAmmo::Draw( float flTime ) ScaleColors( r, g, b, a ); // Does this weapon have a clip? - y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; + y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2 - (ScreenHeight * 0.3f); // Does weapon have any ammo at all? if( m_pWeapon->iAmmoType > 0 ) @@ -881,7 +881,7 @@ int CHudAmmo::Draw( float flTime ) if( pw->iClip >= 0 ) { // room for the number and the '|' and the current ammo - x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; + x = (ScreenWidth * 0.65f) - ( 8 * AmmoWidth ) - iIconWidth; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); /*wrect_t rc; @@ -908,7 +908,7 @@ int CHudAmmo::Draw( float flTime ) else { // SPR_Draw a bullets only line - x = ScreenWidth - 4 * AmmoWidth - iIconWidth; + x = (ScreenWidth * 0.65f) - 4 * AmmoWidth - iIconWidth; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); } @@ -927,7 +927,7 @@ int CHudAmmo::Draw( float flTime ) if( ( pw->iAmmo2Type != 0 ) && ( gWR.CountAmmo( pw->iAmmo2Type ) > 0 ) ) { y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight / 4; - x = ScreenWidth - 4 * AmmoWidth - iIconWidth; + x = (ScreenWidth * 0.65f) - 4 * AmmoWidth - iIconWidth; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmo2Type ), r, g, b ); // Draw the ammo Icon diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo_secondary.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo_secondary.cpp index 148d29b..f626113 100644 --- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo_secondary.cpp +++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/ammo_secondary.cpp @@ -68,8 +68,8 @@ int CHudAmmoSecondary::Draw( float flTime ) AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - y = ScreenHeight - ( gHUD.m_iFontHeight * 4 ); // this is one font height higher than the weapon ammo values - x = ScreenWidth - AmmoWidth; + y = (ScreenHeight * 0.3f) - ( gHUD.m_iFontHeight * 4 ); // this is one font height higher than the weapon ammo values + x = (ScreenWidth * 0.65f) - AmmoWidth; if( m_HUD_ammoicon ) { diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/flashlight.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/flashlight.cpp index ee3d6d2..0e30bd9 100644 --- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/flashlight.cpp +++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/flashlight.cpp @@ -126,8 +126,8 @@ int CHudFlashlight::Draw( float flTime ) ScaleColors( r, g, b, a ); - y = ( m_prc1->bottom - m_prc2->top ) / 2; - x = ScreenWidth - m_iWidth - m_iWidth / 2 ; + y = ( m_prc1->bottom - m_prc2->top ) / 2 + (ScreenHeight * 0.3f); + x = (ScreenWidth * 0.65f) - m_iWidth - m_iWidth / 2 ; // Draw the flashlight casing SPR_Set( m_hSprite1, r, g, b ); @@ -136,14 +136,14 @@ int CHudFlashlight::Draw( float flTime ) if( m_fOn ) { // draw the flashlight beam - x = ScreenWidth - m_iWidth / 2; + x = (ScreenWidth * 0.65f) - m_iWidth / 2; SPR_Set( m_hBeam, r, g, b ); SPR_DrawAdditive( 0, x, y, m_prcBeam ); } // draw the flashlight energy level - x = ScreenWidth - m_iWidth - m_iWidth / 2; + x = (ScreenWidth * 0.65f) - m_iWidth - m_iWidth / 2; int iOffset = m_iWidth * ( 1.0 - m_flBat ); if( iOffset < m_iWidth ) { diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/train.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/train.cpp index de480ec..1c2896a 100644 --- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/train.cpp +++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/train.cpp @@ -57,7 +57,7 @@ int CHudTrain::Draw( float fTime ) SPR_Set( m_hSprite, r, g, b ); // This should show up to the right and part way up the armor number - y = ScreenHeight - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight; + y = (ScreenHeight * 0.6f) - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight; x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4; SPR_DrawAdditive( m_iPos - 1, x, y, NULL ); diff --git a/assets/config.cfg b/assets/config.cfg new file mode 100644 index 0000000..c6c4e88 --- /dev/null +++ b/assets/config.cfg @@ -0,0 +1,85 @@ +unbindall +bind "TAB" "+showscores" +bind "ENTER" "+attack" +bind "ESCAPE" "escape" +bind "SPACE" "+jump" +bind "'" "+moveup" +bind "+" "sizeup" +bind "," "+moveleft" +bind "-" "sizedown" +bind "." "+moveright" +bind "/" "+movedown" +bind "1" "slot1" +bind "2" "slot2" +bind "3" "slot3" +bind "4" "slot4" +bind "5" "slot5" +bind ";" "+mlook" +bind "=" "sizeup" +bind "a" "+moveleft" +bind "c" "+movedown" +bind "d" "+moveright" +bind "e" "+use" +bind "f" "impulse 100" +bind "k" "+voicerecord" +bind "q" "lastinv" +bind "r" "+reload" +bind "s" "+back" +bind "t" "impulse 201" +bind "u" "messagemode2" +bind "v" "+moveup" +bind "w" "+forward" +bind "y" "messagemode" +bind "[" "invprev" +bind "]" "invnext" +bind "`" "toggleconsole" +bind "~" "toggleconsole" +bind "UPARROW" "+forward" +bind "DOWNARROW" "+back" +bind "LEFTARROW" "+left" +bind "RIGHTARROW" "+right" +bind "ALT" "+strafe" +bind "CTRL" "+duck" +bind "SHIFT" "+speed" +bind "F5" "snapshot" +bind "F6" "save quick" +bind "F7" "load quick" +bind "F10" "quit prompt" +bind "INS" "+klook" +bind "PGDN" "+lookdown" +bind "PGUP" "+lookup" +bind "END" "centerview" +bind "MWHEELDOWN" "invnext" +bind "MWHEELUP" "invprev" +bind "MOUSE1" "+attack" +bind "MOUSE2" "+attack2" +bind "PAUSE" "pause" +lookstrafe "0.000000" +m_pitch "0.022000" +lookspring "0.000000" +crosshair "0.000000" +_windowed_mouse "0.000000" +m_filter "0.000000" +joystick "0.000000" +sv_aim "1.000000" +console "1.000000" +cl_himodels "0.000000" +d_spriteskip "0.000000" +sensitivity "3.000000" +viewsize "120.000000" +brightness "0.800000" +gamma "2.000000" +bgmvolume "1.000000" +suitvolume "0.250000" +hisound "1.000000" +volume "0.800000" +s_a3d "0.000000" +s_eax "0.000000" +rate "2500.000000" +model "gordon" +topcolor "30" +bottomcolor "6" +name "VRPlayer" ++mlook ++jlook + diff --git a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java index 39a5009..d6ec8fa 100644 --- a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java +++ b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java @@ -61,23 +61,27 @@ import static android.system.Os.setenv; getWindow().setAttributes( params ); copy_asset(getFilesDir().getPath(), "extras.pak", false); + copy_asset("/sdcard/xash/valve/", "config.cfg", false); // Copy in case user has deleted their config //Copy modified weapon models - copy_asset("/sdcard/xash/valve/", "models/v_9mmar.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_9mmhandgun.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_357.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_crossbow.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_crowbar.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_egon.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_gauss.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_grenade.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_hgun.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_rpg.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_satchel.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_satchel_radio.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_shotgun.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_squeak.mdl", true); - copy_asset("/sdcard/xash/valve/", "models/v_tripmine.mdl", true); + if (!(new File("/sdcard/xash/valve/models/no_copy").exists())) + { + copy_asset("/sdcard/xash/valve/", "models/v_9mmar.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_9mmhandgun.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_357.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_crossbow.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_crowbar.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_egon.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_gauss.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_grenade.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_hgun.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_rpg.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_satchel.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_satchel_radio.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_shotgun.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_squeak.mdl", true); + copy_asset("/sdcard/xash/valve/", "models/v_tripmine.mdl", true); + } //Set default environment try {