Revert "Remove some BUI boilerplate" (#30214)

Revert "Remove some BUI boilerplate (#28399)"

This reverts commit cbf329a82d.
This commit is contained in:
Nemanja
2024-07-20 20:42:27 -04:00
committed by GitHub
parent 6d664c9157
commit cb0ba66be3
137 changed files with 1755 additions and 1096 deletions

View File

@@ -18,17 +18,18 @@ namespace Content.Client.Crayon.UI
[GenerateTypedNameReferences]
public sealed partial class CrayonWindow : DefaultWindow
{
public CrayonBoundUserInterface Owner { get; }
private Dictionary<string, Texture>? _decals;
private string? _selected;
private Color _color;
public event Action<Color>? OnColorSelected;
public event Action<string>? OnSelected;
public CrayonWindow()
public CrayonWindow(CrayonBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
Owner = owner;
Search.OnTextChanged += _ => RefreshList();
ColorSelector.OnColorChanged += SelectColor;
}
@@ -37,16 +38,16 @@ namespace Content.Client.Crayon.UI
{
_color = color;
OnColorSelected?.Invoke(color);
Owner.SelectColor(color);
RefreshList();
}
private void RefreshList()
{
// Clear
Grid.DisposeAllChildren();
if (_decals == null)
return;
Grid.RemoveAllChildren();
if (_decals == null) return;
var filter = Search.Text;
foreach (var (decal, tex) in _decals)
@@ -88,6 +89,7 @@ namespace Content.Client.Crayon.UI
{
if (obj.Button.Name == null) return;
Owner.Select(obj.Button.Name);
_selected = obj.Button.Name;
RefreshList();
}