Skip to content

Commit

Permalink
Merge pull request space-wizards#78 from ss14-harmony/upstream20240925
Browse files Browse the repository at this point in the history
Upstream20240925
  • Loading branch information
KeldWolf authored Sep 26, 2024
2 parents bf201d8 + 16dabf8 commit 4f83878
Show file tree
Hide file tree
Showing 65 changed files with 1,638 additions and 818 deletions.
27 changes: 27 additions & 0 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ public override void Initialize()
SubscribeLocalEvent<EntityWorldTargetActionComponent, ComponentHandleState>(OnEntityWorldTargetHandleState);
}

public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);

var worldActionQuery = EntityQueryEnumerator<WorldTargetActionComponent>();
while (worldActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}

var instantActionQuery = EntityQueryEnumerator<InstantActionComponent>();
while (instantActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}

var entityActionQuery = EntityQueryEnumerator<EntityTargetActionComponent>();
while (entityActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}
}

private void OnInstantHandleState(EntityUid uid, InstantActionComponent component, ref ComponentHandleState args)
{
if (args.Current is not InstantActionComponentState state)
Expand Down Expand Up @@ -95,6 +118,8 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.Icon = state.Icon;
component.IconOn = state.IconOn;
component.IconColor = state.IconColor;
component.OriginalIconColor = state.OriginalIconColor;
component.DisabledIconColor = state.DisabledIconColor;
component.Keywords.Clear();
component.Keywords.UnionWith(state.Keywords);
component.Enabled = state.Enabled;
Expand Down Expand Up @@ -125,6 +150,8 @@ public override void UpdateAction(EntityUid? actionId, BaseActionComponent? acti
if (!ResolveActionData(actionId, ref action))
return;

action.IconColor = action.Charges < 1 ? action.DisabledIconColor : action.OriginalIconColor;

base.UpdateAction(actionId, action);
if (_playerManager.LocalEntity != action.AttachedEntity)
return;
Expand Down
9 changes: 0 additions & 9 deletions Content.Client/GPS/Components/HandheldGPSComponent.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Content.Client/GPS/Systems/HandheldGpsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.GPS.UI;
using Content.Client.Items;

Expand Down
15 changes: 11 additions & 4 deletions Content.Client/GPS/UI/HandheldGpsStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -30,6 +30,13 @@ protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

// don't display the label if the gps component is being removed
if (_parent.Comp.LifeStage > ComponentLifeStage.Running)
{
_label.Visible = false;
return;
}

_updateDif += args.DeltaSeconds;
if (_updateDif < _parent.Comp.UpdateRate)
return;
Expand All @@ -44,9 +51,9 @@ private void UpdateGpsDetails()
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int) pos.X;
var y = (int) pos.Y;
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int)pos.X;
var y = (int)pos.Y;
posText = $"({x}, {y})";
}
_label.SetMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Paper/UI/PaperBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
using Content.Shared.Paper;
using static Content.Shared.Paper.PaperComponent;

namespace Content.Client.Paper.UI;
Expand All @@ -23,6 +24,10 @@ protected override void Open()
_window = this.CreateWindow<PaperWindow>();
_window.OnSaved += InputOnTextEntered;

if (EntMan.TryGetComponent<PaperComponent>(Owner, out var paper))
{
_window.MaxInputLength = paper.ContentSize;
}
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
_window.InitVisuals(Owner, visuals);
Expand Down
11 changes: 7 additions & 4 deletions Content.Client/Paper/UI/PaperWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
<Control Name="TextAlignmentPadding" VerticalAlignment="Top"/>
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
</PanelContainer>
<BoxContainer Name="InputContainer" Orientation="Vertical" VerticalExpand="True" VerticalAlignment="Stretch">
<PanelContainer StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
</PanelContainer>
<Label Name="FillStatus" StyleClasses="LabelSecondaryColor"/>
</BoxContainer>
</BoxContainer>
<paper:StampCollection Name="StampDisplay" VerticalAlignment="Bottom" Margin="6"/>

Expand Down
49 changes: 47 additions & 2 deletions Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public sealed partial class PaperWindow : BaseWindow

public event Action<string>? OnSaved;

private int _MaxInputLength = -1;
public int MaxInputLength
{
get
{
return _MaxInputLength;
}
set
{
_MaxInputLength = value;
UpdateFillState();
}
}

