Color dvar

This commit is contained in:
Diavolo 2021-08-01 14:22:42 +02:00
parent a5680fdc61
commit 1bd4bcba05
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
3 changed files with 22 additions and 22 deletions

View File

@ -4,8 +4,8 @@ namespace Components
{
Dvar::Var Colors::NewColors;
Dvar::Var Colors::ColorBlind;
Game::dvar_t* Colors::ColorAlly;
Game::dvar_t* Colors::ColorEnemy;
Game::dvar_t* Colors::ColorAllyColorBlind;
Game::dvar_t* Colors::ColorEnemyColorBlind;
std::vector<DWORD> Colors::ColorTable;
@ -227,25 +227,23 @@ namespace Components
{
if (Colors::ColorBlind.get<bool>())
{
auto str = std::string(name);
if (!str.compare("g_TeamColor_EnemyTeam"))
const auto str = std::string(name);
if (str == "g_TeamColor_EnemyTeam")
{
// A dark red
auto* colorblindEnemy = Colors::ColorEnemy->current.color;
*expandedColor = (float)(unsigned __int8)colorblindEnemy[0] / 255.0f;
expandedColor[1] = (float)(unsigned __int8)colorblindEnemy[1] / 255.0f;
expandedColor[2] = (float)(unsigned __int8)colorblindEnemy[2] / 255.0f;
expandedColor[3] = (float)(unsigned __int8)colorblindEnemy[3] / 255.0f;
auto* colorblindEnemy = Colors::ColorEnemyColorBlind->current.color;
expandedColor[0] = static_cast<float>(colorblindEnemy[0]) / 255.0f;
expandedColor[1] = static_cast<float>(colorblindEnemy[1]) / 255.0f;
expandedColor[2] = static_cast<float>(colorblindEnemy[2]) / 255.0f;
expandedColor[3] = static_cast<float>(colorblindEnemy[3]) / 255.0f;
return false;
}
else if (!str.compare("g_TeamColor_MyTeam"))
else if (str == "g_TeamColor_MyTeam")
{
// A bright yellow
auto* colorblindAlly = Colors::ColorAlly->current.color;
*expandedColor = (float)(unsigned __int8)colorblindAlly[0] / 255.0f;
expandedColor[1] = (float)(unsigned __int8)colorblindAlly[1] / 255.0f;
expandedColor[2] = (float)(unsigned __int8)colorblindAlly[2] / 255.0f;
expandedColor[3] = (float)(unsigned __int8)colorblindAlly[3] / 255.0f;
auto* colorblindAlly = Colors::ColorAllyColorBlind->current.color;
expandedColor[0] = static_cast<float>(colorblindAlly[0]) / 255.0f;
expandedColor[1] = static_cast<float>(colorblindAlly[1]) / 255.0f;
expandedColor[2] = static_cast<float>(colorblindAlly[2]) / 255.0f;
expandedColor[3] = static_cast<float>(colorblindAlly[3]) / 255.0f;
return false;
}
}
@ -279,8 +277,10 @@ namespace Components
{
// 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::ColorEnemy = 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");
Colors::ColorAlly = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_FLAG_SAVED, "Ally team color for colorblind mode");
// A dark red
Colors::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");
// A bright yellow
Colors::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");
Utils::Hook(0x406530, Colors::GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick();
// Disable SV_UpdateUserinfo_f, to block changing the name ingame

View File

@ -23,8 +23,8 @@ namespace Components
static Dvar::Var NewColors;
static Dvar::Var ColorBlind;
static Game::dvar_t* ColorAlly;
static Game::dvar_t* ColorEnemy;
static Game::dvar_t* ColorAllyColorBlind;
static Game::dvar_t* ColorEnemyColorBlind;
static DWORD HsvToRgb(HsvColor hsv);

View File

@ -2347,7 +2347,7 @@ namespace Game
float value;
float vector[4];
const char *string;
char color[4];
unsigned char color[4];
};
struct $BFBB53559BEAC4289F32B924847E59CB