diff --git a/include/eepp/graphics/ctextcache.hpp b/include/eepp/graphics/ctextcache.hpp index d12c3b2ee..7cbca2d5b 100644 --- a/include/eepp/graphics/ctextcache.hpp +++ b/include/eepp/graphics/ctextcache.hpp @@ -57,6 +57,10 @@ class EE_API cTextCache { /** Set the color of the string rendered */ void Color(const eeColorA& color); + /** @see Set the alpha of each individual character. + ** This doesn't break any custom color per-character setted. */ + void Alpha( const Uint8& alpha ); + /** Set the color of the substring * @param color The color * @param from The first char to change the color diff --git a/src/eepp/graphics/ctextcache.cpp b/src/eepp/graphics/ctextcache.cpp index 0c43af62a..2214c7d11 100644 --- a/src/eepp/graphics/ctextcache.cpp +++ b/src/eepp/graphics/ctextcache.cpp @@ -84,6 +84,13 @@ const eeColorA& cTextCache::Color() const { return mFontColor; } +void cTextCache::Alpha( const Uint8& alpha ) { + std::size_t s = mText.size(); + for ( Uint32 i = 0; i < s; i++ ) { + mColors[ i ].Alpha = alpha; + } +} + void cTextCache::Color( const eeColorA& color ) { if ( mFontColor != color ) { mFontColor = color; diff --git a/src/eepp/ui/cuitextbox.cpp b/src/eepp/ui/cuitextbox.cpp index 40c39f077..c81c0bd4d 100644 --- a/src/eepp/ui/cuitextbox.cpp +++ b/src/eepp/ui/cuitextbox.cpp @@ -104,6 +104,8 @@ const eeColorA& cUITextBox::Color() const { void cUITextBox::Color( const eeColorA& color ) { mFontColor = color; + mTextCache->Color( color ); + Alpha( color.A() ); } @@ -113,7 +115,6 @@ const eeColorA& cUITextBox::ShadowColor() const { void cUITextBox::ShadowColor( const eeColorA& color ) { mFontShadowColor = color; - Alpha( color.A() ); mTextCache->ShadowColor( mFontColor ); } @@ -122,7 +123,7 @@ void cUITextBox::Alpha( const eeFloat& alpha ) { mFontColor.Alpha = (Uint8)alpha; mFontShadowColor.Alpha = (Uint8)alpha; - mTextCache->Color( mFontColor ); + mTextCache->Alpha( mFontColor.Alpha ); } void cUITextBox::AutoShrink() { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index ee4df8c7c..cfe436c69 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -252,7 +252,7 @@ void cEETest::CreateUI() { eePRINTL( "Texture Atlas Loading Time: %4.3f ms.", TE.Elapsed().AsMilliseconds() ); - cUIManager::instance()->Init(UI_MANAGER_HIGHLIGHT_FOCUS); //UI_MANAGER_HIGHLIGHT_FOCUS | UI_MANAGER_HIGHLIGHT_OVER + cUIManager::instance()->Init(); //UI_MANAGER_HIGHLIGHT_FOCUS | UI_MANAGER_HIGHLIGHT_OVER //mTheme = cUITheme::LoadFromPath( eeNew( cUIDefaultTheme, ( "uitheme", "uitheme" ) ), MyPath + "uitheme/" );