diff --git a/game/neo/scripts/HudLayout.res b/game/neo/scripts/HudLayout.res index 574ffbf229..df4c4546ec 100644 --- a/game/neo/scripts/HudLayout.res +++ b/game/neo/scripts/HudLayout.res @@ -908,6 +908,20 @@ "sprint_text_color" "255 255 255 100" "sprint_color" "255 255 255 150" } + neo_walking_indicator + { + "fieldName" "neo_walking_indicator" + "visible" "1" + + "xpos" "c40" + "ypos" "c30" + + "animationSpeed" "4" + + "color" "218 217 213 255" + "color2" "255 150 150 255" + "font" "NHudPanelText" + } RoundResult { "fieldName" "RoundResult" diff --git a/src/game/client/CMakeLists.txt b/src/game/client/CMakeLists.txt index 7b73417fdb..521adc5204 100644 --- a/src/game/client/CMakeLists.txt +++ b/src/game/client/CMakeLists.txt @@ -1697,6 +1697,7 @@ set(UNITY_SOURCE_NEO_UI neo/ui/neo_hud_round_state.cpp neo/ui/neo_hud_spectator_overlay.cpp neo/ui/neo_hud_startup_sequence.cpp + neo/ui/neo_hud_walking_indicator.cpp neo/ui/neo_hud_worldpos_marker.cpp neo/ui/neo_hud_worldpos_marker_generic.cpp neo/ui/neo_scoreboard.cpp @@ -1742,6 +1743,7 @@ target_sources_grouped( neo/ui/neo_hud_round_state.h neo/ui/neo_hud_spectator_overlay.h neo/ui/neo_hud_startup_sequence.h + neo/ui/neo_hud_walking_indicator.h neo/ui/neo_hud_worldpos_marker.h neo/ui/neo_hud_worldpos_marker_generic.h neo/ui/neo_scoreboard.h diff --git a/src/game/client/neo/ui/neo_hud_compass.cpp b/src/game/client/neo/ui/neo_hud_compass.cpp index c3226d9c6c..094397fb4c 100644 --- a/src/game/client/neo/ui/neo_hud_compass.cpp +++ b/src/game/client/neo/ui/neo_hud_compass.cpp @@ -1,20 +1,13 @@ -#include "cbase.h" -#include "neo_hud_compass.h" +#include "neo_hud_compass.h" #include "c_neo_player.h" #include "neo_gamerules.h" #include "view.h" #include "iclientmode.h" -#include #include -#include -#include #include -#include -#include "ienginevgui.h" - #include "c_team.h" // memdbgon must be the last include file in a .cpp file!!! @@ -22,15 +15,6 @@ using vgui::surface; -ConVar cl_neo_hud_rangefinder_enabled("cl_neo_hud_rangefinder_enabled", "1", FCVAR_ARCHIVE, - "Whether the rangefinder HUD is enabled or not.", true, 0.0f, true, 1.0f); -ConVar cl_neo_hud_rangefinder_pos_frac_x("cl_neo_hud_rangefinder_pos_frac_x", "0.55", FCVAR_ARCHIVE, - "In fractional to the total screen width, the x-axis position of the rangefinder.", - true, 0.0f, true, 1.0f); -ConVar cl_neo_hud_rangefinder_pos_frac_y("cl_neo_hud_rangefinder_pos_frac_y", "0.55", FCVAR_ARCHIVE, - "In fractional to the total screen height, the y-axis position of the rangefinder.", - true, 0.0f, true, 1.0f); - ConVar cl_neo_ghost_callout_compass_time("cl_neo_ghost_callout_compass_time", "10.0", FCVAR_CHEAT, "Time in seconds that ghost callouts remain on the compass.", true, 0.0f, false, 0.0f); @@ -152,9 +136,6 @@ static float safeAngle(float angle) { void CNEOHud_Compass::UpdateStateForNeoHudElementDraw() { - auto pFPPlayer = GetFirstPersonPlayer(); - Assert(pFPPlayer); - // Point the objective arrow to the relevant objective, if it exists if (NEORules()->GhostExists() || NEORules()->GetJuggernautMarkerPos() != vec3_origin) { @@ -164,28 +145,6 @@ void CNEOHud_Compass::UpdateStateForNeoHudElementDraw() float objAngle = safeAngle(- objYaw + MainViewAngles()[YAW]); m_objAngle = Clamp(objAngle, -(float)m_fov / 2, (float)m_fov / 2); } - - if (cl_neo_hud_rangefinder_enabled.GetBool()) - { - if (pFPPlayer->IsInAim()) - { - // Update Rangefinder - trace_t tr; - Vector vecForward; - AngleVectors(MainViewAngles(), &vecForward); - UTIL_TraceLine(MainViewOrigin(), MainViewOrigin() + (vecForward * MAX_TRACE_LENGTH), - MASK_SHOT, pFPPlayer, COLLISION_GROUP_NONE, &tr); - const float flDist = METERS_PER_INCH * tr.startpos.DistTo(tr.endpos); - if (flDist >= 999.0f || tr.surface.flags & (SURF_SKY | SURF_SKY2D)) - { - V_swprintf_safe(m_wszRangeFinder, L"RANGE ---m"); - } - else - { - V_swprintf_safe(m_wszRangeFinder, L"RANGE %3.0fm", flDist); - } - } - } } void CNEOHud_Compass::DrawNeoHudElement(void) @@ -199,15 +158,6 @@ void CNEOHud_Compass::DrawNeoHudElement(void) { DrawCompass(); } - - if (cl_neo_hud_rangefinder_enabled.GetBool() && GetFirstPersonPlayer()->IsInAim()) - { - surface()->DrawSetTextColor(COLOR_NEO_WHITE); - surface()->DrawSetTextFont(m_hFont); - surface()->DrawSetTextPos((m_resX * cl_neo_hud_rangefinder_pos_frac_x.GetFloat()), - (m_resY * cl_neo_hud_rangefinder_pos_frac_y.GetFloat())); - surface()->DrawPrintText(m_wszRangeFinder, ARRAYSIZE(m_wszRangeFinder) - 1); - } } void CNEOHud_Compass::ApplySchemeSettings(vgui::IScheme *pScheme) diff --git a/src/game/client/neo/ui/neo_hud_walking_indicator.cpp b/src/game/client/neo/ui/neo_hud_walking_indicator.cpp new file mode 100644 index 0000000000..16a832994b --- /dev/null +++ b/src/game/client/neo/ui/neo_hud_walking_indicator.cpp @@ -0,0 +1,202 @@ +#include "neo_hud_walking_indicator.h" + +#include "iclientmode.h" +#include + +#include "c_neo_player.h" +#include "view.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +DECLARE_NAMED_HUDELEMENT(CNEOHud_WalkingIndicator, neo_walking_indicator); + +NEO_HUD_ELEMENT_DECLARE_FREQ_CVAR(WalkingIndicator, 0.1) + +CNEOHud_WalkingIndicator::CNEOHud_WalkingIndicator(const char *pElementName, vgui::Panel *parent) + : CHudElement(pElementName), Panel(parent, pElementName) +{ + SetAutoDelete(true); + m_iHideHudElementNumber = NEO_HUD_ELEMENT_WALKING_INDICATOR; + + if (parent) + { + SetParent(parent); + } + else + { + SetParent(g_pClientMode->GetViewport()); + } + + SetVisible(true); +} + +const wchar_t notWalkingText[] = L"NOT "; +const wchar_t walkingText[] = L"WALKING"; +int notWalkingTextWidth = 0; +int textHeight = 0; +void CNEOHud_WalkingIndicator::ApplySchemeSettings(vgui::IScheme* pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + + int w,h; + vgui::surface()->GetTextSize(m_hFont, notWalkingText, notWalkingTextWidth, h); + int walkingTextWidth; + vgui::surface()->GetTextSize(m_hFont, walkingText, walkingTextWidth, h); + textHeight = vgui::surface()->GetFontTall(m_hFont); + + vgui::ipanel()->GetSize( GetVParent(), w, h ); + + SetBounds(m_iXpos, m_iYpos, w - m_iXpos, textHeight * 2); + SetFgColor(COLOR_TRANSPARENT); + SetBgColor(COLOR_TRANSPARENT); +} + +ConVar cl_neo_hud_rangefinder_enabled("cl_neo_hud_rangefinder_enabled", "1", FCVAR_ARCHIVE, + "Show the rangefinder", true, 0.0f, true, 1.0f); +wchar_t m_wszRangeFinder[11]; +void CNEOHud_WalkingIndicator::UpdateStateForNeoHudElementDraw() +{ + C_NEO_Player* pLocalPlayer = C_NEO_Player::GetLocalNEOPlayer(); + if (!pLocalPlayer) + return; + + C_NEO_Player* pTargetPlayer = pLocalPlayer->IsObserver() && (pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE || pLocalPlayer->GetObserverMode() == OBS_MODE_CHASE) + ? static_cast(pLocalPlayer->GetObserverTarget()) + : pLocalPlayer; + if (!pTargetPlayer || !pTargetPlayer->IsAlive()) + return; + + if (cl_neo_hud_rangefinder_enabled.GetBool()) + { + if (pTargetPlayer->IsInAim()) + { + // Update Rangefinder + trace_t tr; + Vector vecForward; + AngleVectors(MainViewAngles(), &vecForward); + UTIL_TraceLine(MainViewOrigin(), MainViewOrigin() + (vecForward * MAX_TRACE_LENGTH), + MASK_SHOT, pTargetPlayer, COLLISION_GROUP_NONE, &tr); + const float flDist = METERS_PER_INCH * tr.startpos.DistTo(tr.endpos); + if (flDist >= 999.0f || tr.surface.flags & (SURF_SKY | SURF_SKY2D)) + { + V_swprintf_safe(m_wszRangeFinder, L"RANGE ---m"); + } + else + { + V_swprintf_safe(m_wszRangeFinder, L"RANGE %3.0fm", flDist); + } + } + } +} + +void CNEOHud_WalkingIndicator::DrawRangeFinder(C_NEO_Player * pPlayer, int &offset) +{ + if (!cl_neo_hud_rangefinder_enabled.GetBool()) + return; + + if (pPlayer->IsInAim()) + { + vgui::surface()->DrawSetTextColor(m_color); + vgui::surface()->DrawSetTextFont(m_hFont); + vgui::surface()->DrawSetTextPos(notWalkingTextWidth, offset); + vgui::surface()->DrawPrintText(m_wszRangeFinder, ARRAYSIZE(m_wszRangeFinder) - 1); + } + offset += textHeight; +} + +ConVar cl_neo_hud_walkindicator_enabled("cl_neo_hud_walkindicator_enabled", "1", FCVAR_ARCHIVE, + "Show the walking indicator", true, 0.0f, true, 1.0f); +void CNEOHud_WalkingIndicator::DrawWalkingIndicator(C_NEO_Player * pPlayer, int &offset) +{ + if (!cl_neo_hud_walkindicator_enabled.GetBool()) + return; + + static float animWalkKeyPressed = 0.f; + const bool isWalking = pPlayer->IsWalking(); + static float animIsMakingFootsteps = 0.f; + const bool isMakingFootsteps = pPlayer->IsMakingFootstepSounds() || !(pPlayer->GetFlags() & FL_ONGROUND); + if (isWalking) + { + if (animWalkKeyPressed == 0.f) + { + if (isMakingFootsteps) + { + animIsMakingFootsteps = 1.f; + } + else + { + animIsMakingFootsteps = 0.f; + } + } + animWalkKeyPressed += gpGlobals->frametime * m_flAnimationSpeed; + } + else + { + animWalkKeyPressed -= gpGlobals->frametime * m_flAnimationSpeed; + } + animWalkKeyPressed = Clamp(animWalkKeyPressed, 0.f, 1.f); + + if (animWalkKeyPressed == 0.f) + { + offset += textHeight; + return; + } + + if (isMakingFootsteps) + { + animIsMakingFootsteps += gpGlobals->frametime * m_flAnimationSpeed; + } + else + { + animIsMakingFootsteps -= gpGlobals->frametime * m_flAnimationSpeed; + } + animIsMakingFootsteps = Clamp(animIsMakingFootsteps, 0.f, 1.f); + + const float animWalkKeyPressedSmooth = animWalkKeyPressed * animWalkKeyPressed * (3.0f - 2.0f * animWalkKeyPressed); + const float animIsMakingFootstepsSmoothStep = animIsMakingFootsteps * animIsMakingFootsteps * (3.0f - 2.0f * animIsMakingFootsteps); + const float inverseAnimIsMakingFootstepsSmooth = 1.f - animIsMakingFootstepsSmoothStep; + + const Color finalColor = Color((m_color2.r() * animIsMakingFootstepsSmoothStep) + (m_color.r() * inverseAnimIsMakingFootstepsSmooth), + (m_color2.g() * animIsMakingFootstepsSmoothStep) + (m_color.g() * inverseAnimIsMakingFootstepsSmooth), + (m_color2.b() * animIsMakingFootstepsSmoothStep) + (m_color.b() * inverseAnimIsMakingFootstepsSmooth), + ((m_color2.a() * animIsMakingFootstepsSmoothStep) + (m_color.a() * inverseAnimIsMakingFootstepsSmooth)) * animWalkKeyPressedSmooth); + vgui::surface()->DrawSetTextFont(m_hFont); + if (animIsMakingFootsteps > 0.f) + { + vgui::surface()->DrawSetTextColor(finalColor.r(), finalColor.g(), finalColor.b(), finalColor.a() * animIsMakingFootstepsSmoothStep); + vgui::surface()->DrawSetTextPos(0, offset); + vgui::surface()->DrawPrintText(notWalkingText, ARRAYSIZE(notWalkingText) - 1); + } + vgui::surface()->DrawSetTextColor(finalColor); + vgui::surface()->DrawSetTextPos(notWalkingTextWidth, offset); + vgui::surface()->DrawPrintText(walkingText, ARRAYSIZE(walkingText) - 1); + + offset += textHeight; +} + +void CNEOHud_WalkingIndicator::DrawNeoHudElement() +{ + if (!m_bVisible || !ShouldDraw()) + return; + + C_NEO_Player* pLocalPlayer = C_NEO_Player::GetLocalNEOPlayer(); + if (!pLocalPlayer) + return; + + C_NEO_Player* pTargetPlayer = pLocalPlayer->IsObserver() && (pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE || pLocalPlayer->GetObserverMode() == OBS_MODE_CHASE) + ? assert_cast(pLocalPlayer->GetObserverTarget()) + : pLocalPlayer; + if (!pTargetPlayer || !pTargetPlayer->IsAlive()) + return; + + int offset = 0; + DrawRangeFinder(pTargetPlayer, offset); + DrawWalkingIndicator(pTargetPlayer, offset); +} + +void CNEOHud_WalkingIndicator::Paint() +{ + BaseClass::Paint(); + PaintNeoElement(); +} \ No newline at end of file diff --git a/src/game/client/neo/ui/neo_hud_walking_indicator.h b/src/game/client/neo/ui/neo_hud_walking_indicator.h new file mode 100644 index 0000000000..b70fd2ec4d --- /dev/null +++ b/src/game/client/neo/ui/neo_hud_walking_indicator.h @@ -0,0 +1,39 @@ +#pragma once + +#include "neo_hud_childelement.h" +#include "hudelement.h" +#include + +class CNEOHud_WalkingIndicator : public CNEOHud_ChildElement, public CHudElement, public vgui::Panel +{ + DECLARE_CLASS_SIMPLE(CNEOHud_WalkingIndicator, Panel); + +public: + CNEOHud_WalkingIndicator(const char *pElementName, vgui::Panel *parent = NULL); + void ApplySchemeSettings(vgui::IScheme* pScheme) override; + + virtual void Paint() override; + +protected: + virtual void UpdateStateForNeoHudElementDraw() override; + virtual void DrawNeoHudElement() override; + virtual ConVar* GetUpdateFrequencyConVar() const override; + +private: + void DrawRangeFinder(C_NEO_Player* pPlayer, int &offset); + void DrawWalkingIndicator(C_NEO_Player* pPlayer, int &offset); + + CPanelAnimationVarAliasType(bool, m_bVisible, "visible", "1", "bool"); + + CPanelAnimationVarAliasType(int, m_iXpos, "xpos", "r203", "proportional_xpos"); + CPanelAnimationVarAliasType(int, m_iYpos, "ypos", "446", "proportional_ypos"); + + CPanelAnimationVar(float, m_flAnimationSpeed, "animationSpeed", "2"); + + CPanelAnimationVarAliasType(Color, m_color, "color", COLOR_NEO_WHITE_STR, "Color"); + CPanelAnimationVarAliasType(Color, m_color2, "color2", "255 150 150 255", "Color"); + CPanelAnimationVar(vgui::HFont, m_hFont, "font", "NHudPanelText"); + +private: + CNEOHud_WalkingIndicator(const CNEOHud_WalkingIndicator&other); +}; \ No newline at end of file diff --git a/src/game/client/neo/ui/neo_root_settings.cpp b/src/game/client/neo/ui/neo_root_settings.cpp index 4a03f030dc..b85cb7903e 100644 --- a/src/game/client/neo/ui/neo_root_settings.cpp +++ b/src/game/client/neo/ui/neo_root_settings.cpp @@ -690,6 +690,7 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey pHUD->bShowPos = cvr->cl_showpos.GetBool(); pHUD->iShowFps = cvr->cl_showfps.GetInt(); pHUD->bEnableRangeFinder = cvr->cl_neo_hud_rangefinder_enabled.GetBool(); + pHUD->bEnableWalkIndicator = cvr->cl_neo_hud_walkindicator_enabled.GetBool(); pHUD->iExtendedKillfeed = cvr->cl_neo_hud_extended_killfeed.GetInt(); pHUD->iScoreboardPadding = cvr->cl_neo_hud_scoreboard_padding.GetInt(); pHUD->bShowHudContextHints = cvr->cl_neo_hud_context_hint_enabled.GetBool(); @@ -958,6 +959,7 @@ void NeoSettingsSave(const NeoSettings *ns) cvr->cl_showpos.SetValue(pHUD->bShowPos); cvr->cl_showfps.SetValue(pHUD->iShowFps); cvr->cl_neo_hud_rangefinder_enabled.SetValue(pHUD->bEnableRangeFinder); + cvr->cl_neo_hud_walkindicator_enabled.SetValue(pHUD->bEnableWalkIndicator); cvr->cl_neo_hud_extended_killfeed.SetValue(pHUD->iExtendedKillfeed); cvr->cl_neo_hud_scoreboard_padding.SetValue(pHUD->iScoreboardPadding); cvr->cl_neo_hud_context_hint_enabled.SetValue(pHUD->bShowHudContextHints); @@ -1683,6 +1685,7 @@ void NeoSettings_HUD(NeoSettings *ns) NeoUI::RingBoxBool(L"Show position", &pHud->bShowPos); NeoUI::RingBox(L"Show FPS", SHOWFPS_LABELS, ARRAYSIZE(SHOWFPS_LABELS), &pHud->iShowFps); NeoUI::RingBoxBool(L"Show rangefinder", &pHud->bEnableRangeFinder); + NeoUI::RingBoxBool(L"Show walk indicator", &pHud->bEnableWalkIndicator); NeoUI::RingBox(L"Extended killfeed", EXT_KILLFEED_LABELS, ARRAYSIZE(EXT_KILLFEED_LABELS), &pHud->iExtendedKillfeed); NeoUI::RingBox(L"Scoreboard padding", NEOSCOREBOARDPADDING_LABELS, NEOSCOREBOARDPADDING__TOTAL, &pHud->iScoreboardPadding); diff --git a/src/game/client/neo/ui/neo_root_settings.h b/src/game/client/neo/ui/neo_root_settings.h index 4e4d2d3304..4b17c3dbba 100644 --- a/src/game/client/neo/ui/neo_root_settings.h +++ b/src/game/client/neo/ui/neo_root_settings.h @@ -204,6 +204,7 @@ struct NeoSettings bool bShowPos; int iShowFps; bool bEnableRangeFinder; + bool bEnableWalkIndicator; int iExtendedKillfeed; bool bShowHudContextHints; bool bShowHudContextHintPlayerTakeover; @@ -274,6 +275,7 @@ struct NeoSettings CONVARREF_DEF(cl_neo_streamermode); CONVARREF_DEF(cl_neo_streamermode_autodetect_obs); CONVARREF_DEF(cl_neo_hud_rangefinder_enabled); + CONVARREF_DEF(cl_neo_hud_walkindicator_enabled); CONVARREF_DEF(sv_unlockedchapters); CONVARREF_DEF(cl_neo_hud_context_hint_enabled); CONVARREF_DEF(cl_neo_hud_context_hint_show_player_takeover_hint); diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index 4a5278e505..a74986f19b 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -4398,4 +4398,4 @@ static void BotChangeClassFn(const CCommand& args) if (player && player->IsBot() && player->GetTeamNumber() >= FIRST_GAME_TEAM) player->RequestSetClass(botClass); } -} +} \ No newline at end of file diff --git a/src/game/shared/neo/neo_gamerules.h b/src/game/shared/neo/neo_gamerules.h index 1bdee613ae..72f167d50b 100644 --- a/src/game/shared/neo/neo_gamerules.h +++ b/src/game/shared/neo/neo_gamerules.h @@ -173,6 +173,7 @@ enum NeoHudElements : NEO_HUD_BITS_UNDERLYING_TYPE { NEO_HUD_ELEMENT_WORLDPOS_MARKER_ENT = (static_cast(1) << 16), NEO_HUD_ELEMENT_SPECTATOR_OVERLAY = (static_cast(1) << 17), NEO_HUD_ELEMENT_PLACE_NAME = (static_cast(1) << 18), + NEO_HUD_ELEMENT_WALKING_INDICATOR = (static_cast(1) << 19), }; enum NeoSpectateEvent { diff --git a/src/game/shared/neo/neo_player_shared.cpp b/src/game/shared/neo/neo_player_shared.cpp index 50754f8c07..9d8f8d5aac 100644 --- a/src/game/shared/neo/neo_player_shared.cpp +++ b/src/game/shared/neo/neo_player_shared.cpp @@ -860,6 +860,7 @@ void CNEO_Player::CheckVisionButtons() EmitSound(filter, entindex(), params); } + ConVar sv_neo_hitboxgroup_pen("sv_neo_hitboxgroup_pen", "0", FCVAR_REPLICATED, "When hitting outer limbs, do a second trace against head, chest and stomach", true, 0.f, true, 1.f); // NEO TODO (Adam) remove this and pick one bool CNEO_Player::TestHitboxes(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr) { diff --git a/src/game/shared/neo/neo_player_shared.h b/src/game/shared/neo/neo_player_shared.h index 181f3b85bb..034aac970f 100644 --- a/src/game/shared/neo/neo_player_shared.h +++ b/src/game/shared/neo/neo_player_shared.h @@ -258,6 +258,7 @@ static_assert(NEO_ZOOM_SPEED != 0.0f, "Divide by zero"); #define COLOR_NEO_GREEN Color(154, 255, 154, 255) #define COLOR_NEO_ORANGE Color(243, 190, 52, 255) #define COLOR_NEO_WHITE Color(218, 217, 213, 255) +#define COLOR_NEO_WHITE_STR "218 217 213 255" class CNEO_Player; class CNEOBaseCombatWeapon;