]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Persist Agent ID Job Icon between UI loads (#27379)
authorTy Ashley <42426760+TyAshley@users.noreply.github.com>
Sat, 27 Apr 2024 05:13:12 +0000 (00:13 -0500)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 05:13:12 +0000 (15:13 +1000)
Modified the Agent ID Card to persist the selected Job Icon between UI loads

Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
Content.Server/Access/Systems/AgentIDCardSystem.cs
Content.Shared/Access/SharedAgentIDCardSystem.cs

index 73f18aec8d6b720f06dbbfcf46a33d644d85a0e9..c3fac8cb92a587cb97b21570a6b6bb555ad4c2f3 100644 (file)
@@ -40,9 +40,9 @@ namespace Content.Client.Access.UI
             SendMessage(new AgentIDCardJobChangedMessage(newJob));
         }
 
-        public void OnJobIconChanged(string newJobIcon)
+        public void OnJobIconChanged(string newJobIconId)
         {
-            SendMessage(new AgentIDCardJobIconChangedMessage(newJobIcon));
+            SendMessage(new AgentIDCardJobIconChangedMessage(newJobIconId));
         }
 
         /// <summary>
@@ -57,7 +57,7 @@ namespace Content.Client.Access.UI
 
             _window.SetCurrentName(cast.CurrentName);
             _window.SetCurrentJob(cast.CurrentJob);
-            _window.SetAllowedIcons(cast.Icons);
+            _window.SetAllowedIcons(cast.Icons, cast.CurrentJobIconId);
         }
 
         protected override void Dispose(bool disposing)
index beca0c41ba9301cae59211079d21baa1ee10b849..9a38c0c485309df96f54a9715056cf697fff5460 100644 (file)
@@ -38,7 +38,7 @@ namespace Content.Client.Access.UI
             JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
         }
 
-        public void SetAllowedIcons(HashSet<string> icons)
+        public void SetAllowedIcons(HashSet<string> icons, string currentJobIconId)
         {
             IconGrid.DisposeAllChildren();
 
@@ -79,6 +79,10 @@ namespace Content.Client.Access.UI
                 jobIconButton.AddChild(jobIconTexture);
                 jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID);
                 IconGrid.AddChild(jobIconButton);
+
+                if (jobIconId.Equals(currentJobIconId))
+                    jobIconButton.Pressed = true;
+
                 i++;
             }
         }
index 2c4425ec105cdeea77dae28f66a6160636516777..d5e9dc357ddf6c04ba2ec0a0c36cfb77afdf9d01 100644 (file)
@@ -67,7 +67,7 @@ namespace Content.Server.Access.Systems
             if (!TryComp<IdCardComponent>(uid, out var idCard))
                 return;
 
-            var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons);
+            var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", idCard.JobIcon ?? "", component.Icons);
             _uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
         }
 
@@ -94,7 +94,7 @@ namespace Content.Server.Access.Systems
                 return;
             }
 
-            if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIcon, out var jobIcon))
+            if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIconId, out var jobIcon))
             {
                 return;
             }
index ef6690cc356086551bb2ed53a4c8a5fa15a49900..d027a3937f5accd7b3539fc8cb3b8b4543ede285 100644 (file)
@@ -26,12 +26,14 @@ namespace Content.Shared.Access.Systems
         public readonly HashSet<string> Icons;
         public string CurrentName { get; }
         public string CurrentJob { get; }
+        public string CurrentJobIconId { get; }
 
-        public AgentIDCardBoundUserInterfaceState(string currentName, string currentJob, HashSet<string> icons)
+        public AgentIDCardBoundUserInterfaceState(string currentName, string currentJob, string currentJobIconId, HashSet<string> icons)
         {
             Icons = icons;
             CurrentName = currentName;
             CurrentJob = currentJob;
+            CurrentJobIconId = currentJobIconId;
         }
     }
 
@@ -60,11 +62,11 @@ namespace Content.Shared.Access.Systems
     [Serializable, NetSerializable]
     public sealed class AgentIDCardJobIconChangedMessage : BoundUserInterfaceMessage
     {
-        public string JobIcon { get; }
+        public string JobIconId { get; }
 
-        public AgentIDCardJobIconChangedMessage(string jobIcon)
+        public AgentIDCardJobIconChangedMessage(string jobIconId)
         {
-            JobIcon = jobIcon;
+            JobIconId = jobIconId;
         }
     }
 }