Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offshore Gas Drilling and Pumping #2403

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8ad7bea
gaslock wip
whatston3 Nov 7, 2024
71b431e
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Nov 10, 2024
9ba8cff
gaslock WIP
whatston3 Nov 10, 2024
ce5370e
gaslock: entity's more or less good
whatston3 Nov 11, 2024
a3ed0f6
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Nov 12, 2024
47dc232
deposits & drills, WIP
whatston3 Nov 12, 2024
097e68a
gas deposit drill WIP
whatston3 Nov 13, 2024
e366860
More work on deposits and drills, still WIP
whatston3 Nov 14, 2024
63db091
random gas deposits, drill fixes
whatston3 Nov 14, 2024
53dc3f6
drill visualizers, ignore deposits, yaml fixes
whatston3 Nov 14, 2024
dbaef5d
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Nov 14, 2024
b8bb468
Gas deposits, pipe fixes for the drill
whatston3 Nov 14, 2024
76a9a9a
gaslock RSI fix
whatston3 Nov 15, 2024
92a9890
Merge branch 'master' into 2024-11-04-gaslocks
dvir001 Nov 16, 2024
8cc633a
gaslock to binary.yml, joinSystem test
whatston3 Nov 17, 2024
63daa19
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Nov 17, 2024
0f92d2b
GasDepositExtractor: push into net, not pipe
whatston3 Nov 17, 2024
d492606
Clear pump on undock
whatston3 Nov 17, 2024
f33f05c
WIP docking types, sale point
whatston3 Nov 18, 2024
124c548
selective docking WIP
whatston3 Nov 18, 2024
3ddf876
WIP gas sale point, console, gas sale UI
whatston3 Nov 20, 2024
17fdf4a
Bidirectional pressure pipes
whatston3 Nov 27, 2024
c025795
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Nov 27, 2024
062b98f
gaslock console wip
whatston3 Nov 30, 2024
98943d7
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Dec 1, 2024
7dd4565
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Dec 17, 2024
b669e9e
cleanup, smaller deposits
whatston3 Dec 19, 2024
7a28c73
Add gaslocks to the atmospheric alerts computer
whatston3 Dec 20, 2024
bbc0d46
Fix gaslock pipe readout
whatston3 Dec 20, 2024
ce3adf0
Merge branch 'master' into 2024-11-04-gaslocks
whatston3 Dec 20, 2024
2dc3d6b
Remove unused deposits
whatston3 Dec 20, 2024
a2c2974
Undupe AtmosDirectionChanged log value
whatston3 Dec 20, 2024
993cd4e
Address test failures
whatston3 Dec 20, 2024
feba705
Add remaining missing containers
whatston3 Dec 20, 2024
8fed90b
Fix missing source/sink port refs in gas sale comp
whatston3 Dec 21, 2024
f0a10c9
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions Content.Client/Atmos/Consoles/AtmosAlarmGaslockEntryContainer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Orientation="Vertical" HorizontalExpand ="True" Margin="0 0 0 3">

<!-- Device selection button -->
<Button Name="FocusButton" HorizontalExpand="True" SetHeight="32" Margin="12 0 0 0" StyleClasses="OpenBoth" Access="Public">
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Horizontal">

<!-- Alarm state -->
<TextureRect Stretch="Keep" HorizontalAlignment="Left" Margin="-20 -2 0 0" ModulateSelfOverride="#25252a" TexturePath="/Textures/Interface/AtmosMonitoring/status_bg.png">
<BoxContainer VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal" Margin="8 0">
<TextureRect Name="ArrowTexture" VerticalAlignment="Center" SetSize="12 12" Stretch="KeepAspectCentered" Margin="3 0" TexturePath="/Textures/Interface/Nano/triangle_right.png"></TextureRect>
<Label Name="AlarmStateLabel" HorizontalExpand="True" HorizontalAlignment="Center" FontColorOverride="#5A5A5A" Text="{Loc 'atmos-alerts-window-invalid-state'}"></Label>
</BoxContainer>
</TextureRect>

<!-- Alarm name -->
<Label Name="AlarmNameLabel" Text="???" HorizontalExpand="True" HorizontalAlignment="Center" Margin="5 0"></Label>
</BoxContainer>
</Button>

