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
39 changes: 39 additions & 0 deletions game/bin/rebuild.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,42 @@
[
targetname(target_source) : "Name" : : "The name that other entities refer to this entity by."
]

@PointClass base(Targetname, Parentname) iconsprite("vgui/hud/cp/cp_1.vmt") = neo_worldpos_marker : "Custom Marker"
[
StartDisabled(choices) : "Start Disabled" : 0 =
[
0 : "No"
1 : "Yes"
]
scale(string) : "Scale" : "0.5" : "Scale multiplier of the sprite."
rendercolor(color255) : "Sprite Color (R G B)" : "255 255 255"
Name(string) : "Text to Display" : ""
showdistance(choices) : "Show Distance" : 1 =
[
0 : "No"
1 : "Yes"
]
capzoneeffect(choices) : "Capture Point FX" : 0 =
[
0 : "No"
1 : "Yes"
]
SpriteName1(sprite) : "Sprite 1" : "" : "Material of the sprite to be drawn."
SpriteName2(sprite) : "Sprite 2" : "" : "Material of the sprite to be drawn."
SpriteName3(sprite) : "Sprite 3" : "" : "Material of the sprite to be drawn."
SpriteName4(sprite) : "Sprite 4" : "" : "Material of the sprite to be drawn."
SpriteName5(sprite) : "Sprite 5" : "" : "Material of the sprite to be drawn."
SpriteName6(sprite) : "Sprite 6" : "" : "Material of the sprite to be drawn."
SpriteName7(sprite) : "Sprite 7" : "" : "Material of the sprite to be drawn."
SpriteName8(sprite) : "Sprite 8" : "" : "Material of the sprite to be drawn."
SpriteName9(sprite) : "Sprite 9" : "" : "Material of the sprite to be drawn."
SpriteName10(sprite) : "Sprite 10" : "" : "Material of the sprite to be drawn."

input Enable(void) : "Turn on."
input Disable(void) : "Turn off."
input SetSprite(integer) : "Switch to a sprite from the SpriteName KVs."
input SetText(string) : "Set the message text."
input Alpha(integer) : "Sets the sprite's alpha (0 - 255)."
input Color(color255) : "Sets the sprite's render color (R G B)."
]
4 changes: 4 additions & 0 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,8 @@ target_sources_grouped(
neo/ui/neo_hud_startup_sequence.h
neo/ui/neo_hud_worldpos_marker.cpp
neo/ui/neo_hud_worldpos_marker.h
neo/ui/neo_hud_worldpos_marker_generic.cpp
neo/ui/neo_hud_worldpos_marker_generic.h
neo/ui/neo_scoreboard.cpp
neo/ui/neo_scoreboard.h
neo/ui/neo_hud_context_hint.cpp
Expand Down Expand Up @@ -1648,6 +1650,8 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_weapon_loadout.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_weapon_loadout.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_worldpos_marker.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_worldpos_marker.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_enums.h
)

Expand Down
184 changes: 184 additions & 0 deletions src/game/client/neo/ui/neo_hud_worldpos_marker_generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#include "neo_hud_worldpos_marker_generic.h"
#include "neo_worldpos_marker.h"
#include "iclientmode.h"
#include <vgui/ILocalize.h>

#include "c_neo_player.h"
#include "neo_gamerules.h"

extern ConVar neo_ghost_cap_point_hud_scale_factor;
extern ConVar cl_neo_hud_center_ghost_cap_size;

NEO_HUD_ELEMENT_DECLARE_FREQ_CVAR( WorldPosMarker_Generic, 0 )

CNEOHud_WorldPosMarker_Generic::CNEOHud_WorldPosMarker_Generic( const char *pElementName, C_NEOWorldPosMarkerEnt *src, vgui::Panel *parent )
: CNEOHud_WorldPosMarker (pElementName, parent )
{
SetAutoDelete(true);
m_iHideHudElementNumber = NEO_HUD_ELEMENT_WORLDPOS_MARKER_ENT;

if (parent)
{
SetParent(parent);
}
else
{
SetParent(g_pClientMode->GetViewport());
}

vgui::surface()->GetScreenSize(m_iPosX, m_iPosY);
SetBounds(0, 0, m_iPosX, m_iPosY);

m_pSource = src;

for ( int i = 0; i < MAX_SCREEN_OVERLAYS; i++ )
{
if ( m_pSource->m_iszSpriteNames[i][0] )
{
m_hSprite[i] = vgui::surface()->CreateNewTextureID();
Assert(m_hSprite[i] > 0);
vgui::surface()->DrawSetTextureFile( m_hSprite[i], m_pSource->m_iszSpriteNames[i], 1, false );
}
}

SetVisible(false);
}

