Skip to content

Commit

Permalink
Merge branch 'master' into Psychic-Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Debug <[email protected]>
  • Loading branch information
DebugOk authored Mar 17, 2024
2 parents 79b48ab + 17c8af2 commit 0b00bba
Show file tree
Hide file tree
Showing 2,644 changed files with 99,552 additions and 48,355 deletions.
5 changes: 5 additions & 0 deletions Content.Client/Administration/Managers/ClientAdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Administration.Managers;
using Robust.Client.Console;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.ContentPack;
using Robust.Shared.Network;
using Robust.Shared.Player;
Expand All @@ -16,6 +17,7 @@ public sealed class ClientAdminManager : IClientAdminManager, IClientConGroupImp
[Dependency] private readonly IClientConGroupController _conGroup = default!;
[Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterface = default!;

private AdminData? _adminData;
private readonly HashSet<string> _availableCommands = new();
Expand Down Expand Up @@ -101,6 +103,9 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message)
{
var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags));
_sawmill.Info($"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}");

if (_adminData.Active)
_userInterface.DebugMonitors.SetMonitor(DebugMonitor.Coords, true);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
OnBwoinkTextMessageRecieved?.Invoke(this, message);
}

public void Send(NetUserId channelId, string text)
public void Send(NetUserId channelId, string text, bool playSound)
{
// Reuse the channel ID as the 'true sender'.
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text));
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
SendInputTextUpdated(channelId, false);
}

Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
<BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<CheckBox Visible="True" Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
<Control HorizontalExpand="True" MinWidth="5" />
<Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
<Control HorizontalExpand="True" />
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<BoxContainer Name="VolumeBox" Orientation="Vertical" HorizontalExpand="True" Margin="0 4"/>

<!-- The temperature / heat capacity / thermal energy of the solution -->
<Collapsible Orientation="Vertical">
<Collapsible>
<CollapsibleHeading Name="ThermalHeading" Title="{Loc 'admin-solutions-window-thermals'}" />
<CollapsibleBody>
<BoxContainer Name="ThermalBox" Orientation="Vertical" HorizontalExpand="True" Margin="0 4"/>
Expand All @@ -23,7 +23,7 @@
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" Margin="0 4">
<BoxContainer Name="ReagentList" Orientation="Vertical"/>
</ScrollContainer>

<Button Name="AddButton" Text="{Loc 'admin-solutions-window-add-new-button'}" HorizontalExpand="True" Margin="0 4"/>
</BoxContainer>
</DefaultWindow>
2 changes: 1 addition & 1 deletion Content.Client/Alerts/ClientAlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override void LoadPrototypes()

AlertOrder = _prototypeManager.EnumeratePrototypes<AlertOrderPrototype>().FirstOrDefault();
if (AlertOrder == null)
Log.Error("alert", "no alertOrder prototype found, alerts will be in random order");
Log.Error("No alertOrder prototype found, alerts will be in random order");
}

