Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions game/neo/scripts/HudLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
52 changes: 1 addition & 51 deletions src/game/client/neo/ui/neo_hud_compass.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
#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 <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui_controls/Controls.h>
#include <vgui_controls/ImagePanel.h>
#include <vgui/IScheme.h>

#include <engine/ivdebugoverlay.h>
#include "ienginevgui.h"

#include "c_team.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Seems like this couples the position of the range finder with the walking indicator, and also resets customized positions of the range finder with the disappearance of these convars. I suppose I'm fine with it because one can disable the walking indicator as a new feature that previously didn't exist and just weak the new hud config, but maybe a future refinement is to allow a player to customize these two elements differently. (on the other hand I see how text alignment can be hard and this could be a pain to align separately)

"Time in seconds that ghost callouts remain on the compass.", true, 0.0f, false, 0.0f);

Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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)
Expand Down
202 changes: 202 additions & 0 deletions src/game/client/neo/ui/neo_hud_walking_indicator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#include "neo_hud_walking_indicator.h"

#include "iclientmode.h"
#include <vgui/ISurface.h>

#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;
Comment on lines +36 to +37

@sunzenshen sunzenshen Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: notWalkingTextWidth and textHeight are non-const file-scope globals, so they have external linkage. static (or making them members) would keep them private to this file. On the other hand, if that ever becomes a problem then the naming is more obvious within that future context.

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];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: not technically a member (m_...) of the object instance, so perhaps this should be caps-case instead, for readability. Not that it really matters too much.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The old wchar_t m_wszRangeFinder[11]; member in neo_hud_compass.h is unused now that the rangefinder lives here, so it could be removed. This file-scope buffer could also be static.

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<C_NEO_Player *>(pLocalPlayer->GetObserverTarget())
Comment on lines +64 to +65

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If we ever add observer targets that are non-players (for example observing some kind of objective for a custom game mode like Jeff/Payload/etc, the static_cast<C_NEO_Player *>(pLocalPlayer->GetObserverTarget()) would be UB. I guess we'll hear from it if it happens but could be a place for some defensive if checks.

Perhaps grab a C_BaseEntity* instance first, then check ->IsPlayer, and if that passes, then we should be safe to static cast into C_NEO_Player* as long as it holds true that all players always are CNEOPlayers.

But I'm ok with merging this and fixing in the future if it breaks.

: 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for isMakingFootsteps value, maybe flip the || around to check the simpler FL_ONGROUND case first, so for the lucky case we don't need to call the more complex IsMakingFootstepSounds at all.

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<C_NEO_Player *>(pLocalPlayer->GetObserverTarget())
: pLocalPlayer;
if (!pTargetPlayer || !pTargetPlayer->IsAlive())
return;

int offset = 0;
DrawRangeFinder(pTargetPlayer, offset);
DrawWalkingIndicator(pTargetPlayer, offset);
}

void CNEOHud_WalkingIndicator::Paint()
{
BaseClass::Paint();
PaintNeoElement();
}
39 changes: 39 additions & 0 deletions src/game/client/neo/ui/neo_hud_walking_indicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "neo_hud_childelement.h"
#include "hudelement.h"
#include <vgui_controls/Panel.h>

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");
Comment on lines +27 to +28

@Rainyan Rainyan Nov 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value supposed to be "203" instead of "r203" here, or is that a typo?

Grepping around we also do it at https://github.com/NeotokyoRebuild/neo/blame/5cb282a7a0ea123a2b571c01c22e6f953aa69eb0/src/game/client/neo/ui/neo_hud_ammo.h#L40 but I was too lazy to expand the macros and figure out where this is parsed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifying proportional_xpos uses CProportionalIntWithScreenspacePropertyX, and in ExtractValue ComputePos checks whether the first character is an alignment character. The default value here should follow the default value in HudLayout.res where I actually use c30 and c40, meaning 30 pixels to the right and 40 pixels down from the center of the screen on 640x480, but actually once I remove the entry the text is nowhere near the center, so there must be some difference in how the value in hudlayout.res is handled compared to the default in this constructor 🤔

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);
};
3 changes: 3 additions & 0 deletions src/game/client/neo/ui/neo_root_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
Loading
Loading