Skip to content

Commit

Permalink
Merge remote-tracking branch 'wizard/master' into upstream-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Apr 24, 2024
2 parents 6f14a1c + eb648dd commit 079fbe4
Show file tree
Hide file tree
Showing 70 changed files with 1,197 additions and 419 deletions.
12 changes: 9 additions & 3 deletions Content.Client/DoAfter/DoAfterOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed class DoAfterOverlay : Overlay
private readonly ProgressColorSystem _progressColor;

private readonly Texture _barTexture;
private readonly ShaderInstance _shader;
private readonly ShaderInstance _unshadedShader;

/// <summary>
/// Flash time for cancelled DoAfters
Expand All @@ -45,7 +45,7 @@ public DoAfterOverlay(IEntityManager entManager, IPrototypeManager protoManager,
var sprite = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/progress_bar.rsi"), "icon");
_barTexture = _entManager.EntitySysManager.GetEntitySystem<SpriteSystem>().Frame0(sprite);

_shader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
_unshadedShader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
}

protected override void Draw(in OverlayDrawArgs args)
Expand All @@ -58,7 +58,6 @@ protected override void Draw(in OverlayDrawArgs args)
const float scale = 1f;
var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3.CreateRotation(-rotation);
handle.UseShader(_shader);

var curTime = _timing.CurTime;

Expand All @@ -79,6 +78,13 @@ protected override void Draw(in OverlayDrawArgs args)
if (!bounds.Contains(worldPosition))
continue;

// shades the do-after bar if the do-after bar belongs to other players
// does not shade do-afters belonging to the local player
if (uid != localEnt)
handle.UseShader(null);
else
handle.UseShader(_unshadedShader);

// If the entity is paused, we will draw the do-after as it was when the entity got paused.
var meta = metaQuery.GetComponent(uid);
var time = meta.EntityPaused
Expand Down
16 changes: 6 additions & 10 deletions Content.Client/Implants/UI/ImplanterStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Implants.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
Expand All @@ -17,7 +18,7 @@ public ImplanterStatusControl(ImplanterComponent parent)
_parent = parent;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
_label.MaxWidth = 350;
AddChild(_label);
AddChild(new ClipControl { Children = { _label } });

Update();
}
Expand All @@ -42,17 +43,12 @@ private void Update()
_ => Loc.GetString("injector-invalid-injector-toggle-mode")
};

var (implantName, implantDescription) = _parent.ImplanterSlot.HasItem switch
{
false => (Loc.GetString("implanter-empty-text"), ""),
true => (_parent.ImplantData.Item1, _parent.ImplantData.Item2),
};

var implantName = _parent.ImplanterSlot.HasItem
? _parent.ImplantData.Item1
: Loc.GetString("implanter-empty-text");

_label.SetMarkup(Loc.GetString("implanter-label",
("implantName", implantName),
("implantDescription", implantDescription),
("modeString", modeStringLocalized),
("lineBreak", "\n")));
("modeString", modeStringLocalized)));
}
}
7 changes: 7 additions & 0 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public sealed class StyleNano : StyleBase
public const string StyleClassPowerStateGood = "PowerStateGood";

public const string StyleClassItemStatus = "ItemStatus";
public const string StyleClassItemStatusNotHeld = "ItemStatusNotHeld";
public static readonly Color ItemStatusNotHeldColor = Color.Gray;

//Background
public const string StyleClassBackgroundBaseDark = "PanelBackgroundBaseDark";
Expand Down Expand Up @@ -1234,6 +1236,11 @@ public StyleNano(IResourceCache resCache) : base(resCache)
new StyleProperty("font", notoSans10),
}),

Element()
.Class(StyleClassItemStatusNotHeld)
.Prop("font", notoSansItalic10)
.Prop("font-color", ItemStatusNotHeldColor),

Element<RichTextLabel>()
.Class(StyleClassItemStatus)
.Prop(nameof(RichTextLabel.LineHeightScale), 0.7f)
Expand Down
55 changes: 55 additions & 0 deletions Content.Client/UserInterface/Controls/ClipControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Numerics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;