public PaperWindow()
{
IoCManager.InjectDependencies(this);
Expand All @@ -63,11 +77,21 @@ public PaperWindow()
{
if (args.Function == EngineKeyFunctions.MultilineTextSubmit)
{
RunOnSaved();
args.Handle();
// SaveButton is disabled when we hit the max input limit. Just check
// that flag instead of trying to calculate the input length again
if (!SaveButton.Disabled)
{
RunOnSaved();
args.Handle();
}
}
};

Input.OnTextChanged += args =>
{
UpdateFillState();
};

SaveButton.OnPressed += _ =>
{
RunOnSaved();
Expand Down Expand Up @@ -126,6 +150,7 @@ public void InitVisuals(EntityUid entity, PaperVisualsComponent visuals)

PaperContent.ModulateSelfOverride = visuals.ContentImageModulate;
WrittenTextLabel.ModulateSelfOverride = visuals.FontAccentColor;
FillStatus.ModulateSelfOverride = visuals.FontAccentColor;

var contentImage = visuals.ContentImagePath != null ? _resCache.GetResource<TextureResource>(visuals.ContentImagePath) : null;
if (contentImage != null)
Expand Down Expand Up @@ -296,5 +321,25 @@ private void RunOnSaved()
{
OnSaved?.Invoke(Rope.Collapse(Input.TextRope));
}

private void UpdateFillState()
{
if (MaxInputLength != -1)
{
var inputLength = Input.TextLength;

FillStatus.Text = Loc.GetString("paper-ui-fill-level",
("currentLength", inputLength),
("maxLength", MaxInputLength));

// Disable the save button if we've gone over the limit
SaveButton.Disabled = inputLength > MaxInputLength;
}
else
{
FillStatus.Text = "";
SaveButton.Disabled = false;
}
}
}
}
2 changes: 1 addition & 1 deletion Content.Server/Access/Systems/AgentIDCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize()

private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
{
if (!TryComp<AccessComponent>(args.Target, out var targetAccess) || !HasComp<IdCardComponent>(args.Target) || args.Target == null)
if (args.Target == null || !args.CanReach || !TryComp<AccessComponent>(args.Target, out var targetAccess) || !HasComp<IdCardComponent>(args.Target))
return;

if (!TryComp<AccessComponent>(uid, out var access) || !HasComp<IdCardComponent>(uid))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.GPS;

namespace Content.Server.CartridgeLoader.Cartridges;

[RegisterComponent]
public sealed partial class AstroNavCartridgeComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.GPS.Components;

namespace Content.Server.CartridgeLoader.Cartridges;

public sealed class AstroNavCartridgeSystem : EntitySystem
{
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoaderSystem = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AstroNavCartridgeComponent, CartridgeAddedEvent>(OnCartridgeAdded);
SubscribeLocalEvent<AstroNavCartridgeComponent, CartridgeRemovedEvent>(OnCartridgeRemoved);
}

private void OnCartridgeAdded(Entity<AstroNavCartridgeComponent> ent, ref CartridgeAddedEvent args)
{
EnsureComp<HandheldGPSComponent>(args.Loader);
}

private void OnCartridgeRemoved(Entity<AstroNavCartridgeComponent> ent, ref CartridgeRemovedEvent args)
{
// only remove when the program itself is removed
if (!_cartridgeLoaderSystem.HasProgram<AstroNavCartridgeComponent>(args.Loader))
{
RemComp<HandheldGPSComponent>(args.Loader);
}
}
}
1 change: 1 addition & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private void OnGameChange(GameRunLevelChangedEvent ev)
_configurationManager.SetCVar(CCVars.OocEnabled, false);
break;
case GameRunLevel.PostRound:
case GameRunLevel.PreRoundLobby:
if (!_configurationManager.GetCVar(CCVars.OocEnableDuringRound))
_configurationManager.SetCVar(CCVars.OocEnabled, true);
break;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Database/ServerDbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ServerDbBase(ISawmill opsLog)
.ThenInclude(h => h.Loadouts)
.ThenInclude(l => l.Groups)
.ThenInclude(group => group.Loadouts)
.AsSingleQuery()
.AsSplitQuery()
.SingleOrDefaultAsync(p => p.UserId == userId.UserId, cancel);

