Делаем пикание опциональным на мониторинге экипажа (#144)

* stable

* Доработка

* Update mentor-help-ui.ftl
This commit is contained in:
A-Mironov 2025-12-03 00:33:13 +03:00 committed by GitHub
parent 488682ed5c
commit 72e99b05b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 82 additions and 6 deletions

View file

@ -31,6 +31,7 @@ public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
_menu = this.CreateWindow<CrewMonitoringWindow>();
_menu.Set(stationName, gridUid);
_menu.SetBoundUserInterface(this);
}
protected override void UpdateState(BoundUserInterfaceState state)
@ -42,6 +43,7 @@ public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
case CrewMonitoringState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowSensors(st.Sensors, Owner, xform?.Coordinates);
_menu?.UpdateCorpseAlertToggle(st.CorpseAlertEnabled);
break;
}
}

View file

@ -11,7 +11,13 @@
<BoxContainer Orientation="Vertical" Margin="0 0 10 0">
<controls:StripeBack>
<PanelContainer>
<BoxContainer Orientation="Vertical">
<Label Name="StationName" Text="Unknown station" Align="Center" Margin="0 5 0 3"/>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 2 0 3">
<Button Name="CorpseAlertToggle" Text="{Loc 'crew-monitoring-corpse-alert-off'}"
HorizontalAlignment="Center" Margin="0 0 0 0" SetWidth="260"/>
</BoxContainer>
</BoxContainer>
</PanelContainer>
</controls:StripeBack>

View file

@ -4,6 +4,7 @@ using System.Numerics;
using Content.Client.Pinpointer.UI;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.StatusIcon;
using Robust.Client.AutoGenerated;
@ -12,6 +13,7 @@ using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
@ -31,6 +33,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
private NetEntity? _trackedEntity;
private bool _tryToScrollToListFocus;
private Texture? _blipTexture;
private CrewMonitoringBoundUserInterface? _boundUserInterface;
public CrewMonitoringWindow()
{
@ -41,6 +44,11 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
_spriteSystem = _entManager.System<SpriteSystem>();
NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap;
CorpseAlertToggle.OnPressed += OnCorpseAlertTogglePressed;
// Initialize corpse alert toggle to "off" state
UpdateCorpseAlertToggle(false);
CorpseAlertToggle.Disabled = false;
}
public void Set(string stationName, EntityUid? mapUid)
@ -58,6 +66,11 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
NavMap.ForceNavMapUpdate();
}
public void SetBoundUserInterface(CrewMonitoringBoundUserInterface boundUserInterface)
{
_boundUserInterface = boundUserInterface;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
@ -448,6 +461,41 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
NavMap.TrackedEntities.Clear();
NavMap.LocalizedNames.Clear();
}
public void UpdateCorpseAlertToggle(bool enabled)
{
if (enabled)
{
CorpseAlertToggle.Text = Loc.GetString("crew-monitoring-corpse-alert-on");
CorpseAlertToggle.AddStyleClass(StyleNano.StyleClassButtonColorGreen);
}
else
{
CorpseAlertToggle.Text = Loc.GetString("crew-monitoring-corpse-alert-off");
CorpseAlertToggle.RemoveStyleClass(StyleNano.StyleClassButtonColorGreen);
}
// Re-enable the button when server state is received
CorpseAlertToggle.Disabled = false;
}
private void OnCorpseAlertTogglePressed(BaseButton.ButtonEventArgs args)
{
// Disable button to prevent spam clicks
CorpseAlertToggle.Disabled = true;
// Send message to server
_boundUserInterface?.SendMessage(new CrewMonitoringToggleCorpseAlertMessage());
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_boundUserInterface = null;
}
}
}
public sealed class CrewMonitoringButton : Button

View file

@ -23,7 +23,7 @@ public sealed partial class CrewMonitoringConsoleComponent : Component
/// Whether the console should beep when corpses with sensors are detected outside morgues.
/// </summary>
[DataField("doCorpseAlert"), ViewVariables(VVAccess.ReadWrite)]
public bool DoCorpseAlert = true;
public bool DoCorpseAlert = false;
/// <summary>
/// Next time to check for corpses and potentially play alert sound.

View file

@ -31,6 +31,7 @@ public sealed class CrewMonitoringConsoleSystem : EntitySystem
SubscribeLocalEvent<CrewMonitoringConsoleComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<CrewMonitoringConsoleComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
SubscribeLocalEvent<CrewMonitoringConsoleComponent, BoundUIOpenedEvent>(OnUIOpened);
SubscribeLocalEvent<CrewMonitoringConsoleComponent, CrewMonitoringToggleCorpseAlertMessage>(OnToggleCorpseAlert);
}
public override void Update(float frameTime)
@ -112,7 +113,7 @@ public sealed class CrewMonitoringConsoleSystem : EntitySystem
// Update all sensors info
var allSensors = component.ConnectedSensors.Values.ToList();
_uiSystem.SetUiState(uid, CrewMonitoringUIKey.Key, new CrewMonitoringState(allSensors));
_uiSystem.SetUiState(uid, CrewMonitoringUIKey.Key, new CrewMonitoringState(allSensors, component.DoCorpseAlert));
}
/// <summary>
@ -158,4 +159,10 @@ public sealed class CrewMonitoringConsoleSystem : EntitySystem
return false;
}
private void OnToggleCorpseAlert(EntityUid uid, CrewMonitoringConsoleComponent component, CrewMonitoringToggleCorpseAlertMessage args)
{
component.DoCorpseAlert = !component.DoCorpseAlert;
UpdateUserInterface(uid, component);
}
}

View file

@ -13,9 +13,16 @@ public enum CrewMonitoringUIKey
public sealed class CrewMonitoringState : BoundUserInterfaceState
{
public List<SuitSensorStatus> Sensors;
public bool CorpseAlertEnabled;
public CrewMonitoringState(List<SuitSensorStatus> sensors)
public CrewMonitoringState(List<SuitSensorStatus> sensors, bool corpseAlertEnabled = false)
{
Sensors = sensors;
CorpseAlertEnabled = corpseAlertEnabled;
}
}
[Serializable, NetSerializable]
public sealed class CrewMonitoringToggleCorpseAlertMessage : BoundUserInterfaceMessage
{
}

View file

@ -19,3 +19,6 @@ crew-monitoring-user-interface-no-department = Unknown
crew-monitoring-user-interface-flavor-left = In case of an emergency, contact station medical staff immediately
crew-monitoring-user-interface-flavor-right = v1.7
crew-monitoring-corpse-alert-on = Corpse Alert: ON
crew-monitoring-corpse-alert-off = Corpse Alert: OFF

View file

@ -1,4 +1,4 @@
ui-lobby-mhelp-button = MHelp
ui-lobby-mhelp-button = Ментор-помощь
ui-options-function-open-mentor-help = Открыть ментор помощь
ui-options-function-open-help-choice = Открыть выбор помощи

View file

@ -13,3 +13,6 @@ crew-monitoring-user-interface-no-server = Сервер не найден
crew-monitoring-user-interface-no-department = Неизвестно
crew-monitoring-user-interface-flavor-left = В случае экстренной ситуации, немедленно свяжитесь с мед. персоналом станции.
crew-monitoring-user-interface-flavor-right = v1.7
crew-monitoring-corpse-alert-on = Оповещение о трупах: ВКЛ
crew-monitoring-corpse-alert-off = Оповещение о трупах: ВЫКЛ