]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make `SlotControl` textures nullable (#16519)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Wed, 17 May 2023 00:18:52 +0000 (12:18 +1200)
committerGitHub <noreply@github.com>
Wed, 17 May 2023 00:18:52 +0000 (10:18 +1000)
Content.Client/UserInterface/Controls/SlotControl.cs

index 36ffacc5c554dbb8268c86f82d19ad4b73b0e030..527802c26dbd5a43ea093fb98e8bc1acc0f2b791 100644 (file)
@@ -1,6 +1,6 @@
 using Content.Client.Cooldown;
 using Content.Client.UserInterface.Systems.Inventory.Controls;
-using Robust.Client.Graphics;
+using Robust.Client.ResourceManagement;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Shared.Input;
@@ -10,8 +10,6 @@ namespace Content.Client.UserInterface.Controls
     [Virtual]
     public abstract class SlotControl : Control
     {
-        private const string HighlightShader = "SelectionOutlineInrange";
-
         public static int DefaultButtonSize = 64;
 
         public TextureRect ButtonRect { get; }
@@ -52,52 +50,48 @@ namespace Content.Client.UserInterface.Controls
 
         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;
             set
             {
                 _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;
             set
             {
                 _buttonTexturePath = value;
-                ButtonRect.Texture = Theme.ResolveTexture(_buttonTexturePath);
+                ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
             }
         }
 
-        public Texture StorageTexture => Theme.ResolveTexture(StorageTexturePath);
 
-        private string _storageTexturePath = "";
-        public string StorageTexturePath
+        private string? _storageTexturePath;
+        public string? StorageTexturePath
         {
             get => _buttonTexturePath;
             set
             {
                 _storageTexturePath = value;
-                StorageButton.TextureNormal = Theme.ResolveTexture(_storageTexturePath);
+                StorageButton.TextureNormal = Theme.ResolveTextureOrNull(_storageTexturePath)?.Texture;
             }
         }
 
-        private string _highlightTexturePath = "";
-        public string HighlightTexturePath
+        private string? _highlightTexturePath;
+        public string? HighlightTexturePath
         {
             get => _highlightTexturePath;
             set
             {
                 _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()
         {
             base.OnThemeUpdated();
-            StorageButton.TextureNormal = Theme.ResolveTexture(_storageTexturePath);
-            ButtonRect.Texture = Theme.ResolveTexture(_buttonTexturePath);
-            HighlightRect.Texture = Theme.ResolveTexture(_highlightTexturePath);
+
+            StorageButton.TextureNormal = Theme.ResolveTextureOrNull(_storageTexturePath)?.Texture;
+            ButtonRect.Texture = Theme.ResolveTextureOrNull(_buttonTexturePath)?.Texture;
+            HighlightRect.Texture = Theme.ResolveTextureOrNull(_highlightTexturePath)?.Texture;
         }
     }
 }