Skip to content

Commit

Permalink
Merge pull request #132 from SS14-Classic/update-2/17/2025
Browse files Browse the repository at this point in the history
Update 02 17 2025
  • Loading branch information
VMSolidus authored Feb 18, 2025
2 parents 93854c0 + 5388441 commit 630752d
Show file tree
Hide file tree
Showing 530 changed files with 212,385 additions and 185,042 deletions.
21 changes: 11 additions & 10 deletions Content.Client/Cargo/Systems/CargoSystem.Telepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,34 @@ private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component,

private void OnChangeData(EntityUid uid, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref sprite))
if (!Resolve(uid, ref sprite)
|| !EntityManager.TryGetComponent(uid, out AnimationPlayerComponent? animation))
return;

var entity = new Entity<AnimationPlayerComponent>(uid, animation);
_appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
AnimationPlayerComponent? player = null;

switch (state)
{
case CargoTelepadState.Teleporting:
if (_player.HasRunningAnimation(uid, TelepadBeamKey))
if (_player.HasRunningAnimation(uid, animation, TelepadBeamKey))
return;
_player.Stop(uid, player, TelepadIdleKey);
_player.Play(uid, player, CargoTelepadBeamAnimation, TelepadBeamKey);
_player.Stop(entity, animation, TelepadIdleKey);
_player.Play(entity, CargoTelepadBeamAnimation, TelepadBeamKey);
break;
case CargoTelepadState.Unpowered:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, false);
_player.Stop(uid, player, TelepadBeamKey);
_player.Stop(uid, player, TelepadIdleKey);
_player.Stop(uid, animation, TelepadBeamKey);
_player.Stop(uid, animation, TelepadIdleKey);
break;
default:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, true);

if (_player.HasRunningAnimation(uid, player, TelepadIdleKey) ||
_player.HasRunningAnimation(uid, player, TelepadBeamKey))
if (_player.HasRunningAnimation(uid, animation, TelepadIdleKey) ||
_player.HasRunningAnimation(uid, animation, TelepadBeamKey))
return;

_player.Play(uid, player, CargoTelepadIdleAnimation, TelepadIdleKey);
_player.Play(entity, CargoTelepadIdleAnimation, TelepadIdleKey);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Client.Chemistry.UI;
using Content.Client.Items;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Robust.Shared.GameStates;

namespace Content.Client.Chemistry.EntitySystems;

