Fix humanoid appearance error (#13721)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Humanoid.HumanoidAppearanceState;
|
||||
|
||||
namespace Content.Client.Humanoid;
|
||||
@@ -18,12 +20,14 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
public Action<MarkingSet>? OnMarkingColorChange;
|
||||
public Action<MarkingSet>? OnMarkingRankChange;
|
||||
public Action<HumanoidVisualLayers, CustomBaseLayerInfo?>? OnLayerInfoModified;
|
||||
private readonly IPrototypeManager _protoMan = default!;
|
||||
|
||||
private readonly Dictionary<HumanoidVisualLayers, HumanoidBaseLayerModifier> _modifiers = new();
|
||||
|
||||
public HumanoidMarkingModifierWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
foreach (var layer in Enum.GetValues<HumanoidVisualLayers>())
|
||||
{
|
||||
@@ -31,14 +35,7 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
BaseLayersContainer.AddChild(modifier);
|
||||
_modifiers.Add(layer, modifier);
|
||||
|
||||
modifier.OnStateChanged += delegate
|
||||
{
|
||||
OnLayerInfoModified!(
|
||||
layer,
|
||||
modifier.Enabled
|
||||
? new CustomBaseLayerInfo(modifier.State, modifier.Color)
|
||||
: null);
|
||||
};
|
||||
modifier.OnStateChanged += () => OnStateChanged(layer, modifier);
|
||||
}
|
||||
|
||||
MarkingPickerWidget.OnMarkingAdded += set => OnMarkingAdded!(set);
|
||||
@@ -52,6 +49,18 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
MarkingPickerWidget.IgnoreSpecies = MarkingForced.Pressed;
|
||||
}
|
||||
|
||||
private void OnStateChanged(HumanoidVisualLayers layer, HumanoidBaseLayerModifier modifier)
|
||||
{
|
||||
if (!modifier.Enabled)
|
||||
{
|
||||
OnLayerInfoModified?.Invoke(layer, null);
|
||||
return;
|
||||
}
|
||||
|
||||
string? state = _protoMan.HasIndex<HumanoidSpeciesSpriteLayer>(modifier.Text) ? modifier.Text : null;
|
||||
OnLayerInfoModified?.Invoke(layer, new CustomBaseLayerInfo(state, modifier.Color));
|
||||
}
|
||||
|
||||
public void SetState(MarkingSet markings, string species, Color skinColor, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> info)
|
||||
{
|
||||
MarkingPickerWidget.SetData(markings, species, skinColor);
|
||||
@@ -64,7 +73,7 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
continue;
|
||||
}
|
||||
|
||||
modifier.SetState(true, layerInfo.ID, layerInfo.Color ?? Color.White);
|
||||
modifier.SetState(true, layerInfo.ID ?? string.Empty, layerInfo.Color ?? Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +85,7 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
private BoxContainer _infoBox;
|
||||
|
||||
public bool Enabled => _enable.Pressed;
|
||||
public string State => _lineEdit.Text;
|
||||
public string Text => _lineEdit.Text;
|
||||
public Color Color => _colorSliders.Color;
|
||||
|
||||
public Action? OnStateChanged;
|
||||
@@ -117,7 +126,9 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow
|
||||
|
||||
var lineEditBox = new BoxContainer();
|
||||
lineEditBox.AddChild(new Label { Text = "Prototype id: "});
|
||||
_lineEdit = new();
|
||||
|
||||
// TODO: This line edit should really be an options / dropdown selector, not text.
|
||||
_lineEdit = new() { MinWidth = 200 };
|
||||
_lineEdit.OnTextEntered += args => OnStateChanged!();
|
||||
lineEditBox.AddChild(_lineEdit);
|
||||
_infoBox.AddChild(lineEditBox);
|
||||
|
||||
Reference in New Issue
Block a user