Remove some BUI boilerplate (#28399)

* Remove some BUI boilerplate

- The disposals overrides got removed due to the helper method handling it.
- Replace window creation with CreateWindow helper.
- Fixed some stinky code which would cause exceptions.

* More

* moar

* weh

* done

* More BUIs

* More updates

* weh

* moar

* look who it is

* weh

* merge

* weh

* fixes
This commit is contained in:
metalgearsloth
2024-07-20 15:40:16 +10:00
committed by GitHub
parent 4aba9ec131
commit cbf329a82d
137 changed files with 1094 additions and 1753 deletions

View File

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