Color blind dvars

This commit is contained in:
Diavolo 2021-08-01 10:35:59 +02:00
parent 7d8f01b223
commit de0c3b2762
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
3 changed files with 17 additions and 8 deletions

View File

@ -4,6 +4,9 @@ namespace Components
{ {
Dvar::Var Colors::NewColors; Dvar::Var Colors::NewColors;
Dvar::Var Colors::ColorBlind; Dvar::Var Colors::ColorBlind;
Dvar::Var Colors::ColorAlly;
Dvar::Var Colors::ColorEnemy;
std::vector<DWORD> Colors::ColorTable; std::vector<DWORD> Colors::ColorTable;
DWORD Colors::HsvToRgb(Colors::HsvColor hsv) DWORD Colors::HsvToRgb(Colors::HsvColor hsv)
@ -228,17 +231,19 @@ namespace Components
if (!str.compare("g_TeamColor_EnemyTeam")) if (!str.compare("g_TeamColor_EnemyTeam"))
{ {
// A dark red // A dark red
color[0] = 0.659f; auto* colorlindEnemy = Colors::ColorEnemy.get<float*>();
color[1] = 0.088f; color[0] = colorlindEnemy[0];
color[2] = 0.145f; color[1] = colorlindEnemy[1];
color[2] = colorlindEnemy[2];
return false; return false;
} }
else if (!str.compare("g_TeamColor_MyTeam")) else if (!str.compare("g_TeamColor_MyTeam"))
{ {
// A bright yellow // A bright yellow
color[0] = 1.f; auto* colorblindAlly = Colors::ColorAlly.get<float*>();
color[1] = 0.859f; color[0] = colorblindAlly[0];
color[2] = 0.125f; color[1] = colorblindAlly[1];
color[2] = colorblindAlly[2];
return false; return false;
} }
} }
@ -272,6 +277,8 @@ namespace Components
{ {
// Add a colorblind mode for team colors // Add a colorblind mode for team colors
Colors::ColorBlind = Dvar::Register<bool>("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names"); Colors::ColorBlind = Dvar::Register<bool>("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names");
Colors::ColorEnemy = Game::Dvar_RegisterVec4("g_TeamColor_EnemyTeam_Color", 0.659f, 0.088f, 0.145f, 1, 0, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Enemy team color");
Colors::ColorAlly = Game::Dvar_RegisterVec4("g_TeamColor_MyTeam_Color", 1, 0.859f, 0.125f, 1, 0, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Allied team color");
Utils::Hook(0x406530, Colors::GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x406530, Colors::GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick();
// Disable SV_UpdateUserinfo_f, to block changing the name ingame // Disable SV_UpdateUserinfo_f, to block changing the name ingame

View File

@ -23,6 +23,8 @@ namespace Components
static Dvar::Var NewColors; static Dvar::Var NewColors;
static Dvar::Var ColorBlind; static Dvar::Var ColorBlind;
static Dvar::Var ColorAlly;
static Dvar::Var ColorEnemy;
static DWORD HsvToRgb(HsvColor hsv); static DWORD HsvToRgb(HsvColor hsv);

View File

@ -99,11 +99,11 @@ namespace Game
Dvar_RegisterFloat_t Dvar_RegisterFloat = Dvar_RegisterFloat_t(0x648440); Dvar_RegisterFloat_t Dvar_RegisterFloat = Dvar_RegisterFloat_t(0x648440);
Dvar_RegisterVec2_t Dvar_RegisterVec2 = Dvar_RegisterVec2_t(0x4F6070); Dvar_RegisterVec2_t Dvar_RegisterVec2 = Dvar_RegisterVec2_t(0x4F6070);
Dvar_RegisterVec3_t Dvar_RegisterVec3 = Dvar_RegisterVec3_t(0x4EF8E0); Dvar_RegisterVec3_t Dvar_RegisterVec3 = Dvar_RegisterVec3_t(0x4EF8E0);
Dvar_RegisterVec4_t Dvar_RegisterVec4 = Dvar_RegisterVec4_t(0x4F28E0); Dvar_RegisterVec4_t Dvar_RegisterVec4 = Dvar_RegisterVec4_t(0x471500);
Dvar_RegisterInt_t Dvar_RegisterInt = Dvar_RegisterInt_t(0x479830); Dvar_RegisterInt_t Dvar_RegisterInt = Dvar_RegisterInt_t(0x479830);
Dvar_RegisterEnum_t Dvar_RegisterEnum = Dvar_RegisterEnum_t(0x412E40); Dvar_RegisterEnum_t Dvar_RegisterEnum = Dvar_RegisterEnum_t(0x412E40);
Dvar_RegisterString_t Dvar_RegisterString = Dvar_RegisterString_t(0x4FC7E0); Dvar_RegisterString_t Dvar_RegisterString = Dvar_RegisterString_t(0x4FC7E0);
Dvar_RegisterColor_t Dvar_RegisterColor = Dvar_RegisterColor_t(0x4F28E0);//0x471500; Dvar_RegisterColor_t Dvar_RegisterColor = Dvar_RegisterColor_t(0x4F28E0);
Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName = Dvar_GetUnpackedColorByName_t(0x406530); Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName = Dvar_GetUnpackedColorByName_t(0x406530);
Dvar_FindVar_t Dvar_FindVar = Dvar_FindVar_t(0x4D5390); Dvar_FindVar_t Dvar_FindVar = Dvar_FindVar_t(0x4D5390);