mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
commit
eac208c9e0
|
@ -41,16 +41,12 @@ std::string RatingComponent::getValue() const
|
|||
void RatingComponent::setOpacity(unsigned char opacity)
|
||||
{
|
||||
mOpacity = opacity;
|
||||
mColorShift = (mColorShift >> 8 << 8) | mOpacity;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
void RatingComponent::setColorShift(unsigned int color)
|
||||
{
|
||||
mColorShift = color;
|
||||
// Grab the opacity from the color shift because we may need to apply it if
|
||||
// fading textures in
|
||||
mOpacity = color & 0xff;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
|
@ -75,21 +71,22 @@ void RatingComponent::onSizeChanged()
|
|||
|
||||
void RatingComponent::updateVertices()
|
||||
{
|
||||
const float numStars = NUM_RATING_STARS;
|
||||
const float h = getSize().y(); // is the same as a single star's width
|
||||
const float w = getSize().y() * mValue * numStars;
|
||||
const float fw = getSize().y() * numStars;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const float numStars = NUM_RATING_STARS;
|
||||
const float h = getSize().y(); // is the same as a single star's width
|
||||
const float w = getSize().y() * mValue * numStars;
|
||||
const float fw = getSize().y() * numStars;
|
||||
|
||||
mVertices[0] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, color };
|
||||
mVertices[1] = { { 0.0f, h }, { 0.0f, 0.0f }, color };
|
||||
mVertices[2] = { { w, 0.0f }, { mValue * numStars, 1.0f }, color };
|
||||
mVertices[3] = { { w, h }, { mValue * numStars, 0.0f }, color };
|
||||
mVertices[0] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, 0 };
|
||||
mVertices[1] = { { 0.0f, h }, { 0.0f, 0.0f }, 0 };
|
||||
mVertices[2] = { { w, 0.0f }, { mValue * numStars, 1.0f }, 0 };
|
||||
mVertices[3] = { { w, h }, { mValue * numStars, 0.0f }, 0 };
|
||||
|
||||
mVertices[4] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, color };
|
||||
mVertices[5] = { { 0.0f, h }, { 0.0f, 0.0f }, color };
|
||||
mVertices[6] = { { fw, 0.0f }, { numStars, 1.0f }, color };
|
||||
mVertices[7] = { { fw, h }, { numStars, 0.0f }, color };
|
||||
mVertices[4] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, 0 };
|
||||
mVertices[5] = { { 0.0f, h }, { 0.0f, 0.0f }, 0 };
|
||||
mVertices[6] = { { fw, 0.0f }, { numStars, 1.0f }, 0 };
|
||||
mVertices[7] = { { fw, h }, { numStars, 0.0f }, 0 };
|
||||
|
||||
updateColors();
|
||||
|
||||
// round vertices
|
||||
for(int i = 0; i < 8; ++i)
|
||||
|
@ -98,7 +95,8 @@ void RatingComponent::updateVertices()
|
|||
|
||||
void RatingComponent::updateColors()
|
||||
{
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const float opacity = mOpacity / 255.0;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift & 0xFFFFFF00 | (unsigned char)((mColorShift & 0xFF) * opacity));
|
||||
|
||||
for(int i = 0; i < 8; ++i)
|
||||
mVertices[i].col = color;
|
||||
|
|
|
@ -247,18 +247,13 @@ void ImageComponent::setFlipY(bool flip)
|
|||
void ImageComponent::setColorShift(unsigned int color)
|
||||
{
|
||||
mColorShift = color;
|
||||
// Grab the opacity from the color shift because we may need to apply it if
|
||||
// fading textures in
|
||||
mOpacity = color & 0xff;
|
||||
mColorShiftEnd = color;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
void ImageComponent::setColorShiftEnd(unsigned int color)
|
||||
{
|
||||
mColorShiftEnd = color;
|
||||
// Grab the opacity from the color shift because we may need to apply it if
|
||||
// fading textures in
|
||||
mOpacity = color & 0xff;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
|
@ -271,7 +266,6 @@ void ImageComponent::setColorGradientHorizontal(bool horizontal)
|
|||
void ImageComponent::setOpacity(unsigned char opacity)
|
||||
{
|
||||
mOpacity = opacity;
|
||||
mColorShift = (mColorShift >> 8 << 8) | mOpacity;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
|
@ -282,17 +276,17 @@ void ImageComponent::updateVertices()
|
|||
|
||||
// we go through this mess to make sure everything is properly rounded
|
||||
// if we just round vertices at the end, edge cases occur near sizes of 0.5
|
||||
const Vector2f topLeft = { mSize * mTopLeftCrop };
|
||||
const Vector2f bottomRight = { mSize * mBottomRightCrop };
|
||||
const float px = mTexture->isTiled() ? mSize.x() / getTextureSize().x() : 1.0f;
|
||||
const float py = mTexture->isTiled() ? mSize.y() / getTextureSize().y() : 1.0f;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd);
|
||||
const Vector2f topLeft = { mSize * mTopLeftCrop };
|
||||
const Vector2f bottomRight = { mSize * mBottomRightCrop };
|
||||
const float px = mTexture->isTiled() ? mSize.x() / getTextureSize().x() : 1.0f;
|
||||
const float py = mTexture->isTiled() ? mSize.y() / getTextureSize().y() : 1.0f;
|
||||
|
||||
mVertices[0] = { { topLeft.x(), topLeft.y() }, { mTopLeftCrop.x(), py - mTopLeftCrop.y() }, color };
|
||||
mVertices[1] = { { topLeft.x(), bottomRight.y() }, { mTopLeftCrop.x(), 1.0f - mBottomRightCrop.y() }, mColorGradientHorizontal ? colorEnd : color };
|
||||
mVertices[2] = { { bottomRight.x(), topLeft.y() }, { mBottomRightCrop.x() * px, py - mTopLeftCrop.y() }, mColorGradientHorizontal ? color : colorEnd };
|
||||
mVertices[3] = { { bottomRight.x(), bottomRight.y() }, { mBottomRightCrop.x() * px, 1.0f - mBottomRightCrop.y() }, color };
|
||||
mVertices[0] = { { topLeft.x(), topLeft.y() }, { mTopLeftCrop.x(), py - mTopLeftCrop.y() }, 0 };
|
||||
mVertices[1] = { { topLeft.x(), bottomRight.y() }, { mTopLeftCrop.x(), 1.0f - mBottomRightCrop.y() }, 0 };
|
||||
mVertices[2] = { { bottomRight.x(), topLeft.y() }, { mBottomRightCrop.x() * px, py - mTopLeftCrop.y() }, 0 };
|
||||
mVertices[3] = { { bottomRight.x(), bottomRight.y() }, { mBottomRightCrop.x() * px, 1.0f - mBottomRightCrop.y() }, 0 };
|
||||
|
||||
updateColors();
|
||||
|
||||
// round vertices
|
||||
for(int i = 0; i < 4; ++i)
|
||||
|
@ -313,12 +307,13 @@ void ImageComponent::updateVertices()
|
|||
|
||||
void ImageComponent::updateColors()
|
||||
{
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd);
|
||||
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift & 0xFFFFFF00 | (unsigned char)((mColorShift & 0xFF) * opacity));
|
||||
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd & 0xFFFFFF00 | (unsigned char)((mColorShiftEnd & 0xFF) * opacity));
|
||||
|
||||
mVertices[0].col = color;
|
||||
mVertices[1].col = mColorGradientHorizontal ? colorEnd : color;
|
||||
mVertices[2].col = mColorGradientHorizontal ? color : colorEnd;
|
||||
mVertices[2].col = mColorGradientHorizontal ? color : colorEnd;
|
||||
mVertices[3].col = colorEnd;
|
||||
}
|
||||
|
||||
|
@ -367,8 +362,6 @@ void ImageComponent::fadeIn(bool textureLoaded)
|
|||
// Start with a zero opacity and flag it as fading
|
||||
mFadeOpacity = 0;
|
||||
mFading = true;
|
||||
// Set the colours to be translucent
|
||||
mColorShift = (mColorShift >> 8 << 8) | 0;
|
||||
updateColors();
|
||||
}
|
||||
}
|
||||
|
@ -388,9 +381,6 @@ void ImageComponent::fadeIn(bool textureLoaded)
|
|||
{
|
||||
mFadeOpacity = (unsigned char)opacity;
|
||||
}
|
||||
// Apply the combination of the target opacity and current fade
|
||||
float newOpacity = (float)mOpacity * ((float)mFadeOpacity / 255.0f);
|
||||
mColorShift = (mColorShift >> 8 << 8) | (unsigned char)newOpacity;
|
||||
updateColors();
|
||||
}
|
||||
}
|
||||
|
@ -435,10 +425,7 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
if(properties & COLOR)
|
||||
{
|
||||
if(elem->has("color"))
|
||||
{
|
||||
setColorShift(elem->get<unsigned int>("color"));
|
||||
setColorShiftEnd(elem->get<unsigned int>("color"));
|
||||
}
|
||||
|
||||
if (elem->has("colorEnd"))
|
||||
setColorShiftEnd(elem->get<unsigned int>("colorEnd"));
|
||||
|
|
|
@ -29,7 +29,7 @@ void NinePatchComponent::updateColors()
|
|||
mVertices[i].col = edgeColor;
|
||||
|
||||
for(int i = 6*4; i < 6; ++i)
|
||||
mVertices[(6*4)+i].col = mCenterColor;
|
||||
mVertices[(6*4)+i].col = centerColor;
|
||||
}
|
||||
|
||||
void NinePatchComponent::buildVertices()
|
||||
|
|
Loading…
Reference in a new issue