Merge pull request #18 from diamante0018/colordblind_team_colors
Colordblind team colors
This commit is contained in:
commit
4e859ea616
@ -4,8 +4,8 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Dvar::Var Colors::NewColors;
|
Dvar::Var Colors::NewColors;
|
||||||
Dvar::Var Colors::ColorBlind;
|
Dvar::Var Colors::ColorBlind;
|
||||||
Dvar::Var Colors::ColorAlly;
|
Game::dvar_t* Colors::ColorAllyColorBlind;
|
||||||
Dvar::Var Colors::ColorEnemy;
|
Game::dvar_t* Colors::ColorEnemyColorBlind;
|
||||||
|
|
||||||
std::vector<DWORD> Colors::ColorTable;
|
std::vector<DWORD> Colors::ColorTable;
|
||||||
|
|
||||||
@ -223,29 +223,27 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Patches team overhead normally
|
// Patches team overhead normally
|
||||||
bool Colors::Dvar_GetUnpackedColorByName(const char* name, float* color)
|
bool Colors::Dvar_GetUnpackedColorByName(const char* name, float* expandedColor)
|
||||||
{
|
{
|
||||||
if (Colors::ColorBlind.get<bool>())
|
if (Colors::ColorBlind.get<bool>())
|
||||||
{
|
{
|
||||||
auto str = std::string(name);
|
const auto str = std::string(name);
|
||||||
if (!str.compare("g_TeamColor_EnemyTeam"))
|
if (str == "g_TeamColor_EnemyTeam")
|
||||||
{
|
{
|
||||||
// A dark red
|
auto* colorblindEnemy = Colors::ColorEnemyColorBlind->current.color;
|
||||||
auto* colorlindEnemy = Colors::ColorEnemy.get<float*>();
|
expandedColor[0] = static_cast<float>(colorblindEnemy[0]) / 255.0f;
|
||||||
color[0] = colorlindEnemy[0];
|
expandedColor[1] = static_cast<float>(colorblindEnemy[1]) / 255.0f;
|
||||||
color[1] = colorlindEnemy[1];
|
expandedColor[2] = static_cast<float>(colorblindEnemy[2]) / 255.0f;
|
||||||
color[2] = colorlindEnemy[2];
|
expandedColor[3] = static_cast<float>(colorblindEnemy[3]) / 255.0f;
|
||||||
color[3] = colorlindEnemy[3];
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!str.compare("g_TeamColor_MyTeam"))
|
else if (str == "g_TeamColor_MyTeam")
|
||||||
{
|
{
|
||||||
// A bright yellow
|
auto* colorblindAlly = Colors::ColorAllyColorBlind->current.color;
|
||||||
auto* colorblindAlly = Colors::ColorAlly.get<float*>();
|
expandedColor[0] = static_cast<float>(colorblindAlly[0]) / 255.0f;
|
||||||
color[0] = colorblindAlly[0];
|
expandedColor[1] = static_cast<float>(colorblindAlly[1]) / 255.0f;
|
||||||
color[1] = colorblindAlly[1];
|
expandedColor[2] = static_cast<float>(colorblindAlly[2]) / 255.0f;
|
||||||
color[2] = colorblindAlly[2];
|
expandedColor[3] = static_cast<float>(colorblindAlly[3]) / 255.0f;
|
||||||
color[3] = colorblindAlly[3];
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,8 +277,10 @@ 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");
|
// A dark red
|
||||||
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");
|
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();
|
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
|
||||||
|
@ -23,8 +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 Game::dvar_t* ColorAllyColorBlind;
|
||||||
static Dvar::Var ColorEnemy;
|
static Game::dvar_t* ColorEnemyColorBlind;
|
||||||
|
|
||||||
static DWORD HsvToRgb(HsvColor hsv);
|
static DWORD HsvToRgb(HsvColor hsv);
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace Components
|
|||||||
static void LookupColor(DWORD* color, char index);
|
static void LookupColor(DWORD* color, char index);
|
||||||
static void LookupColorStub();
|
static void LookupColorStub();
|
||||||
static char* CleanStrStub(char* string);
|
static char* CleanStrStub(char* string);
|
||||||
static bool Dvar_GetUnpackedColorByName(const char* name, float* color);
|
static bool Dvar_GetUnpackedColorByName(const char* name, float* expandedColor);
|
||||||
static void GetUnpackedColorByNameStub();
|
static void GetUnpackedColorByNameStub();
|
||||||
static std::vector<DWORD> ColorTable;
|
static std::vector<DWORD> ColorTable;
|
||||||
};
|
};
|
||||||
|
@ -2347,7 +2347,7 @@ namespace Game
|
|||||||
float value;
|
float value;
|
||||||
float vector[4];
|
float vector[4];
|
||||||
const char *string;
|
const char *string;
|
||||||
char color[4];
|
unsigned char color[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct $BFBB53559BEAC4289F32B924847E59CB
|
struct $BFBB53559BEAC4289F32B924847E59CB
|
||||||
|
Loading…
Reference in New Issue
Block a user