Skip to content

Commit b52aacb

Browse files
committed
PicButton: more accurate WON HL-like buttons when they greyed-off
1 parent 7162b7c commit b52aacb

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

Color.h

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ class CColor
3131
return color;
3232
}
3333

34+
inline CColor& operator =( CColor& c )
35+
{
36+
Set( c.rgba );
37+
return c;
38+
}
39+
3440
inline operator unsigned int() { return rgba; }
3541

3642
inline void Set( unsigned int color )

controls/PicButton.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -339,44 +339,42 @@ void CMenuPicButton::Draw( )
339339
{
340340
const uint heavy_blur_flags = ETF_NOSIZELIMIT | ETF_FORCECOL;
341341
const uint light_blur_flags = ETF_NOSIZELIMIT | ETF_FORCECOL | ETF_ADDITIVE;
342+
CColor light_blur_color, heavy_blur_color = colorBase;
342343
Point pos = m_scPos;
343344

345+
if( iFlags & QMF_GRAYED )
346+
light_blur_color = InterpColor( uiColorBlack, colorBase, 0.333f ); // because additive, tone down all channels
347+
else
348+
light_blur_color = colorBase;
349+
344350
pos.x += 7 * uiStatic.scaleX;
345351

346-
if( iFlags & QMF_GRAYED )
347-
{
348-
if( a > 0 )
349-
{
350-
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName,
351-
InterpColor( uiColorBlack, uiColorDkGrey, a / 255.0f ), m_scChSize, eTextAlignment, heavy_blur_flags );
352-
}
353-
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, uiColorDkGrey, m_scChSize, eTextAlignment, light_blur_flags );
354-
} else if( this != m_pParent->ItemAtCursor() )
352+
if( this != m_pParent->ItemAtCursor() )
355353
{
356354
if( a > 0 )
357355
{
358356
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName,
359-
InterpColor( uiColorBlack, colorBase, a / 255.0f ), m_scChSize, eTextAlignment, heavy_blur_flags );
357+
InterpColor( uiColorBlack, heavy_blur_color, a / 255.0f ), m_scChSize, eTextAlignment, heavy_blur_flags );
360358
}
361-
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, light_blur_flags );
359+
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, light_blur_color, m_scChSize, eTextAlignment, light_blur_flags );
362360
}
363361
else if( m_bPressed )
364362
{
365-
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, heavy_blur_flags );
363+
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName, heavy_blur_color, m_scChSize, eTextAlignment, heavy_blur_flags );
366364
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, 0xFF000000, m_scChSize, eTextAlignment, light_blur_flags & ( ~ETF_ADDITIVE ));
367365
}
368366
else if( eFocusAnimation == QM_HIGHLIGHTIFFOCUS )
369367
{
370-
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, heavy_blur_flags );
371-
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, light_blur_flags );
368+
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName, heavy_blur_color, m_scChSize, eTextAlignment, heavy_blur_flags );
369+
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, light_blur_color, m_scChSize, eTextAlignment, light_blur_flags );
372370
}
373371
else if( eFocusAnimation == QM_PULSEIFFOCUS )
374372
{
375373
float pulsar = 0.5f + 0.5f * sin( (float)uiStatic.realTime / UI_PULSE_DIVISOR );
376374

377375
UI_DrawString( uiStatic.hHeavyBlur, pos, m_scSize, szName,
378-
InterpColor( uiColorBlack, colorBase, pulsar ), m_scChSize, eTextAlignment, heavy_blur_flags );
379-
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, light_blur_flags );
376+
InterpColor( uiColorBlack, heavy_blur_color, pulsar ), m_scChSize, eTextAlignment, heavy_blur_flags );
377+
UI_DrawString( uiStatic.hLightBlur, pos, m_scSize, szName, light_blur_color, m_scChSize, eTextAlignment, light_blur_flags );
380378
}
381379
}
382380
else

0 commit comments

Comments
 (0)