From dadb142f4ea4dcea211679a8beb9bc362e585bb8 Mon Sep 17 00:00:00 2001 From: furo Date: Fri, 27 Oct 2023 00:28:29 +0200 Subject: [PATCH] Add `cl_race_ghost_alpha`, add title for ghost settings. --- src/engine/shared/config_variables.h | 1 + src/game/client/components/menus_settings.cpp | 18 +++++++++++++----- src/game/client/components/players.cpp | 4 ++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 175f95e63..760adf627 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -324,6 +324,7 @@ MACRO_CONFIG_INT(ClRaceShowGhost, cl_race_show_ghost, 1, 0, 1, CFGFLAG_CLIENT | MACRO_CONFIG_INT(ClRaceSaveGhost, cl_race_save_ghost, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save ghost") MACRO_CONFIG_INT(ClRaceGhostStrictMap, cl_race_ghost_strict_map, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Strict map checking when loading ghosts") MACRO_CONFIG_INT(ClRaceGhostSaveBest, cl_race_ghost_save_best, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save only ghosts that are better than the previous record.") +MACRO_CONFIG_INT(ClRaceGhostAlpha, cl_race_ghost_alpha, 40, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Visbility of ghosts (alpha value, 0 invisible, 100 fully visible)") MACRO_CONFIG_INT(ClDDRaceScoreBoard, cl_ddrace_scoreboard, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable DDRace Scoreboard") MACRO_CONFIG_INT(SvResetPickups, sv_reset_pickups, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether the weapons are reset on passing the start tile or not") diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index e550e0711..e4afe00b0 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -3002,6 +3002,9 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) MainView.HSplitTop(110.0f, &Demo, &MainView); Demo.HSplitTop(30.0f, &Label, &Demo); UI()->DoLabel(&Label, Localize("Demo"), 20.0f, TEXTALIGN_ML); + Label.VSplitMid(nullptr, &Label, 20.0f); + UI()->DoLabel(&Label, Localize("Ghost"), 20.0f, TEXTALIGN_ML); + Demo.HSplitTop(5.0f, nullptr, &Demo); Demo.VSplitMid(&Left, &Right, 20.0f); @@ -3041,10 +3044,12 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) if(g_Config.m_ClRaceGhost) { Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_CheckBox(&g_Config.m_ClRaceShowGhost, Localize("Show ghost"), g_Config.m_ClRaceShowGhost, &Button)) + Button.VSplitMid(&LeftLeft, &Button); + if(DoButton_CheckBox(&g_Config.m_ClRaceShowGhost, Localize("Show ghost"), g_Config.m_ClRaceShowGhost, &LeftLeft)) { g_Config.m_ClRaceShowGhost ^= 1; } + UI()->DoScrollbarOption(&g_Config.m_ClRaceGhostAlpha, &g_Config.m_ClRaceGhostAlpha, &Button, Localize("Opacity"), 0, 100, &CUI::ms_LinearScrollbarScale, 0u, "%"); Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_CheckBox(&g_Config.m_ClRaceSaveGhost, Localize("Save ghost"), g_Config.m_ClRaceSaveGhost, &Button)) @@ -3052,10 +3057,13 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) g_Config.m_ClRaceSaveGhost ^= 1; } - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_CheckBox(&g_Config.m_ClRaceGhostSaveBest, Localize("Only save improvements"), g_Config.m_ClRaceGhostSaveBest, &Button)) + if(g_Config.m_ClRaceSaveGhost) { - g_Config.m_ClRaceGhostSaveBest ^= 1; + Right.HSplitTop(20.0f, &Button, &Right); + if(DoButton_CheckBox(&g_Config.m_ClRaceGhostSaveBest, Localize("Only save improvements"), g_Config.m_ClRaceGhostSaveBest, &Button)) + { + g_Config.m_ClRaceGhostSaveBest ^= 1; + } } } @@ -3085,7 +3093,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == SHOW_OTHERS_ON, &LeftLeft)) g_Config.m_ClShowOthers = g_Config.m_ClShowOthers != SHOW_OTHERS_ON ? SHOW_OTHERS_ON : SHOW_OTHERS_OFF; - UI()->DoScrollbarOption(&g_Config.m_ClShowOthersAlpha, &g_Config.m_ClShowOthersAlpha, &Button, Localize("Opacity"), 0, 100); + UI()->DoScrollbarOption(&g_Config.m_ClShowOthersAlpha, &g_Config.m_ClShowOthersAlpha, &Button, Localize("Opacity"), 0, 100, &CUI::ms_LinearScrollbarScale, 0u, "%"); GameClient()->m_Tooltips.DoToolTip(&g_Config.m_ClShowOthersAlpha, &Button, Localize("Adjust the opacity of entities belonging to other teams, such as tees and nameplates")); diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 7a470aef5..6fa651167 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -283,6 +283,8 @@ void CPlayers::RenderHook( bool OtherTeam = m_pClient->IsOtherTeam(ClientID); float Alpha = (OtherTeam || ClientID < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; + if(ClientID == -2) // ghost + Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; RenderInfo.m_Size = 64.0f; @@ -356,6 +358,8 @@ void CPlayers::RenderPlayer( bool Local = m_pClient->m_Snap.m_LocalClientID == ClientID; bool OtherTeam = m_pClient->IsOtherTeam(ClientID); float Alpha = (OtherTeam || ClientID < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; + if(ClientID == -2) // ghost + Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; // set size RenderInfo.m_Size = 64.0f;