<!-- Panel that appears on selecting the device -->
<PanelContainer Name="FocusContainer" HorizontalExpand="True" Margin="1 -1 1 0" ReservesSpace="False" Visible="False" Access="Public">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#25252a"/>
</PanelContainer.PanelOverride>
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">

<!-- Atmosphere status -->
<Control>

<!-- Main container for displaying atmospheric data -->
<BoxContainer Name="MainDataContainer" HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical" ReservesSpace="False" Visible="False">
<BoxContainer HorizontalExpand="True" Orientation="Horizontal">
<Label Name="DirectionHeaderLabel" Text="{Loc 'atmos-alerts-window-direction-label'}" HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9" Margin="0 2 0 0" SetHeight="24"/>
<Label Name="PressureHeaderLabel" Text="{Loc 'atmos-alerts-window-pressure-label'}" HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9" Margin="0 2 0 0" SetHeight="24"/>
<Label Name="EnabledHeaderLabel" Text="{Loc 'atmos-alerts-window-enabled-label'}" HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9" Margin="0 2 0 0" SetHeight="24"/>
<Label Name="DockedHeaderLabel" Text="{Loc 'atmos-alerts-window-docked-label'}" HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9" Margin="0 2 0 0" SetHeight="24"/>
</BoxContainer>
<PanelContainer HorizontalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#202023"/>
</PanelContainer.PanelOverride>
<BoxContainer HorizontalExpand="True" Orientation="Horizontal">
<Button Name="DirectionLabel" Text="???" HorizontalAlignment="Center" HorizontalExpand="True" Margin="0 2 0 0" />
<LineEdit Name="PressureInput" Text="???" MinSize="70 0" HorizontalAlignment="Center" HorizontalExpand="True" Margin="0 2 0 0"/>
<Button Name="EnabledLabel" Text="???" HorizontalAlignment="Center" HorizontalExpand="True" Margin="0 2 0 0"/>
<Button Name="DockedLabel" Text="???" HorizontalAlignment="Center" HorizontalExpand="True" Margin="0 2 0 0"/>
</BoxContainer>
</PanelContainer>
<BoxContainer HorizontalExpand="True" Orientation="Horizontal">
<Label Name="GasesHeaderLabel" Text="{Loc 'atmos-alerts-window-gaslock-gases-label'}" HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9" Margin="0 4 0 0" SetHeight="24"></Label>
</BoxContainer> <PanelContainer HorizontalExpand=
"True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#202023"/>
</PanelContainer.PanelOverride>

<!-- Gas entries added via C# code -->
<GridContainer Name="GasGridContainer" HorizontalExpand="True" Columns = "4"></GridContainer>
</PanelContainer>
</BoxContainer>

<!-- If the alarm is inactive, this is label is diplayed instead -->
<Label Name="NoDataLabel" Text="{Loc 'atmos-alerts-window-no-data-available'}" HorizontalAlignment="Center" Margin="0 15" FontColorOverride="#a9a9a9" ReservesSpace="False" Visible="False"></Label>
</Control>
</BoxContainer>
</PanelContainer>

</BoxContainer>
211 changes: 211 additions & 0 deletions Content.Client/Atmos/Consoles/AtmosAlarmGaslockEntryContainer.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
using Content.Client.Stylesheets;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.Monitor;
using Content.Shared.FixedPoint;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map;
using System.Linq;

namespace Content.Client.Atmos.Consoles;

