@@ -60,6 +60,8 @@ static char scr_centerstring[MAX_STRING_CHARS];
60
60
static unsigned scr_centertime_start ; // for slow victory printing
61
61
static int scr_center_lines ;
62
62
63
+ static color_t ui_color ;
64
+
63
65
static void CGC_Init (void )
64
66
{
65
67
/* We don't consider rerelease servers here and assume the appropriate
@@ -72,6 +74,8 @@ static void CGC_Init(void)
72
74
ch_scale = cgi .cvar ("ch_scale" , "1" , 0 );
73
75
ch_x = cgi .cvar ("ch_x" , "0" , 0 );
74
76
ch_y = cgi .cvar ("ch_y" , "0" , 0 );
77
+
78
+ ui_color = COLOR_WHITE ;
75
79
}
76
80
77
81
static void CGC_Shutdown (void )
@@ -91,22 +95,11 @@ static void DrawPic(int x, int y, const char* pic)
91
95
cgi .SCR_DrawPic (x , y , w , h , pic );
92
96
}
93
97
94
- static void CG_DrawString (int x , int y , int flags , size_t maxlen , const char * s )
98
+ static void CG_DrawString (int x , int y , int flags , size_t maxlen , const char * s , color_t color )
95
99
{
96
- const char * write_str = s ;
97
- if (flags & UI_XORCOLOR ) {
98
- size_t new_str_len = min (strlen (s ), maxlen );
99
- char * new_str = alloca (new_str_len + 1 );
100
- for (size_t i = 0 ; i < new_str_len ; i ++ ) {
101
- new_str [i ] = s [i ] ^ 0x80 ;
102
- }
103
- new_str [new_str_len ] = 0 ;
104
- write_str = new_str ;
105
- }
106
-
107
- while (maxlen -- && * write_str ) {
108
- byte c = * write_str ++ ;
109
- cgi .SCR_DrawChar (x , y , 1 , c , flags & UI_DROPSHADOW );
100
+ while (maxlen -- && * s ) {
101
+ byte c = * s ++ ;
102
+ cgix .DrawCharEx (x , y , flags , c , color );
110
103
x += CHAR_WIDTH ;
111
104
}
112
105
}
@@ -116,7 +109,7 @@ static void CG_DrawString(int x, int y, int flags, size_t maxlen, const char *s)
116
109
DrawStringEx
117
110
==============
118
111
*/
119
- static void CG_DrawStringEx (int x , int y , int flags , size_t maxlen , const char * s )
112
+ static void CG_DrawStringEx (int x , int y , int flags , size_t maxlen , const char * s , color_t color )
120
113
{
121
114
size_t len = strlen (s );
122
115
@@ -130,54 +123,54 @@ static void CG_DrawStringEx(int x, int y, int flags, size_t maxlen, const char *
130
123
x -= len * CHAR_WIDTH ;
131
124
}
132
125
133
- CG_DrawString (x , y , flags , maxlen , s );
126
+ CG_DrawString (x , y , flags , maxlen , s , color );
134
127
}
135
128
136
129
/*
137
130
==============
138
131
DrawStringMulti
139
132
==============
140
133
*/
141
- static void CG_DrawStringMulti (int x , int y , int flags , size_t maxlen , const char * s )
134
+ static void CG_DrawStringMulti (int x , int y , int flags , size_t maxlen , const char * s , color_t color )
142
135
{
143
136
char * p ;
144
137
size_t len ;
145
138
146
139
while (* s ) {
147
140
p = strchr (s , '\n' );
148
141
if (!p ) {
149
- CG_DrawStringEx (x , y , flags , maxlen , s );
142
+ CG_DrawStringEx (x , y , flags , maxlen , s , color );
150
143
break ;
151
144
}
152
145
153
146
len = p - s ;
154
147
if (len > maxlen ) {
155
148
len = maxlen ;
156
149
}
157
- CG_DrawStringEx (x , y , flags , len , s );
150
+ CG_DrawStringEx (x , y , flags , len , s , color );
158
151
159
152
y += CHAR_HEIGHT ;
160
153
s = p + 1 ;
161
154
}
162
155
}
163
156
164
157
#define HUD_DrawString (x , y , string ) \
165
- CG_DrawString(x, y, 0, MAX_STRING_CHARS, string)
158
+ CG_DrawString(x, y, 0, MAX_STRING_CHARS, string, ui_color )
166
159
167
160
#define HUD_DrawAltString (x , y , string ) \
168
- CG_DrawString(x, y, UI_XORCOLOR, MAX_STRING_CHARS, string)
161
+ CG_DrawString(x, y, UI_XORCOLOR, MAX_STRING_CHARS, string, ui_color )
169
162
170
163
#define HUD_DrawCenterString (x , y , string ) \
171
- CG_DrawStringMulti(x, y, UI_CENTER, MAX_STRING_CHARS, string)
164
+ CG_DrawStringMulti(x, y, UI_CENTER, MAX_STRING_CHARS, string, ui_color )
172
165
173
166
#define HUD_DrawAltCenterString (x , y , string ) \
174
- CG_DrawStringMulti(x, y, UI_CENTER | UI_XORCOLOR, MAX_STRING_CHARS, string)
167
+ CG_DrawStringMulti(x, y, UI_CENTER | UI_XORCOLOR, MAX_STRING_CHARS, string, ui_color )
175
168
176
169
#define HUD_DrawRightString (x , y , string ) \
177
- CG_DrawStringEx(x, y, UI_RIGHT, MAX_STRING_CHARS, string)
170
+ CG_DrawStringEx(x, y, UI_RIGHT, MAX_STRING_CHARS, string, ui_color )
178
171
179
172
#define HUD_DrawAltRightString (x , y , string ) \
180
- CG_DrawStringEx(x, y, UI_RIGHT | UI_XORCOLOR, MAX_STRING_CHARS, string)
173
+ CG_DrawStringEx(x, y, UI_RIGHT | UI_XORCOLOR, MAX_STRING_CHARS, string, ui_color )
181
174
182
175
static const char field_pic [] = "field_3" ;
183
176
static const char inven_pic [] = "inventory" ;
@@ -708,7 +701,7 @@ static void SCR_ExecuteLayoutString(vrect_t hud_vrect, const char *s, int32_t pl
708
701
709
702
token = COM_Parse (& s );
710
703
if (SCR_ParseColor (token , & color )) {
711
- cgix . SetColor ( color ) ;
704
+ ui_color = color ;
712
705
}
713
706
continue ;
714
707
}
@@ -734,7 +727,7 @@ static void SCR_ExecuteLayoutString(vrect_t hud_vrect, const char *s, int32_t pl
734
727
}
735
728
}
736
729
737
- cgix . ClearColor () ;
730
+ ui_color = COLOR_WHITE ;
738
731
}
739
732
740
733
// The status bar is a small layout program that is based on the stats array
@@ -849,14 +842,13 @@ static void SCR_DrawCenterString(vrect_t hud_vrect)
849
842
return ;
850
843
}
851
844
852
- cgix .SetAlpha (alpha );
845
+ color_t color = ui_color ;
846
+ color .a *= alpha ;
853
847
854
848
y = hud_vrect .height / 4 - scr_center_lines * 8 / 2 ;
855
849
856
850
CG_DrawStringMulti (hud_vrect .width / 2 , y , UI_CENTER ,
857
- MAX_STRING_CHARS , scr_centerstring );
858
-
859
- cgix .ClearColor ();
851
+ MAX_STRING_CHARS , scr_centerstring , color );
860
852
}
861
853
862
854
static void CGC_DrawHUD (int32_t isplit , const cg_server_data_t * data , vrect_t hud_vrect , vrect_t hud_safe , int32_t scale , int32_t playernum , const player_state_t * ps )
0 commit comments