public IReadOnlyDictionary<AlertKey, AlertState>? ActiveAlerts
Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Ame/UI/AmeControllerBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.Ame.UI
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Ame/UI/AmeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Client.UserInterface;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Vertical" Margin="2 0 2 4">
<Collapsible Orientation="Vertical">
<Collapsible>
<CollapsibleHeading Name="CAddress" />
<!-- Upper row: toggle, direction, checks -->
<CollapsibleBody Margin="20 0 0 0">
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Vertical" Margin="2 0 2 4">
<Collapsible Orientation="Vertical">
<Collapsible>
<CollapsibleHeading Name="CAddress" />
<CollapsibleBody Margin="20 0 0 0">
<BoxContainer Orientation="Vertical">
Expand All @@ -26,7 +26,7 @@
<Button Name="CCopySettings" Text="{Loc 'air-alarm-ui-widget-copy'}" ToolTip="{Loc 'air-alarm-ui-widget-copy-tooltip'}" />
</BoxContainer>
<!-- Lower row: every single gas -->
<Collapsible Orientation="Vertical" Margin="2 2 2 2">
<Collapsible Margin="2 2 2 2">
<CollapsibleHeading Title="Gas filters" />
<CollapsibleBody Margin="20 0 0 0">
<GridContainer HorizontalExpand="True" Name="CGasContainer" Columns="3" />
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Atmos/Monitor/UI/Widgets/SensorInfo.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<BoxContainer xmlns="https://spacestation14.io" HorizontalExpand="True">
<Collapsible Orientation="Vertical">
<Collapsible>
<CollapsibleHeading Name="SensorAddress" />
<CollapsibleBody Margin="20 2 2 2">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
Expand All @@ -10,7 +10,7 @@
<RichTextLabel Name="TemperatureLabel" />
<Control Name="TemperatureThresholdContainer" Margin="20 0 2 0" />
</BoxContainer>
<Collapsible Orientation="Vertical" Margin="2">
<Collapsible Margin="2">
<CollapsibleHeading Title="{Loc 'air-alarm-ui-sensor-gases'}" />
<CollapsibleBody Margin="20 0 0 0">
<BoxContainer Name="GasContainer" Orientation="Vertical" Margin="2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Vertical" Margin="0 0 0 4">
<Collapsible Orientation="Vertical">
<Collapsible>
<CollapsibleHeading Name="CName" />
<CollapsibleBody Margin="20 0 0 0">
<BoxContainer Orientation="Vertical">
Expand Down
90 changes: 90 additions & 0 deletions Content.Client/Atmos/UI/SpaceHeaterBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Content.Shared.Atmos.Piping.Portable.Components;
using JetBrains.Annotations;
using Robust.Client.UserInterface.Controls;

namespace Content.Client.Atmos.UI;

/// <summary>
/// Initializes a <see cref="SpaceHeaterWindow"/> and updates it when new server messages are received.
/// </summary>
[UsedImplicitly]
public sealed class SpaceHeaterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SpaceHeaterWindow? _window;

public SpaceHeaterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_window = new SpaceHeaterWindow();

if (State != null)
UpdateState(State);

_window.OpenCentered();

_window.OnClose += Close;

_window.ToggleStatusButton.OnPressed += _ => OnToggleStatusButtonPressed();
_window.IncreaseTempRange.OnPressed += _ => OnTemperatureRangeChanged(_window.TemperatureChangeDelta);
_window.DecreaseTempRange.OnPressed += _ => OnTemperatureRangeChanged(-_window.TemperatureChangeDelta);
_window.ModeSelector.OnItemSelected += OnModeChanged;

_window.PowerLevelSelector.OnItemSelected += OnPowerLevelChange;
}

private void OnToggleStatusButtonPressed()
{
_window?.SetActive(!_window.Active);
SendMessage(new SpaceHeaterToggleMessage());
}

private void OnTemperatureRangeChanged(float changeAmount)
{
SendMessage(new SpaceHeaterChangeTemperatureMessage(changeAmount));
}

private void OnModeChanged(OptionButton.ItemSelectedEventArgs args)
{
_window?.ModeSelector.SelectId(args.Id);
SendMessage(new SpaceHeaterChangeModeMessage((SpaceHeaterMode)args.Id));
}

private void OnPowerLevelChange(RadioOptionItemSelectedEventArgs<int> args)
{
_window?.PowerLevelSelector.Select(args.Id);
SendMessage(new SpaceHeaterChangePowerLevelMessage((SpaceHeaterPowerLevel)args.Id));
}

/// <summary>
/// Update the UI state based on server-sent info
/// </summary>
/// <param name="state"></param>
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null || state is not SpaceHeaterBoundUserInterfaceState cast)
return;

_window.SetActive(cast.Enabled);
_window.ModeSelector.SelectId((int)cast.Mode);
_window.PowerLevelSelector.Select((int)cast.PowerLevel);

_window.MinTemp = cast.MinTemperature;
_window.MaxTemp = cast.MaxTemperature;
_window.SetTemperature(cast.TargetTemperature);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_window?.Dispose();
}
}
34 changes: 34 additions & 0 deletions Content.Client/Atmos/UI/SpaceHeaterWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinSize="280 160" Title="Temperature Control Unit">

