Skip to content

Commit

Permalink
Various Indicator Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Apr 27, 2022
1 parent 795a102 commit d2d4cf5
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 35 deletions.
46 changes: 42 additions & 4 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,9 @@ void CMenus::RenderSettingsTClient(CUIRect MainView)
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClPlayerIndicator, ("Show any enabled Indicators"), &g_Config.m_ClPlayerIndicator, &MainView, LineMargin);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClPlayerIndicatorFreeze, ("Show only freeze Players"), &g_Config.m_ClPlayerIndicatorFreeze, &MainView, LineMargin);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClIndicatorTeamOnly, ("Only show after joining a team"), &g_Config.m_ClIndicatorTeamOnly, &MainView, LineMargin);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClIndicatorTees, ("Render tiny tees instead of circles"), &g_Config.m_ClIndicatorTees, &MainView, LineMargin);

DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClIndicatorVariableDistance, ("Change indicator offset based on distance to other tees"), &g_Config.m_ClIndicatorVariableDistance, &MainView, LineMargin);

static int IndicatorAliveColorID, IndicatorDeadColorID;

Expand All @@ -2873,26 +2876,61 @@ void CMenus::RenderSettingsTClient(CUIRect MainView)

MainView.HSplitTop(25.0f, &Section, &MainView);
DoLine_ColorPicker(&IndicatorDeadColorID, 25.0f, 200.0f, 14.0f, 0.0f, &Section, ("Indicator dead color"), &g_Config.m_ClIndicatorFreeze, ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f), false);

{
CUIRect Button, Label;
MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(150.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Indicator size", g_Config.m_ClIndicatorRadius);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, TEXTALIGN_LEFT);
g_Config.m_ClIndicatorRadius = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorRadius, &Button, (g_Config.m_ClIndicatorRadius - 1) / 15.0f) * 15.0f) + 1;
}
{
CUIRect Button, Label;
MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(150.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Indicator opacity", g_Config.m_ClIndicatorOpacity);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, TEXTALIGN_LEFT);
g_Config.m_ClIndicatorOpacity = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorOpacity, &Button, (g_Config.m_ClIndicatorOpacity) / 100.0f) * 100.0f);
}
{
CUIRect Button, Label;
MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(150.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Indicator offset", g_Config.m_ClIndicatorOffset);
if(g_Config.m_ClIndicatorVariableDistance)
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Min offset", g_Config.m_ClIndicatorOffset);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, TEXTALIGN_LEFT);
g_Config.m_ClIndicatorOffset = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorOffset, &Button, (g_Config.m_ClIndicatorOffset - 1) / 63.0f) * 63.0f) + 1;
g_Config.m_ClIndicatorOffset = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorOffset, &Button, (g_Config.m_ClIndicatorOffset - 16) / 184.0f) * 184.0f) + 16;
}
if(g_Config.m_ClIndicatorVariableDistance)
{
CUIRect Button, Label;
MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(150.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Indicator width", g_Config.m_ClIndicatorRadius);
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Max offset", g_Config.m_ClIndicatorOffsetMax);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, TEXTALIGN_LEFT);
g_Config.m_ClIndicatorRadius = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorRadius, &Button, (g_Config.m_ClIndicatorRadius - 1) / 15.0f) * 15.0f) + 1;
g_Config.m_ClIndicatorOffsetMax = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorOffsetMax, &Button, (g_Config.m_ClIndicatorOffsetMax - 16) / 184.0f) * 184.0f) + 16;
}
if(g_Config.m_ClIndicatorVariableDistance)
{
CUIRect Button, Label;
MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(150.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i ", "Max distance", g_Config.m_ClIndicatorMaxDistance);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, TEXTALIGN_LEFT);
int NewValue = (g_Config.m_ClIndicatorMaxDistance) / 50.0f;
NewValue = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClIndicatorMaxDistance, &Button, (NewValue - 10) / 130.0f) * 130.0f) + 10;
g_Config.m_ClIndicatorMaxDistance = NewValue * 50;
}
}
}
Expand Down
73 changes: 48 additions & 25 deletions src/game/client/components/player_indicator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <engine/graphics.h>
#include <engine/shared/config.h>

#include <game/client/animstate.h>
#include <game/client/render.h>
#include <game/generated/client_data.h>
#include <game/generated/protocol.h>

Expand All @@ -13,13 +15,18 @@ vec2 NormalizedDirection(vec2 src, vec2 dst)
return normalize(vec2(dst.x - src.x, dst.y - src.y));
}

