Skip to content

Commit

Permalink
Upstream 19 Feb
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokilife committed Feb 19, 2024
2 parents d2a695d + 706b072 commit 6a75327
Show file tree
Hide file tree
Showing 249 changed files with 46,534 additions and 56,894 deletions.
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
fi
use flake
21 changes: 0 additions & 21 deletions Content.Client/Chemistry/Components/InjectorComponent.cs

This file was deleted.

19 changes: 3 additions & 16 deletions Content.Client/Chemistry/EntitySystems/InjectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,21 @@
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 InjectorSystem : EntitySystem
public sealed class InjectorSystem : SharedInjectorSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<InjectorComponent, ComponentHandleState>(OnHandleInjectorState);
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent));
Subs.ItemStatus<InjectorComponent>(ent => new InjectorStatusControl(ent, SolutionContainers));
SubscribeLocalEvent<HyposprayComponent, ComponentHandleState>(OnHandleHyposprayState);
Subs.ItemStatus<HyposprayComponent>(ent => new HyposprayStatusControl(ent));
}

private void OnHandleInjectorState(EntityUid uid, InjectorComponent component, ref ComponentHandleState args)
{
if (args.Current is not SharedInjectorComponent.InjectorComponentState state)
{
return;
}

component.CurrentVolume = state.CurrentVolume;
component.TotalVolume = state.TotalVolume;
component.CurrentMode = state.CurrentMode;
component.UiUpdateNeeded = true;
}

private void OnHandleHyposprayState(EntityUid uid, HyposprayComponent component, ref ComponentHandleState args)
{
if (args.Current is not HyposprayComponentState cState)
Expand Down
39 changes: 18 additions & 21 deletions Content.Client/Chemistry/UI/InjectorStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Client.Chemistry.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
Expand All @@ -10,40 +10,37 @@ namespace Content.Client.Chemistry.UI;

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

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

Update();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_parent.UiUpdateNeeded)
return;
Update();
}

public void Update()
{
_parent.UiUpdateNeeded = false;
if (!_solutionContainers.TryGetSolution(_parent.Owner, InjectorComponent.SolutionName, out _, out var solution))
return;

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

_label.SetMarkup(Loc.GetString("injector-volume-label",
("currentVolume", _parent.CurrentVolume),
("totalVolume", _parent.TotalVolume),
("modeString", modeStringLocalized)));
("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized),
("transferVolume", _parent.Comp.TransferAmount)));
}
}
38 changes: 38 additions & 0 deletions Content.Client/Lock/Visualizers/LockVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.Storage;
using Content.Shared.Lock;
using Robust.Client.GameObjects;

namespace Content.Client.Lock.Visualizers;

public sealed class LockVisualizerSystem : VisualizerSystem<LockVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, LockVisualsComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null
|| !AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out _, args.Component))
return;

// Lock state for the entity.
if (!AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out var locked, args.Component))
locked = true;

var unlockedStateExist = args.Sprite.BaseRSI?.TryGetState(comp.StateUnlocked, out _);

if (AppearanceSystem.TryGetData<bool>(uid, StorageVisuals.Open, out var open, args.Component))
{
args.Sprite.LayerSetVisible(LockVisualLayers.Lock, !open);
}
else if (!(bool) unlockedStateExist!)
args.Sprite.LayerSetVisible(LockVisualLayers.Lock, locked);

if (!open && (bool) unlockedStateExist!)
{
args.Sprite.LayerSetState(LockVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked);
}
}
}

public enum LockVisualLayers : byte
{
Lock
}
20 changes: 20 additions & 0 deletions Content.Client/Lock/Visualizers/LockVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Content.Client.Lock.Visualizers;

