Persist Agent ID Job Icon between UI loads (#27379)
Modified the Agent ID Card to persist the selected Job Icon between UI loads
This commit is contained in:
@@ -40,9 +40,9 @@ namespace Content.Client.Access.UI
|
|||||||
SendMessage(new AgentIDCardJobChangedMessage(newJob));
|
SendMessage(new AgentIDCardJobChangedMessage(newJob));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnJobIconChanged(string newJobIcon)
|
public void OnJobIconChanged(string newJobIconId)
|
||||||
{
|
{
|
||||||
SendMessage(new AgentIDCardJobIconChangedMessage(newJobIcon));
|
SendMessage(new AgentIDCardJobIconChangedMessage(newJobIconId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -57,7 +57,7 @@ namespace Content.Client.Access.UI
|
|||||||
|
|
||||||
_window.SetCurrentName(cast.CurrentName);
|
_window.SetCurrentName(cast.CurrentName);
|
||||||
_window.SetCurrentJob(cast.CurrentJob);
|
_window.SetCurrentJob(cast.CurrentJob);
|
||||||
_window.SetAllowedIcons(cast.Icons);
|
_window.SetAllowedIcons(cast.Icons, cast.CurrentJobIconId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Content.Client.Access.UI
|
|||||||
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
|
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAllowedIcons(HashSet<string> icons)
|
public void SetAllowedIcons(HashSet<string> icons, string currentJobIconId)
|
||||||
{
|
{
|
||||||
IconGrid.DisposeAllChildren();
|
IconGrid.DisposeAllChildren();
|
||||||
|
|
||||||
@@ -79,6 +79,10 @@ namespace Content.Client.Access.UI
|
|||||||
jobIconButton.AddChild(jobIconTexture);
|
jobIconButton.AddChild(jobIconTexture);
|
||||||
jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID);
|
jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID);
|
||||||
IconGrid.AddChild(jobIconButton);
|
IconGrid.AddChild(jobIconButton);
|
||||||
|
|
||||||
|
if (jobIconId.Equals(currentJobIconId))
|
||||||
|
jobIconButton.Pressed = true;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Content.Server.Access.Systems
|
|||||||
if (!TryComp<IdCardComponent>(uid, out var idCard))
|
if (!TryComp<IdCardComponent>(uid, out var idCard))
|
||||||
return;
|
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);
|
_uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace Content.Server.Access.Systems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIcon, out var jobIcon))
|
if (!_prototypeManager.TryIndex<StatusIconPrototype>(args.JobIconId, out var jobIcon))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,14 @@ namespace Content.Shared.Access.Systems
|
|||||||
public readonly HashSet<string> Icons;
|
public readonly HashSet<string> Icons;
|
||||||
public string CurrentName { get; }
|
public string CurrentName { get; }
|
||||||
public string CurrentJob { 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;
|
Icons = icons;
|
||||||
CurrentName = currentName;
|
CurrentName = currentName;
|
||||||
CurrentJob = currentJob;
|
CurrentJob = currentJob;
|
||||||
|
CurrentJobIconId = currentJobIconId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +62,11 @@ namespace Content.Shared.Access.Systems
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class AgentIDCardJobIconChangedMessage : BoundUserInterfaceMessage
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user