Skip to content

Commit

Permalink
Fixed an issue where TextCoords weren't properly updating when set th…
Browse files Browse the repository at this point in the history
…rough a conditional template path (Uninteractable, Hovered, Clicked... etc)

FIxed an issue where NineSliceCoords would not be set additively from conditional template paths
  • Loading branch information
NixAJ committed Sep 17, 2024
1 parent 16759a1 commit a958dc7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace ECS::Systems::UI
{
void UpdateBoundingRects::Update(entt::registry& registry, f32 deltaTime)
{
registry.clear<Components::UI::DirtyWidgetTransform>();

auto& transform2DSystem = ECS::Transform2DSystem::Get(registry);

// Dirty transforms
Expand Down
10 changes: 10 additions & 0 deletions Source/Game-Lib/Game-Lib/ECS/Util/UIUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ namespace ECS::Util

panelTemplateComp = panelTemplate;

if (panelTemplateComp.setFlags.texCoords)
{
registry->get_or_emplace<ECS::Components::UI::DirtyWidgetTransform>(entity);
}

registry->get_or_emplace<ECS::Components::UI::DirtyWidgetData>(entity);
}
else if (widget.type == ECS::Components::UI::WidgetType::Text)
Expand Down Expand Up @@ -379,6 +384,11 @@ namespace ECS::Util
if (panelTemplate.setFlags.texCoords)
{
panelTemplateComp.texCoords = panelTemplate.texCoords;
registry->get_or_emplace<ECS::Components::UI::DirtyWidgetTransform>(entity);
}
if (panelTemplate.setFlags.nineSliceCoords)
{
panelTemplateComp.nineSliceCoords = panelTemplate.nineSliceCoords;
}

registry->get_or_emplace<ECS::Components::UI::DirtyWidgetData>(entity);
Expand Down
25 changes: 13 additions & 12 deletions Source/Game-Lib/Game-Lib/Rendering/Canvas/CanvasRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ void CanvasRenderer::Update(f32 deltaTime)
entt::registry* registry = ServiceLocator::GetEnttRegistries()->uiRegistry;
ECS::Singletons::UISingleton& uiSingleton = registry->ctx().get<ECS::Singletons::UISingleton>();

// Dirty widget flags
registry->view<Widget, EventInputInfo, DirtyWidgetFlags>().each([&](entt::entity entity, Widget& widget, EventInputInfo& eventInputInfo)
{
bool wasInteractable = eventInputInfo.isInteractable;
eventInputInfo.isInteractable = (widget.flags & WidgetFlags::Interactable) == WidgetFlags::Interactable;

if (wasInteractable != eventInputInfo.isInteractable)
{
ECS::Util::UI::RefreshTemplate(registry, entity, eventInputInfo);
}
});

// Dirty transforms
registry->view<DirtyWidgetTransform>().each([&](entt::entity entity)
{
Expand All @@ -70,18 +82,7 @@ void CanvasRenderer::Update(f32 deltaTime)
UpdateTextVertices(transform, text, textTemplate);
}
});

// Dirty widget flags
registry->view<Widget, EventInputInfo, DirtyWidgetFlags>().each([&](entt::entity entity, Widget& widget, EventInputInfo& eventInputInfo)
{
bool wasInteractable = eventInputInfo.isInteractable;
eventInputInfo.isInteractable = (widget.flags & WidgetFlags::Interactable) == WidgetFlags::Interactable;

if (wasInteractable != eventInputInfo.isInteractable)
{
ECS::Util::UI::RefreshTemplate(registry, entity, eventInputInfo);
}
});
registry->clear<DirtyWidgetTransform>();

// Dirty widget datas
registry->view<DirtyWidgetData>().each([&](entt::entity entity)
Expand Down

0 comments on commit a958dc7

Please sign in to comment.