float DistanceBetweenTwoPoints(vec2 src, vec2 dst)
{
return sqrt(pow(dst.x - src.x, 2) + pow(dst.y - src.y, 2));
}

void CPlayerIndicator::OnRender()
{
//Don't Render if we can't find our own tee
// Don't render if we can't find our own tee
if(m_pClient->m_Snap.m_LocalClientID == -1 || !m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientID].m_Active)
return;

//Don't Render if not race gamemode or in demo
// Don't render if not race gamemode or in demo
if(!GameClient()->m_GameInfo.m_Race || Client()->State() == IClient::STATE_DEMOPLAYBACK)
return;

Expand All @@ -34,51 +41,67 @@ void CPlayerIndicator::OnRender()
{
for(int i = 0; i < MAX_CLIENTS; ++i)
{
CGameClient::CClientData enemy = m_pClient->m_aClients[i];
if(!m_pClient->m_Snap.m_paPlayerInfos[i] || i == m_pClient->m_Snap.m_LocalClientID)
continue;

CGameClient::CClientData OtherTee = m_pClient->m_aClients[i];
if(
enemy.m_Team == m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Team &&
!enemy.m_Paused &&
!enemy.m_Spec &&
OtherTee.m_Team == m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Team &&
!OtherTee.m_Paused &&
!OtherTee.m_Spec &&
m_pClient->m_Snap.m_aCharacters[i].m_Active)
{
if(g_Config.m_ClPlayerIndicatorFreeze && OtherTee.m_RenderCur.m_Weapon != WEAPON_NINJA)
continue;

vec2 norm = NormalizedDirection(m_pClient->m_aClients[i].m_RenderPos, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_RenderPos) * (-1);

vec2 cPoint(norm.x * g_Config.m_ClIndicatorOffset + Position.x, norm.y * g_Config.m_ClIndicatorOffset + Position.y);
Graphics()->QuadsBegin();
float Offset = g_Config.m_ClIndicatorOffset;
if(g_Config.m_ClIndicatorVariableDistance)
{
Offset = mix((float)g_Config.m_ClIndicatorOffset, (float)g_Config.m_ClIndicatorOffsetMax,
std::min(DistanceBetweenTwoPoints(Position, OtherTee.m_RenderPos) / g_Config.m_ClIndicatorMaxDistance, 1.0f));
}

if(enemy.m_RenderCur.m_Weapon == WEAPON_NINJA)
vec2 IndicatorPos(norm.x * Offset + Position.x, norm.y * Offset + Position.y);
CTeeRenderInfo TeeInfo = OtherTee.m_RenderInfo;
float Alpha = g_Config.m_ClIndicatorOpacity / 100.0f;
if(OtherTee.m_RenderCur.m_Weapon == WEAPON_NINJA)
{
col = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClIndicatorFreeze));
if(g_Config.m_ClIndicatorTees)
{
TeeInfo.m_ColorBody.r *= 0.4;
TeeInfo.m_ColorBody.g *= 0.4;
TeeInfo.m_ColorBody.b *= 0.4;
TeeInfo.m_ColorFeet.r *= 0.4;
TeeInfo.m_ColorFeet.g *= 0.4;
TeeInfo.m_ColorFeet.b *= 0.4;
Alpha *= 0.8;
}
}
else
{
col = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClIndicatorAlive));
}
col.a = Alpha;

Graphics()->SetColor(col);
CAnimState *pIdleState = CAnimState::GetIdle();
TeeInfo.m_Size = g_Config.m_ClIndicatorRadius * 4.f;

if(g_Config.m_ClPlayerIndicatorFreeze)
if(g_Config.m_ClIndicatorTees)
{
if(enemy.m_RenderCur.m_Weapon == WEAPON_NINJA)
{
RenderTools()->DrawCircle(cPoint.x, cPoint.y, g_Config.m_ClIndicatorRadius, 16);
}
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, OtherTee.m_RenderCur.m_Emote, vec2(1.0f, 0.0f), IndicatorPos, col.a);
}
else
{
RenderTools()->DrawCircle(cPoint.x, cPoint.y, g_Config.m_ClIndicatorRadius, 16);
Graphics()->QuadsBegin();
Graphics()->SetColor(col);
RenderTools()->DrawCircle(IndicatorPos.x, IndicatorPos.y, g_Config.m_ClIndicatorRadius, 16);
Graphics()->QuadsEnd();
}

Graphics()->QuadsEnd();
}
}
}
Graphics()->QuadsBegin();
ColorRGBA rgb = color_cast<ColorRGBA>(ColorHSLA(100.0f / 1000.0f, 1.0f, 0.5f, 0.8f));

