From 067321141758e3fa7042b8a8226e97b39c1f2681 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Tue, 18 Jun 2024 21:19:32 -0400 Subject: [PATCH 01/84] Two new CVars and height slider now shows actual height in CM --- .../UI/HumanoidProfileEditor.xaml.cs | 24 +++++++++---------- Content.Shared/CCVar/CCVars.cs | 10 ++++++++ .../HeightAdjust/HeightAdjustSystem.cs | 11 +++++---- .../Humanoid/Prototypes/SpeciesPrototype.cs | 12 ++++++++++ .../ui/humanoid-profile-editor.ftl | 4 ++-- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index 537b19479c..c203995fa4 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -1,9 +1,7 @@ -using System.Globalization; using System.Linq; using System.Numerics; using System.Text; using Content.Client.Guidebook; -using System.Text.RegularExpressions; using Content.Client.Humanoid; using Content.Client.Lobby.UI; using Content.Client.Message; @@ -217,7 +215,8 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt _heightSlider.MinValue = prototype.MinHeight; _heightSlider.MaxValue = prototype.MaxHeight; _heightSlider.Value = Profile?.Height ?? prototype.DefaultHeight; - CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", _heightSlider.Value)); + var height = MathF.Round(prototype.AverageHeight * _heightSlider.Value); + CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height)); _heightSlider.OnValueChanged += args => { @@ -227,8 +226,8 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt prototype = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First(); // Just in case var value = Math.Clamp(args.Value, prototype.MinHeight, prototype.MaxHeight); - var height = value.ToString(CultureInfo.InvariantCulture); - CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", height.Length > 4 ? height[..4] : height)); + var height = MathF.Round(prototype.AverageHeight * value); + CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height)); SetProfileHeight(value); }; @@ -242,7 +241,8 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt _widthSlider.MinValue = prototype.MinWidth; _widthSlider.MaxValue = prototype.MaxWidth; _widthSlider.Value = Profile?.Width ?? prototype.DefaultWidth; - CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", _widthSlider.Value)); + var width = MathF.Round(prototype.AverageWidth * _widthSlider.Value); + CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width)); _widthSlider.OnValueChanged += args => { @@ -252,8 +252,8 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt prototype = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First(); // Just in case var value = Math.Clamp(args.Value, prototype.MinWidth, prototype.MaxWidth); - var width = value.ToString(CultureInfo.InvariantCulture); - CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width.Length > 4 ? width[..4] : width)); + var width = MathF.Round(prototype.AverageWidth * value); + CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width)); SetProfileWidth(value); }; @@ -1200,8 +1200,8 @@ private void UpdateHeightControls() _heightSlider.Value = Profile.Height; _heightSlider.MaxValue = species.MaxHeight; - var height = Profile.Height.ToString(CultureInfo.InvariantCulture); - CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", height.Length > 4 ? height[..4] : height)); + var height = MathF.Round(species.AverageHeight * _heightSlider.Value); + CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height)); } private void UpdateWidthControls() @@ -1215,8 +1215,8 @@ private void UpdateWidthControls() _widthSlider.Value = Profile.Width; _widthSlider.MaxValue = species.MaxWidth; - var width = Profile.Width.ToString(CultureInfo.InvariantCulture); - CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width.Length > 4 ? width[..4] : width)); + var width = MathF.Round(species.AverageWidth * _widthSlider.Value); + CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width)); } private void UpdateHairPickers() diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 891c790d52..3ece4b48de 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2106,5 +2106,15 @@ public static readonly CVarDef /// public static readonly CVarDef PsionicRollsEnabled = CVarDef.Create("psionics.rolls_enabled", true, CVar.SERVERONLY); + + /* + * Miscellaneous + */ + + public static readonly CVarDef HeightAdjustModifiesHitbox = + CVarDef.Create("heightadjust.modifies_hitbox", true, CVar.SERVERONLY); + + public static readonly CVarDef HeightAdjustModifiesZoom = + CVarDef.Create("heightadjust.modifies_zoom", true, CVar.SERVERONLY); } } diff --git a/Content.Shared/HeightAdjust/HeightAdjustSystem.cs b/Content.Shared/HeightAdjust/HeightAdjustSystem.cs index ef97272073..f7d917545a 100644 --- a/Content.Shared/HeightAdjust/HeightAdjustSystem.cs +++ b/Content.Shared/HeightAdjust/HeightAdjustSystem.cs @@ -1,7 +1,9 @@ using System.Numerics; +using Content.Shared.CCVar; using Content.Shared.Humanoid; using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; @@ -12,6 +14,7 @@ public sealed class HeightAdjustSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedContentEyeSystem _eye = default!; [Dependency] private readonly SharedHumanoidAppearanceSystem _appearance = default!; + [Dependency] private readonly IConfigurationManager _config = default!; /// @@ -23,12 +26,12 @@ public sealed class HeightAdjustSystem : EntitySystem public bool SetScale(EntityUid uid, float scale) { var succeeded = true; - if (EntityManager.TryGetComponent(uid, out var eye)) + if (_config.GetCVar(CCVars.HeightAdjustModifiesZoom) && EntityManager.TryGetComponent(uid, out var eye)) _eye.SetMaxZoom(uid, eye.MaxZoom * scale); else succeeded = false; - if (EntityManager.TryGetComponent(uid, out var fixtures)) + if (_config.GetCVar(CCVars.HeightAdjustModifiesHitbox) && EntityManager.TryGetComponent(uid, out var fixtures)) { foreach (var fixture in fixtures.Fixtures) { @@ -61,12 +64,12 @@ public bool SetScale(EntityUid uid, Vector2 scale) var succeeded = true; var avg = (scale.X + scale.Y) / 2; - if (EntityManager.TryGetComponent(uid, out var eye)) + if (_config.GetCVar(CCVars.HeightAdjustModifiesZoom) && EntityManager.TryGetComponent(uid, out var eye)) _eye.SetMaxZoom(uid, eye.MaxZoom * avg); else succeeded = false; - if (EntityManager.TryGetComponent(uid, out var fixtures)) + if (_config.GetCVar(CCVars.HeightAdjustModifiesHitbox) && EntityManager.TryGetComponent(uid, out var fixtures)) { foreach (var fixture in fixtures.Fixtures) { diff --git a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs index 6184ba5839..8268d0d7c7 100644 --- a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs +++ b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs @@ -162,6 +162,18 @@ public sealed partial class SpeciesPrototype : IPrototype /// [DataField] public float MaxWidth = 1.3f; + + /// + /// The average height in centimeters for this species, used to calculate player facing height values in UI elements + /// + [DataField] + public float AverageHeight = 176.1f; + + /// + /// The average shoulder-to-shoulder width in cm for this species, used to calculate player facing width values in UI elements + /// + [DataField] + public float AverageWidth = 40f; } public enum SpeciesNaming : byte diff --git a/Resources/Locale/en-US/preferences/ui/humanoid-profile-editor.ftl b/Resources/Locale/en-US/preferences/ui/humanoid-profile-editor.ftl index cf0957b894..d767a3ddf3 100644 --- a/Resources/Locale/en-US/preferences/ui/humanoid-profile-editor.ftl +++ b/Resources/Locale/en-US/preferences/ui/humanoid-profile-editor.ftl @@ -12,8 +12,8 @@ humanoid-profile-editor-sex-unsexed-text = None humanoid-profile-editor-age-label = Age: humanoid-profile-editor-skin-color-label = Skin color: # Parkstation-HeightSlider -humanoid-profile-editor-height-label = Height: {$height}x -humanoid-profile-editor-width-label = Width: {$width}x +humanoid-profile-editor-height-label = Height: {$height}cm +humanoid-profile-editor-width-label = Width: {$width}cm humanoid-profile-editor-species-label = Species: humanoid-profile-editor-pronouns-label = Pronouns: humanoid-profile-editor-pronouns-male-text = He / Him From 639a17ee0f94bf0532587bef0f599f86aa5749c1 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Tue, 18 Jun 2024 22:38:53 -0400 Subject: [PATCH 02/84] Height sliders now include weight --- .../Preferences/UI/HumanoidProfileEditor.xaml | 4 ++ .../UI/HumanoidProfileEditor.xaml.cs | 43 ++++++++++++++++++- .../ui/humanoid-profile-editor.ftl | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml index 2242720dac..a6b3266a84 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml @@ -121,6 +121,10 @@