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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user