Skip to content

Commit

Permalink
Debugger: Tilemap viewer - Fixed crash caused by the new separators i…
Browse files Browse the repository at this point in the history
…n tooltips
  • Loading branch information
SourMesen committed Jul 1, 2024
1 parent ed4d97b commit 990b99f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion UI/Debugger/Controls/DynamicTooltip.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@

<UserControl.DataTemplates>
<DataTemplate DataType="dc:TooltipSeparator">
<Rectangle Height="1" Fill="{StaticResource MesenGrayBorderColor}" Margin="5 3" />
<Rectangle
Height="1"
Fill="{StaticResource MesenGrayBorderColor}"
Margin="5 3"
IsVisible="{Binding !Hidden}"
/>
</DataTemplate>

<DataTemplate DataType="dc:CustomTooltipEntry">
Expand Down
16 changes: 9 additions & 7 deletions UI/Debugger/Controls/DynamicTooltip.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public CustomTooltipEntry(string name, object value, bool useMonoFont = false) :

public class TooltipSeparator : TooltipEntry
{
[Reactive] public bool Hidden { get; set; } = false;

public TooltipSeparator(string name) : base(name, false, false)
{
}
Expand Down Expand Up @@ -176,12 +178,7 @@ public void AddCustomEntry(string name, Control value)

public void AddSeparator(string name)
{
if(this.Count > _updatedKeys.Count - 1 && this[_updatedKeys.Count - 1] is TooltipSeparator) {
return;
}

_updatedKeys.Add(name);

if(!_entries.TryGetValue(name, out _)) {
TooltipEntry? entry = new TooltipSeparator(name);
_entries[name] = entry;
Expand Down Expand Up @@ -231,8 +228,13 @@ public void EndUpdate()
}
}

while(this.Count > 0 && this[^1] is TooltipSeparator) {
RemoveAt(this.Count - 1);
for(int i = 0; i < Count; i++) {
if(this[i] is TooltipSeparator sep) {
bool hideSeparator = (i < Count - 1 && this[i + 1] is TooltipSeparator) || i == Count - 1;
if(sep.Hidden != hideSeparator) {
sep.Hidden = hideSeparator;
}
}
}

if(updated) {
Expand Down

0 comments on commit 990b99f

Please sign in to comment.