diff --git a/src/Components/Modules/Colors.cpp b/src/Components/Modules/Colors.cpp index cc98da81..a64b9f3f 100644 --- a/src/Components/Modules/Colors.cpp +++ b/src/Components/Modules/Colors.cpp @@ -3,6 +3,7 @@ namespace Components { Dvar::Var Colors::NewColors; + Dvar::Var Colors::ColorBlind; std::vector Colors::ColorTable; DWORD Colors::HsvToRgb(Colors::HsvColor hsv) @@ -220,18 +221,21 @@ namespace Components // Patches team overhead normally - signed int __cdecl Colors::Dvar_GetUnpackedColorByName(const char* name, float* color) { - - if (Dvar::Var("r_colorBlindTeams").get()) { + signed int __cdecl Colors::Dvar_GetUnpackedColorByName(const char* name, float* color) + { + if (Colors::ColorBlind.get()) + { auto str = std::string(name); - if (str.compare("g_TeamColor_EnemyTeam") == 0) { + if (str.compare("g_TeamColor_EnemyTeam") == 0) + { // A dark red color[0] = 0.659f; color[1] = 0.088f; color[2] = 0.145f; return 0; } - else if (str.compare("g_TeamColor_MyTeam") == 0) { + else if (str.compare("g_TeamColor_MyTeam") == 0) + { // A bright yellow color[0] = 1.f; color[1] = 0.859f; @@ -246,7 +250,7 @@ namespace Components Colors::Colors() { // Add a colorblind mode for team colors - Dvar::Register("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names"); + Colors::ColorBlind = Dvar::Register("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names"); Utils::Hook(0x4C09BE, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick(); Utils::Hook(0x583661, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick(); Utils::Hook(0x5836A5, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick(); @@ -272,7 +276,7 @@ namespace Components Utils::Hook(0x4AD470, Colors::CleanStrStub, HOOK_JUMP).install()->quick(); // Register dvar - Colors::NewColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use Warfare² color code style."); + Colors::NewColors = Dvar::Register("cg_newColors", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use Warfare� color code style."); Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_FLAG_REPLICATED, "Color for the extended color code."); Dvar::Register("sv_allowColoredNames", true, Game::dvar_flag::DVAR_FLAG_NONE, "Allow colored names on the server"); diff --git a/src/Components/Modules/Colors.hpp b/src/Components/Modules/Colors.hpp index b63aa51d..638ce070 100644 --- a/src/Components/Modules/Colors.hpp +++ b/src/Components/Modules/Colors.hpp @@ -22,6 +22,7 @@ namespace Components }; static Dvar::Var NewColors; + static Dvar::Var ColorBlind; static DWORD HsvToRgb(HsvColor hsv);