Index: binaries/data/mods/public/gui/session/minimap/MiniMap.xml =================================================================== --- binaries/data/mods/public/gui/session/minimap/MiniMap.xml +++ binaries/data/mods/public/gui/session/minimap/MiniMap.xml @@ -5,7 +5,7 @@ type="image" > - + +void CollectVisibleObjectsRecursively(const std::vector& objects, Container* visibleObjects) +{ + for (IGUIObject* const& object : objects) + { + if (!object->IsHidden()) + { + visibleObjects->emplace_back(object); + CollectVisibleObjectsRecursively(object->GetChildren(), visibleObjects); + } + } +} + +} // anonynous namespace + CGUI::CGUI(const shared_ptr& context) : m_BaseObject(std::make_unique(*this)), m_FocusedObject(nullptr), @@ -302,7 +322,20 @@ // drawn on top of everything else glClear(GL_DEPTH_BUFFER_BIT); - m_BaseObject->RecurseObject(&IGUIObject::IsHidden, &IGUIObject::Draw); + using Arena = Allocators::DynamicArena<128 * KiB>; + using ObjectListAllocator = ProxyAllocator; + Arena arena; + + std::vector visibleObjects((ObjectListAllocator(arena))); + CollectVisibleObjectsRecursively(m_BaseObject->GetChildren(), &visibleObjects); + + std::sort(visibleObjects.begin(), visibleObjects.end(), [](const IGUIObject* object1, const IGUIObject* object2) -> bool { + if (object1->GetBufferedZ() != object2->GetBufferedZ()) + return object1->GetBufferedZ() < object2->GetBufferedZ(); + return object1 < object2; + }); + for (IGUIObject* const& object : visibleObjects) + object->Draw(); } void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, const float& Z, const CRect& Rect, const CRect& UNUSED(Clipping)) Index: source/gui/ObjectTypes/CTooltip.h =================================================================== --- source/gui/ObjectTypes/CTooltip.h +++ source/gui/ObjectTypes/CTooltip.h @@ -50,6 +50,8 @@ virtual void Draw(); + virtual float GetBufferedZ() const; + // Settings float m_BufferZone; CGUIString m_Caption; Index: source/gui/ObjectTypes/CTooltip.cpp =================================================================== --- source/gui/ObjectTypes/CTooltip.cpp +++ source/gui/ObjectTypes/CTooltip.cpp @@ -147,8 +147,6 @@ void CTooltip::Draw() { - float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else - // Normally IGUITextOwner will handle this updating but since SetupText can modify the position // we need to call it now *before* we do the rest of the drawing if (!m_GeneratedTextsValid) @@ -157,7 +155,13 @@ m_GeneratedTextsValid = true; } - m_pGUI.DrawSprite(m_Sprite, z, m_CachedActualSize); + m_pGUI.DrawSprite(m_Sprite, GetBufferedZ(), m_CachedActualSize); + + DrawText(0, m_TextColor, m_CachedActualSize.TopLeft(), GetBufferedZ() + 0.1f); +} - DrawText(0, m_TextColor, m_CachedActualSize.TopLeft(), z + 0.1f); +float CTooltip::GetBufferedZ() const +{ + // TODO: Find a nicer way of putting the tooltip on top of everything else. + return 900.f; }