Revert "Remove some BUI boilerplate" (#30214)
Revert "Remove some BUI boilerplate (#28399)"
This reverts commit cbf329a82d.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user