From ccefbeb8854a1c885ff7a3a810b90d89bed56078 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 7 Sep 2021 13:53:56 +0200 Subject: [PATCH] Rename r_colorBlindTeams to r_colorBlind to be compatible to future colorblind patches --- src/Components/Modules/TextRenderer.cpp | 19 ++++++++++--------- src/Components/Modules/TextRenderer.hpp | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Components/Modules/TextRenderer.cpp b/src/Components/Modules/TextRenderer.cpp index 56f85d9c..88db6d0e 100644 --- a/src/Components/Modules/TextRenderer.cpp +++ b/src/Components/Modules/TextRenderer.cpp @@ -39,9 +39,9 @@ namespace Components Dvar::Var TextRenderer::cg_newColors; Game::dvar_t* TextRenderer::sv_customTextColor; Dvar::Var TextRenderer::sv_allowColoredNames; - Dvar::Var TextRenderer::ColorBlind; - Game::dvar_t* TextRenderer::ColorAllyColorBlind; - Game::dvar_t* TextRenderer::ColorEnemyColorBlind; + Dvar::Var TextRenderer::r_colorBlind; + Game::dvar_t* TextRenderer::g_ColorBlind_MyTeam; + Game::dvar_t* TextRenderer::g_ColorBlind_EnemyTeam; unsigned TextRenderer::HsvToRgb(HsvColor hsv) { @@ -750,13 +750,13 @@ namespace Components // Patches team overhead normally bool TextRenderer::Dvar_GetUnpackedColorByName(const char* name, float* expandedColor) { - if (ColorBlind.get()) + if (r_colorBlind.get()) { const auto str = std::string(name); if (str == "g_TeamColor_EnemyTeam") { // Dvar_GetUnpackedColor - auto* colorblindEnemy = ColorEnemyColorBlind->current.color; + const auto* colorblindEnemy = g_ColorBlind_EnemyTeam->current.color; expandedColor[0] = static_cast(colorblindEnemy[0]) / 255.0f; expandedColor[1] = static_cast(colorblindEnemy[1]) / 255.0f; expandedColor[2] = static_cast(colorblindEnemy[2]) / 255.0f; @@ -766,7 +766,7 @@ namespace Components else if (str == "g_TeamColor_MyTeam") { // Dvar_GetUnpackedColor - auto* colorblindAlly = ColorAllyColorBlind->current.color; + const auto* colorblindAlly = g_ColorBlind_MyTeam->current.color; expandedColor[0] = static_cast(colorblindAlly[0]) / 255.0f; expandedColor[1] = static_cast(colorblindAlly[1]) / 255.0f; expandedColor[2] = static_cast(colorblindAlly[2]) / 255.0f; @@ -831,12 +831,13 @@ namespace Components Utils::Hook(0x417770, ColorIndex, HOOK_JUMP).install()->quick(); // Add a colorblind mode for team colors - ColorBlind = Dvar::Register("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names"); + r_colorBlind = Dvar::Register("r_colorBlind", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors"); // A dark red - ColorEnemyColorBlind = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Enemy team color for colorblind mode"); + g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Enemy team color for colorblind mode"); // A bright yellow - ColorAllyColorBlind = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Ally team color for colorblind mode"); + g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Ally team color for colorblind mode"); + // Replace team colors with colorblind team colors when colorblind is enabled Utils::Hook(0x406530, GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick(); // Disable SV_UpdateUserinfo_f, to block changing the name ingame diff --git a/src/Components/Modules/TextRenderer.hpp b/src/Components/Modules/TextRenderer.hpp index 7b00fb95..6e4db036 100644 --- a/src/Components/Modules/TextRenderer.hpp +++ b/src/Components/Modules/TextRenderer.hpp @@ -75,9 +75,9 @@ namespace Components static Dvar::Var cg_newColors; static Game::dvar_t* sv_customTextColor; static Dvar::Var sv_allowColoredNames; - static Dvar::Var ColorBlind; - static Game::dvar_t* ColorAllyColorBlind; - static Game::dvar_t* ColorEnemyColorBlind; + static Dvar::Var r_colorBlind; + static Game::dvar_t* g_ColorBlind_MyTeam; + static Game::dvar_t* g_ColorBlind_EnemyTeam; public: static void DrawText2D(const char* text, float x, float y, Game::Font_s* font, float xScale, float yScale, float sinAngle, float cosAngle, Game::GfxColor color, int maxLength, int renderFlags, int cursorPos, char cursorLetter, float padding, Game::GfxColor glowForcedColor, int fxBirthTime, int fxLetterTime, int fxDecayStartTime, int fxDecayDuration, Game::Material* fxMaterial, Game::Material* fxMaterialGlow);