void CNEOHud_WorldPosMarker_Generic::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings(pScheme);

m_hFont = pScheme->GetFont("NHudOCRSmall");

vgui::surface()->GetScreenSize(m_iPosX, m_iPosY);
SetBounds(0, 0, m_iPosX, m_iPosY);

const int widerAxis = max(m_viewWidth, m_viewHeight);
m_viewCentreSize = widerAxis * (cl_neo_hud_center_ghost_cap_size.GetFloat() / 100.0f);
}

void CNEOHud_WorldPosMarker_Generic::UpdateStateForNeoHudElementDraw()
{
auto *player = C_NEO_Player::GetLocalNEOPlayer();
if ( !player || !m_pSource )
{
return;
}

m_vecMyPos = m_pSource->GetAbsOrigin();
m_flDistance = METERS_PER_INCH * player->GetAbsOrigin().DistTo( m_vecMyPos );

g_pVGuiLocalize->ConvertANSIToUnicode( m_pSource->m_szText, m_wszMarkerTextUnicode, sizeof( m_wszMarkerTextUnicode ) );
if ( m_wszMarkerTextUnicode[0] != L'\0' && m_pSource->m_bShowDistance )
{
wchar_t wszTemp[ARRAYSIZE(m_wszMarkerTextUnicode)];
V_wcsncpy( wszTemp, m_wszMarkerTextUnicode, sizeof( wszTemp ) );

V_snwprintf( m_wszMarkerTextUnicode, ARRAYSIZE( m_wszMarkerTextUnicode ), L"%ls %.0f m", wszTemp, m_flDistance );
}
}

void CNEOHud_WorldPosMarker_Generic::DrawNeoHudElement()
{
if ( !ShouldDraw() )
{
return;
}

auto *player = C_NEO_Player::GetLocalNEOPlayer();
const int playerTeam = player->GetTeamNumber();

const color32 rCol = m_pSource->GetRenderColor();
Color targetColor( rCol.r, rCol.g, rCol.b, rCol.a );

const bool playerIsPlaying = ( playerTeam == TEAM_JINRAI || playerTeam == TEAM_NSF );

int x, y;
GetVectorInScreenSpace(m_vecMyPos, x, y);

const float scale = neo_ghost_cap_point_hud_scale_factor.GetFloat() * ( m_pSource->m_flScale / 0.5f );

constexpr float HALF_BASE_TEX_LENGTH = 64;
if ( playerIsPlaying && m_wszMarkerTextUnicode[0] != L'\0' )
{
const float fadeTextMultiplier = GetFadeValueTowardsScreenCentre(x, y);
if (m_flDistance > 0.2f && fadeTextMultiplier > 0.001f)
{
int xWide = 0;
int yTall = 0;
vgui::surface()->GetTextSize(m_hFont, m_wszMarkerTextUnicode, xWide, yTall);
vgui::surface()->DrawSetColor(COLOR_TRANSPARENT);
vgui::surface()->DrawSetTextColor(FadeColour(COLOR_TINTGREY, fadeTextMultiplier));
vgui::surface()->DrawSetTextFont(m_hFont);
vgui::surface()->DrawSetTextPos(x - (xWide / 2), y + (HALF_BASE_TEX_LENGTH * scale));
vgui::surface()->DrawPrintText(m_wszMarkerTextUnicode, V_wcslen(m_wszMarkerTextUnicode));
}
}

vgui::surface()->DrawSetTexture( m_hSprite[m_pSource->m_iCurrentSprite] );
if ( m_pSource->m_bCapzoneEffect )
{
for (int i = 0; i < 4; i++) {
m_fMarkerScalesCurrent[i] = (remainder(gpGlobals->curtime, 2) / 2) + 0.5 + m_fMarkerScalesStart[i];
if (m_fMarkerScalesCurrent[i] > 1)
m_fMarkerScalesCurrent[i] -= 1;

int alpha = 32;
if (m_fMarkerScalesCurrent[i] > 0.5)
alpha *= ((0.5 - (m_fMarkerScalesCurrent[i] - 0.5)) * 2);

targetColor[3] = alpha;
vgui::surface()->DrawSetColor(targetColor);

const float halfArrowLength = HALF_BASE_TEX_LENGTH * m_fMarkerScalesCurrent[i] * scale;
vgui::surface()->DrawTexturedRect(
x - halfArrowLength,
y - halfArrowLength,
x + halfArrowLength,
y + halfArrowLength);
}

float alpha6 = remainder(gpGlobals->curtime, 6) + 3;
alpha6 = alpha6 / 6;
if (alpha6 > 0.5)
alpha6 = 1 - alpha6;
alpha6 = 255 * alpha6;

targetColor[3] = alpha6;

const float halfArrowLength = HALF_BASE_TEX_LENGTH * scale;
vgui::surface()->DrawSetColor(targetColor);
vgui::surface()->DrawTexturedRect(
x - halfArrowLength,
y - halfArrowLength,
x + halfArrowLength,
y + halfArrowLength);
}
else
{
const float halfArrowLength = HALF_BASE_TEX_LENGTH * scale;
vgui::surface()->DrawSetColor( targetColor );
vgui::surface()->DrawTexturedRect(
x - halfArrowLength,
y - halfArrowLength,
x + halfArrowLength,
y + halfArrowLength);
}
}

