mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
bunch of optimizations
This commit is contained in:
@@ -47,7 +47,7 @@ void UIFrameCounter::draw()
|
||||
}
|
||||
m_frameCount++;
|
||||
|
||||
m_font->renderText(m_fpsText, m_rect, m_align, Fw::white);
|
||||
m_font->renderText(m_fpsText, m_rect, m_align, Color::white);
|
||||
}
|
||||
|
||||
void UIFrameCounter::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
|
||||
|
@@ -60,7 +60,7 @@ void UIWidget::draw()
|
||||
void UIWidget::drawSelf()
|
||||
{
|
||||
// draw style components in order
|
||||
if(m_backgroundColor.a() > 0) {
|
||||
if(m_backgroundColor.aF() != 0.0f) {
|
||||
Rect backgroundDestRect = m_rect;
|
||||
backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left);
|
||||
drawBackground(m_rect);
|
||||
@@ -92,10 +92,10 @@ void UIWidget::drawChildren()
|
||||
|
||||
// debug draw box
|
||||
if(g_ui.isDrawingDebugBoxes()) {
|
||||
g_painter.setColor(Fw::green);
|
||||
g_painter.setColor(Color::green);
|
||||
g_painter.drawBoundingRect(child->getRect());
|
||||
}
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Fw::red);
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Color::red);
|
||||
|
||||
g_painter.setOpacity(oldOpacity);
|
||||
}
|
||||
|
@@ -33,10 +33,10 @@
|
||||
|
||||
void UIWidget::initBaseStyle()
|
||||
{
|
||||
m_backgroundColor = Fw::alpha;
|
||||
m_borderColor.set(Fw::black);
|
||||
m_iconColor = Fw::white;
|
||||
m_color = Fw::white;
|
||||
m_backgroundColor = Color::alpha;
|
||||
m_borderColor.set(Color::black);
|
||||
m_iconColor = Color::white;
|
||||
m_color = Color::white;
|
||||
m_opacity = 1.0f;
|
||||
|
||||
// generate an unique id, this is need because anchored layouts find widgets by id
|
||||
@@ -312,7 +312,7 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
void UIWidget::drawBackground(const Rect& screenCoords)
|
||||
{
|
||||
if(m_backgroundColor.a() > 0) {
|
||||
if(m_backgroundColor.aF() != 0.0f) {
|
||||
Rect drawRect = screenCoords;
|
||||
drawRect.translate(m_backgroundRect.topLeft());
|
||||
if(m_backgroundRect.isValid())
|
||||
@@ -325,28 +325,28 @@ void UIWidget::drawBackground(const Rect& screenCoords)
|
||||
void UIWidget::drawBorder(const Rect& screenCoords)
|
||||
{
|
||||
// top
|
||||
if(m_borderWidth.top > 0 && m_borderColor.top.a() > 0) {
|
||||
if(m_borderWidth.top > 0 && m_borderColor.top.aF() != 0.0f) {
|
||||
g_painter.setColor(m_borderColor.top);
|
||||
|
||||
Rect borderRect(screenCoords.topLeft(), screenCoords.width(), m_borderWidth.top);
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// right
|
||||
if(m_borderWidth.right > 0 && m_borderColor.right.a() > 0) {
|
||||
if(m_borderWidth.right > 0 && m_borderColor.right.aF() != 0.0f) {
|
||||
g_painter.setColor(m_borderColor.right);
|
||||
|
||||
Rect borderRect(screenCoords.topRight() - Point(m_borderWidth.right - 1, 0), m_borderWidth.right, screenCoords.height());
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// bottom
|
||||
if(m_borderWidth.bottom > 0 && m_borderColor.bottom.a() > 0) {
|
||||
if(m_borderWidth.bottom > 0 && m_borderColor.bottom.aF() != 0.0f) {
|
||||
g_painter.setColor(m_borderColor.bottom);
|
||||
|
||||
Rect borderRect(screenCoords.bottomLeft() - Point(0, m_borderWidth.bottom - 1), screenCoords.width(), m_borderWidth.bottom);
|
||||
g_painter.drawFilledRect(borderRect);
|
||||
}
|
||||
// left
|
||||
if(m_borderWidth.left > 0 && m_borderColor.left.a() > 0) {
|
||||
if(m_borderWidth.left > 0 && m_borderColor.left.aF() != 0.0f) {
|
||||
g_painter.setColor(m_borderColor.left);
|
||||
|
||||
Rect borderRect(screenCoords.topLeft(), m_borderWidth.left, screenCoords.height());
|
||||
@@ -356,7 +356,7 @@ void UIWidget::drawBorder(const Rect& screenCoords)
|
||||
|
||||
void UIWidget::drawIcon(const Rect& screenCoords)
|
||||
{
|
||||
if(m_icon && m_iconColor.a() > 0) {
|
||||
if(m_icon && m_iconColor.aF() != 0.0f) {
|
||||
Rect drawRect;
|
||||
if(m_iconRect.isValid()) {
|
||||
drawRect = screenCoords;
|
||||
|
@@ -70,7 +70,7 @@ void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
void UIWidget::drawImage(const Rect& screenCoords)
|
||||
{
|
||||
if(!m_imageTexture || m_imageColor.a() == 0 || !screenCoords.isValid())
|
||||
if(!m_imageTexture || m_imageColor.aF() == 0.0f || !screenCoords.isValid())
|
||||
return;
|
||||
|
||||
// cache vertex buffers
|
||||
|
@@ -48,7 +48,7 @@ void UIWidget::parseTextStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
void UIWidget::drawText(const Rect& screenCoords)
|
||||
{
|
||||
if(m_text.length() == 0 || m_color.a() == 0)
|
||||
if(m_text.length() == 0 || m_color.aF() == 0.0f)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
@@ -66,7 +66,7 @@ void UIWidget::drawText(const Rect& screenCoords)
|
||||
virtualTextRect.translate(m_textOffset);
|
||||
g_painter.saveAndResetState();
|
||||
g_painter.setCompositionMode(Painter::CompositionMode_DestBlending);
|
||||
m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white);
|
||||
m_font->renderText(m_text, virtualTextRect, m_textAlign, Color::white);
|
||||
g_painter.restoreSavedState();
|
||||
m_textFramebuffer->release();
|
||||
|
||||
|
Reference in New Issue
Block a user