mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 12:42:32 +00:00
[ui] Refresh hierarchy pointers
With the change to hierarchies being components, any pointers to the hierarchy component are not stable and must be refreshed after the possibility of adding or removing a hierarchy.
This commit is contained in:
parent
c2316a4173
commit
4d0c1c66b3
2 changed files with 14 additions and 7 deletions
|
@ -274,8 +274,13 @@ Text_PassageView (text_system_t textsys, view_t parent,
|
|||
}
|
||||
}
|
||||
ecs_system_t viewsys = { reg, textsys.view_base };
|
||||
if (Ent_HasComponent (h->ent[0], viewsys.base + view_href, viewsys.reg)) {
|
||||
Ent_RemoveComponent (h->ent[0], viewsys.base + view_href, viewsys.reg);
|
||||
h = Ent_GetComponent (passage->hierarchy, ecs_hierarchy, reg);
|
||||
}
|
||||
view_t passage_view = View_AddToEntity (h->ent[0], viewsys, parent,
|
||||
false);
|
||||
h = Ent_GetComponent (passage->hierarchy, ecs_hierarchy, reg);
|
||||
glyphref_t passage_ref = {};
|
||||
glyphobj_t *glyphs = malloc (glyph_count * sizeof (glyphobj_t));
|
||||
glyphnode_t *g = glyph_nodes;
|
||||
|
@ -285,11 +290,13 @@ Text_PassageView (text_system_t textsys, view_t parent,
|
|||
uint32_t paragraph = h->childIndex[0] + i;
|
||||
view_t paraview = View_AddToEntity (h->ent[paragraph], viewsys,
|
||||
passage_view, false);
|
||||
h = Ent_GetComponent (passage->hierarchy, ecs_hierarchy, reg);
|
||||
glyphref_t pararef = { .start = passage_ref.count };
|
||||
for (uint32_t j = 0; j < h->childCount[paragraph]; j++, g = g->next) {
|
||||
uint32_t to = h->childIndex[paragraph] + j;
|
||||
view_t textview = View_AddToEntity (h->ent[to], viewsys,
|
||||
paraview, false);
|
||||
h = Ent_GetComponent (passage->hierarchy, ecs_hierarchy, reg);
|
||||
configure_textview (textview, glyphs, g, passage_ref.count,
|
||||
c_glyphs);
|
||||
View_SetGravity (textview, grav_flow);
|
||||
|
|
|
@ -147,18 +147,18 @@ view_t
|
|||
View_AddToEntity (uint32_t ent, ecs_system_t viewsys, view_t parent, bool own)
|
||||
{
|
||||
uint32_t href_comp = viewsys.base + view_href;
|
||||
hierref_t *ref = Ent_AddComponent (ent, href_comp, viewsys.reg);
|
||||
hierref_t ref = {};
|
||||
|
||||
if (parent.reg && parent.id != nullent) {
|
||||
hierref_t pref = View_GetRef (parent);
|
||||
*ref = Hierarchy_InsertHierarchy (pref, nullhref, viewsys.reg);
|
||||
ref = Hierarchy_InsertHierarchy (pref, nullhref, viewsys.reg);
|
||||
} else {
|
||||
ref->id = Hierarchy_New (viewsys.reg, href_comp, &view_type, 1);
|
||||
ref->index = 0;
|
||||
ref.id = Hierarchy_New (viewsys.reg, href_comp, &view_type, 1);
|
||||
}
|
||||
hierarchy_t *h = Ent_GetComponent (ref->id, ecs_hierarchy, viewsys.reg);
|
||||
h->ent[ref->index] = ent;
|
||||
h->own[ref->index] = own;
|
||||
Ent_SetComponent (ent, href_comp, viewsys.reg, &ref);
|
||||
hierarchy_t *h = Ent_GetComponent (ref.id, ecs_hierarchy, viewsys.reg);
|
||||
h->ent[ref.index] = ent;
|
||||
h->own[ref.index] = own;
|
||||
return (view_t) { .reg = viewsys.reg, .id = ent, .comp = href_comp };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue