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 mining refactor #2750

Merged
merged 6 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 26 additions & 30 deletions Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow

private AtmosAlertsComputerEntry[]? _airAlarms = null;
private AtmosAlertsComputerEntry[]? _fireAlarms = null;
private AtmosAlertsComputerEntry[]? _gaslocks = null; // Frontier
private IEnumerable<AtmosAlertsComputerEntry>? _allAlarms = null;

private IEnumerable<AtmosAlertsComputerEntry>? _activeAlarms = null;
Expand Down Expand Up @@ -195,7 +194,6 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
// Retain alarm data for use inbetween updates
_airAlarms = airAlarms;
_fireAlarms = fireAlarms;
_gaslocks = gaslocks; // Frontier
_allAlarms = airAlarms.Concat(fireAlarms);
_allAlarms = airAlarms.Concat(gaslocks); // Frontier

Expand Down Expand Up @@ -288,7 +286,7 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
}

// Frontier: gaslocks
for (int index = 0; index < gaslocks.Count(); index++)
for (var index = 0; index < gaslocks.Length; index++)
{
var entry = gaslocks.ElementAt(index);
UpdateGaslockUIEntry(entry, index, GaslocksTable, console, focusGaslockData);
Expand Down Expand Up @@ -470,7 +468,7 @@ private void UpdateGaslockUIEntry(AtmosAlertsComputerEntry entry, int index, Con
newEntryContainer.SendUndockAction += SendGaslockUndockAction;

// On click
newEntryContainer.FocusButton.OnButtonUp += args =>
newEntryContainer.FocusButton.OnButtonUp += _ =>
{
if (_trackedEntity == newEntryContainer.NetEntity)
{
Expand Down Expand Up @@ -502,16 +500,14 @@ private void UpdateGaslockUIEntry(AtmosAlertsComputerEntry entry, int index, Con
// Update values and UI elements
var tableChild = table.GetChild(index);

if (tableChild is not AtmosAlarmGaslockEntryContainer)
if (tableChild is not AtmosAlarmGaslockEntryContainer entryContainer)
{
table.RemoveChild(tableChild);
UpdateGaslockUIEntry(entry, index, table, console, focusData);

return;
}

var entryContainer = (AtmosAlarmGaslockEntryContainer)tableChild;

entryContainer.UpdateEntry(entry, entry.NetEntity == _trackedEntity, focusData);
}
// End Frontier: separate UpdateUI function for gaslocks
Expand All @@ -520,26 +516,27 @@ private void UpdateConsoleTable(AtmosAlertsComputerComponent console, Control ta
{
foreach (var tableChild in table.Children)
{
// Frontier: multiple type checks
if (tableChild is AtmosAlarmEntryContainer)
switch (tableChild)
{
var entryContainer = (AtmosAlarmEntryContainer)tableChild;

if (entryContainer.NetEntity != currTrackedEntity)
entryContainer.RemoveAsFocus();

else if (entryContainer.NetEntity == currTrackedEntity)
entryContainer.SetAsFocus();
}
else if (tableChild is AtmosAlarmGaslockEntryContainer)
{
var entryContainer = (AtmosAlarmGaslockEntryContainer)tableChild;
// Frontier: multiple type checks
case AtmosAlarmEntryContainer entry:
{
if (entry.NetEntity != currTrackedEntity)
entry.RemoveAsFocus();

if (entryContainer.NetEntity != currTrackedEntity)
entryContainer.RemoveAsFocus();
else if (entry.NetEntity == currTrackedEntity)
entry.SetAsFocus();
break;
}
case AtmosAlarmGaslockEntryContainer gaslockEntry:
{
if (gaslockEntry.NetEntity != currTrackedEntity)
gaslockEntry.RemoveAsFocus();

else if (entryContainer.NetEntity == currTrackedEntity)
entryContainer.SetAsFocus();
else if (gaslockEntry.NetEntity == currTrackedEntity)
gaslockEntry.SetAsFocus();
break;
}
}
// End Frontier
}
Expand Down Expand Up @@ -671,14 +668,13 @@ private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollP

foreach (var control in container.Children)
{
if (control == null) // Frontier: move type checks down
continue;

if (control is AtmosAlarmEntryContainer && ((AtmosAlarmEntryContainer)control).NetEntity == _trackedEntity) // Frontier: add type check
// Frontier - Move type checks down
if (control is AtmosAlarmEntryContainer entry && entry.NetEntity == _trackedEntity)
return true;

if (control is AtmosAlarmGaslockEntryContainer && ((AtmosAlarmGaslockEntryContainer)control).NetEntity == _trackedEntity) // Frontier
return true; // Frontier
// Frontier - Add gaslock check
if (control is AtmosAlarmGaslockEntryContainer gaslockEntry && gaslockEntry.NetEntity == _trackedEntity)
return true;

nextScrollPosition += control.Height;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@

namespace Content.Client._NF.Atmos.BUI;

public sealed class GasSaleConsoleBoundUserInterface : BoundUserInterface
public sealed class GasSaleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[ViewVariables]
private GasSaleMenu? _menu;

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

protected override void Open()
{
base.Open();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,73 +1,93 @@
<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">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
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">
<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">
<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>
<TextureRect Name="ArrowTexture" VerticalAlignment="Center" SetSize="12 12"
Stretch="KeepAspectCentered" Margin="3 0"
TexturePath="/Textures/Interface/Nano/triangle_right.png" />
<Label Name="AlarmStateLabel" HorizontalExpand="True" HorizontalAlignment="Center"
FontColorOverride="#5A5A5A" Text="{Loc 'atmos-alerts-window-invalid-state'}" />
</BoxContainer>
</TextureRect>

<!-- Alarm name -->
<Label Name="AlarmNameLabel" Text="???" HorizontalExpand="True" HorizontalAlignment="Center" Margin="5 0"></Label>
<Label Name="AlarmNameLabel" Text="???" HorizontalExpand="True" HorizontalAlignment="Center" Margin="5 0" />
</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 Name="FocusContainer" HorizontalExpand="True" Margin="1 -1 1 0" ReservesSpace="False"
Visible="False" Access="Public">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#25252a"/>
<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 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"/>
<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"/>
<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"/>
<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">
<Label Name="GasesHeaderLabel" Text="{Loc 'atmos-alerts-window-gaslock-gases-label'}"
HorizontalAlignment="Center" HorizontalExpand="True" FontColorOverride="#a9a9a9"
Margin="0 4 0 0" SetHeight="24" />
</BoxContainer>
<PanelContainer HorizontalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#202023"/>
<gfx:StyleBoxFlat BackgroundColor="#202023" />
</PanelContainer.PanelOverride>

<!-- Gas entries added via C# code -->
<GridContainer Name="GasGridContainer" HorizontalExpand="True" Columns = "4"></GridContainer>
<GridContainer Name="GasGridContainer" HorizontalExpand="True" Columns="4" />
</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>
<Label Name="NoDataLabel" Text="{Loc 'atmos-alerts-window-no-data-available'}"
HorizontalAlignment="Center" Margin="0 15" FontColorOverride="#a9a9a9" ReservesSpace="False"
Visible="False" />
</Control>
</BoxContainer>
</PanelContainer>

</BoxContainer>
Loading
Loading