if (prefs is null)
Expand Down
1 change: 0 additions & 1 deletion Content.Server/Entry/IgnoredComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static class IgnoredComponents
"GuideHelp",
"Clickable",
"Icon",
"HandheldGPS",
"CableVisualizer",
"SolutionItemStatus",
"UIFragment",
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Power/EntitySystems/BatterySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public override void Update(float frameTime)
while (query.MoveNext(out var uid, out var comp, out var batt))
{
if (!comp.AutoRecharge) continue;
if (batt.IsFullyCharged) continue;
SetCharge(uid, batt.CurrentCharge + comp.AutoRechargeRate * frameTime, batt);
}
}
Expand Down Expand Up @@ -138,7 +137,8 @@ public void SetCharge(EntityUid uid, float value, BatteryComponent? battery = nu

var old = battery.CurrentCharge;
battery.CurrentCharge = MathHelper.Clamp(value, 0, battery.MaxCharge);
if (MathHelper.CloseTo(battery.CurrentCharge, old))
if (MathHelper.CloseTo(battery.CurrentCharge, old) &&
!(old != battery.CurrentCharge && battery.CurrentCharge == battery.MaxCharge))
return;

var ev = new ChargeChangedEvent(battery.CurrentCharge, battery.MaxCharge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ namespace Content.Server.VendingMachines;
[DataDefinition]
public sealed partial class VendingMachineContrabandWireAction : BaseToggleWireAction
{
private VendingMachineSystem _vendingMachineSystem = default!;

public override Color Color { get; set; } = Color.Green;
public override string Name { get; set; } = "wire-name-vending-contraband";
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;

public override void Initialize()
{
base.Initialize();

_vendingMachineSystem = EntityManager.System<VendingMachineSystem>();
}

public override StatusLightState? GetLightState(Wire wire)
{
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
Expand All @@ -28,7 +37,7 @@ public override void ToggleValue(EntityUid owner, bool setting)
{
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent? vending))
{
vending.Contraband = !setting;
_vendingMachineSystem.SetContraband(owner, !vending.Contraband, vending);
}
}

Expand Down
12 changes: 12 additions & 0 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ public void SetShooting(EntityUid uid, bool canShoot, VendingMachineComponent? c
component.CanShoot = canShoot;
}

/// <summary>
/// Sets the <see cref="VendingMachineComponent.Contraband"/> property of the vending machine.
/// </summary>
public void SetContraband(EntityUid uid, bool contraband, VendingMachineComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

component.Contraband = contraband;
Dirty(uid, component);
}

public void Deny(EntityUid uid, VendingMachineComponent? vendComponent = null)
{
if (!Resolve(uid, ref vendComponent))
Expand Down
14 changes: 14 additions & 0 deletions Content.Shared/Actions/BaseActionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public abstract partial class BaseActionComponent : Component
/// </remarks>
[DataField("iconColor")] public Color IconColor = Color.White;

/// <summary>
/// The original <see cref="IconColor"/> this action was.
/// </summary>
[DataField] public Color OriginalIconColor;

/// <summary>
/// The color the action should turn to when disabled
/// </summary>
[DataField] public Color DisabledIconColor = Color.DimGray;

/// <summary>
/// Keywords that can be used to search for this action in the action menu.
/// </summary>
Expand Down Expand Up @@ -179,6 +189,8 @@ public abstract class BaseActionComponentState : ComponentState
public SpriteSpecifier? Icon;
public SpriteSpecifier? IconOn;
public Color IconColor;
public Color OriginalIconColor;
public Color DisabledIconColor;
public HashSet<string> Keywords;
public bool Enabled;
public bool Toggled;
Expand Down Expand Up @@ -209,6 +221,8 @@ protected BaseActionComponentState(BaseActionComponent component, IEntityManager
Icon = component.Icon;
IconOn = component.IconOn;
IconColor = component.IconColor;
OriginalIconColor = component.OriginalIconColor;
DisabledIconColor = component.DisabledIconColor;
Keywords = component.Keywords;
Enabled = component.Enabled;
Toggled = component.Toggled;
Expand Down
Loading

0 comments on commit 4f83878

Please sign in to comment.