Revert "Remove some BUI boilerplate" (#30214)
Revert "Remove some BUI boilerplate (#28399)"
This reverts commit cbf329a82d.
This commit is contained in:
@@ -18,11 +18,10 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
{
|
||||
public sealed class ParticleAcceleratorControlMenu : BaseWindow
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly IResourceCache _cache = default!;
|
||||
|
||||
private readonly ShaderInstance _greyScaleShader;
|
||||
|
||||
private readonly ParticleAcceleratorBoundUserInterface _owner;
|
||||
|
||||
private readonly Label _drawLabel;
|
||||
private readonly FastNoiseLite _drawNoiseGenerator;
|
||||
private readonly Button _onButton;
|
||||
@@ -51,21 +50,19 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
private bool _shouldContinueAnimating;
|
||||
private int _maxStrength = 3;
|
||||
|
||||
public event Action<bool>? OnOverallState;
|
||||
public event Action<ParticleAcceleratorPowerState>? OnPowerState;
|
||||
public event Action? OnScanPartsRequested;
|
||||
|
||||
public ParticleAcceleratorControlMenu()
|
||||
public ParticleAcceleratorControlMenu(ParticleAcceleratorBoundUserInterface owner)
|
||||
{
|
||||
SetSize = new Vector2(400, 320);
|
||||
_greyScaleShader = _protoManager.Index<ShaderPrototype>("Greyscale").Instance();
|
||||
_greyScaleShader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>("Greyscale").Instance();
|
||||
|
||||
_owner = owner;
|
||||
_drawNoiseGenerator = new();
|
||||
_drawNoiseGenerator.SetFractalType(FastNoiseLite.FractalType.FBm);
|
||||
_drawNoiseGenerator.SetFrequency(0.5f);
|
||||
|
||||
var font = _cache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
|
||||
var panelTex = _cache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
|
||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||
var font = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
|
||||
var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
|
||||
|
||||
MouseFilter = MouseFilterMode.Stop;
|
||||
|
||||
@@ -115,8 +112,7 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
Text = Loc.GetString("particle-accelerator-control-menu-off-button"),
|
||||
StyleClasses = { StyleBase.ButtonOpenRight },
|
||||
};
|
||||
|
||||
_offButton.OnPressed += args => OnOverallState?.Invoke(false);
|
||||
_offButton.OnPressed += args => owner.SendEnableMessage(false);
|
||||
|
||||
_onButton = new Button
|
||||
{
|
||||
@@ -124,7 +120,7 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
Text = Loc.GetString("particle-accelerator-control-menu-on-button"),
|
||||
StyleClasses = { StyleBase.ButtonOpenLeft },
|
||||
};
|
||||
_onButton.OnPressed += args => OnOverallState?.Invoke(true);
|
||||
_onButton.OnPressed += args => owner.SendEnableMessage(true);
|
||||
|
||||
var closeButton = new TextureButton
|
||||
{
|
||||
@@ -320,7 +316,7 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
}
|
||||
});
|
||||
|
||||
_scanButton.OnPressed += args => OnScanPartsRequested?.Invoke();
|
||||
_scanButton.OnPressed += args => _owner.SendScanPartsMessage();
|
||||
|
||||
_alarmControl.AnimationCompleted += s =>
|
||||
{
|
||||
@@ -336,7 +332,7 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
|
||||
PASegmentControl Segment(string name)
|
||||
{
|
||||
return new(this, _cache, name);
|
||||
return new(this, resourceCache, name);
|
||||
}
|
||||
|
||||
UpdateUI(false, false, false, false);
|
||||
@@ -372,7 +368,7 @@ namespace Content.Client.ParticleAccelerator.UI
|
||||
}
|
||||
|
||||
_stateSpinBox.SetButtonDisabled(true);
|
||||
OnPowerState?.Invoke(newState);
|
||||
_owner.SendPowerStateMessage(newState);
|
||||
}
|
||||
|
||||
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
|
||||
|
||||
Reference in New Issue
Block a user