Skip to content

Commit

Permalink
Merge branch 'master' into Port-Of-Supermatter
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jun 29, 2024
2 parents 4570415 + 45b5c92 commit e5de134
Show file tree
Hide file tree
Showing 1,133 changed files with 11,843 additions and 444 deletions.
12 changes: 12 additions & 0 deletions Content.Client/Humanoid/HumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
Expand Down Expand Up @@ -30,6 +31,15 @@ private void UpdateSprite(HumanoidAppearanceComponent component, SpriteComponent
UpdateLayers(component, sprite);
ApplyMarkingSet(component, sprite);

var speciesPrototype = _prototypeManager.Index(component.Species);

var height = Math.Clamp(component.Height, speciesPrototype.MinHeight, speciesPrototype.MaxHeight);
var width = Math.Clamp(component.Width, speciesPrototype.MinWidth, speciesPrototype.MaxWidth);
component.Height = height;
component.Width = width;

sprite.Scale = new Vector2(width, height);

sprite[sprite.LayerMapReserveBlank(HumanoidVisualLayers.Eyes)].Color = component.EyeColor;
}

Expand Down Expand Up @@ -194,6 +204,8 @@ public override void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile
humanoid.Species = profile.Species;
humanoid.SkinColor = profile.Appearance.SkinColor;
humanoid.EyeColor = profile.Appearance.EyeColor;
humanoid.Height = profile.Height;
humanoid.Width = profile.Width;

UpdateSprite(humanoid, Comp<SpriteComponent>(uid));
}
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@
<Label Text="{Loc 'humanoid-profile-editor-spawn-priority-label'}" />
<Control HorizontalExpand="True"/>
<OptionButton Name="CSpawnPriorityButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Height -->
<BoxContainer HorizontalExpand="True">
<Label Name="CHeightLabel" MinWidth="110" />
<Slider Name="CHeightSlider" MinValue="0.5" Value="1" MaxValue="1.5" HorizontalExpand="True" Margin="5 0 5 0" />
<Button Name="CHeightReset" Text="{Loc 'ui-options-bind-reset'}" />
</BoxContainer>
<!-- Width -->
<BoxContainer HorizontalExpand="True">
<Label Name="CWidthLabel" MinWidth="110" />
<Slider Name="CWidthSlider" MinValue="0.5" Value="1" MaxValue="1.5" HorizontalExpand="True" Margin="5 0 5 0" />
<Button Name="CWidthReset" Text="{Loc 'ui-options-bind-reset'}" />
</BoxContainer>
<!--Weight -->
<BoxContainer HorizontalExpand="True">
<Label Name="CWeightLabel" />
</BoxContainer>
</BoxContainer>
<!-- Skin -->
Expand Down
148 changes: 148 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
Expand Down Expand Up @@ -81,6 +82,8 @@ public sealed partial class HumanoidProfileEditor : Control
private SingleMarkingPicker _hairPicker => CHairStylePicker;
private SingleMarkingPicker _facialHairPicker => CFacialHairPicker;
private EyeColorPicker _eyesPicker => CEyeColorPicker;
private Slider _heightSlider => CHeightSlider;
private Slider _widthSlider => CWidthSlider;

private TabContainer _tabContainer => CTabContainer;
private BoxContainer _jobList => CJobList;
Expand Down Expand Up @@ -213,6 +216,82 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Species

#region Height

var prototype = _speciesList.Find(x => x.ID == Profile?.Species) ?? _speciesList.First();

_heightSlider.MinValue = prototype.MinHeight;
_heightSlider.MaxValue = prototype.MaxHeight;
_heightSlider.Value = Profile?.Height ?? prototype.DefaultHeight;
var height = MathF.Round(prototype.AverageHeight * _heightSlider.Value);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height));

_heightSlider.OnValueChanged += args =>
{
if (Profile is null)
return;
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 = MathF.Round(prototype.AverageHeight * value);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height));
SetProfileHeight(value);
UpdateWeight();
};

CHeightReset.OnPressed += _ =>
{
_heightSlider.Value = prototype.DefaultHeight;
SetProfileHeight(prototype.DefaultHeight);
UpdateWeight();
};


_widthSlider.MinValue = prototype.MinWidth;
_widthSlider.MaxValue = prototype.MaxWidth;
_widthSlider.Value = Profile?.Width ?? prototype.DefaultWidth;
var width = MathF.Round(prototype.AverageWidth * _widthSlider.Value);
CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width));

