Merge pull request #9200 from SollyBunny/cl_hook_coll_size_other

Add cl_hook_coll_size_other & +hookcoll button in UI
This commit is contained in:
Dennis Felsing 2024-11-08 22:26:55 +00:00 committed by GitHub
commit 6a0b0fc04b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 20 deletions

View file

@ -667,7 +667,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(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(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_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);
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);
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);
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();
if(g_Config.m_ClHookCollSize > 0)
if(Size > 0)
{
Graphics()->QuadsBegin();
Graphics()->SetColor(Color.WithAlpha((float)g_Config.m_ClHookCollAlpha / 100));
float LineWidth = 0.5f + (float)(g_Config.m_ClHookCollSize - 1) * 0.25f;
Graphics()->SetColor(ColorModified);
float LineWidth = 0.5f + (float)(Size - 1) * 0.25f;
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y - LineWidth, Length, LineWidth * 2.f);
Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd();
@ -2966,7 +2973,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
else
{
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);
Graphics()->LinesDraw(&LineItem, 1);
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.m_Size = 50.0f;
vec2 TeeRenderPos, DummyRenderPos;
const float LineLength = 150.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;
RightView.HSplitTop(50.0f, &PreviewNoColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
vec2 TeeRenderPos = vec2(PreviewNoColl.x + LeftMargin, PreviewNoColl.y + PreviewNoColl.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewNoColl.w - LineLength, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorNoColl)));
TeeRenderPos = vec2(PreviewNoColl.x + LeftMargin, PreviewNoColl.y + PreviewNoColl.h / 2.0f);
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);
CUIRect NoHookTileRect;
@ -2999,18 +3016,17 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
NoHookTileRect.Margin(10.0f, &NoHookTileRect);
// Render unhookable tile
int TileScale = 32.0f;
Graphics()->TextureClear();
Graphics()->TextureSet(m_pClient->m_MapImages.GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH));
Graphics()->BlendNormal();
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));
CUIRect PreviewColl;
// ***** Hookable Tile Preview *****
RightView.HSplitTop(50.0f, &PreviewColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
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);
CUIRect HookTileRect;
@ -3025,14 +3041,28 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
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));
CUIRect PreviewCollTee;
RightView.HSplitTop(50.0f, &PreviewCollTee, &RightView);
// ***** Hook Dummy Preivew *****
RightView.HSplitTop(50.0f, &PreviewColl, &RightView);
RightView.HSplitTop(4 * MarginSmall, nullptr, &RightView);
TeeRenderPos = vec2(PreviewCollTee.x + LeftMargin, PreviewCollTee.y + PreviewCollTee.h / 2.0f);
const vec2 DummyRenderPos = vec2(PreviewCollTee.x + PreviewCollTee.w - LineLength - 5.f + LeftMargin, PreviewCollTee.y + PreviewCollTee.h / 2.0f);
DoHookCollision(TeeRenderPos, PreviewCollTee.w - LineLength - 15.f, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl)));
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_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(), &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)
{

View file

@ -244,7 +244,8 @@ void CPlayers::RenderHookCollLine(
vec2 InitPos = Position;
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();
else
Graphics()->LinesBegin();
@ -302,9 +303,9 @@ void CPlayers::RenderHookCollLine(
HookCollColor = color_invert(HookCollColor);
}
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 Pos0 = FinishPos + PerpToAngle * -LineWidth;
vec2 Pos1 = FinishPos + PerpToAngle * LineWidth;