<BoxContainer Name="VboxContainer" Orientation="Vertical" Margin="5 5 5 5" SeparationOverride="10">

<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Button Text="{Loc comp-space-heater-ui-status-disabled}" Access="Public" Name="ToggleStatusButton"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" SeparationOverride="5">
<Label Text="{Loc comp-space-heater-ui-mode}"/>
<OptionButton Access="Public" Name="ModeSelector"/>
</BoxContainer>
</BoxContainer>

<BoxContainer Orientation="Horizontal" HorizontalExpand="True" SeparationOverride="5">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc comp-space-heater-ui-thermostat}"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Right">
<Button Text="{Loc comp-space-heater-ui-decrease-temperature-range}" Access="Public" Name="DecreaseTempRange" StyleClasses="OpenRight"/>
<LineEdit Name ="Thermostat" MinSize="55 0"></LineEdit>
<Button Text="{Loc comp-space-heater-ui-increase-temperature-range}" Access="Public" Name="IncreaseTempRange" StyleClasses="OpenLeft"/>
</BoxContainer>
</BoxContainer>

<BoxContainer Orientation="Horizontal" HorizontalExpand="True" SeparationOverride="5">
<Label Text="{Loc comp-space-heater-ui-power-consumption}"/>
<BoxContainer Name="PowerLevelSelectorHBox" Access="Public" SeparationOverride="2"/>
</BoxContainer>

</BoxContainer>
</DefaultWindow>
73 changes: 73 additions & 0 deletions Content.Client/Atmos/UI/SpaceHeaterWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Portable.Components;

namespace Content.Client.Atmos.UI;

/// <summary>
/// Client-side UI used to control a space heater.
/// </summary>
[GenerateTypedNameReferences]
public sealed partial class SpaceHeaterWindow : DefaultWindow
{
// To account for a minimum delta temperature for atmos equalization to trigger we use a fixed step for target temperature increment/decrement
public int TemperatureChangeDelta = 5;
public bool Active;

// Temperatures range bounds in Kelvin (K)
public float MinTemp;
public float MaxTemp;

public RadioOptions<int> PowerLevelSelector;

public SpaceHeaterWindow()
{
RobustXamlLoader.Load(this);

// Add the Mode selector list
foreach (var value in Enum.GetValues<SpaceHeaterMode>())
{
ModeSelector.AddItem(Loc.GetString($"comp-space-heater-mode-{value}"), (int)value);
}

// Add the Power level radio buttons
PowerLevelSelectorHBox.AddChild(PowerLevelSelector = new RadioOptions<int>(RadioOptionsLayout.Horizontal));
PowerLevelSelector.FirstButtonStyle = "OpenRight";
PowerLevelSelector.LastButtonStyle = "OpenLeft";
PowerLevelSelector.ButtonStyle = "OpenBoth";
foreach (var value in Enum.GetValues<SpaceHeaterPowerLevel>())
{
PowerLevelSelector.AddItem(Loc.GetString($"comp-space-heater-ui-{value}-power-consumption"), (int)value);
}

// Only allow temperature increment/decrement of TemperatureChangeDelta
Thermostat.Editable = false;
}

public void SetActive(bool active)
{
Active = active;
ToggleStatusButton.Pressed = active;

if (active)
{
ToggleStatusButton.Text = Loc.GetString("comp-space-heater-ui-status-enabled");
}
else
{
ToggleStatusButton.Text = Loc.GetString("comp-space-heater-ui-status-disabled");
}
}

public void SetTemperature(float targetTemperature)
{
Thermostat.SetText($"{targetTemperature - Atmospherics.T0C} °C");

IncreaseTempRange.Disabled = targetTemperature + TemperatureChangeDelta > MaxTemp;
DecreaseTempRange.Disabled = targetTemperature - TemperatureChangeDelta < MinTemp;
}
}

Loading

0 comments on commit 0b00bba

Please sign in to comment.