_widthSlider.OnValueChanged += args =>
{
if (Profile is null)
return;
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 = MathF.Round(prototype.AverageWidth * value);
CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", width));
SetProfileWidth(value);
UpdateWeight();
};

CWidthReset.OnPressed += _ =>
{
_widthSlider.Value = prototype.DefaultWidth;
SetProfileWidth(prototype.DefaultWidth);
UpdateWeight();
};

prototypeManager.Index(prototype.Prototype).TryGetComponent<FixturesComponent>(out var fixture);
if (fixture != null)
{
var radius = fixture.Fixtures["fix1"].Shape.Radius;
var density = fixture.Fixtures["fix1"].Density;
var avg = (_widthSlider.Value + _heightSlider.Value) / 2;
var weight = MathF.Round(MathF.PI * MathF.Pow(radius * avg, 2) * density);
CWeightLabel.Text = Loc.GetString("humanoid-profile-editor-weight-label", ("weight", (int) weight));
}
else
{
// Whelp, the fixture doesn't exist, guesstimate it instead
CWeightLabel.Text = Loc.GetString("humanoid-profile-editor-weight-label", ("weight", (int) 71));
}

#endregion Height

#region Skin


Expand Down Expand Up @@ -877,6 +956,10 @@ private void SetSpecies(string newSpecies)
OnSkinColorOnValueChanged(); // Species may have special color prefs, make sure to update it.
CMarkings.SetSpecies(newSpecies); // Repopulate the markings tab as well.
UpdateSexControls(); // update sex for new species
// Changing species provides inaccurate sliders without these
UpdateHeightControls();
UpdateWidthControls();
UpdateWeight();
RebuildSpriteView(); // they might have different inv so we need a new dummy
UpdateSpeciesGuidebookIcon();
IsDirty = true;
Expand Down Expand Up @@ -907,6 +990,18 @@ private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
IsDirty = true;
}

private void SetProfileHeight(float height)
{
Profile = Profile?.WithHeight(height);
IsDirty = true;
}

private void SetProfileWidth(float width)
{
Profile = Profile?.WithWidth(width);
IsDirty = true;
}

public void Save()
{
IsDirty = false;
Expand Down Expand Up @@ -1111,6 +1206,56 @@ private void UpdateSpawnPriorityControls()
_spawnPriorityButton.SelectId((int) Profile.SpawnPriority);
}

private void UpdateHeightControls()
{
if (Profile == null)
return;

var species = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First();

_heightSlider.MinValue = species.MinHeight;
_heightSlider.Value = Profile.Height;
_heightSlider.MaxValue = species.MaxHeight;

var height = MathF.Round(species.AverageHeight * _heightSlider.Value);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height));
}

private void UpdateWidthControls()
{
if (Profile == null)
return;

var species = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First();

_widthSlider.MinValue = species.MinWidth;
_widthSlider.Value = Profile.Width;
_widthSlider.MaxValue = species.MaxWidth;

var width = MathF.Round(species.AverageWidth * _widthSlider.Value);
CWidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", (int) width));
}

private void UpdateWeight()
{
if (Profile == null)
return;

var species = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First();
_prototypeManager.Index(species.Prototype).TryGetComponent<FixturesComponent>(out var fixture);

if (fixture != null)
{
var radius = fixture.Fixtures["fix1"].Shape.Radius;
var density = fixture.Fixtures["fix1"].Density;
var avg = (Profile.Width + Profile.Height) / 2;
var weight = MathF.Round(MathF.PI * MathF.Pow(radius * avg, 2) * density);
CWeightLabel.Text = Loc.GetString("humanoid-profile-editor-weight-label", ("weight", (int) weight));
}

_previewSpriteView.InvalidateMeasure();
}

