mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
Improve minimap
This commit is contained in:
@@ -218,6 +218,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setIconHeight", &UIWidget::setIconHeight);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setIconSize", &UIWidget::setIconSize);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setIconRect", &UIWidget::setIconRect);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setIconClip", &UIWidget::setIconClip);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setBorderWidth", &UIWidget::setBorderWidth);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthTop", &UIWidget::setBorderWidthTop);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthRight", &UIWidget::setBorderWidthRight);
|
||||
@@ -267,6 +268,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getIconHeight", &UIWidget::getIconHeight);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getIconSize", &UIWidget::getIconSize);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getIconRect", &UIWidget::getIconRect);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getIconClip", &UIWidget::getIconClip);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getBorderTopColor", &UIWidget::getBorderTopColor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getBorderRightColor", &UIWidget::getBorderRightColor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getBorderBottomColor", &UIWidget::getBorderBottomColor);
|
||||
|
@@ -278,6 +278,7 @@ protected:
|
||||
TexturePtr m_icon;
|
||||
Color m_iconColor;
|
||||
Rect m_iconRect;
|
||||
Rect m_iconClipRect;
|
||||
EdgeGroup<Color> m_borderColor;
|
||||
EdgeGroup<int> m_borderWidth;
|
||||
EdgeGroup<int> m_margin;
|
||||
@@ -311,6 +312,7 @@ public:
|
||||
void setIconHeight(int height) { m_iconRect.setHeight(height); }
|
||||
void setIconSize(const Size& size) { m_iconRect.resize(size); }
|
||||
void setIconRect(const Rect& rect) { m_iconRect = rect; }
|
||||
void setIconClip(const Rect& rect) { m_iconClipRect = rect; }
|
||||
void setBorderWidth(int width) { m_borderWidth.set(width); updateLayout(); }
|
||||
void setBorderWidthTop(int width) { m_borderWidth.top = width; }
|
||||
void setBorderWidthRight(int width) { m_borderWidth.right = width; }
|
||||
@@ -361,6 +363,7 @@ public:
|
||||
int getIconHeight() { return m_iconRect.height(); }
|
||||
Size getIconSize() { return m_iconRect.size(); }
|
||||
Rect getIconRect() { return m_iconRect; }
|
||||
Rect getIconClip() { return m_iconClipRect; }
|
||||
Color getBorderTopColor() { return m_borderColor.top; }
|
||||
Color getBorderRightColor() { return m_borderColor.right; }
|
||||
Color getBorderBottomColor() { return m_borderColor.bottom; }
|
||||
|
@@ -100,6 +100,8 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
setIconSize(node->value<Size>());
|
||||
else if(node->tag() == "icon-rect")
|
||||
setIconRect(node->value<Rect>());
|
||||
else if(node->tag() == "icon-clip")
|
||||
setIconClip(node->value<Rect>());
|
||||
else if(node->tag() == "opacity")
|
||||
setOpacity(node->value<float>());
|
||||
else if(node->tag() == "enabled")
|
||||
@@ -369,15 +371,17 @@ void UIWidget::drawIcon(const Rect& screenCoords)
|
||||
drawRect.translate(m_iconRect.topLeft());
|
||||
drawRect.resize(m_iconRect.size());
|
||||
} else {
|
||||
drawRect.resize(m_icon->getSize());
|
||||
drawRect.resize(m_iconClipRect.size());
|
||||
drawRect.moveCenter(screenCoords.center());
|
||||
}
|
||||
g_painter->setColor(m_iconColor);
|
||||
g_painter->drawTexturedRect(drawRect, m_icon);
|
||||
g_painter->drawTexturedRect(drawRect, m_icon, m_iconClipRect);
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::setIcon(const std::string& iconFile)
|
||||
{
|
||||
m_icon = g_textures.getTexture(iconFile);
|
||||
if(!m_iconClipRect.isValid())
|
||||
m_iconClipRect = Rect(0, 0, m_icon->getSize());
|
||||
}
|
||||
|
Reference in New Issue
Block a user