[RegisterComponent]
[Access(typeof(LockVisualizerSystem))]
public sealed partial class LockVisualsComponent : Component
{
/// <summary>
/// The RSI state used for the lock indicator while the entity is locked.
/// </summary>
[DataField("stateLocked")]
[ViewVariables(VVAccess.ReadWrite)]
public string? StateLocked = "locked";

/// <summary>
/// The RSI state used for the lock indicator entity is unlocked.
/// </summary>
[DataField("stateUnlocked")]
[ViewVariables(VVAccess.ReadWrite)]
public string? StateUnlocked = "unlocked";
}
72 changes: 37 additions & 35 deletions Content.Client/MainMenu/UI/MainMenuControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,46 @@
xmlns:pllax="clr-namespace:Content.Client.Parallax"
xmlns:clog="clr-namespace:Content.Client.Changelog">
<pllax:ParallaxControl />
<LayoutContainer>
<BoxContainer Name="VBox"
Orientation="Vertical"
StyleIdentifier="mainMenuVBox">
<TextureRect Name="Logo"
Stretch="KeepCentered" />
<BoxContainer Orientation="Horizontal"
SeparationOverride="4">
<Label Text="{Loc 'main-menu-username-label'}" />
<LineEdit Name="UsernameBox"
Access="Public"
PlaceHolder="{Loc 'main-menu-username-text'}"
HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="VBox"
Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalExpand="True"
VerticalExpand="True"
StyleIdentifier="mainMenuVBox"
SeparationOverride="3">
<TextureRect Name="Logo"
Stretch="KeepCentered"/>
<GridContainer Columns="2">
<Label Text="{Loc 'main-menu-username-label'}" />
<LineEdit Name="UsernameBox"
Access="Public"
PlaceHolder="{Loc 'main-menu-username-text'}"
HorizontalExpand="True" />
<Label Text="{Loc 'main-menu-address-label'}"/>
<LineEdit Name="AddressBox"
Access="Public"
Text="localhost"
PlaceHolder="server address:port"
HorizontalExpand="True" />
<Button Name="DirectConnectButton"
Access="Public"
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Control MinSize="0 2" />
<Button Name="OptionsButton"
Access="Public"
Text="{Loc 'main-menu-options-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Button Name="QuitButton"
Access="Public"
Text="{Loc 'main-menu-quit-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<clog:ChangelogButton
Name="ChangelogButton"
Access="Public"/>
</BoxContainer>
</LayoutContainer>
</GridContainer>
<Button Name="DirectConnectButton"
Access="Public"
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="OptionsButton"
Access="Public"
Text="{Loc 'main-menu-options-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="QuitButton"
Access="Public"
Text="{Loc 'main-menu-quit-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<clog:ChangelogButton
Name="ChangelogButton"
Access="Public"/>
</BoxContainer>
</Control>
84 changes: 84 additions & 0 deletions Content.Client/Options/OptionsVisualizerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using Content.Shared.CCVar;

namespace Content.Client.Options;

/// <summary>
/// Allows specifying sprite alternatives depending on the client's accessibility options.
/// </summary>
/// <remarks>
/// A list of layer mappings is given that the component applies to,
/// and it will pick one entry to apply based on the settings configuration. Example:
///
/// <code>
/// - type: Sprite
/// sprite: Effects/optionsvisualizertest.rsi
/// layers:
/// - state: none
/// map: [ "layer" ]
/// - type: OptionsVisualizer
/// visuals:
/// layer:
/// - options: Default
/// data: { state: none }
/// - options: Test
/// data: { state: test }
/// - options: ReducedMotion
/// data: { state: motion }
/// - options: [Test, ReducedMotion]
/// data: { state: both }
/// </code>
/// </remarks>
/// <seealso cref="OptionsVisualizerSystem"/>
/// <seealso cref="OptionVisualizerOptions"/>
[RegisterComponent]
public sealed partial class OptionsVisualizerComponent : Component
{
/// <summary>
/// A mapping storing data about which sprite layer keys should be controlled.
/// </summary>
/// <remarks>
/// Each layer stores an array of possible options. The last entry with a
/// <see cref="LayerDatum.Options"/> matching the active user preferences will be picked.
/// This allows choosing a priority if multiple entries are matched.
/// </remarks>
[DataField(required: true)]
public Dictionary<string, LayerDatum[]> Visuals = default!;

/// <summary>
/// A single option for a layer to be selected.
/// </summary>
[DataDefinition]
public sealed partial class LayerDatum
{
/// <summary>
/// Which options must be set by the user to make this datum match.
/// </summary>
[DataField]
public OptionVisualizerOptions Options { get; set; }

/// <summary>
/// The sprite layer data to set on the sprite when this datum matches.
/// </summary>
[DataField]
public PrototypeLayerData Data { get; set; }
}
}

[Flags]
public enum OptionVisualizerOptions
{
/// <summary>
/// Corresponds to no special options being set, can be used as a "default" state.
/// </summary>
Default = 0,

/// <summary>
/// Corresponds to the <see cref="CCVars.DebugOptionVisualizerTest"/> CVar being set.
/// </summary>
Test = 1 << 0,

/// <summary>
/// Corresponds to the <see cref="CCVars.ReducedMotion"/> CVar being set.
/// </summary>
ReducedMotion = 1 << 1,
}
Loading

0 comments on commit 6a75327

Please sign in to comment.