namespace Content.Client.UserInterface.Controls;

/// <summary>
/// Pretends to child controls that there's infinite space.
/// This can be used to make something like a <see cref="RichTextLabel"/> clip instead of wrapping.
/// </summary>
public sealed class ClipControl : Control
{
private bool _clipHorizontal = true;
private bool _clipVertical = true;

public bool ClipHorizontal
{
get => _clipHorizontal;
set
{
_clipHorizontal = value;
InvalidateMeasure();
}
}

public bool ClipVertical
{
get => _clipVertical;
set
{
_clipVertical = value;
InvalidateMeasure();
}
}

protected override Vector2 MeasureOverride(Vector2 availableSize)
{
if (ClipHorizontal)
availableSize = availableSize with { X = float.PositiveInfinity };
if (ClipVertical)
availableSize = availableSize with { Y = float.PositiveInfinity };

return base.MeasureOverride(availableSize);
}

protected override Vector2 ArrangeOverride(Vector2 finalSize)
{
foreach (var child in Children)
{
child.Arrange(UIBox2.FromDimensions(Vector2.Zero, child.DesiredSize));
}

return finalSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ namespace Content.Client.UserInterface.Systems.Hands.Controls;

public sealed class HandButton : SlotControl
{
public HandLocation HandLocation { get; }

public HandButton(string handName, HandLocation handLocation)
{
HandLocation = handLocation;
Name = "hand_" + handName;
SlotName = handName;
SetBackground(handLocation);
Expand Down
30 changes: 27 additions & 3 deletions Content.Client/UserInterface/Systems/Hands/HandsUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ private void SetActiveHand(string? handName)
_player.LocalSession?.AttachedEntity is { } playerEntity &&
_handsSystem.TryGetHand(playerEntity, handName, out var hand, _playerHandsComponent))
{
if (hand.Location == HandLocation.Left)
var foldedLocation = hand.Location.GetUILocation();
if (foldedLocation == HandUILocation.Left)
{
_statusHandLeft = handControl;
HandsGui.UpdatePanelEntityLeft(hand.HeldEntity);
Expand All @@ -268,7 +269,7 @@ private void SetActiveHand(string? handName)
HandsGui.UpdatePanelEntityRight(hand.HeldEntity);
}

HandsGui.SetHighlightHand(hand.Location);
HandsGui.SetHighlightHand(foldedLocation);
}
}

Expand Down Expand Up @@ -299,11 +300,13 @@ private HandButton AddHand(string handName, HandLocation location)
// If we don't have a status for this hand type yet, set it.
// This means we have status filled by default in most scenarios,
// otherwise the user'd need to switch hands to "activate" the hands the first time.
if (location == HandLocation.Left)
if (location.GetUILocation() == HandUILocation.Left)
_statusHandLeft ??= button;
else
_statusHandRight ??= button;

UpdateVisibleStatusPanels();

return button;
}

Expand Down Expand Up @@ -369,9 +372,30 @@ private bool RemoveHand(string handName, out HandButton? handButton)

_handLookup.Remove(handName);
handButton.Dispose();
UpdateVisibleStatusPanels();
return true;
}

private void UpdateVisibleStatusPanels()
{
var leftVisible = false;
var rightVisible = false;

foreach (var hand in _handLookup.Values)
{
if (hand.HandLocation.GetUILocation() == HandUILocation.Left)
{
leftVisible = true;
}
else
{
rightVisible = true;
}
}

HandsGui?.UpdateStatusVisibility(leftVisible, rightVisible);
}