Graphics()->SetColor(rgb);

// RenderTools()->DrawCircle(InitPos.x, InitPos.y, 32, 360);
Graphics()->QuadsEnd();
}
}
20 changes: 14 additions & 6 deletions src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ MACRO_CONFIG_INT(ClShowCenterLines, tc_show_center, 0, 0, 1, CFGFLAG_CLIENT | CF

//MACRO_CONFIG_INT(ClFreeGhost, tc_freeghost, 0, 0, 1, CFGFLAG_CLIENT , "")

//Outline Variables
MACRO_CONFIG_INT(ClOutline, tc_outline, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Draws outlines")
MACRO_CONFIG_INT(ClOutlineFreeze, tc_outline_freeze, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Draws outline around freeze and deep")
MACRO_CONFIG_INT(ClOutlineUnFreeze, tc_outline_unfreeze, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Draws outline around unfreeze and undeep")
Expand All @@ -103,13 +104,20 @@ MACRO_CONFIG_COL(ClOutlineColorFreeze, tc_outline_color_freeze, 0, CFGFLAG_CLIEN
MACRO_CONFIG_COL(ClOutlineColorTele, tc_outline_color_tele, 0, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Tele outline color") //0 0 0
MACRO_CONFIG_COL(ClOutlineColorUnfreeze, tc_outline_color_unfreeze, 0, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Unfreeze outline color") //0 0 0

MACRO_CONFIG_COL(ClIndicatorAlive, tc_indicator_alive, 255, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Indicator for player alive")
MACRO_CONFIG_COL(ClIndicatorFreeze, tc_indicator_freeze, 65407, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Indicator for player dead")
MACRO_CONFIG_INT(ClIndicatorOffset, tc_indicator_offset, 42, 1, 64, CFGFLAG_CLIENT | CFGFLAG_SAVE, "(1-64) Offset of indicator to player")
MACRO_CONFIG_INT(ClIndicatorRadius, tc_indicator_radius, 4, 1, 16, CFGFLAG_CLIENT | CFGFLAG_SAVE, "(1-16) Radius of indicator")
MACRO_CONFIG_INT(ClPlayerIndicator, tc_player_indicator, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show a circle with Player position in Team")
MACRO_CONFIG_INT(ClPlayerIndicatorFreeze, tc_player_indicator_freeze, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show a circle with failed players in Team")
//Indicator Variables
MACRO_CONFIG_COL(ClIndicatorAlive, tc_indicator_alive, 255, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Color of alive tees in player indicator")
MACRO_CONFIG_COL(ClIndicatorFreeze, tc_indicator_freeze, 65407, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Color of frozen tees in player indicator")
MACRO_CONFIG_INT(ClIndicatorOffset, tc_indicator_offset, 42, 16, 200, CFGFLAG_CLIENT | CFGFLAG_SAVE, "(16-128) Offset of indicator position")
MACRO_CONFIG_INT(ClIndicatorOffsetMax, tc_indicator_offset_max, 100, 16, 200, CFGFLAG_CLIENT | CFGFLAG_SAVE, "(16-128) Max indicator offset for variable offset setting")
MACRO_CONFIG_INT(ClIndicatorVariableDistance, tc_indicator_variable_distance, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Indicator circles will be further away the further the tee is")
MACRO_CONFIG_INT(ClIndicatorMaxDistance, tc_indicator_variable_max_distance, 1000, 500, 7000, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Maximum tee distance for variable offset")
MACRO_CONFIG_INT(ClIndicatorRadius, tc_indicator_radius, 4, 1, 16, CFGFLAG_CLIENT | CFGFLAG_SAVE, "(1-16) indicator circle size")
MACRO_CONFIG_INT(ClIndicatorOpacity, tc_indicator_opacity, 50, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Opacity of indicator circles")
MACRO_CONFIG_INT(ClPlayerIndicator, tc_player_indicator, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show radial indicator of other tees")
MACRO_CONFIG_INT(ClPlayerIndicatorFreeze, tc_player_indicator_freeze, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Only show frozen tees in indicator")
MACRO_CONFIG_INT(ClIndicatorTeamOnly, tc_indicator_inteam, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Only show indicator while in team")
MACRO_CONFIG_INT(ClIndicatorTees, tc_indicator_tees, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show tees instead of circles")


MACRO_CONFIG_INT(ClWhiteFeet, tc_white_feet, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Render all feet as perfectly white base color")

Expand Down

0 comments on commit d2d4cf5

Please sign in to comment.