private void UpdateHairPickers()
{
if (Profile == null)
Expand Down Expand Up @@ -1266,6 +1411,9 @@ public void UpdateControls()
UpdateHairPickers();
UpdateCMarkingsHair();
UpdateCMarkingsFacialHair();
UpdateHeightControls();
UpdateWidthControls();
UpdateWeight();

_preferenceUnavailableButton.SelectId((int) Profile.PreferenceUnavailable);
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Shuttles/UI/BaseShuttleControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public BaseShuttleControl(float minRange, float maxRange, float range) : base(mi

protected void DrawData(DrawingHandleScreen handle, string text)
{
var coordsDimensions = handle.GetDimensions(Font, text, UIScale);
var coordsDimensions = handle.GetDimensions(Font, text, 1f);
const float coordsMargins = 5f;

handle.DrawString(Font,
new Vector2(coordsMargins, Height) - new Vector2(0f, coordsDimensions.Y + coordsMargins),
new Vector2(coordsMargins, PixelHeight) - new Vector2(0f, coordsDimensions.Y + coordsMargins),
text,
Color.FromSrgb(IFFComponent.SelfColor));
}
Expand Down
11 changes: 6 additions & 5 deletions Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected override void KeyBindUp(GUIBoundKeyEventArgs args)

var mapTransform = Matrix3.CreateInverseTransform(Offset, Angle.Zero);

if (beaconsOnly && TryGetBeacon(_beacons, mapTransform, args.RelativePosition, PixelRect, out var foundBeacon, out _))
if (beaconsOnly && TryGetBeacon(_beacons, mapTransform, args.RelativePixelPosition, PixelRect, out var foundBeacon, out _))
{
RequestBeaconFTL?.Invoke(foundBeacon.Entity, _ftlAngle);
}
Expand Down Expand Up @@ -206,7 +206,8 @@ private void DrawParallax(DrawingHandleScreen handle)
private List<IMapObject> GetViewportMapObjects(Matrix3 matty, List<IMapObject> mapObjects)
{
var results = new List<IMapObject>();
var viewBox = SizeBox.Scale(1.2f);
var enlargement = new Vector2i((int) (16 * UIScale), (int) (16 * UIScale));
var viewBox = new UIBox2i(Vector2i.Zero - enlargement, PixelSize + enlargement);

foreach (var mapObj in mapObjects)
{
Expand Down Expand Up @@ -398,8 +399,8 @@ protected override void Draw(DrawingHandleScreen handle)

foreach (var (gridUiPos, iffText) in sendStrings)
{
var textWidth = handle.GetDimensions(_font, iffText, UIScale);
handle.DrawString(_font, gridUiPos + textWidth with { X = -textWidth.X / 2f }, iffText, adjustedColor);
var textWidth = handle.GetDimensions(_font, iffText, 1f);
handle.DrawString(_font, gridUiPos + textWidth with { X = -textWidth.X / 2f, Y = textWidth.Y * UIScale }, iffText, adjustedColor);
}
}

Expand Down Expand Up @@ -587,7 +588,7 @@ private bool TryGetBeacon(IEnumerable<IMapObject> mapObjects, Matrix3 mapTransfo

var distance = (localPos - mousePos).Length();

if (distance > BeaconSnapRange ||
if (distance > BeaconSnapRange * UIScale ||
distance > nearestValue)
{
continue;
Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Content.Client.Gameplay;
using Content.Client.Items;
using Content.Client.Weapons.Ranged.Components;
using Content.Shared.Camera;
Expand All @@ -12,6 +13,7 @@
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.State;
using Robust.Shared.Animations;
using Robust.Shared.Input;
using Robust.Shared.Map;
Expand All @@ -27,6 +29,7 @@ public sealed partial class GunSystem : SharedGunSystem
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IStateManager _state = default!;
[Dependency] private readonly AnimationPlayerSystem _animPlayer = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly SharedCameraRecoilSystem _recoil = default!;
Expand Down Expand Up @@ -171,10 +174,15 @@ public override void Update(float frameTime)
// Define target coordinates relative to gun entity, so that network latency on moving grids doesn't fuck up the target location.
var coordinates = EntityCoordinates.FromMap(entity, mousePos, TransformSystem, EntityManager);

NetEntity? target = null;
if (_state.CurrentState is GameplayStateBase screen)
target = GetNetEntity(screen.GetClickedEntity(mousePos));

Log.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}");

EntityManager.RaisePredictiveEvent(new RequestShootEvent
{
Target = target,
Coordinates = GetNetCoordinates(coordinates),
Gun = GetNetEntity(gunUid),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ private static HumanoidCharacterProfile CharlieCharlieson()
"Charlie Charlieson",
"The biggest boy around.",
"Human",
1,
1,
21,
Sex.Male,
Gender.Epicene,
Expand Down
Loading

0 comments on commit e5de134

Please sign in to comment.