public string RegisterHandContainer(HandsContainer handContainer)
{
var name = "HandContainer_" + _backupSuffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Name="StatusPanelRight"
HorizontalAlignment="Center" Margin="0 0 -2 2"
SetWidth="125"
MaxHeight="60"/>
SetHeight="60"/>
<hands:HandsContainer
Name="HandContainer"
Access="Public"
Expand All @@ -43,7 +43,7 @@
Name="StatusPanelLeft"
HorizontalAlignment="Center" Margin="-2 0 0 2"
SetWidth="125"
MaxHeight="60"/>
SetHeight="60"/>
<inventory:ItemSlotButtonContainer
Name="MainHotbar"
SlotGroup="MainHotbar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public sealed partial class HotbarGui : UIWidget
public HotbarGui()
{
RobustXamlLoader.Load(this);
StatusPanelRight.SetSide(HandLocation.Right);
StatusPanelLeft.SetSide(HandLocation.Left);
StatusPanelRight.SetSide(HandUILocation.Right);
StatusPanelLeft.SetSide(HandUILocation.Left);
var hotbarController = UserInterfaceManager.GetUIController<HotbarUIController>();

hotbarController.Setup(HandContainer, StoragePanel);
Expand All @@ -29,9 +29,15 @@ public void UpdatePanelEntityRight(EntityUid? entity)
StatusPanelRight.Update(entity);
}

public void SetHighlightHand(HandLocation? hand)
public void SetHighlightHand(HandUILocation? hand)
{
StatusPanelLeft.UpdateHighlight(hand is HandLocation.Left);
StatusPanelRight.UpdateHighlight(hand is HandLocation.Middle or HandLocation.Right);
StatusPanelLeft.UpdateHighlight(hand is HandUILocation.Left);
StatusPanelRight.UpdateHighlight(hand is HandUILocation.Right);
}

public void UpdateStatusVisibility(bool left, bool right)
{
StatusPanelLeft.Visible = left;
StatusPanelRight.Visible = right;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
VerticalAlignment="Bottom"
HorizontalAlignment="Center">
<Control Name="VisWrapper" Visible="False">
<PanelContainer Name="Panel">
<PanelContainer.PanelOverride>
<graphics:StyleBoxTexture
PatchMarginBottom="4"
PatchMarginTop="6"
TextureScale="2 2"
Mode="Tile"/>
</PanelContainer.PanelOverride>
</PanelContainer>
<PanelContainer Name="HighlightPanel">
<PanelContainer.PanelOverride>
<graphics:StyleBoxTexture PatchMarginBottom="4" PatchMarginTop="6" TextureScale="2 2">
</graphics:StyleBoxTexture>
</PanelContainer.PanelOverride>
</PanelContainer>
<BoxContainer Name="Contents" Orientation="Vertical" Margin="0 6 0 4">
<BoxContainer Name="StatusContents" Orientation="Vertical" />
<Label Name="ItemNameLabel" ClipText="True" StyleClasses="ItemStatus" Align="Left" />
</BoxContainer>
</Control>
<PanelContainer Name="Panel">
<PanelContainer.PanelOverride>
<graphics:StyleBoxTexture
PatchMarginBottom="4"
PatchMarginTop="6"
TextureScale="2 2"
Mode="Tile"/>
</PanelContainer.PanelOverride>
</PanelContainer>
<PanelContainer Name="HighlightPanel">
<PanelContainer.PanelOverride>
<graphics:StyleBoxTexture PatchMarginBottom="4" PatchMarginTop="6" TextureScale="2 2">
</graphics:StyleBoxTexture>
</PanelContainer.PanelOverride>
</PanelContainer>
<BoxContainer Name="Contents" Orientation="Vertical" Margin="0 6 0 4" RectClipContent="True">
<BoxContainer Name="StatusContents" Orientation="Vertical" VerticalExpand="True" VerticalAlignment="Bottom" />
<Control>
<Label Name="NoItemLabel" ClipText="True" StyleClasses="ItemStatusNotHeld" Align="Left" Text="{Loc 'item-status-not-held'}" />
<Label Name="ItemNameLabel" ClipText="True" StyleClasses="ItemStatus" Align="Left" Visible="False" />
</Control>
</BoxContainer>
</controls:ItemStatusPanel>
Loading

0 comments on commit 079fbe4

Please sign in to comment.