Improve stripping UI (#9768)
This commit is contained in:
@@ -1,64 +1,45 @@
|
||||
using System;
|
||||
using Content.Client.Stylesheets;
|
||||
using Robust.Client.UserInterface;
|
||||
using Content.Client.Inventory;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Timing;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
|
||||
namespace Content.Client.Strip
|
||||
{
|
||||
public sealed class StrippingMenu : DefaultWindow
|
||||
{
|
||||
private readonly BoxContainer _vboxContainer;
|
||||
public LayoutContainer InventoryContainer = new();
|
||||
public BoxContainer HandsContainer = new() { Orientation = LayoutOrientation.Horizontal };
|
||||
public BoxContainer SnareContainer = new();
|
||||
private StrippableBoundUserInterface _bui;
|
||||
public bool Dirty = true;
|
||||
|
||||
public StrippingMenu(string title)
|
||||
public StrippingMenu(string title, StrippableBoundUserInterface bui)
|
||||
{
|
||||
MinSize = SetSize = (400, 620);
|
||||
Title = title;
|
||||
_bui = bui;
|
||||
|
||||
_vboxContainer = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
VerticalExpand = true,
|
||||
SeparationOverride = 5,
|
||||
};
|
||||
|
||||
Contents.AddChild(_vboxContainer);
|
||||
var box = new BoxContainer() { Orientation = LayoutOrientation.Vertical, Margin = new Thickness(0, 8) };
|
||||
Contents.AddChild(box);
|
||||
box.AddChild(SnareContainer);
|
||||
box.AddChild(HandsContainer);
|
||||
box.AddChild(InventoryContainer);
|
||||
}
|
||||
|
||||
public void ClearButtons()
|
||||
{
|
||||
_vboxContainer.DisposeAllChildren();
|
||||
InventoryContainer.DisposeAllChildren();
|
||||
HandsContainer.DisposeAllChildren();
|
||||
SnareContainer.DisposeAllChildren();
|
||||
}
|
||||
|
||||
public void AddButton(string title, string name, Action<BaseButton.ButtonEventArgs> onPressed)
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
var button = new Button()
|
||||
{
|
||||
Text = name,
|
||||
StyleClasses = { StyleBase.ButtonOpenRight }
|
||||
};
|
||||
if (!Dirty)
|
||||
return;
|
||||
|
||||
button.OnPressed += onPressed;
|
||||
|
||||
_vboxContainer.AddChild(new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal,
|
||||
HorizontalExpand = true,
|
||||
SeparationOverride = 5,
|
||||
Children =
|
||||
{
|
||||
new Label()
|
||||
{
|
||||
Text = $"{title}:"
|
||||
},
|
||||
new Control()
|
||||
{
|
||||
HorizontalExpand = true
|
||||
},
|
||||
button,
|
||||
}
|
||||
});
|
||||
Dirty = false;
|
||||
_bui.UpdateMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user