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

@@ -23,11 +23,12 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
public Action<string>? OnDisablePressed;
public Action<string>? OnDestroyPressed;
private Entity<RoboticsConsoleComponent, LockComponent?> _console;
private string? _selected;
private Dictionary<string, CyborgControlData> _cyborgs = new();
public RoboticsConsoleWindow(EntityUid console)
public EntityUid Entity;
public RoboticsConsoleWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
@@ -35,9 +36,6 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
_lock = _entMan.System<LockSystem>();
_sprite = _entMan.System<SpriteSystem>();
_console = (console, _entMan.GetComponent<RoboticsConsoleComponent>(console), null);
_entMan.TryGetComponent(_console, out _console.Comp2);
Cyborgs.OnItemSelected += args =>
{
if (Cyborgs[args.ItemIndex].Metadata is not string address)
@@ -66,6 +64,11 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
DestroyButton.StyleClasses.Add(StyleBase.ButtonCaution);
}
public void SetEntity(EntityUid uid)
{
Entity = uid;
}
public void UpdateState(RoboticsConsoleState state)
{
_cyborgs = state.Cyborgs;
@@ -81,7 +84,7 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
PopulateData();
var locked = _lock.IsLocked((_console, _console.Comp2));
var locked = _lock.IsLocked(Entity);
DangerZone.Visible = !locked;
LockedMessage.Visible = locked;
}
@@ -135,13 +138,19 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
// how the turntables
DisableButton.Disabled = !(data.HasBrain && data.CanDisable);
DestroyButton.Disabled = _timing.CurTime < _console.Comp1.NextDestroy;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
DestroyButton.Disabled = _timing.CurTime < _console.Comp1.NextDestroy;
if (_entMan.TryGetComponent(Entity, out RoboticsConsoleComponent? console))
{
DestroyButton.Disabled = _timing.CurTime < console.NextDestroy;
}
else
{
DestroyButton.Disabled = true;
}
}
}