diff --git a/src/client/map.cpp b/src/client/map.cpp index 0ca1070d8..cf1e23d1e 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -23,6 +23,7 @@ #include "map.h" #include "animatedtext.h" +#include "client/const.h" #include "creatures.h" #include "game.h" #include "gameconfig.h" @@ -1249,7 +1250,7 @@ bool Map::removeAttachedWidgetFromObject(const UIWidgetPtr& widget) { void Map::updateAttachedWidgets(const MapViewPtr& mapView) { - g_drawPool.select(DrawPoolType::MAP); + bool should_repaint = false; for (const auto& [widget, object] : m_attachedObjectWidgetMap) { if (widget->isDestroyed()) { continue; @@ -1300,9 +1301,16 @@ void Map::updateAttachedWidgets(const MapViewPtr& mapView) const auto& widgetRect = widget->getRect(); const auto& newWidgetRect = Rect(p, widgetRect.width(), widgetRect.height()); - widget->disableUpdateTemporarily(); - widget->setRect(newWidgetRect); + if (widgetRect != newWidgetRect) { + widget->disableUpdateTemporarily(); + widget->setRect(newWidgetRect); + should_repaint = true; + } } + + // only repaint if some widget changed position on the screen + if (should_repaint) + g_drawPool.repaint(DrawPoolType::FOREGROUND); } std::map> Map::findEveryPath(const Position& start, int maxDistance, const std::map& params) diff --git a/src/framework/core/graphicalapplication.cpp b/src/framework/core/graphicalapplication.cpp index a7d49868a..5b7bf767b 100644 --- a/src/framework/core/graphicalapplication.cpp +++ b/src/framework/core/graphicalapplication.cpp @@ -169,7 +169,8 @@ bool GraphicalApplication::canDrawMap() const { if (!m_drawEvents->canDraw(MAP)) return false; - static constexpr std::array types{ MAP, LIGHT, FOREGROUND_MAP, CREATURE_INFORMATION }; + // FOREGROUND is here only because of attached widgets on the map (like tile widgets) + static constexpr std::array types{ MAP, LIGHT, FOREGROUND_MAP, CREATURE_INFORMATION, FOREGROUND }; for (DrawPoolType type : types) { if (g_drawPool.isDrawing(type)) @@ -212,7 +213,7 @@ void GraphicalApplication::run() continue; } - { + if (g_game.isOnline()) { AutoStat s(STATS_RENDER, "DrawPreload"); m_drawEvents->preLoad(); } @@ -222,11 +223,13 @@ void GraphicalApplication::run() if (!g_game.isOnline() && canDrawForeground) { AutoStat s(STATS_RENDER, "DrawForegroundUI"); g_ui.render(DrawPoolType::FOREGROUND); - } else if (canDrawMap() && canDrawForeground) { - tasks.emplace_back(g_asyncDispatcher->submit_task([] { - AutoStat s(STATS_RENDER, "DrawForegroundUI"); - g_ui.render(DrawPoolType::FOREGROUND); - })); + } else if (canDrawMap()) { + if (canDrawForeground) { + tasks.emplace_back(g_asyncDispatcher->submit_task([] { + AutoStat s(STATS_RENDER, "DrawForegroundUI"); + g_ui.render(DrawPoolType::FOREGROUND); + })); + } static constexpr std::array types{ DrawPoolType::LIGHT, DrawPoolType::FOREGROUND_MAP }; for (const auto type : types) { diff --git a/src/framework/graphics/drawpool.cpp b/src/framework/graphics/drawpool.cpp index 229b28ca1..4f62766b5 100644 --- a/src/framework/graphics/drawpool.cpp +++ b/src/framework/graphics/drawpool.cpp @@ -524,4 +524,4 @@ std::shared_ptr DrawPool::getCoordsBuffer() { delete ptr; } }); -} \ No newline at end of file +}