Add cl_hook_coll_size_other & +hookcoll button in UI

This commit is contained in:
SollyBunny 2024-11-05 22:30:36 +00:00
parent c0ff4c35f4
commit 96b3b70a7d
3 changed files with 52 additions and 20 deletions

View file

@ -666,7 +666,8 @@ MACRO_CONFIG_INT(ClPredictFreeze, cl_predict_freeze, 1, 0, 2, CFGFLAG_CLIENT | C
MACRO_CONFIG_INT(ClShowNinja, cl_show_ninja, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ninja skin") MACRO_CONFIG_INT(ClShowNinja, cl_show_ninja, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ninja skin")
MACRO_CONFIG_INT(ClShowHookCollOther, cl_show_hook_coll_other, 1, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show other players' hook collision line (2 to always show)") MACRO_CONFIG_INT(ClShowHookCollOther, cl_show_hook_coll_other, 1, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show other players' hook collision line (2 to always show)")
MACRO_CONFIG_INT(ClShowHookCollOwn, cl_show_hook_coll_own, 1, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show own players' hook collision line (2 to always show)") MACRO_CONFIG_INT(ClShowHookCollOwn, cl_show_hook_coll_own, 1, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show own players' hook collision line (2 to always show)")
MACRO_CONFIG_INT(ClHookCollSize, cl_hook_coll_size, 0, 0, 20, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of hook collision line") MACRO_CONFIG_INT(ClHookCollSize, cl_hook_coll_size, 0, 0, 20, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Width of your own hook collision line")
MACRO_CONFIG_INT(ClHookCollSizeOther, cl_hook_coll_size_other, 0, 0, 20, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Width of others' hook collision line")
MACRO_CONFIG_INT(ClHookCollAlpha, cl_hook_coll_alpha, 100, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Alpha of hook collision line (0 invisible, 100 fully visible)") MACRO_CONFIG_INT(ClHookCollAlpha, cl_hook_coll_alpha, 100, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Alpha of hook collision line (0 invisible, 100 fully visible)")
MACRO_CONFIG_COL(ClHookCollColorNoColl, cl_hook_coll_color_no_coll, 65407, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Specifies the color of a hookline that hits nothing.") MACRO_CONFIG_COL(ClHookCollColorNoColl, cl_hook_coll_color_no_coll, 65407, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Specifies the color of a hookline that hits nothing.")

View file

@ -2930,7 +2930,10 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
} }
LeftView.HSplitTop(2 * LineSize, &Button, &LeftView); LeftView.HSplitTop(2 * LineSize, &Button, &LeftView);
Ui()->DoScrollbarOption(&g_Config.m_ClHookCollSize, &g_Config.m_ClHookCollSize, &Button, Localize("Hook collision line width"), 0, 20, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE); Ui()->DoScrollbarOption(&g_Config.m_ClHookCollSize, &g_Config.m_ClHookCollSize, &Button, Localize("Width of your own hook collision line"), 0, 20, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE);
LeftView.HSplitTop(2 * LineSize, &Button, &LeftView);
Ui()->DoScrollbarOption(&g_Config.m_ClHookCollSizeOther, &g_Config.m_ClHookCollSizeOther, &Button, Localize("Width of others' hook collision line"), 0, 20, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE);
LeftView.HSplitTop(2 * LineSize, &Button, &LeftView); LeftView.HSplitTop(2 * LineSize, &Button, &LeftView);
Ui()->DoScrollbarOption(&g_Config.m_ClHookCollAlpha, &g_Config.m_ClHookCollAlpha, &Button, Localize("Hook collision line opacity"), 0, 100, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE, "%"); Ui()->DoScrollbarOption(&g_Config.m_ClHookCollAlpha, &g_Config.m_ClHookCollAlpha, &Button, Localize("Hook collision line opacity"), 0, 100, &CUi::ms_LinearScrollbarScale, CUi::SCROLLBAR_OPTION_MULTILINE, "%");
@ -2952,13 +2955,17 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Ui()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_ML);
RightView.HSplitTop(2 * MarginSmall, nullptr, &RightView); RightView.HSplitTop(2 * MarginSmall, nullptr, &RightView);
auto DoHookCollision = [this](const vec2 &Pos, const float &Length, const ColorRGBA &Color) { auto DoHookCollision = [this](const vec2 &Pos, const float &Length, const int &Size, const ColorRGBA &Color, const bool &Invert) {
ColorRGBA ColorModified = Color;
if(Invert)
ColorModified = color_invert(ColorModified);
ColorModified = ColorModified.WithAlpha((float)g_Config.m_ClHookCollAlpha / 100);
Graphics()->TextureClear(); Graphics()->TextureClear();
if(g_Config.m_ClHookCollSize > 0) if(Size > 0)
{ {
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
Graphics()->SetColor(Color.WithAlpha((float)g_Config.m_ClHookCollAlpha / 100)); Graphics()->SetColor(ColorModified);
float LineWidth = 0.5f + (float)(g_Config.m_ClHookCollSize - 1) * 0.25f; float LineWidth = 0.5f + (float)(Size - 1) * 0.25f;
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y - LineWidth, Length, LineWidth * 2.f); IGraphics::CQuadItem QuadItem(Pos.x, Pos.y - LineWidth, Length, LineWidth * 2.f);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
@ -2966,7 +2973,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
else else
{ {
Graphics()->LinesBegin(); Graphics()->LinesBegin();
Graphics()->SetColor(Color.WithAlpha((float)g_Config.m_ClHookCollAlpha / 100)); Graphics()->SetColor(ColorModified);
IGraphics::CLineItem LineItem(Pos.x, Pos.y, Pos.x + Length, Pos.y); IGraphics::CLineItem LineItem(Pos.x, Pos.y, Pos.x + Length, Pos.y);
Graphics()->LinesDraw(&LineItem, 1); Graphics()->LinesDraw(&LineItem, 1);
Graphics()->LinesEnd(); Graphics()->LinesEnd();
@ -2983,14 +2990,24 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
DummySkinInfo.ApplyColors(g_Config.m_ClDummyUseCustomColor, g_Config.m_ClDummyColorBody, g_Config.m_ClDummyColorFeet); DummySkinInfo.ApplyColors(g_Config.m_ClDummyUseCustomColor, g_Config.m_ClDummyColorBody, g_Config.m_ClDummyColorFeet);
DummySkinInfo.m_Size = 50.0f; DummySkinInfo.m_Size = 50.0f;
vec2 TeeRenderPos, DummyRenderPos;
const float LineLength = 150.f; const float LineLength = 150.f;
const float LeftMargin = 30.f; const float LeftMargin = 30.f;
const int TileScale = 32.0f;
// Toggled via checkbox later, inverts some previews
static bool s_HookCollPressed = false;
CUIRect PreviewColl;
// ***** Unhookable Tile Preview *****
CUIRect PreviewNoColl; CUIRect PreviewNoColl;
RightView.HSplitTop(50.0f, &PreviewNoColl, &RightView); RightView.HSplitTop(50.0f, &PreviewNoColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView); RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
vec2 TeeRenderPos = vec2(PreviewNoColl.x + LeftMargin, PreviewNoColl.y + PreviewNoColl.h / 2.0f); TeeRenderPos = vec2(PreviewNoColl.x + LeftMargin, PreviewNoColl.y + PreviewNoColl.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewNoColl.w - LineLength, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorNoColl))); DoHookCollision(TeeRenderPos, PreviewNoColl.w - LineLength, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorNoColl)), s_HookCollPressed);
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos); RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos);
CUIRect NoHookTileRect; CUIRect NoHookTileRect;
@ -2999,18 +3016,17 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
NoHookTileRect.Margin(10.0f, &NoHookTileRect); NoHookTileRect.Margin(10.0f, &NoHookTileRect);
// Render unhookable tile // Render unhookable tile
int TileScale = 32.0f;
Graphics()->TextureClear(); Graphics()->TextureClear();
Graphics()->TextureSet(m_pClient->m_MapImages.GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH)); Graphics()->TextureSet(m_pClient->m_MapImages.GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH));
Graphics()->BlendNormal(); Graphics()->BlendNormal();
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderTools()->RenderTile(NoHookTileRect.x, NoHookTileRect.y, TILE_NOHOOK, TileScale, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); RenderTools()->RenderTile(NoHookTileRect.x, NoHookTileRect.y, TILE_NOHOOK, TileScale, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
CUIRect PreviewColl; // ***** Hookable Tile Preview *****
RightView.HSplitTop(50.0f, &PreviewColl, &RightView); RightView.HSplitTop(50.0f, &PreviewColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView); RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f); TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorHookableColl))); DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorHookableColl)), s_HookCollPressed);
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos); RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos);
CUIRect HookTileRect; CUIRect HookTileRect;
@ -3025,14 +3041,28 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderTools()->RenderTile(HookTileRect.x, HookTileRect.y, TILE_SOLID, TileScale, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); RenderTools()->RenderTile(HookTileRect.x, HookTileRect.y, TILE_SOLID, TileScale, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
CUIRect PreviewCollTee; // ***** Hook Dummy Preivew *****
RightView.HSplitTop(50.0f, &PreviewCollTee, &RightView); RightView.HSplitTop(50.0f, &PreviewColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView); RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
TeeRenderPos = vec2(PreviewCollTee.x + LeftMargin, PreviewCollTee.y + PreviewCollTee.h / 2.0f); TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
const vec2 DummyRenderPos = vec2(PreviewCollTee.x + PreviewCollTee.w - LineLength - 5.f + LeftMargin, PreviewCollTee.y + PreviewCollTee.h / 2.0f); DummyRenderPos = vec2(PreviewColl.x + PreviewColl.w - LineLength - 5.f + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewCollTee.w - LineLength - 15.f, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl))); DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength - 15.f, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl)), s_HookCollPressed);
RenderTools()->RenderTee(CAnimState::GetIdle(), &DummySkinInfo, 0, vec2(1.0f, 0.0f), DummyRenderPos); RenderTools()->RenderTee(CAnimState::GetIdle(), &DummySkinInfo, 0, vec2(1.0f, 0.0f), DummyRenderPos);
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos); RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos);
// ***** Hook Dummy Reverse Preivew *****
RightView.HSplitTop(50.0f, &PreviewColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
DummyRenderPos = vec2(PreviewColl.x + PreviewColl.w - LineLength - 5.f + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength - 15.f, g_Config.m_ClHookCollSizeOther, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl)), false);
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1.0f, 0.0f), DummyRenderPos);
RenderTools()->RenderTee(CAnimState::GetIdle(), &DummySkinInfo, 0, vec2(1.0f, 0.0f), TeeRenderPos);
// ***** Preview +hookcoll pressed toggle *****
RightView.HSplitTop(LineSize, &Button, &RightView);
if(DoButton_CheckBox(&s_HookCollPressed, Localize("Preview \"Hook collisions\" being pressed"), s_HookCollPressed, &Button))
s_HookCollPressed = !s_HookCollPressed;
} }
else if(s_CurTab == APPEARANCE_TAB_INFO_MESSAGES) else if(s_CurTab == APPEARANCE_TAB_INFO_MESSAGES)
{ {

View file

@ -244,7 +244,8 @@ void CPlayers::RenderHookCollLine(
vec2 InitPos = Position; vec2 InitPos = Position;
vec2 FinishPos = InitPos + ExDirection * (m_pClient->m_aTuning[g_Config.m_ClDummy].m_HookLength - 42.0f); vec2 FinishPos = InitPos + ExDirection * (m_pClient->m_aTuning[g_Config.m_ClDummy].m_HookLength - 42.0f);
if(g_Config.m_ClHookCollSize > 0) const int HookCollSize = Local ? g_Config.m_ClHookCollSize : g_Config.m_ClHookCollSizeOther;
if(HookCollSize > 0)
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
else else
Graphics()->LinesBegin(); Graphics()->LinesBegin();
@ -302,9 +303,9 @@ void CPlayers::RenderHookCollLine(
HookCollColor = color_invert(HookCollColor); HookCollColor = color_invert(HookCollColor);
} }
Graphics()->SetColor(HookCollColor.WithAlpha(Alpha)); Graphics()->SetColor(HookCollColor.WithAlpha(Alpha));
if(g_Config.m_ClHookCollSize > 0) if(HookCollSize > 0)
{ {
float LineWidth = 0.5f + (float)(g_Config.m_ClHookCollSize - 1) * 0.25f; float LineWidth = 0.5f + (float)(HookCollSize - 1) * 0.25f;
vec2 PerpToAngle = normalize(vec2(ExDirection.y, -ExDirection.x)) * GameClient()->m_Camera.m_Zoom; vec2 PerpToAngle = normalize(vec2(ExDirection.y, -ExDirection.x)) * GameClient()->m_Camera.m_Zoom;
vec2 Pos0 = FinishPos + PerpToAngle * -LineWidth; vec2 Pos0 = FinishPos + PerpToAngle * -LineWidth;
vec2 Pos1 = FinishPos + PerpToAngle * LineWidth; vec2 Pos1 = FinishPos + PerpToAngle * LineWidth;