[GenerateTypedNameReferences]
public sealed partial class AtmosAlarmGaslockEntryContainer : BoxContainer
{
public NetEntity NetEntity;
public EntityCoordinates? Coordinates;

private readonly IEntityManager _entManager;
private readonly IResourceCache _cache;

public event Action<NetEntity, bool>? SendChangeDirectionMessageAction;
public event Action<NetEntity, float>? SendPressureChangeAction;
public event Action<NetEntity, bool>? SendChangeEnabledAction;
public event Action<NetEntity>? SendUndockAction;

private bool _lastDirectionInwards = false;
private bool _lastEnabled = false;
private bool _lastDocked = false;

private Dictionary<Gas, string> _gasShorthands = new Dictionary<Gas, string>()
{
[Gas.Ammonia] = "NH₃",
[Gas.CarbonDioxide] = "CO₂",
[Gas.Frezon] = "F",
[Gas.Nitrogen] = "N₂",
[Gas.NitrousOxide] = "N₂O",
[Gas.Oxygen] = "O₂",
[Gas.Plasma] = "P",
[Gas.Tritium] = "T",
[Gas.WaterVapor] = "H₂O",
};

public AtmosAlarmGaslockEntryContainer(NetEntity uid, EntityCoordinates? coordinates)
{
RobustXamlLoader.Load(this);

_entManager = IoCManager.Resolve<IEntityManager>();
_cache = IoCManager.Resolve<IResourceCache>();

NetEntity = uid;
Coordinates = coordinates;

// Load fonts
var headerFont = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Bold.ttf"), 11);
NoDataLabel.FontOverride = headerFont;

DirectionLabel.OnPressed += _ => TrySendDirectionChangeAction();
PressureInput.OnTextEntered += _ => TrySendPressureChangeAction();
EnabledLabel.OnPressed += _ => TrySendEnableChangeAction();
DockedLabel.OnPressed += _ => TrySendUndockAction();
}

public void TrySendDirectionChangeAction()
{
if (SendChangeDirectionMessageAction == null)
return;
SendChangeDirectionMessageAction(NetEntity, !_lastDirectionInwards);
}

public void TrySendPressureChangeAction()
{
if (SendPressureChangeAction == null)
return;
if (!float.TryParse(PressureInput.Text, out var result))
return;
SendPressureChangeAction(NetEntity, result);
}

public void TrySendEnableChangeAction()
{
if (SendChangeEnabledAction == null)
return;
SendChangeEnabledAction(NetEntity, !_lastEnabled);
}

public void TrySendUndockAction()
{
if (SendUndockAction == null)
return;
if (!_lastDocked)
return;
SendUndockAction(NetEntity);
}

public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlertsFocusGaslockData? focusData = null)
{
NetEntity = entry.NetEntity;
Coordinates = _entManager.GetCoordinates(entry.Coordinates);

// Load fonts
var normalFont = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf"), 11);

AlarmStateLabel.Text = Loc.GetString("atmos-alerts-window-normal-state");
AlarmStateLabel.FontColorOverride = StyleNano.GoodGreenFore;

// Update alarm name
AlarmNameLabel.Text = Loc.GetString("atmos-alerts-window-alarm-label", ("name", entry.EntityName), ("address", entry.Address));

// Focus updates
FocusContainer.Visible = isFocus;

if (isFocus)
SetAsFocus();
else
RemoveAsFocus();

// Frontier: update state
if (focusData != null)
{
_lastDirectionInwards = focusData.Value.PumpingInwards;
_lastEnabled = focusData.Value.Enabled;
_lastDocked = focusData.Value.DockedEntity != NetEntity.Invalid;
}
// End Frontier

if (isFocus && entry.Group == AtmosAlertsComputerGroup.Gaslock)
{
MainDataContainer.Visible = (entry.AlarmState != AtmosAlarmType.Invalid);
NoDataLabel.Visible = (entry.AlarmState == AtmosAlarmType.Invalid);

if (focusData != null)
{
DirectionLabel.Text = Loc.GetString(focusData.Value.PumpingInwards ? "atmos-alerts-window-direction-inwards" : "atmos-alerts-window-direction-outwards");

// Update pressure (if user is not editing text)
if (!PressureInput.HasKeyboardFocus())
PressureInput.Text = focusData.Value.Pressure.ToString();
EnabledLabel.Text = Loc.GetString(focusData.Value.Enabled ? "atmos-alerts-window-enabled-on" : "atmos-alerts-window-enabled-off");
DockedLabel.Text = Loc.GetString(focusData.Value.DockedEntity == NetEntity.Invalid ? "atmos-alerts-window-docked-off" : "atmos-alerts-window-docked-on");
DockedLabel.Disabled = focusData.Value.DockedEntity == NetEntity.Invalid;

// Update other present gases
GasGridContainer.RemoveAllChildren();

var gasData = focusData.Value.GasData.Where(g => g.Key != Gas.Oxygen);

if (gasData.Count() == 0)
{
// No other gases
var gasLabel = new Label()
{
Text = Loc.GetString("atmos-alerts-window-other-gases-value-nil"),
FontOverride = normalFont,
FontColorOverride = StyleNano.DisabledFore,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
HorizontalExpand = true,
Margin = new Thickness(0, 2, 0, 0),
SetHeight = 24f,
};

GasGridContainer.AddChild(gasLabel);
}

else
{
// Add an entry for each gas
foreach ((var gas, (var mol, var percent)) in gasData)
{
var gasPercent = (FixedPoint2)0f;
gasPercent = percent * 100f;

if (!_gasShorthands.TryGetValue(gas, out var gasShorthand))
gasShorthand = "X";

var gasLabel = new Label()
{
Text = Loc.GetString("atmos-alerts-window-other-gases-value", ("shorthand", gasShorthand), ("value", gasPercent)),
FontOverride = normalFont,
FontColorOverride = StyleNano.GoodGreenFore,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
HorizontalExpand = true,
Margin = new Thickness(0, 2, 0, 0),
SetHeight = 24f,
};

GasGridContainer.AddChild(gasLabel);
}
}
}
}
}

