From 2b4589487944890e03617bbebc56bb9a43d947ec Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Mon, 23 May 2022 18:55:43 -0700 Subject: [PATCH] Markings tweaks (#8394) * fixes issue with indexing into colors on multi-sprite markings * should rebuild the dummy upon character profile switch in client * markings, when selected, should now default to the current character's skin color * whoops, missed one * adds a type serializer into marking points * that has to be a list serializer, oops --- Content.Client/Markings/MarkingPicker.xaml.cs | 18 ++++++++++++++---- .../UI/HumanoidProfileEditor.xaml.cs | 8 ++++++-- Content.Shared/Markings/MarkingsComponent.cs | 4 +++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Content.Client/Markings/MarkingPicker.xaml.cs b/Content.Client/Markings/MarkingPicker.xaml.cs index 50a4e04dc9..56ca102fd0 100644 --- a/Content.Client/Markings/MarkingPicker.xaml.cs +++ b/Content.Client/Markings/MarkingPicker.xaml.cs @@ -47,11 +47,13 @@ namespace Content.Client.Markings private List _markingCategories = Enum.GetValues().ToList(); private string _currentSpecies = SpeciesManager.DefaultSpecies; + public Color CurrentSkinColor = Color.White; - public void SetData(MarkingsSet newMarkings, string species) + public void SetData(MarkingsSet newMarkings, string species, Color skinColor) { _currentMarkings = newMarkings; _currentSpecies = species; + CurrentSkinColor = skinColor; // Should marking limits be dependent on species prototypes, // or should it be dependent on the entity the @@ -72,6 +74,8 @@ namespace Content.Client.Markings PopulateUsed(); } + public void SetSkinColor(Color color) => CurrentSkinColor = color; + public MarkingPicker() { RobustXamlLoader.Load(this); @@ -349,9 +353,9 @@ namespace Content.Client.Markings ); colorSelector.Color = currentColor; _currentMarkingColors.Add(currentColor); - int colorIndex = _currentMarkingColors.IndexOf(currentColor); + var colorIndex = _currentMarkingColors.Count - 1; - Action colorChanged = delegate(Color color) + Action colorChanged = _ => { _currentMarkingColors[colorIndex] = colorSelector.Color; @@ -394,7 +398,13 @@ namespace Content.Client.Markings UpdatePoints(); - _currentMarkings.AddBack(marking.AsMarking()); + var markingObject = marking.AsMarking(); + for (var i = 0; i < markingObject.MarkingColors.Count; i++) + { + markingObject.SetColor(i, CurrentSkinColor); + } + + _currentMarkings.AddBack(markingObject); CMarkingsUnused.Remove(_selectedUnusedMarking); var item = new ItemList.Item(CMarkingsUsed) diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index 29c92588e1..7eebe5e842 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -555,6 +555,7 @@ namespace Content.Client.Preferences.UI var color = Color.FromHsv(new Vector4(hue / 360, sat / 100, val / 100, 1.0f)); + CMarkings.CurrentSkinColor = color; Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color)); break; } @@ -567,6 +568,8 @@ namespace Content.Client.Preferences.UI } var color = new Color(_rgbSkinColorSelector.Color.R, _rgbSkinColorSelector.Color.G, _rgbSkinColorSelector.Color.B); + + CMarkings.CurrentSkinColor = color; Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color)); break; } @@ -584,6 +587,7 @@ namespace Content.Client.Preferences.UI newColor.Y = .1f; color = Color.FromHsv(newColor); + CMarkings.CurrentSkinColor = color; Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color)); break; } @@ -834,7 +838,7 @@ namespace Content.Client.Preferences.UI return; } - CMarkings.SetData(Profile.Appearance.Markings, Profile.Species); + CMarkings.SetData(Profile.Appearance.Markings, Profile.Species, Profile.Appearance.SkinColor); } private void UpdateSpecies() @@ -945,7 +949,7 @@ namespace Content.Client.Preferences.UI UpdateAntagPreferences(); UpdateMarkings(); - _needUpdatePreview = true; + NeedsDummyRebuild = true; _preferenceUnavailableButton.SelectId((int) Profile.PreferenceUnavailable); } diff --git a/Content.Shared/Markings/MarkingsComponent.cs b/Content.Shared/Markings/MarkingsComponent.cs index 3aff0ff213..04faee9577 100644 --- a/Content.Shared/Markings/MarkingsComponent.cs +++ b/Content.Shared/Markings/MarkingsComponent.cs @@ -1,4 +1,6 @@ using Content.Shared.CharacterAppearance; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Markings { @@ -32,7 +34,7 @@ namespace Content.Shared.Markings [DataField("required", required: true)] public bool Required = false; // Default markings for this layer. - [DataField("defaultMarkings")] + [DataField("defaultMarkings", customTypeSerializer:typeof(PrototypeIdListSerializer))] public List DefaultMarkings = new(); public static Dictionary CloneMarkingPointDictionary(Dictionary self)