Make SlotControl textures nullable (#16519)

This commit is contained in:
Leon Friedrich
2023-05-17 12:18:52 +12:00
committed by GitHub
parent aa399daa5a
commit 6269548835

View File

@@ -1,6 +1,6 @@
using Content.Client.Cooldown; using Content.Client.Cooldown;
using Content.Client.UserInterface.Systems.Inventory.Controls; using Content.Client.UserInterface.Systems.Inventory.Controls;
using Robust.Client.Graphics; using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input; using Robust.Shared.Input;
@@ -10,8 +10,6 @@ namespace Content.Client.UserInterface.Controls
[Virtual] [Virtual]
public abstract class SlotControl : Control public abstract class SlotControl : Control
{ {
private const string HighlightShader = "SelectionOutlineInrange";
public static int DefaultButtonSize = 64; public static int DefaultButtonSize = 64;
public TextureRect ButtonRect { get; } public TextureRect ButtonRect { get; }
@@ -52,52 +50,48 @@ namespace Content.Client.UserInterface.Controls
public bool Blocked { get => BlockedRect.Visible; set => BlockedRect.Visible = value;} public bool Blocked { get => BlockedRect.Visible; set => BlockedRect.Visible = value;}
public Texture BlockedTexture => Theme.ResolveTexture(BlockedTexturePath); private string? _blockedTexturePath;
public string? BlockedTexturePath
private string _blockedTexturePath = "";
public string BlockedTexturePath
{ {
get => _blockedTexturePath; get => _blockedTexturePath;
set set
{ {
_blockedTexturePath = value; _blockedTexturePath = value;
BlockedRect.Texture = Theme.ResolveTexture(_blockedTexturePath); BlockedRect.Texture = Theme.ResolveTextureOrNull(_blockedTexturePath)?.Texture;
} }
} }
public Texture ButtonTexture => Theme.ResolveTexture(ButtonTexturePath); private string? _buttonTexturePath;
public string? ButtonTexturePath
private string _buttonTexturePath = ""; {
public string ButtonTexturePath {
get => _buttonTexturePath; get => _buttonTexturePath;
set set
{ {
_buttonTexturePath = value; _buttonTexturePath = value;
ButtonRect.Texture = Theme.ResolveTexture(_buttonTexturePath); ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
} }
} }
public Texture StorageTexture => Theme.ResolveTexture(StorageTexturePath);
private string _storageTexturePath = ""; private string? _storageTexturePath;
public string StorageTexturePath public string? StorageTexturePath
{ {
get => _buttonTexturePath; get => _buttonTexturePath;
set set
{ {
_storageTexturePath = value; _storageTexturePath = value;
StorageButton.TextureNormal = Theme.ResolveTexture(_storageTexturePath); StorageButton.TextureNormal = Theme.ResolveTextureOrNull(_storageTexturePath)?.Texture;
} }
} }
private string _highlightTexturePath = ""; private string? _highlightTexturePath;
public string HighlightTexturePath public string? HighlightTexturePath
{ {
get => _highlightTexturePath; get => _highlightTexturePath;
set set
{ {
_highlightTexturePath = value; _highlightTexturePath = value;
HighlightRect.Texture = Theme.ResolveTexture(_highlightTexturePath); HighlightRect.Texture = Theme.ResolveTextureOrNull(_highlightTexturePath)?.Texture;
} }
} }
@@ -233,9 +227,10 @@ namespace Content.Client.UserInterface.Controls
protected override void OnThemeUpdated() protected override void OnThemeUpdated()
{ {
base.OnThemeUpdated(); base.OnThemeUpdated();
StorageButton.TextureNormal = Theme.ResolveTexture(_storageTexturePath);
ButtonRect.Texture = Theme.ResolveTexture(_buttonTexturePath); StorageButton.TextureNormal = Theme.ResolveTextureOrNull(_storageTexturePath)?.Texture;
HighlightRect.Texture = Theme.ResolveTexture(_highlightTexturePath); ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
HighlightRect.Texture = Theme.ResolveTextureOrNull(_highlightTexturePath)?.Texture;
} }
} }
} }