diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 3bc6e733e2..29a2c9e65f 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -68,7 +68,8 @@ enum FlagProp : uint32_t PropImageFixedRatio = 1 << 19, PropImageRepeated = 1 << 20, PropImageSmooth = 1 << 21, - PropImageAutoResize = 1 << 22 + PropImageAutoResize = 1 << 22, + propImageIndividualAnimation = 1 << 23 }; // @bindclass @@ -462,6 +463,8 @@ class UIWidget : public LuaObject Rect m_imageRect; Color m_imageColor{ Color::white }; Point m_iconOffset; + Timer m_imageAnimatorTimer; + uint32_t m_currentFrame{ 0 }; EdgeGroup m_imageBorder; @@ -480,6 +483,7 @@ class UIWidget : public LuaObject void setImageRepeated(bool repeated) { setProp(PropImageRepeated, repeated); updateImageCache(); } void setImageSmooth(bool smooth) { setProp(PropImageSmooth, smooth); } void setImageAutoResize(bool autoResize) { setProp(PropImageAutoResize, autoResize); } + void setImageIndividualAnimation(bool v) { setProp(propImageIndividualAnimation, v); } void setImageBorderTop(int border) { m_imageBorder.top = border; configureBorderImage(); } void setImageBorderRight(int border) { m_imageBorder.right = border; configureBorderImage(); } void setImageBorderBottom(int border) { m_imageBorder.bottom = border; configureBorderImage(); } @@ -499,6 +503,7 @@ class UIWidget : public LuaObject bool isImageFixedRatio() { return hasProp(PropImageFixedRatio); } bool isImageSmooth() { return hasProp(PropImageSmooth); } bool isImageAutoResize() { return hasProp(PropImageAutoResize); } + bool isImageIndividualAnimation() { return hasProp(propImageIndividualAnimation); } int getImageBorderTop() { return m_imageBorder.top; } int getImageBorderRight() { return m_imageBorder.right; } int getImageBorderBottom() { return m_imageBorder.bottom; } diff --git a/src/framework/ui/uiwidgetimage.cpp b/src/framework/ui/uiwidgetimage.cpp index bfb60d3f95..a85385d621 100644 --- a/src/framework/ui/uiwidgetimage.cpp +++ b/src/framework/ui/uiwidgetimage.cpp @@ -71,6 +71,8 @@ void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode) setImageBorder(node->value()); else if (node->tag() == "image-auto-resize") setImageAutoResize(node->value()); + else if (node->tag() == "image-individual-animation") + setImageIndividualAnimation(node->value()); } } @@ -164,6 +166,9 @@ void UIWidget::drawImage(const Rect& screenCoords) //m_imageTexture->setSmooth(m_imageSmooth); const bool useRepeated = hasProp(PropImageBordered) || hasProp(PropImageRepeated); for (const auto& [dest, src] : m_imageCoordsCache) { + const auto& texture = m_imageTexture->isAnimatedTexture() && isImageIndividualAnimation() ? + std::static_pointer_cast(m_imageTexture)->get(m_currentFrame, m_imageAnimatorTimer) : m_imageTexture; + if (useRepeated) g_drawPool.addTexturedRepeatedRect(dest, m_imageTexture, src, m_imageColor); else