Marking default coloring (#13039)

* Marking coloring WIP

* EnsureDefault now supports coloring!

* Now markings have coloring when they get added

* Many things

* yml files

* cleanup

* Some requested changes

* Nullable type and WIP caching

* Time to resolve that thing with deprecated hair fields

* Latest reviews + im still trying to use these hair markings

* FirstOrDefault thing and Tattoo docs

* IDK

* It's now works a bit more properly in preferences GUI

* THEY SYNCING! However preferences GUI still broken and doesn't work properly

* Markings now updating when changing in GUI. However they still don't work properly with bald humanoids

* Forgor...

* Default hair-colored markings will not color to hair if there is no hair

* Fixed default colors for customizable markings

* Fixed bug in prefs GUI that set current hair to null

* Now markings that must match skin color because of limb (e.x. Slimes) - will match skin color

* final tweaks: if hair uses skin color then markings will use skin color as hair color (slimes)

* fix

* fixed dirty. no more funni invis bug

* Mirrors and client profile loading

* default colors soon TM

* review + better coloring

* Hardcode is gone

* diona markings

* oh my god

* fixed CategoryColoring

* cool fallback, clean up and some other tweaks

* code style

* more style

* a
This commit is contained in:
csqrb
2023-03-05 08:59:07 +06:00
committed by GitHub
parent 0ad9af7ae2
commit 8b3d7728d7
26 changed files with 863 additions and 83 deletions

View File

@@ -53,7 +53,7 @@ namespace Content.Client.Preferences.UI
private readonly IEntityManager _entMan;
private readonly IConfigurationManager _configurationManager;
private readonly MarkingManager _markingManager;
private LineEdit _ageEdit => CAgeEdit;
private LineEdit _nameEdit => CNameEdit;
private LineEdit _flavorTextEdit = null!;
@@ -223,6 +223,7 @@ namespace Content.Client.Preferences.UI
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithHairColor(newColor.marking.MarkingColors[0]));
UpdateCMarkingsHair();
IsDirty = true;
};
@@ -241,6 +242,7 @@ namespace Content.Client.Preferences.UI
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithFacialHairColor(newColor.marking.MarkingColors[0]));
UpdateCMarkingsFacialHair();
IsDirty = true;
};
@@ -252,6 +254,7 @@ namespace Content.Client.Preferences.UI
Profile.Appearance.WithHairStyleName(HairStyles.DefaultHairStyle)
);
UpdateHairPickers();
UpdateCMarkingsHair();
IsDirty = true;
};
@@ -263,6 +266,7 @@ namespace Content.Client.Preferences.UI
Profile.Appearance.WithFacialHairStyleName(HairStyles.DefaultFacialHairStyle)
);
UpdateHairPickers();
UpdateCMarkingsFacialHair();
IsDirty = true;
};
@@ -282,7 +286,7 @@ namespace Content.Client.Preferences.UI
);
UpdateHairPickers();
UpdateCMarkingsHair();
IsDirty = true;
};
@@ -302,7 +306,7 @@ namespace Content.Client.Preferences.UI
);
UpdateHairPickers();
UpdateCMarkingsFacialHair();
IsDirty = true;
};
@@ -343,6 +347,7 @@ namespace Content.Client.Preferences.UI
return;
Profile = Profile.WithCharacterAppearance(
Profile.Appearance.WithEyeColor(newColor));
CMarkings.CurrentEyeColor = Profile.Appearance.EyeColor;
IsDirty = true;
};
@@ -646,7 +651,7 @@ namespace Content.Client.Preferences.UI
var color = SkinColor.HumanSkinTone((int) _skinColor.Value);
CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));//
break;
}
case HumanoidSkinColor.Hues:
@@ -746,8 +751,8 @@ namespace Content.Client.Preferences.UI
Profile = (HumanoidCharacterProfile) _preferencesManager.Preferences!.SelectedCharacter;
CharacterSlot = _preferencesManager.Preferences.SelectedCharacterIndex;
_needUpdatePreview = true;
UpdateControls();
_needUpdatePreview = true;
}
private void SetAge(int newAge)
@@ -941,7 +946,9 @@ namespace Content.Client.Preferences.UI
return;
}
CMarkings.SetData(Profile.Appearance.Markings, Profile.Species, Profile.Appearance.SkinColor);
CMarkings.SetData(Profile.Appearance.Markings, Profile.Species,
Profile.Appearance.SkinColor, Profile.Appearance.EyeColor
);
}
private void UpdateSpecies()
@@ -990,7 +997,6 @@ namespace Content.Client.Preferences.UI
{
return;
}
var hairMarking = Profile.Appearance.HairStyleId switch
{
HairStyles.DefaultHairStyle => new List<Marking>(),
@@ -1013,6 +1019,76 @@ namespace Content.Client.Preferences.UI
1);
}
private void UpdateCMarkingsHair()
{
if (Profile == null)
{
return;
}
// hair color
Color? hairColor = null;
if ( Profile.Appearance.HairStyleId != HairStyles.DefaultHairStyle &&
_markingManager.Markings.TryGetValue(Profile.Appearance.HairStyleId, out var hairProto)
)
{
if (_markingManager.CanBeApplied(Profile.Species, hairProto, _prototypeManager))
{
if (_markingManager.MustMatchSkin(Profile.Species, HumanoidVisualLayers.Hair, _prototypeManager))
{
hairColor = Profile.Appearance.SkinColor;
}
else
{
hairColor = Profile.Appearance.HairColor;
}
}
}
if (hairColor != null)
{
CMarkings.HairMarking = new (Profile.Appearance.HairStyleId, new List<Color>() { hairColor.Value });
}
else
{
CMarkings.HairMarking = null;
}
}
private void UpdateCMarkingsFacialHair()
{
if (Profile == null)
{
return;
}
// facial hair color
Color? facialHairColor = null;
if ( Profile.Appearance.FacialHairStyleId != HairStyles.DefaultFacialHairStyle &&
_markingManager.Markings.TryGetValue(Profile.Appearance.FacialHairStyleId, out var facialHairProto)
)
{
if (_markingManager.CanBeApplied(Profile.Species, facialHairProto, _prototypeManager))
{
if (_markingManager.MustMatchSkin(Profile.Species, HumanoidVisualLayers.Hair, _prototypeManager))
{
facialHairColor = Profile.Appearance.SkinColor;
}
else
{
facialHairColor = Profile.Appearance.FacialHairColor;
}
}
}
if (facialHairColor != null)
{
CMarkings.FacialHairMarking = new (Profile.Appearance.FacialHairStyleId, new List<Color>() { facialHairColor.Value });
}
else
{
CMarkings.FacialHairMarking = null;
}
}
private void UpdateEyePickers()
{
if (Profile == null)
@@ -1020,6 +1096,7 @@ namespace Content.Client.Preferences.UI
return;
}
CMarkings.CurrentEyeColor = Profile.Appearance.EyeColor;
_eyesPicker.SetData(Profile.Appearance.EyeColor);
}
@@ -1049,7 +1126,6 @@ namespace Content.Client.Preferences.UI
UpdateClothingControls();
UpdateBackpackControls();
UpdateAgeEdit();
UpdateHairPickers();
UpdateEyePickers();
UpdateSaveButton();
UpdateJobPriorities();
@@ -1057,6 +1133,9 @@ namespace Content.Client.Preferences.UI
UpdateTraitPreferences();
UpdateMarkings();
RebuildSpriteView();
UpdateHairPickers();
UpdateCMarkingsHair();
UpdateCMarkingsFacialHair();
_preferenceUnavailableButton.SelectId((int) Profile.PreferenceUnavailable);
}