diff --git a/src/engine/shared/config_variables_tclient.h b/src/engine/shared/config_variables_tclient.h index bbe87154c65..18efbfee592 100644 --- a/src/engine/shared/config_variables_tclient.h +++ b/src/engine/shared/config_variables_tclient.h @@ -274,3 +274,8 @@ MACRO_CONFIG_INT(TcUiShowDDNet, tc_ui_show_ddnet, 0, 0, 1, CFGFLAG_CLIENT | CFGF MACRO_CONFIG_INT(TcUiShowTClient, tc_ui_show_tclient, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show TClient domain in Configs tab") MACRO_CONFIG_INT(TcUiOnlyModified, tc_ui_only_modified, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show only modified settings in Configs tab") MACRO_CONFIG_INT(TcUiCompactList, tc_ui_compact_list, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Use compact row layout in Configs tab") + +// Dummy Info +MACRO_CONFIG_INT(TcShowhudDummyPosition, tc_showhud_dummy_position, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ingame HUD (Dummy Position)") +MACRO_CONFIG_INT(TcShowhudDummySpeed, tc_showhud_dummy_speed, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ingame HUD (Dummy Speed)") +MACRO_CONFIG_INT(TcShowhudDummyAngle, tc_showhud_dummy_angle, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ingame HUD (Dummy Aim Angle)") diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index e0601d7d761..3c9472b94cf 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -1674,6 +1674,56 @@ void CHud::RenderMovementInformation() const float Fontsize = 6.0f; float BoxHeight = GetMovementInformationBoxHeight(); + bool HasDummyInfo = false; + CMovementInformation DummyInfo{}; + + if(Client()->DummyConnected()) + { + int DummyClientId = -1; + + if(GameClient()->m_Snap.m_SpecInfo.m_Active) + { + const int SpectId = GameClient()->m_Snap.m_SpecInfo.m_SpectatorId; + + if(SpectId == GameClient()->m_aLocalIds[0]) + { + DummyClientId = GameClient()->m_aLocalIds[1]; + } + else if(SpectId == GameClient()->m_aLocalIds[1]) + { + DummyClientId = GameClient()->m_aLocalIds[0]; + } + else + { + DummyClientId = GameClient()->m_aLocalIds[1 - (g_Config.m_ClDummy ? 1 : 0)]; + } + } + else + { + DummyClientId = GameClient()->m_aLocalIds[1 - (g_Config.m_ClDummy ? 1 : 0)]; + } + + if(DummyClientId >= 0 && DummyClientId < MAX_CLIENTS && + GameClient()->m_aClients[DummyClientId].m_Active) + { + DummyInfo = GetMovementInformation( + DummyClientId, + DummyClientId == GameClient()->m_aLocalIds[1]); + HasDummyInfo = true; + } + } + + const bool ShowDummyPos = HasDummyInfo && g_Config.m_ClShowhudPlayerPosition && g_Config.m_TcShowhudDummyPosition; + const bool ShowDummySpeed = HasDummyInfo && !PosOnly && g_Config.m_ClShowhudPlayerSpeed && g_Config.m_TcShowhudDummySpeed; + const bool ShowDummyAngle = HasDummyInfo && !PosOnly && g_Config.m_ClShowhudPlayerAngle && g_Config.m_TcShowhudDummyAngle; + + if(ShowDummyPos) + BoxHeight += 2.0f * MOVEMENT_INFORMATION_LINE_HEIGHT; + if(ShowDummySpeed) + BoxHeight += 2.0f * MOVEMENT_INFORMATION_LINE_HEIGHT; + if(ShowDummyAngle) + BoxHeight += 1.0f * MOVEMENT_INFORMATION_LINE_HEIGHT; + const float BoxWidth = 62.0f; float StartX = m_Width - BoxWidth; @@ -1698,13 +1748,40 @@ void CHud::RenderMovementInformation() TextRender()->Text(LeftX, y, Fontsize, "X:", -1.0f); UpdateMovementInformationTextContainer(m_aPlayerPositionContainers[0], Fontsize, Info.m_Pos.x, m_aPlayerPrevPosition[0]); - RenderMovementInformationTextContainer(m_aPlayerPositionContainers[0], TextRender()->DefaultTextColor(), RightX, y); + + ColorRGBA TextColor = TextRender()->DefaultTextColor(); + if(ShowDummyPos && fabsf(Info.m_Pos.x - DummyInfo.m_Pos.x) < 0.01f) + TextColor = ColorRGBA(0.2f, 1.0f, 0.2f, 1.0f); + + RenderMovementInformationTextContainer(m_aPlayerPositionContainers[0], TextColor, RightX, y); y += MOVEMENT_INFORMATION_LINE_HEIGHT; TextRender()->Text(LeftX, y, Fontsize, "Y:", -1.0f); UpdateMovementInformationTextContainer(m_aPlayerPositionContainers[1], Fontsize, Info.m_Pos.y, m_aPlayerPrevPosition[1]); RenderMovementInformationTextContainer(m_aPlayerPositionContainers[1], TextRender()->DefaultTextColor(), RightX, y); y += MOVEMENT_INFORMATION_LINE_HEIGHT; + + if(ShowDummyPos) + { + char aBuf[32]; + + TextRender()->Text(LeftX, y, Fontsize, "DX:", -1.0f); + str_format(aBuf, sizeof(aBuf), "%.2f", DummyInfo.m_Pos.x); + + ColorRGBA DummyTextColor = TextRender()->DefaultTextColor(); + if(fabsf(Info.m_Pos.x - DummyInfo.m_Pos.x) < 0.01f) + DummyTextColor = ColorRGBA(0.2f, 1.0f, 0.2f, 1.0f); + + TextRender()->TextColor(DummyTextColor); + TextRender()->Text(RightX - TextRender()->TextWidth(Fontsize, aBuf), y, Fontsize, aBuf, -1.0f); + TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); + y += MOVEMENT_INFORMATION_LINE_HEIGHT; + + TextRender()->Text(LeftX, y, Fontsize, "DY:", -1.0f); + str_format(aBuf, sizeof(aBuf), "%.2f", DummyInfo.m_Pos.y); + TextRender()->Text(RightX - TextRender()->TextWidth(Fontsize, aBuf), y, Fontsize, aBuf, -1.0f); + y += MOVEMENT_INFORMATION_LINE_HEIGHT; + } } if(PosOnly) @@ -1729,6 +1806,21 @@ void CHud::RenderMovementInformation() y += MOVEMENT_INFORMATION_LINE_HEIGHT; } + if(ShowDummySpeed) + { + char aBuf[32]; + + TextRender()->Text(LeftX, y, Fontsize, "DX:", -1.0f); + str_format(aBuf, sizeof(aBuf), "%.2f", DummyInfo.m_Speed.x); + TextRender()->Text(RightX - TextRender()->TextWidth(Fontsize, aBuf), y, Fontsize, aBuf, -1.0f); + y += MOVEMENT_INFORMATION_LINE_HEIGHT; + + TextRender()->Text(LeftX, y, Fontsize, "DY:", -1.0f); + str_format(aBuf, sizeof(aBuf), "%.2f", DummyInfo.m_Speed.y); + TextRender()->Text(RightX - TextRender()->TextWidth(Fontsize, aBuf), y, Fontsize, aBuf, -1.0f); + y += MOVEMENT_INFORMATION_LINE_HEIGHT; + } + TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } @@ -1739,6 +1831,16 @@ void CHud::RenderMovementInformation() UpdateMovementInformationTextContainer(m_PlayerAngleTextContainerIndex, Fontsize, Info.m_Angle, m_PlayerPrevAngle); RenderMovementInformationTextContainer(m_PlayerAngleTextContainerIndex, TextRender()->DefaultTextColor(), RightX, y); + y += MOVEMENT_INFORMATION_LINE_HEIGHT; + + if(ShowDummyAngle) + { + char aBuf[32]; + + TextRender()->Text(LeftX, y, Fontsize, "DA:", -1.0f); + str_format(aBuf, sizeof(aBuf), "%.2f", DummyInfo.m_Angle); + TextRender()->Text(RightX - TextRender()->TextWidth(Fontsize, aBuf), y, Fontsize, aBuf, -1.0f); + } } } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 0566607b325..0bd76277e1b 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1938,6 +1938,11 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowhudPlayerSpeed, Localize("Show player speed"), &g_Config.m_ClShowhudPlayerSpeed, &RightView, LineSize); DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowhudPlayerAngle, Localize("Show player target angle"), &g_Config.m_ClShowhudPlayerAngle, &RightView, LineSize); + // Dummy movement information display settings + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_TcShowhudDummyPosition, TCLocalize("Show dummy position"), &g_Config.m_TcShowhudDummyPosition, &RightView, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_TcShowhudDummySpeed, TCLocalize("Show dummy speed"), &g_Config.m_TcShowhudDummySpeed, &RightView, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_TcShowhudDummyAngle, TCLocalize("Show dummy target angle"), &g_Config.m_TcShowhudDummyAngle, &RightView, LineSize); + // Freeze bar settings DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowFreezeBars, Localize("Show freeze bars"), &g_Config.m_ClShowFreezeBars, &RightView, LineSize); RightView.HSplitTop(LineSize * 2.0f, &Button, &RightView);