public sealed class FillableOneTimeInjectorSystem : SharedFillableOneTimeInjectorSystem
{
public override void Initialize()
{
base.Initialize();
Subs.ItemStatus<FillableOneTimeInjectorComponent>(ent => new FillableOneTimeInjectorStatusControl(ent, SolutionContainers));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;

namespace Content.Client.Chemistry.UI;

public sealed class FillableOneTimeInjectorStatusControl : Control
{
private readonly Entity<FillableOneTimeInjectorComponent> _parent;
private readonly SharedSolutionContainerSystem _solutionContainers;
private readonly RichTextLabel _label;

private FixedPoint2 PrevVolume;
private FixedPoint2 PrevMaxVolume;
private FixedPoint2 PrevTransferAmount;
private FillableOneTimeInjectorToggleMode PrevToggleStateIndex;

public FillableOneTimeInjectorStatusControl(Entity<FillableOneTimeInjectorComponent> parent, SharedSolutionContainerSystem solutionContainers)
{
_parent = parent;
_solutionContainers = solutionContainers;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution))
return;

// only updates the UI if any of the details are different than they previously were
if (PrevVolume == solution.Volume
&& PrevMaxVolume == solution.MaxVolume
&& PrevTransferAmount == _parent.Comp.TransferAmount)
return;

PrevVolume = solution.Volume;
PrevMaxVolume = solution.MaxVolume;
PrevTransferAmount = _parent.Comp.TransferAmount;
var modeStringLocalized = "";

// only updates the UI if any of the details are different than they previously were
if(PrevToggleStateIndex == _parent.Comp.ToggleState)
return;

PrevToggleStateIndex = _parent.Comp.ToggleState;

// Update current volume and injector state
modeStringLocalized = Loc.GetString(
_parent.Comp.ToggleState switch
{
FillableOneTimeInjectorToggleMode.Draw => "injector-draw-text",
FillableOneTimeInjectorToggleMode.Inject => "injector-inject-text",
FillableOneTimeInjectorToggleMode.Spent => "injector-spent-text",
_ => "injector-invalid-injector-toggle-mode"
});

if (_parent.Comp.ToggleState != FillableOneTimeInjectorToggleMode.Draw)
{
_label.SetMarkup(
Loc.GetString(
"onetime-injector-simple-volume-label",
("currentVolume", solution.Volume),
("modeString", modeStringLocalized)));
}
else
{
_label.SetMarkup(
Loc.GetString(
"injector-volume-label",
("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized),
("transferVolume", _parent.Comp.TransferAmount)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ private void SelectChat(uint number)
UpdateChatList(_recipients);
}

if (MessageList.Parent is ScrollContainer scroll)
scroll.SetScrollValue(new Vector2(0, float.MaxValue));

ActionSendUiMessage?.Invoke(NanoChatUiMessageType.SelectChat, number, null, null);
UpdateCurrentChat();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void UpdateState(BoundUserInterfaceState state)
}
}

private static void SendStockTradingUiMessage(StockTradingUiAction action, int company, float amount, BoundUserInterface userInterface)
private static void SendStockTradingUiMessage(StockTradingUiAction action, int company, int amount, BoundUserInterface userInterface)
{
var newsMessage = new StockTradingUiMessageEvent(action, company, amount);
var message = new CartridgeUiMessage(newsMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public sealed partial class StockTradingUiFragment : BoxContainer
private readonly Dictionary<int, CompanyEntry> _companyEntries = new();

// Event handlers for the parent UI
public event Action<int, float>? OnBuyButtonPressed;
public event Action<int, float>? OnSellButtonPressed;
public event Action<int, int>? OnBuyButtonPressed;
public event Action<int, int>? OnSellButtonPressed;

// Define colors
public static readonly Color PositiveColor = Color.FromHex("#00ff00"); // Green
Expand Down Expand Up @@ -70,8 +70,8 @@ private sealed class CompanyEntry

public CompanyEntry(int companyIndex,
string displayName,
Action<int, float>? onBuyPressed,
Action<int, float>? onSellPressed)
Action<int, int>? onBuyPressed,
Action<int, int>? onSellPressed)
{
Container = new BoxContainer
{
Expand Down Expand Up @@ -216,13 +216,13 @@ public CompanyEntry(int companyIndex,
// Button click events
_buyButton.OnPressed += _ =>
{
if (float.TryParse(_amountEdit.Text, out var amount) && amount > 0)
if (int.TryParse(_amountEdit.Text, out var amount) && amount > 0)
onBuyPressed?.Invoke(companyIndex, amount);
};

_sellButton.OnPressed += _ =>
{
if (float.TryParse(_amountEdit.Text, out var amount) && amount > 0)
if (int.TryParse(_amountEdit.Text, out var amount) && amount > 0)
onSellPressed?.Invoke(companyIndex, amount);
};

Expand All @@ -235,7 +235,7 @@ public CompanyEntry(int companyIndex,
};
}

public void Update(StockCompanyStruct company, int ownedStocks)
public void Update(StockCompany company, int ownedStocks)
{
_nameLabel.Text = company.LocalizedDisplayName;
_priceLabel.Text = $"${company.CurrentPrice:F2}";
Expand Down
8 changes: 6 additions & 2 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:fancyTree="clr-namespace:Content.Client.UserInterface.Controls.FancyTree"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="750 700"
SetSize="850 700"
MinSize="100 200"
Resizable="True"
Title="{Loc 'guidebook-window-title'}">
Expand All @@ -21,9 +21,13 @@
Margin="0 5 10 5">
</LineEdit>
</BoxContainer>
<BoxContainer Access="Internal" Name="ReturnContainer" Orientation="Horizontal" HorizontalAlignment="Right" Visible="False">
<Button Name="HomeButton" Text="{Loc 'ui-rules-button-home'}" Margin="0 0 10 0"/>
</BoxContainer>
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<Control>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False"/>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False">
</BoxContainer>
<BoxContainer Orientation="Vertical" Name="Placeholder" Margin="5 5 5 5">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text'}"/>
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text-2'}"/>
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Controls.FancyTree;
using JetBrains.Annotations;
using Content.Client.UserInterface.Systems.Info;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.ContentPack;
using Robust.Shared.Prototypes;

namespace Content.Client.Guidebook.Controls;

Expand All @@ -21,6 +23,8 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler

private Dictionary<string, GuideEntry> _entries = new();

public ProtoId<GuideEntryPrototype> LastEntry;

public GuidebookWindow()
{
RobustXamlLoader.Load(this);
Expand All @@ -37,7 +41,13 @@ public GuidebookWindow()
private void OnSelectionChanged(TreeItem? item)
{
if (item != null && item.Metadata is GuideEntry entry)
{
ShowGuide(entry);

var isRulesEntry = entry.RuleEntry;
ReturnContainer.Visible = isRulesEntry;
HomeButton.OnPressed += _ => ShowGuide(entry);
}
else
ClearSelectedGuide();
}
Expand Down Expand Up @@ -66,6 +76,8 @@ private void ShowGuide(GuideEntry entry)
EntryContainer.AddChild(new Label() { Text = "ERROR: Failed to parse document." });
Logger.Error($"Failed to parse contents of guide document {entry.Id}.");
}

LastEntry = entry.Id;
}

public void UpdateGuides(
Expand Down Expand Up @@ -152,6 +164,10 @@ private void RepopulateTree(List<string>? roots = null, string? forcedRoot = nul
return null;
}

var rulesProto = UserInterfaceManager.GetUIController<InfoUIController>().GetCoreRuleEntry();
if (entry.RuleEntry && entry.Id != rulesProto.Id)
return null;

var item = Tree.AddItem(parent);
item.Metadata = entry;
var name = Loc.GetString(entry.Name);
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Guidebook/GuideEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class GuideEntry
/// </summary>
[DataField("filterEnabled")] public bool FilterEnabled = default!;

[DataField] public bool RuleEntry;

/// <summary>
/// Priority for sorting top-level guides when shown in a tree / table of contents.
/// If the guide is the child of some other guide, the order simply determined by the order of children in <see cref="Children"/>.
Expand Down
58 changes: 58 additions & 0 deletions Content.Client/Light/AfterLightTargetOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Numerics;
using Robust.Client.Graphics;
using Robust.Shared.Enums;

namespace Content.Client.Light;

/// <summary>
/// This exists just to copy <see cref="BeforeLightTargetOverlay"/> to the light render target
/// </summary>
public sealed class AfterLightTargetOverlay : Overlay
{
public override OverlaySpace Space => OverlaySpace.BeforeLighting;

[Dependency] private readonly IOverlayManager _overlay = default!;

public const int ContentZIndex = LightBlurOverlay.ContentZIndex + 1;

public AfterLightTargetOverlay()
{
IoCManager.InjectDependencies(this);
ZIndex = ContentZIndex;
}

protected override void Draw(in OverlayDrawArgs args)
{
var viewport = args.Viewport;
var worldHandle = args.WorldHandle;

if (viewport.Eye == null)
return;

var lightOverlay = _overlay.GetOverlay<BeforeLightTargetOverlay>();
var bounds = args.WorldBounds;

// at 1-1 render scale it's mostly fine but at 4x4 it's way too fkn big
var newScale = viewport.RenderScale / 2f;

var localMatrix =
viewport.LightRenderTarget.GetWorldToLocalMatrix(viewport.Eye, newScale);
var diff = (lightOverlay.EnlargedLightTarget.Size - viewport.LightRenderTarget.Size);
var halfDiff = diff / 2;

// Pixels -> Metres -> Half distance.
// If we're zoomed in need to enlarge the bounds further.
args.WorldHandle.RenderInRenderTarget(viewport.LightRenderTarget,
() =>
{
// We essentially need to draw the cropped version onto the lightrendertarget.
var subRegion = new UIBox2i(halfDiff.X,
halfDiff.Y,
viewport.LightRenderTarget.Size.X + halfDiff.X,
viewport.LightRenderTarget.Size.Y + halfDiff.Y);

worldHandle.SetTransform(localMatrix);
worldHandle.DrawTextureRectRegion(lightOverlay.EnlargedLightTarget.Texture, bounds, subRegion: subRegion);
}, null);
}
}
Loading

0 comments on commit 630752d

Please sign in to comment.