Skip to content

Commit

Permalink
Merge branch 'space-wizards:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Merrokitsune authored Sep 26, 2024
2 parents fa5cbf1 + 4491550 commit 7769a90
Show file tree
Hide file tree
Showing 87 changed files with 2,023 additions and 1,049 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;
}
}
}
}
20 changes: 4 additions & 16 deletions Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,17 @@ protected override void Open()
{
base.Open();

var vendingMachineSys = EntMan.System<VendingMachineSystem>();

_cachedInventory = vendingMachineSys.GetAllInventory(Owner);

_menu = this.CreateWindow<VendingMachineMenu>();
_menu.OpenCenteredLeft();
_menu.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;

_menu.OnItemSelected += OnItemSelected;

_menu.Populate(_cachedInventory);

_menu.OpenCenteredLeft();
Refresh();
}

protected override void UpdateState(BoundUserInterfaceState state)
public void Refresh()
{
base.UpdateState(state);

if (state is not VendingMachineInterfaceState newState)
return;

_cachedInventory = newState.Inventory;
var system = EntMan.System<VendingMachineSystem>();
_cachedInventory = system.GetAllInventory(Owner);

_menu?.Populate(_cachedInventory);
}
Expand Down
10 changes: 10 additions & 0 deletions Content.Client/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ public sealed class VendingMachineSystem : SharedVendingMachineSystem
{
[Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;

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

SubscribeLocalEvent<VendingMachineComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<VendingMachineComponent, AnimationCompletedEvent>(OnAnimationCompleted);
SubscribeLocalEvent<VendingMachineComponent, AfterAutoHandleStateEvent>(OnVendingAfterState);
}

private void OnVendingAfterState(EntityUid uid, VendingMachineComponent component, ref AfterAutoHandleStateEvent args)
{
if (_uiSystem.TryGetOpenUi<VendingMachineBoundUserInterface>(uid, VendingMachineUiKey.Key, out var bui))
{
bui.Refresh();
}
}

private void OnAnimationCompleted(EntityUid uid, VendingMachineComponent component, AnimationCompletedEvent args)
Expand Down
Loading

0 comments on commit 7769a90

Please sign in to comment.