void CNEOHud_WorldPosMarker_Generic::Paint()
{
SetFgColor( COLOR_TRANSPARENT );
SetBgColor( COLOR_TRANSPARENT );
BaseClass::Paint();
PaintNeoElement();
}

bool CNEOHud_WorldPosMarker_Generic::ShouldDraw()
{
if ( !BaseClass::ShouldDraw() || NEORules()->IsRoundOver() || !m_pSource || !m_pSource->m_bEnabled )
{
return false;
}
return true;
}
34 changes: 34 additions & 0 deletions src/game/client/neo/ui/neo_hud_worldpos_marker_generic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include "neo_hud_worldpos_marker.h"

class C_NEOWorldPosMarkerEnt;

class CNEOHud_WorldPosMarker_Generic : public CNEOHud_WorldPosMarker
{
DECLARE_CLASS_SIMPLE( CNEOHud_WorldPosMarker_Generic, CNEOHud_WorldPosMarker );

public:
CNEOHud_WorldPosMarker_Generic( const char *pElementName, C_NEOWorldPosMarkerEnt *src, vgui::Panel *parent = nullptr );
CNEOHud_WorldPosMarker_Generic( const CNEOHud_WorldPosMarker_Generic &other ) = delete;

protected:
virtual void ApplySchemeSettings(vgui::IScheme *pScheme) override;
virtual void Paint() override;
virtual void UpdateStateForNeoHudElementDraw() override;
virtual void DrawNeoHudElement() override;
virtual ConVar *GetUpdateFrequencyConVar() const override;

virtual bool ShouldDraw() override;

private:
C_NEOWorldPosMarkerEnt *m_pSource = nullptr;
int m_iPosX = 0;
int m_iPosY = 0;
float m_flDistance = 0.0f;
float m_fMarkerScalesStart[4] = { 0.78f, 0.6f, 0.38f, 0.0f };
float m_fMarkerScalesCurrent[4] = { 0.78f, 0.6f, 0.38f, 0.0f };
wchar_t m_wszMarkerTextUnicode[64 + 1] = {};
Vector m_vecMyPos = vec3_origin;
vgui::HFont m_hFont = 0UL;
vgui::HTexture m_hSprite[MAX_SCREEN_OVERLAYS] = {};
};
3 changes: 3 additions & 0 deletions src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,8 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_weapon_loadout.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_weapon_loadout.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_worldpos_marker.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_worldpos_marker.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_enums.h
neo/neo_bloom_controller.cpp
neo/neo_client.cpp
Expand All @@ -1391,6 +1393,7 @@ target_sources_grouped(
neo/neo_npc_dummy.cpp
neo/neo_npc_dummy.h
neo/neo_npc_targetsystem.cpp
neo/neo_npc_targetsystem.h
neo/neo_player.cpp
neo/neo_player.h
neo/neo_smokelineofsightblocker.cpp
Expand Down
Loading