-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_ifrit
- Loading branch information
Showing
2,062 changed files
with
105,456 additions
and
62,129 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
Oops, something went wrong.