Skip to content

Commit

Permalink
Merge branch 'master' into 2024-11-22-AjustedMerc
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 authored Jan 19, 2025
2 parents f85a8a3 + 86f1fa3 commit bdd5392
Show file tree
Hide file tree
Showing 250 changed files with 8,899 additions and 2,519 deletions.
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 All @@ -23,7 +25,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
var castState = (AtmosAlertsComputerBoundInterfaceState) state;

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 @@ -36,6 +38,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 @@ -76,6 +76,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
131 changes: 120 additions & 11 deletions Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Robust.Shared.Utility;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Client._NF.Atmos.Consoles; // Frontier

namespace Content.Client.Atmos.Consoles;

Expand All @@ -30,6 +31,7 @@ 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 All @@ -38,6 +40,13 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
public event Action<NetEntity?>? SendFocusChangeMessageAction;
public event Action<NetEntity, bool>? SendDeviceSilencedMessageAction;

// Frontier: gaslock actions
public event Action<NetEntity, bool>? SendGaslockChangeDirectionMessageAction;
public event Action<NetEntity, float>? SendGaslockPressureChangeMessageAction;
public event Action<NetEntity, bool>? SendGaslockChangeEnabledAction;
public event Action<NetEntity>? SendGaslockUndockAction;
// End Frontier: gaslock actions

private bool _autoScrollActive = false;
private bool _autoScrollAwaitsUpdate = false;

Expand Down Expand Up @@ -77,7 +86,7 @@ public AtmosAlertsComputerWindow(AtmosAlertsComputerBoundUserInterface userInter
{
NavMap.MapUid = xform.GridUid;

// Assign station name
// Assign station name
if (_entManager.TryGetComponent<MetaDataComponent>(xform.GridUid, out var stationMetaData))
stationName = stationMetaData.EntityName;

Expand All @@ -103,6 +112,7 @@ public AtmosAlertsComputerWindow(AtmosAlertsComputerBoundUserInterface userInter
MasterTabContainer.SetTabTitle(0, Loc.GetString("atmos-alerts-window-tab-no-alerts"));
MasterTabContainer.SetTabTitle(1, Loc.GetString("atmos-alerts-window-tab-air-alarms"));
MasterTabContainer.SetTabTitle(2, Loc.GetString("atmos-alerts-window-tab-fire-alarms"));
MasterTabContainer.SetTabTitle(3, Loc.GetString("atmos-alerts-window-tab-gaslocks")); // Frontier

// Set UI toggles
ShowInactiveAlarms.OnToggled += _ => OnShowAlarmsToggled(ShowInactiveAlarms, AtmosAlarmType.Invalid);
Expand All @@ -113,6 +123,12 @@ public AtmosAlertsComputerWindow(AtmosAlertsComputerBoundUserInterface userInter
// Set atmos monitoring message action
SendFocusChangeMessageAction += userInterface.SendFocusChangeMessage;
SendDeviceSilencedMessageAction += userInterface.SendDeviceSilencedMessage;

// Frontier: set gaslock message actions
SendGaslockChangeDirectionMessageAction += userInterface.SendGaslockChangeDirectionMessage;
SendGaslockPressureChangeMessageAction += userInterface.SendGaslockPressureChangeMessage;
SendGaslockChangeEnabledAction += userInterface.SendGaslockChangeEnabled;
SendGaslockUndockAction += userInterface.SendGaslockUndock;
}

#region Toggle handling
Expand Down Expand Up @@ -162,7 +178,7 @@ private void OnSilenceAlertsToggled(NetEntity netEntity, bool toggleState)

#endregion

public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[] airAlarms, AtmosAlertsComputerEntry[] fireAlarms, AtmosAlertsFocusDeviceData? focusData)
public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[] airAlarms, AtmosAlertsComputerEntry[] fireAlarms, AtmosAlertsFocusDeviceData? focusData, AtmosAlertsComputerEntry[] gaslocks, AtmosAlertsFocusGaslockData? focusGaslockData) // Frontier: add gaslocks, gaslock data
{
if (_owner == null)
return;
Expand All @@ -179,7 +195,9 @@ 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

var silenced = console.SilencedDevices;

Expand Down Expand Up @@ -245,6 +263,11 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
while (FireAlarmsTable.ChildCount > fireAlarms.Length)
FireAlarmsTable.RemoveChild(FireAlarmsTable.GetChild(FireAlarmsTable.ChildCount - 1));

// Frontier: gaslocks
while (GaslocksTable.ChildCount > gaslocks.Length)
GaslocksTable.RemoveChild(GaslocksTable.GetChild(GaslocksTable.ChildCount - 1));
// End Frontier

// Update all entries in each table
for (int index = 0; index < _activeAlarms.Count(); index++)
{
Expand All @@ -264,6 +287,14 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
UpdateUIEntry(entry, index, FireAlarmsTable, console, focusData);
}

// Frontier: gaslocks
for (int index = 0; index < gaslocks.Count(); index++)
{
var entry = gaslocks.ElementAt(index);
UpdateGaslockUIEntry(entry, index, GaslocksTable, console, focusGaslockData);
}
// End Frontier

// If no alerts are active, display a message
if (MasterTabContainer.CurrentTab == 0 && activeAlarmCount == 0)
{
Expand Down Expand Up @@ -391,6 +422,7 @@ private void UpdateUIEntry(AtmosAlertsComputerEntry entry, int index, Control ta
UpdateConsoleTable(console, AlertsTable, _trackedEntity);
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity);
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity);
UpdateConsoleTable(console, GaslocksTable, _trackedEntity); // Frontier
};

// On toggling the silence check box
Expand Down Expand Up @@ -424,20 +456,92 @@ private void UpdateUIEntry(AtmosAlertsComputerEntry entry, int index, Control ta
entryContainer.SilenceAlarmProgressBar.Visible = (table == AlertsTable && _deviceSilencingProgress.ContainsKey(entry.NetEntity));
}

// Frontier: separate UpdateUI function for gaslocks
private void UpdateGaslockUIEntry(AtmosAlertsComputerEntry entry, int index, Control table, AtmosAlertsComputerComponent console, AtmosAlertsFocusGaslockData? focusData = null)
{
// Make new UI entry if required
if (index >= table.ChildCount)
{
var newEntryContainer = new AtmosAlarmGaslockEntryContainer(entry.NetEntity, _entManager.GetCoordinates(entry.Coordinates));

newEntryContainer.SendChangeDirectionMessageAction += SendGaslockChangeDirectionMessageAction;
newEntryContainer.SendPressureChangeAction += SendGaslockPressureChangeMessageAction;
newEntryContainer.SendChangeEnabledAction += SendGaslockChangeEnabledAction;
newEntryContainer.SendUndockAction += SendGaslockUndockAction;

// On click
newEntryContainer.FocusButton.OnButtonUp += args =>
{
if (_trackedEntity == newEntryContainer.NetEntity)
{
_trackedEntity = null;
}

else
{
_trackedEntity = newEntryContainer.NetEntity;

if (newEntryContainer.Coordinates != null)
NavMap.CenterToCoordinates(newEntryContainer.Coordinates.Value);
}

// Send message to console that the focus has changed
SendFocusChangeMessageAction?.Invoke(_trackedEntity);

// Update affected UI elements across all tables
UpdateConsoleTable(console, AlertsTable, _trackedEntity);
UpdateConsoleTable(console, AirAlarmsTable, _trackedEntity);
UpdateConsoleTable(console, FireAlarmsTable, _trackedEntity);
UpdateConsoleTable(console, GaslocksTable, _trackedEntity); // Frontier
};

// Add the entry to the current table
table.AddChild(newEntryContainer);
}

// Update values and UI elements
var tableChild = table.GetChild(index);

if (tableChild is not AtmosAlarmGaslockEntryContainer)
{
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

private void UpdateConsoleTable(AtmosAlertsComputerComponent console, Control table, NetEntity? currTrackedEntity)
{
foreach (var tableChild in table.Children)
{
if (tableChild is not AtmosAlarmEntryContainer)
continue;
// Frontier: multiple type checks
if (tableChild is AtmosAlarmEntryContainer)
{
var entryContainer = (AtmosAlarmEntryContainer)tableChild;

var entryContainer = (AtmosAlarmEntryContainer)tableChild;
if (entryContainer.NetEntity != currTrackedEntity)
entryContainer.RemoveAsFocus();

if (entryContainer.NetEntity != currTrackedEntity)
entryContainer.RemoveAsFocus();
else if (entryContainer.NetEntity == currTrackedEntity)
entryContainer.SetAsFocus();
}
else if (tableChild is AtmosAlarmGaslockEntryContainer)
{
var entryContainer = (AtmosAlarmGaslockEntryContainer)tableChild;

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

else if (entryContainer.NetEntity == currTrackedEntity)
entryContainer.SetAsFocus();
}
// End Frontier
}
}

Expand All @@ -464,6 +568,8 @@ private void SetTrackedEntityFromNavMap(NetEntity? netEntity)
MasterTabContainer.CurrentTab = 1; break;
case AtmosAlertsComputerGroup.FireAlarm:
MasterTabContainer.CurrentTab = 2; break;
case AtmosAlertsComputerGroup.Gaslock: // Frontier
MasterTabContainer.CurrentTab = 3; break; // Frontier
}
}

Expand Down Expand Up @@ -565,12 +671,15 @@ private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollP

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

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

if (control is AtmosAlarmGaslockEntryContainer && ((AtmosAlarmGaslockEntryContainer)control).NetEntity == _trackedEntity) // Frontier
return true; // Frontier

nextScrollPosition += control.Height;
}

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public override void Init()
_prototypeManager.RegisterIgnore("alertLevels");
_prototypeManager.RegisterIgnore("nukeopsRole");
_prototypeManager.RegisterIgnore("ghostRoleRaffleDecider");
_prototypeManager.RegisterIgnore("gasDeposit"); // Frontier
_prototypeManager.RegisterIgnore("pointOfInterest"); // Frontier: worldgen-related, server-only

_componentFactory.GenerateNetIds();
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Fax/AdminUI/AdminFaxEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AdminFaxEui()
_window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close());
_window.OnFollowFax += entity => SendMessage(new AdminFaxEuiMsg.Follow(entity));
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.entity, args.title,
args.stampedBy, args.message, args.stampSprite, args.stampColor, args.locked));
args.stampedBy, args.message, args.stampSprite, args.stampColor, args.locked, args.stampProtected)); // Frontier
}

public override void Opened()
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Fax/AdminUI/AdminFaxWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<Label Text="{Loc admin-fax-stamp-color}" />
<ColorSelectorSliders Margin="12 0 0 0" Name="StampColorSelector" Color="#BB3232"/>
<CheckBox Name="LockPageCheckbox" Text="{Loc admin-fax-lock-page}" ToolTip="{Loc admin-fax-lock-page-tooltip}"/>
<!-- Frontier: stamp protection -->
<CheckBox Name="StampProtectPageCheckbox" Text="{Loc admin-fax-stamp-protect-page}" ToolTip="{Loc admin-fax-stamp-protect-page-tooltip}"/>
<!-- End Frontier: stamp protection -->
<Button Name="SendButton" Text="{Loc admin-fax-send}" Margin="0 10 0 0" />
</BoxContainer>
</DefaultWindow>
5 changes: 3 additions & 2 deletions Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed partial class AdminFaxWindow : DefaultWindow
{
private const string StampsRsiPath = "/Textures/Objects/Misc/bureaucracy.rsi";

public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor, bool locked)>? OnMessageSend;
public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor, bool locked, bool stampProtected)>? OnMessageSend; // Frontier: add stampProtected
public Action<NetEntity>? OnFollowFax;

[Dependency] private readonly IResourceCache _resCache = default!;
Expand Down Expand Up @@ -99,6 +99,7 @@ private void SendMessage(BaseButton.ButtonEventArgs obj)
var from = FromEdit.Text;
var stampColor = StampColorSelector.Color;
var locked = LockPageCheckbox.Pressed;
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor, locked));
var stampProtected = StampProtectPageCheckbox.Pressed; // Frontier
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor, locked, stampProtected)); // Frontier: add stampProtected
}
}
Loading

0 comments on commit bdd5392

Please sign in to comment.