@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
8
8
9
9
This program is distributed in the hope that it will be useful,
10
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
12
13
13
See the GNU General Public License for more details.
14
14
@@ -34,22 +34,97 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34
34
35
35
#define MAX_PLAYERMODELS 100
36
36
37
- static struct
37
+ static const byte Orange[] = { 255 , 120 , 24 };
38
+ static const byte Yellow[] = { 225 , 180 , 24 };
39
+ static const byte Blue[] = { 0 , 60 , 255 };
40
+ static const byte Ltblue[] = { 0 , 167 , 255 };
41
+ static const byte Green[] = { 0 , 167 , 0 };
42
+ static const byte Red[] = { 255 , 43 , 0 };
43
+ static const byte Brown[] = { 123 , 73 , 0 };
44
+ static const byte Ltgray[] = { 100 , 100 , 100 };
45
+ static const byte Dkgray[] = { 36 , 36 , 36 };
46
+ static const byte Rainbow[] = {
47
+ 0xE4 , 0x03 , 0x03 ,
48
+ 0xFF , 0x8C , 0x00 ,
49
+ 0xFF , 0xED , 0x00 ,
50
+ 0x00 , 0x80 , 0x26 ,
51
+ 0x24 , 0x40 , 0x8E ,
52
+ 0x73 , 0x29 , 0x82 ,
53
+ };
54
+ static const byte Lesbian[] = {
55
+ 0xD5 , 0x2D , 0x00 ,
56
+ 0xEF , 0x76 , 0x27 ,
57
+ 0xFF , 0x9A , 0x56 ,
58
+ 0xFF , 0xFF , 0xFF ,
59
+ 0xD1 , 0x62 , 0xA4 ,
60
+ 0xB5 , 0x56 , 0x90 ,
61
+ 0xA3 , 0x02 , 0x62 ,
62
+ };
63
+ static const byte Gay[] = {
64
+ 0x07 , 0x8D , 0x70 ,
65
+ 0x26 , 0xCE , 0xAA ,
66
+ 0x98 , 0xE8 , 0xC1 ,
67
+ 0xFF , 0xFF , 0xFF ,
68
+ 0x7B , 0xAD , 0xE2 ,
69
+ 0x50 , 0x49 , 0xCC ,
70
+ 0x3D , 0x1A , 0x78 ,
71
+ };
72
+ static const byte Bi[] = {
73
+ 0xD6 , 0x02 , 0x70 ,
74
+ 0xD6 , 0x02 , 0x70 ,
75
+ 0x9B , 0x4F , 0x96 ,
76
+ 0x00 , 0x38 , 0xA8 ,
77
+ 0x00 , 0x38 , 0xA8 ,
78
+ };
79
+ static const byte Trans[] = {
80
+ 0x5B , 0xCE , 0xFA ,
81
+ 0xF5 , 0xA9 , 0xB8 ,
82
+ 0xFF , 0xFF , 0xFF ,
83
+ 0xF5 , 0xA9 , 0xB8 ,
84
+ 0x5B , 0xCE , 0xFA ,
85
+ };
86
+ static const byte Pan[] = {
87
+ 0xFF , 0x21 , 0x8C ,
88
+ 0xFF , 0xD8 , 0x00 ,
89
+ 0x21 , 0xB1 , 0xFF ,
90
+ };
91
+ static const byte Enby[] = {
92
+ 0xFC , 0xF4 , 0x34 ,
93
+ 0xFF , 0xFF , 0xFF ,
94
+ 0x9C , 0x59 , 0xD1 ,
95
+ 0x2C , 0x2C , 0x2C ,
96
+ };
97
+
98
+ #define FLAG_L ( str, x ) str, x, sizeof ( x ) / 3
99
+ #define FLAG ( x ) FLAG_L( #x, x )
100
+
101
+ // TODO: Get rid of this hardcoded mess
102
+ // allow user to set whatever they want
103
+ // through UI or some config lst file
104
+ static const struct logo_color_t
38
105
{
39
106
const char *name;
40
- int r, g, b;
107
+ const byte *rgb;
108
+ int stripes;
41
109
} g_LogoColors[] =
42
110
{
43
- { " FullColor" , -1 , -1 , -1 },
44
- { " #Valve_Orange" , 255 , 120 , 24 }, // L( "Valve_Orange" )
45
- { " #Valve_Yellow" , 225 , 180 , 24 }, // L( "Valve_Yellow" )
46
- { " #Valve_Blue" , 0 , 60 , 255 }, // L( "Valve_Blue" )
47
- { " #Valve_Ltblue" , 0 , 167 , 255 }, // L( "Valve_Ltblue" )
48
- { " #Valve_Green" , 0 , 167 , 0 }, // L( "Valve_Green" )
49
- { " #Valve_Red" , 255 , 43 , 0 }, // L( "Valve_Red" )
50
- { " #Valve_Brown" , 123 , 73 , 0 }, // L( "Valve_Brown" )
51
- { " #Valve_Ltgray" , 100 , 100 , 100 }, // L( "Valve_Ltgray" )
52
- { " #Valve_Dkgray" , 36 , 36 , 36 }, // L( "Valve_Dkgray" )
111
+ { " FullColor" , 0 , 0 },
112
+ { FLAG_L ( " #Valve_Orange" , Orange ) }, // L( "Valve_Orange" )
113
+ { FLAG_L ( " #Valve_Yellow" , Yellow ) }, // L( "Valve_Yellow" )
114
+ { FLAG_L ( " #Valve_Blue" , Blue ) }, // L( "Valve_Blue" )
115
+ { FLAG_L ( " #Valve_Ltblue" , Ltblue ) }, // L( "Valve_Ltblue" )
116
+ { FLAG_L ( " #Valve_Green" , Green ) }, // L( "Valve_Green" )
117
+ { FLAG_L ( " #Valve_Red" , Red ) }, // L( "Valve_Red" )
118
+ { FLAG_L ( " #Valve_Brown" , Brown ) }, // L( "Valve_Brown" )
119
+ { FLAG_L ( " #Valve_Ltgray" , Ltgray ) }, // L( "Valve_Ltgray" )
120
+ { FLAG_L ( " #Valve_Dkgray" , Dkgray ) }, // L( "Valve_Dkgray" )
121
+ { FLAG ( Rainbow ) },
122
+ { FLAG ( Lesbian ) },
123
+ { FLAG ( Gay ) },
124
+ { FLAG ( Bi ) },
125
+ { FLAG ( Trans ) },
126
+ { FLAG ( Pan ) },
127
+ { FLAG ( Enby ) },
53
128
};
54
129
55
130
class CMenuPlayerSetup : public CMenuFramework
@@ -116,7 +191,7 @@ class CMenuPlayerSetup : public CMenuFramework
116
191
{
117
192
public:
118
193
virtual void Draw ();
119
- int r, g, b ;
194
+ const logo_color_t *color ;
120
195
HIMAGE hImage;
121
196
} logoImage;
122
197
@@ -137,14 +212,40 @@ void CMenuPlayerSetup::CMenuLogoPreview::Draw()
137
212
138
213
UI_DrawString ( font, m_scPos, m_scSize, L ( " No logo" ), colorBase, m_scChSize, QM_CENTER, ETF_SHADOW );
139
214
}
140
- else
215
+ else if ( color-> stripes == 0 )
141
216
{
142
- if ( r != -1 && g != -1 && b != -1 )
143
- EngFuncs::PIC_Set ( hImage, r, g, b );
144
- else
145
- EngFuncs::PIC_Set ( hImage, 255 , 255 , 255 );
217
+ EngFuncs::PIC_Set ( hImage, 255 , 255 , 255 );
146
218
EngFuncs::PIC_DrawTrans ( m_scPos, m_scSize );
147
219
}
220
+ else
221
+ {
222
+ const Size img_sz = EngFuncs::PIC_Size ( hImage );
223
+ Size ui_sz = m_scSize;
224
+ wrect_t rc = { 0 };
225
+
226
+ rc.right = img_sz.w ;
227
+ rc.bottom = img_sz.h ;
228
+
229
+ double texture_pixels_per_stripe = img_sz.h / (double )color->stripes ;
230
+ double screen_pixels_per_stripe = ui_sz.h / (double )color->stripes ;
231
+
232
+ ui_sz.h = round ( screen_pixels_per_stripe );
233
+
234
+ for ( int i = 0 ; i < color->stripes ; i++ )
235
+ {
236
+ wrect_t rc2 = rc;
237
+ Point ui_pt;
238
+
239
+ rc2.top = round ( i * texture_pixels_per_stripe );
240
+ rc2.bottom = round (( i + 1 ) * texture_pixels_per_stripe );
241
+
242
+ ui_pt.x = m_scPos.x ;
243
+ ui_pt.y = m_scPos.y + round ( i * screen_pixels_per_stripe );
244
+
245
+ EngFuncs::PIC_Set ( hImage, color->rgb [i * 3 + 0 ], color->rgb [i * 3 + 1 ], color->rgb [i * 3 + 2 ] );
246
+ EngFuncs::PIC_DrawTrans ( ui_pt, ui_sz, &rc2 );
247
+ }
248
+ }
148
249
149
250
// draw the rectangle
150
251
if ( eFocusAnimation == QM_HIGHLIGHTIFFOCUS && IsCurrentSelected () )
@@ -164,7 +265,7 @@ void CMenuPlayerSetup::CModelListModel::Update( void )
164
265
char name[256 ];
165
266
char **filenames;
166
267
int numFiles, i;
167
-
268
+
168
269
m_iCount = 0 ;
169
270
170
271
// Get file list
@@ -183,12 +284,12 @@ void CMenuPlayerSetup::CModelListModel::Update( void )
183
284
{
184
285
COM_FileBase ( filenames[i], name );
185
286
Q_strncpy ( models[m_iCount], name, sizeof ( models[0 ] ) );
186
-
287
+
187
288
// check if the path is a valid model
188
289
snprintf ( name, sizeof ( name ), " models/player/%s/%s.mdl" , models[m_iCount], models[m_iCount] );
189
290
if ( !EngFuncs::FileExists ( name ) )
190
291
continue ;
191
-
292
+
192
293
m_iCount++;
193
294
}
194
295
}
@@ -219,10 +320,9 @@ void CMenuPlayerSetup::CLogosListModel::Update( )
219
320
{
220
321
CUtlString logoFileName = filenames[i];
221
322
char temp[256 ];
222
- bool png;
323
+ bool png = logoFileName. BEndsWithCaseless ( " .png " ) ;
223
324
224
- if (( png = logoFileName.BEndsWithCaseless ( " .png" )) ||
225
- logoFileName.BEndsWithCaseless ( " .bmp" ))
325
+ if ( png || logoFileName.BEndsWithCaseless ( " .bmp" ))
226
326
{
227
327
COM_FileBase ( logoFileName.String (), temp );
228
328
@@ -301,7 +401,7 @@ void CMenuPlayerSetup::UpdateLogo()
301
401
logoImage.hImage = EngFuncs::PIC_Load ( filename, 0 );
302
402
if ( logosModel.IsPng ( pos ))
303
403
{
304
- logoImage.r = logoImage. g = logoImage. b = - 1 ;
404
+ logoImage.color = &g_LogoColors[ 0 ] ;
305
405
logoColor.SetGrayed ( true );
306
406
}
307
407
else
@@ -314,7 +414,7 @@ void CMenuPlayerSetup::UpdateLogo()
314
414
}
315
415
else
316
416
{
317
- logoImage.r = logoImage. g = logoImage. b = - 1 ;
417
+ logoImage.color = &g_LogoColors[ 0 ] ;
318
418
logoColor.SetGrayed ( true );
319
419
}
320
420
delete bmpFile;
@@ -338,17 +438,13 @@ void CMenuPlayerSetup::ApplyColorToLogoPreview()
338
438
{
339
439
if ( !stricmp ( logoColorStr, L ( g_LogoColors[i].name )))
340
440
{
341
- logoImage.r = g_LogoColors[i].r ;
342
- logoImage.g = g_LogoColors[i].g ;
343
- logoImage.b = g_LogoColors[i].b ;
441
+ logoImage.color = &g_LogoColors[i];
344
442
return ;
345
443
}
346
444
}
347
445
348
446
logoColor.SetCurrentValue ( L ( g_LogoColors[0 ].name ) );
349
- logoImage.r = g_LogoColors[0 ].r ;
350
- logoImage.g = g_LogoColors[0 ].g ;
351
- logoImage.b = g_LogoColors[0 ].b ;
447
+ logoImage.color = &g_LogoColors[0 ];
352
448
}
353
449
354
450
void CMenuPlayerSetup::WriteNewLogo ( void )
@@ -386,8 +482,8 @@ void CMenuPlayerSetup::WriteNewLogo( void )
386
482
return ;
387
483
388
484
// remap logo if needed
389
- if ( logoImage.r != - 1 && logoImage. g != - 1 && logoImage. b != - 1 )
390
- bmpFile->RemapLogo ( logoImage.r , logoImage.g , logoImage. b );
485
+ if ( logoImage.color -> stripes >= 1 )
486
+ bmpFile->RemapLogo ( logoImage.color -> stripes , logoImage.color -> rgb );
391
487
392
488
EngFuncs::COM_SaveFile ( " logos/remapped.bmp" , bmpFile->GetBitmap (), bmpFile->GetBitmapHdr ()->fileSize );
393
489
EngFuncs::CvarSetString ( " cl_logoext" , " bmp" );
0 commit comments