From e62b6a55ae47316d468b623490438d7d62078ee9 Mon Sep 17 00:00:00 2001 From: SollyBunny Date: Sat, 23 Nov 2024 02:26:50 +0000 Subject: [PATCH] Add ClImproveMousePrecision --- src/engine/shared/tater_variables.h | 1 + src/game/client/components/controls.cpp | 39 +++++++-------- src/game/client/components/menus_settings.cpp | 5 +- src/game/client/components/players.cpp | 50 +++++++++---------- 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/engine/shared/tater_variables.h b/src/engine/shared/tater_variables.h index d2934c23ba4..8d805974f28 100644 --- a/src/engine/shared/tater_variables.h +++ b/src/engine/shared/tater_variables.h @@ -24,6 +24,7 @@ MACRO_CONFIG_INT(ClPingNameCircle, tc_nameplate_ping_circle, 0, 0, 1, CFGFLAG_CL MACRO_CONFIG_INT(ClSpecmenuID, tc_spec_menu_ID, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Shows player IDs in spectate menu") MACRO_CONFIG_INT(ClLimitMouseToScreen, tc_limit_mouse_to_screen, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Limit mouse to screen boundries") +MACRO_CONFIG_INT(ClImproveMousePrecision, tc_improve_mouse_precision, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Improve mouse precision by scaling max distance to 2000") MACRO_CONFIG_INT(ClHammerRotatesWithCursor, tc_hammer_rotates_with_cursor, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Allow your hammer to rotate like other weapons") diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index a60dc10a19d..5bddaf66f15 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -208,30 +208,36 @@ int CControls::SnapInput(int *pData) // set the target anyway though so that we can keep seeing our surroundings, // even if chat or menu are activated - m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)m_aMousePos[g_Config.m_ClDummy].x; - m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)m_aMousePos[g_Config.m_ClDummy].y; - - // scale TargetX, TargetY by zoom. + vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; + if(g_Config.m_ClImproveMousePrecision) + Pos *= length(Pos) * 2000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance); if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom) - { - m_aInputData[g_Config.m_ClDummy].m_TargetX *= m_pClient->m_Camera.m_Zoom; - m_aInputData[g_Config.m_ClDummy].m_TargetY *= m_pClient->m_Camera.m_Zoom; - } + Pos *= m_pClient->m_Camera.m_Zoom; + m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)Pos.x; + m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)Pos.y; // send once a second just to be sure Send = Send || time_get() > m_LastSendTime + time_freq(); } else { - m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)m_aMousePos[g_Config.m_ClDummy].x; - m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)m_aMousePos[g_Config.m_ClDummy].y; - + vec2 Pos; if(g_Config.m_ClSubTickAiming && m_aMousePosOnAction[g_Config.m_ClDummy] != vec2(0.0f, 0.0f)) { - m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)m_aMousePosOnAction[g_Config.m_ClDummy].x; - m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)m_aMousePosOnAction[g_Config.m_ClDummy].y; + Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; m_aMousePosOnAction[g_Config.m_ClDummy] = vec2(0.0f, 0.0f); } + else + Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; + if(!m_pClient->m_Snap.m_SpecInfo.m_Active) + { + if(g_Config.m_ClImproveMousePrecision) + Pos *= length(Pos) * 2000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance); + if(!g_Config.m_ClOldMouseZoom) + Pos *= m_pClient->m_Camera.m_Zoom; + } + m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)Pos.x; + m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)Pos.y; if(!m_aInputData[g_Config.m_ClDummy].m_TargetX && !m_aInputData[g_Config.m_ClDummy].m_TargetY) { @@ -246,13 +252,6 @@ int CControls::SnapInput(int *pData) if(!m_aInputDirectionLeft[g_Config.m_ClDummy] && m_aInputDirectionRight[g_Config.m_ClDummy]) m_aInputData[g_Config.m_ClDummy].m_Direction = 1; - // scale TargetX, TargetY by zoom. - if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !g_Config.m_ClOldMouseZoom) - { - m_aInputData[g_Config.m_ClDummy].m_TargetX *= m_pClient->m_Camera.m_Zoom; - m_aInputData[g_Config.m_ClDummy].m_TargetY *= m_pClient->m_Camera.m_Zoom; - } - // dummy copy moves if(g_Config.m_ClDummyCopyMoves) { diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index c13b9cb57a4..66d460ae017 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -3354,6 +3354,8 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Column.HSplitTop(LineSize, nullptr, &Column); Column.HSplitTop(MarginSmall, nullptr, &Column); DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClOldMouseZoom, Localize("Old Mouse Precision (fixes precision at low zoom levels, \nbreaks /tc, /telecursor while zoomed)"), &g_Config.m_ClOldMouseZoom, &Column, LineSize); + Column.HSplitTop(MarginSmall, nullptr, &Column); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClImproveMousePrecision, Localize("Improve mouse precision by scaling max distance to 2000"), &g_Config.m_ClImproveMousePrecision, &Column, LineSize); s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Anti Latency Tools ***** // @@ -3615,6 +3617,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) int RainbowSelectedOld = g_Config.m_ClRainbowMode - 1; DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRainbow, Localize("Rainbow"), &g_Config.m_ClRainbow, &Column, LineSize); DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRainbowOthers, Localize("Rainbow Others"), &g_Config.m_ClRainbowOthers, &Column, LineSize); + Column.HSplitTop(MarginExtraSmall, nullptr, &Column); CUIRect DropDownRect; Column.HSplitTop(LineSize, &DropDownRect, &Column); const int RainbowSelectedNew = Ui()->DoDropDown(&DropDownRect, RainbowSelectedOld, s_DropDownNames.data(), s_DropDownNames.size(), s_RainbowDropDownState); @@ -3634,7 +3637,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) // Scroll CUIRect ScrollRegion; ScrollRegion.x = MainView.x; - ScrollRegion.y = maximum(LeftView.y, RightView.y) + MarginSmall; + ScrollRegion.y = maximum(LeftView.y, RightView.y) + MarginSmall * 2.0f; ScrollRegion.w = MainView.w; ScrollRegion.h = 0.0f; s_ScrollRegion.AddRect(ScrollRegion); diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index d37b3ce8179..4a0e6291a94 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -193,16 +193,21 @@ void CPlayers::RenderHookCollLine( if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) { // just use the direct input if it's the local player we are rendering - Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom); - if(g_Config.m_ClOldMouseZoom) - Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]); + vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; + if(g_Config.m_ClImproveMousePrecision) + Pos *= length(Pos) * 2000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance); + if(!g_Config.m_ClOldMouseZoom) + Pos *= m_pClient->m_Camera.m_Zoom; + Pos.x = (int)Pos.x; + Pos.y = (int)Pos.y; + Angle = angle(Pos); } else { Angle = GetPlayerTargetAngle(&Prev, &Player, ClientId, IntraTick); } - vec2 Direction = direction(Angle); + vec2 ExDirection = direction(Angle); vec2 Position; if(in_range(ClientId, MAX_CLIENTS - 1)) Position = m_pClient->m_aClients[ClientId].m_RenderPos; @@ -234,23 +239,6 @@ void CPlayers::RenderHookCollLine( #endif if((AlwaysRenderHookColl || RenderHookCollPlayer) && RenderHookCollVideo) { - vec2 ExDirection = Direction; - - if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) - { - ExDirection = normalize( - vec2((int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].x * m_pClient->m_Camera.m_Zoom), - (int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].y * m_pClient->m_Camera.m_Zoom))); - - if(g_Config.m_ClOldMouseZoom) - ExDirection = normalize( - vec2((int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].x), - (int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].y))); - - // fix direction if mouse is exactly in the center - if(!(int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].x && !(int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].y) - ExDirection = vec2(1, 0); - } Graphics()->TextureClear(); vec2 InitPos = Position; vec2 FinishPos = InitPos + ExDirection * (m_pClient->m_aTuning[g_Config.m_ClDummy].m_HookLength - 42.0f); @@ -484,9 +472,14 @@ void CPlayers::RenderPlayer( if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) { // just use the direct input if it's the local player we are rendering - Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom); - if(g_Config.m_ClOldMouseZoom) - Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]); + vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; + if(g_Config.m_ClImproveMousePrecision) + Pos *= length(Pos) * 2000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance); + if(!g_Config.m_ClOldMouseZoom) + Pos *= m_pClient->m_Camera.m_Zoom; + Pos.x = (int)Pos.x; + Pos.y = (int)Pos.y; + Angle = angle(Pos); } else { @@ -914,7 +907,14 @@ void CPlayers::RenderPlayerGhost( if(Local && Client()->State() != IClient::STATE_DEMOPLAYBACK) { // just use the direct input if it's the local player we are rendering - Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]); + vec2 Pos = m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy]; + if(g_Config.m_ClImproveMousePrecision) + Pos *= length(Pos) * 2000.0f / (float)(g_Config.m_ClDyncam ? g_Config.m_ClDyncamMaxDistance : g_Config.m_ClMouseMaxDistance); + if(!g_Config.m_ClOldMouseZoom) + Pos *= m_pClient->m_Camera.m_Zoom; + Pos.x = (int)Pos.x; + Pos.y = (int)Pos.y; + Angle = angle(Pos); } else {