Reapply "Remove some BUI boilerplate" (#30214) (#30219)

* Reapply "Remove some BUI boilerplate" (#30214)

This reverts commit cb0ba66be3.

* Fix gas tank

* Fix PA

* Fix microwave

* Comms console underwrap

* Fix rcd

* log wehs
This commit is contained in:
metalgearsloth
2024-07-21 14:48:13 +10:00
committed by GitHub
parent 87e52e50b4
commit edb05e36bb
137 changed files with 1102 additions and 1757 deletions

View File

@@ -1,4 +1,5 @@
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
using static Content.Shared.Paper.SharedPaperComponent;
@@ -19,16 +20,13 @@ public sealed class PaperBoundUserInterface : BoundUserInterface
{
base.Open();
_window = new PaperWindow();
_window.OnClose += Close;
_window.OnSaved += Input_OnTextEntered;
_window = this.CreateWindow<PaperWindow>();
_window.OnSaved += InputOnTextEntered;
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
_window.InitVisuals(Owner, visuals);
}
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
@@ -37,7 +35,7 @@ public sealed class PaperBoundUserInterface : BoundUserInterface
_window?.Populate((PaperBoundUserInterfaceState) state);
}
private void Input_OnTextEntered(string text)
private void InputOnTextEntered(string text)
{
SendMessage(new PaperInputTextMessage(text));
@@ -47,11 +45,4 @@ public sealed class PaperBoundUserInterface : BoundUserInterface
_window.Input.CursorPosition = new TextEdit.CursorPos(0, TextEdit.LineBreakBias.Top);
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_window?.Dispose();
}
}

View File

@@ -17,6 +17,7 @@ namespace Content.Client.Paper.UI
public sealed partial class PaperWindow : BaseWindow
{
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IResourceCache _resCache = default!;
private static Color DefaultTextColor = new(25, 25, 25);
@@ -85,11 +86,10 @@ namespace Content.Client.Paper.UI
// Randomize the placement of any stamps based on the entity UID
// so that there's some variety in different papers.
StampDisplay.PlacementSeed = (int)entity;
var resCache = IoCManager.Resolve<IResourceCache>();
// Initialize the background:
PaperBackground.ModulateSelfOverride = visuals.BackgroundModulate;
var backgroundImage = visuals.BackgroundImagePath != null? resCache.GetResource<TextureResource>(visuals.BackgroundImagePath) : null;
var backgroundImage = visuals.BackgroundImagePath != null? _resCache.GetResource<TextureResource>(visuals.BackgroundImagePath) : null;
if (backgroundImage != null)
{
var backgroundImageMode = visuals.BackgroundImageTile ? StyleBoxTexture.StretchMode.Tile : StyleBoxTexture.StretchMode.Stretch;
@@ -127,7 +127,7 @@ namespace Content.Client.Paper.UI
PaperContent.ModulateSelfOverride = visuals.ContentImageModulate;
WrittenTextLabel.ModulateSelfOverride = visuals.FontAccentColor;
var contentImage = visuals.ContentImagePath != null ? resCache.GetResource<TextureResource>(visuals.ContentImagePath) : null;
var contentImage = visuals.ContentImagePath != null ? _resCache.GetResource<TextureResource>(visuals.ContentImagePath) : null;
if (contentImage != null)
{
// Setup the paper content texture, but keep a reference to it, as we can't set