fix: handle DTR node removals when reloading plugins (fixes #759)

This commit is contained in:
goat 2022-02-14 01:39:25 +01:00
parent aac5cdfef7
commit 5cb693e834
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
2 changed files with 20 additions and 8 deletions

View file

@ -74,6 +74,19 @@ namespace Dalamud.Game.Gui.Dtr
Service<Framework>.Get().Update -= this.Update;
}
/// <summary>
/// Remove nodes marked as "should be removed" from the bar.
/// </summary>
internal void HandleRemovedNodes()
{
foreach (var data in this.entries.Where(d => d.ShouldBeRemoved))
{
this.RemoveNode(data.TextNode);
}
this.entries.RemoveAll(d => d.ShouldBeRemoved);
}
/// <summary>
/// Check whether an entry with the specified title exists.
/// </summary>
@ -123,12 +136,7 @@ namespace Dalamud.Game.Gui.Dtr
var dtr = GetDtr();
if (dtr == null) return;
foreach (var data in this.entries.Where(d => d.ShouldBeRemoved))
{
this.RemoveNode(data.TextNode);
}
this.entries.RemoveAll(d => d.ShouldBeRemoved);
this.HandleRemovedNodes();
// The collision node on the DTR element is always the width of its content
if (dtr->UldManager.NodeList == null) return;
@ -206,7 +214,7 @@ namespace Dalamud.Game.Gui.Dtr
var dtr = GetDtr();
if (dtr == null || dtr->RootNode == null) return false;
for (int i = 0; i < dtr->UldManager.NodeListCount; i++)
for (var i = 0; i < dtr->UldManager.NodeListCount; i++)
{
if (dtr->UldManager.NodeList[i]->NodeID > 1000)
return true;