public void SetAsFocus()
{
FocusButton.AddStyleClass(StyleNano.StyleClassButtonColorGreen);
ArrowTexture.TexturePath = "/Textures/Interface/Nano/inverted_triangle.svg.png";
}

public void RemoveAsFocus()
{
FocusButton.RemoveStyleClass(StyleNano.StyleClassButtonColorGreen);
ArrowTexture.TexturePath = "/Textures/Interface/Nano/triangle_right.png";
FocusContainer.Visible = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Content.Shared.Atmos.Components;
using Content.Shared.Shuttles.Events; // Frontier
using Content.Shared._NF.Atmos.BUI; // Frontier

namespace Content.Client.Atmos.Consoles;

Expand Down Expand Up @@ -28,7 +30,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
return;

EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.UpdateUI(xform?.Coordinates, castState.AirAlarms, castState.FireAlarms, castState.FocusData);
_menu?.UpdateUI(xform?.Coordinates, castState.AirAlarms, castState.FireAlarms, castState.FocusData, castState.Gaslocks, castState.FocusGaslockData); // Frontier: add gaslocks, focusGaslockData
}

public void SendFocusChangeMessage(NetEntity? netEntity)
Expand All @@ -41,6 +43,28 @@ public void SendDeviceSilencedMessage(NetEntity netEntity, bool silenceDevice)
SendMessage(new AtmosAlertsComputerDeviceSilencedMessage(netEntity, silenceDevice));
}

// Frontier: gaslock message
public void SendGaslockChangeDirectionMessage(NetEntity netEntity, bool direction)
{
SendMessage(new RemoteGasPressurePumpChangePumpDirectionMessage(netEntity, direction));
}

public void SendGaslockPressureChangeMessage(NetEntity netEntity, float pressure)
{
SendMessage(new RemoteGasPressurePumpChangeOutputPressureMessage(netEntity, pressure));
}

public void SendGaslockChangeEnabled(NetEntity netEntity, bool enabled)
{
SendMessage(new RemoteGasPressurePumpToggleStatusMessage(netEntity, enabled));
}

public void SendGaslockUndock(NetEntity netEntity)
{
SendMessage(new UndockRequestMessage { DockEntity = netEntity });
}
// End Frontier

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<ScrollContainer HorizontalExpand="True" Margin="8, 8, 8, 8">
<BoxContainer Name="FireAlarmsTable" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" Margin="0 0 0 10"/>
</ScrollContainer>
<!-- Frontier: gaslock entries -->
<ScrollContainer HorizontalExpand="True" Margin="8, 8, 8, 8">
<BoxContainer Name="GaslocksTable" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" Margin="0 0 0 10"/>
</ScrollContainer>
<!-- End Frontier: gaslock entries -->
</TabContainer>

<!-- Overlay toggles -->
Expand Down
Loading
Loading