@@ -45,6 +45,72 @@ string(string img) getImage = {
4545 return strcat(huddir, img);
4646}
4747
48+ //
49+ // HUD_ResolveTextColorForPlayer(index)
50+ // Returns the color as a vector to use for a
51+ // player of the given index.
52+ //
53+ vector (float index) HUD_ResolveTextColorForPlayer =
54+ {
55+ switch (index) {
56+ case 0 :
57+ // White.
58+ return '1 1 1' ;
59+ case 1 :
60+ // Light Blue.
61+ if (cvar("cl_colorblind" )) {
62+ return '0.39 0.76 0.93' ;
63+ } else {
64+ return '0 0.46 0.70' ;
65+ }
66+ case 2 :
67+ // Orange.
68+ if (cvar("cl_colorblind" )) {
69+ return '0.93 0.42 0' ;
70+ } else {
71+ return '0.92 0.74 0' ;
72+ }
73+ case 3 :
74+ // Green.
75+ if (cvar("cl_colorblind" )) {
76+ return '0 0.69 0.52' ;
77+ } else {
78+ return '0 0.90 0.13' ;
79+ }
80+ case 4 :
81+ // Salmon Pink.
82+ if (cvar("cl_colorblind" )) {
83+ return '1 0.46 0.54' ;
84+ } else {
85+ return '1 0.57 0.64' ;
86+ }
87+ case 5 :
88+ // Magenta.
89+ if (cvar("cl_colorblind" )) {
90+ return '0.73 0.29 0.54' ;
91+ } else {
92+ return '0.80 0.20 0.55' ;
93+ }
94+ case 6 :
95+ // Cyan.
96+ if (cvar("cl_colorblind" )) {
97+ return '0.36 0.84 0.96' ;
98+ } else {
99+ return '0.42 0.82 0.82' ;
100+ }
101+ case 7 :
102+ // Yellow.
103+ if (cvar("cl_colorblind" )) {
104+ return '0.86 0.78 0.25' ;
105+ } else {
106+ return '1 0.87 0.13' ;
107+ }
108+ default :
109+ // White.
110+ return '1 1 1' ;
111+ }
112+ };
113+
48114//
49115// HUD_GetAlphaForWeaponObjects()
50116// Used for objects on the ammo-corner, where
@@ -336,20 +402,15 @@ void() HUD_Points =
336402 float backwidth = 0.8 * g_width;
337403 vector TEXTCOLOR = '0 0 0' ;
338404
339- for (int i = 3 ; i >= 0 ; i = i - 1 )
405+ for (int i = 7 ; i >= 0 ; i = i - 1 )
340406 {
341407 float player_number = getplayerkeyfloat(i, "client_index" );
342408 entity client = findfloat(world, playernum, player_number);
343409
344410 if ((client == world || ! client. classname) && ! client. is_spectator)
345411 continue ;
346412
347- switch (i) {
348- case 1 : TEXTCOLOR = TEXT_LIGHTBLUE; break ;
349- case 2 : TEXTCOLOR = TEXT_ORANGE; break ;
350- case 3 : TEXTCOLOR = TEXT_GREEN; break ;
351- default : TEXTCOLOR = [1 , 1 , 1 ]; break ;
352- }
413+ TEXTCOLOR = HUD_ResolveTextColorForPlayer(i);
353414
354415 pointwidth = getTextWidth(ftos(client. points), 12 );
355416 x = (99 - pointwidth)/ 2 + GetUltraWideOffset();
@@ -1657,12 +1718,7 @@ void() HUD_Scores =
16571718 if ((client == world || ! client. classname) && ! client. is_spectator)
16581719 continue ;
16591720
1660- switch (i) {
1661- case 1 : TEXTCOLOR = TEXT_LIGHTBLUE; break ;
1662- case 2 : TEXTCOLOR = TEXT_ORANGE; break ;
1663- case 3 : TEXTCOLOR = TEXT_GREEN; break ;
1664- default : TEXTCOLOR = [1 , 1 , 1 ]; break ;
1665- }
1721+ TEXTCOLOR = HUD_ResolveTextColorForPlayer(i);
16661722
16671723 float y_pos = (scoreboard_text_size + 5 ) * i;
16681724
@@ -1990,7 +2046,7 @@ void() HUD_Spectator =
19902046
19912047void () HUD_PlayerNames =
19922048{
1993- for (float i = 3 ; i >= 0 ; i = i - 1 ) {
2049+ for (float i = 7 ; i >= 0 ; i = i - 1 ) {
19942050 float player_number = getplayerkeyfloat(i, "client_index" );
19952051
19962052 if (player_number == getstatf(STAT_PLAYERNUM))
@@ -2018,13 +2074,7 @@ void() HUD_PlayerNames =
20182074 continue ;
20192075
20202076 screen_position_x -= getTextWidth(text, 8 )/ 2 ;
2021-
2022- switch (i) {
2023- case 1 : text_color = TEXT_LIGHTBLUE; break ;
2024- case 2 : text_color = TEXT_ORANGE; break ;
2025- case 3 : text_color = TEXT_GREEN; break ;
2026- default : break ;
2027- }
2077+ text_color = HUD_ResolveTextColorForPlayer(i);
20282078
20292079 if (screen_position_z > 0 ) {
20302080 HUD_DrawStringWithBackdrop(screen_position, text, [8 , 8 ], text_color, 1 , 0 );
0 commit comments