Removes linter warnings from the PDA module (#17097)
This commit is contained in:
@@ -37,11 +37,11 @@ namespace Content.Client.PDA
|
|||||||
|
|
||||||
ViewContainer.OnChildAdded += control => control.Visible = false;
|
ViewContainer.OnChildAdded += control => control.Visible = false;
|
||||||
|
|
||||||
HomeButton.IconTexture = new SpriteSpecifier.Texture(new ("/Textures/Interface/home.png"));
|
HomeButton.IconTexture = new SpriteSpecifier.Texture(new("/Textures/Interface/home.png"));
|
||||||
FlashLightToggleButton.IconTexture = new SpriteSpecifier.Texture(new ("/Textures/Interface/light.png"));
|
FlashLightToggleButton.IconTexture = new SpriteSpecifier.Texture(new("/Textures/Interface/light.png"));
|
||||||
EjectPenButton.IconTexture = new SpriteSpecifier.Texture(new ("/Textures/Interface/pencil.png"));
|
EjectPenButton.IconTexture = new SpriteSpecifier.Texture(new("/Textures/Interface/pencil.png"));
|
||||||
EjectIdButton.IconTexture = new SpriteSpecifier.Texture(new ("/Textures/Interface/eject.png"));
|
EjectIdButton.IconTexture = new SpriteSpecifier.Texture(new("/Textures/Interface/eject.png"));
|
||||||
ProgramCloseButton.IconTexture = new SpriteSpecifier.Texture(new ("/Textures/Interface/Nano/cross.svg.png"));
|
ProgramCloseButton.IconTexture = new SpriteSpecifier.Texture(new("/Textures/Interface/Nano/cross.svg.png"));
|
||||||
|
|
||||||
|
|
||||||
HomeButton.OnPressed += _ => ToHomeScreen();
|
HomeButton.OnPressed += _ => ToHomeScreen();
|
||||||
@@ -102,8 +102,8 @@ namespace Content.Client.PDA
|
|||||||
if (state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null)
|
if (state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null)
|
||||||
{
|
{
|
||||||
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
||||||
("owner",state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
|
("owner", state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
|
||||||
("jobTitle",state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
|
("jobTitle", state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ namespace Content.Client.PDA
|
|||||||
}
|
}
|
||||||
|
|
||||||
StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
|
StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
|
||||||
("station",state.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
|
("station", state.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
|
||||||
|
|
||||||
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
|
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ namespace Content.Client.PDA
|
|||||||
_currentView = view;
|
_currentView = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BoxContainer CreateProgramListRow()
|
private static BoxContainer CreateProgramListRow()
|
||||||
{
|
{
|
||||||
return new BoxContainer()
|
return new BoxContainer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.UserInterface;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.Input;
|
|
||||||
|
|
||||||
namespace Content.Client.PDA;
|
namespace Content.Client.PDA;
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ public sealed class PDASystem : SharedPDASystem
|
|||||||
if (args.Sprite == null)
|
if (args.Sprite == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_appearance.TryGetData<bool>(uid, UnpoweredFlashlightVisuals.LightOn, out var isFlashlightOn, args.Component))
|
if (Appearance.TryGetData<bool>(uid, UnpoweredFlashlightVisuals.LightOn, out var isFlashlightOn, args.Component))
|
||||||
args.Sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
|
args.Sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
|
||||||
|
|
||||||
if (_appearance.TryGetData<bool>(uid, PDAVisuals.IDCardInserted, out var isCardInserted, args.Component))
|
if (Appearance.TryGetData<bool>(uid, PDAVisuals.IDCardInserted, out var isCardInserted, args.Component))
|
||||||
args.Sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
|
args.Sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ public sealed class PDASystem : SharedPDASystem
|
|||||||
{
|
{
|
||||||
base.OnComponentInit(uid, component, args);
|
base.OnComponentInit(uid, component, args);
|
||||||
|
|
||||||
if(!TryComp<SpriteComponent>(uid, out var sprite))
|
if (!TryComp<SpriteComponent>(uid, out var sprite))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.State != null)
|
if (component.State != null)
|
||||||
@@ -38,11 +38,11 @@ public sealed class PDASystem : SharedPDASystem
|
|||||||
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, component.FlashlightOn);
|
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, component.FlashlightOn);
|
||||||
sprite.LayerSetVisible(PDAVisualLayers.IDLight, component.IdSlot.StartingItem != null);
|
sprite.LayerSetVisible(PDAVisualLayers.IDLight, component.IdSlot.StartingItem != null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
enum PDAVisualLayers : byte
|
public enum PDAVisualLayers : byte
|
||||||
{
|
{
|
||||||
Base,
|
Base,
|
||||||
Flashlight,
|
Flashlight,
|
||||||
IDLight
|
IDLight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public partial class PDAWindow : BaseWindow
|
|||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
AccentH.ModulateSelfOverride = Color. FromHex(value, Color.White);
|
AccentH.ModulateSelfOverride = Color.FromHex(value, Color.White);
|
||||||
AccentH.Visible = value != null;
|
AccentH.Visible = value != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public partial class PDAWindow : BaseWindow
|
|||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
AccentV.ModulateSelfOverride = Color. FromHex(value, Color.White);
|
AccentV.ModulateSelfOverride = Color.FromHex(value, Color.White);
|
||||||
AccentV.Visible = value != null;
|
AccentV.Visible = value != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,20 +18,38 @@ namespace Content.Client.PDA.Ringer
|
|||||||
|
|
||||||
RingerNoteInputs = new[] { RingerNoteOneInput, RingerNoteTwoInput, RingerNoteThreeInput, RingerNoteFourInput };
|
RingerNoteInputs = new[] { RingerNoteOneInput, RingerNoteTwoInput, RingerNoteThreeInput, RingerNoteFourInput };
|
||||||
|
|
||||||
for (int i = 0; i < RingerNoteInputs.Length; i++)
|
for (var i = 0; i < RingerNoteInputs.Length; ++i)
|
||||||
{
|
{
|
||||||
var input = RingerNoteInputs[i];
|
var input = RingerNoteInputs[i];
|
||||||
int index = i;
|
var index = i;
|
||||||
input.OnTextChanged += _ => //Prevents unauthorized characters from being entered into the LineEdit
|
var foo = () => // Prevents unauthorized characters from being entered into the LineEdit
|
||||||
{
|
{
|
||||||
input.Text = input.Text.ToUpper();
|
input.Text = input.Text.ToUpper();
|
||||||
|
|
||||||
if (!IsNote(input.Text))
|
if (!IsNote(input.Text))
|
||||||
|
{
|
||||||
input.Text = PreviousNoteInputs[index];
|
input.Text = PreviousNoteInputs[index];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
PreviousNoteInputs[index] = input.Text;
|
PreviousNoteInputs[index] = input.Text;
|
||||||
|
|
||||||
input.CursorPosition = input.Text.Length; //Resets caret position to the end of the typed input
|
input.RemoveStyleClass("Caution");
|
||||||
|
};
|
||||||
|
|
||||||
|
input.OnFocusExit += _ => foo();
|
||||||
|
input.OnTextEntered += _ =>
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
input.CursorPosition = input.Text.Length; // Resets caret position to the end of the typed input
|
||||||
|
};
|
||||||
|
input.OnTextChanged += _ =>
|
||||||
|
{
|
||||||
|
input.Text = input.Text.ToUpper();
|
||||||
|
|
||||||
|
if (!IsNote(input.Text))
|
||||||
|
input.AddStyleClass("Caution");
|
||||||
|
else
|
||||||
|
input.RemoveStyleClass("Caution");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Content.Server.Store.Components;
|
|||||||
using Content.Server.Store.Systems;
|
using Content.Server.Store.Systems;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Content.Shared.Light.Component;
|
using Content.Shared.Light.Component;
|
||||||
|
|
||||||
@@ -32,20 +33,25 @@ namespace Content.Server.PDA
|
|||||||
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
|
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
|
||||||
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
|
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
|
||||||
SubscribeLocalEvent<PDAComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
|
SubscribeLocalEvent<PDAComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||||
|
|
||||||
|
// UI Events:
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDARequestUpdateInterfaceMessage>(OnUiMessage);
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDAToggleFlashlightMessage>(OnUiMessage);
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDAShowRingtoneMessage>(OnUiMessage);
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDAShowMusicMessage>(OnUiMessage);
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDAShowUplinkMessage>(OnUiMessage);
|
||||||
|
SubscribeLocalEvent<PDAComponent, PDALockUplinkMessage>(OnUiMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
||||||
{
|
{
|
||||||
base.OnComponentInit(uid, pda, args);
|
base.OnComponentInit(uid, pda, args);
|
||||||
|
|
||||||
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
|
if (!HasComp<ServerUserInterfaceComponent>(uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateAlertLevel(uid, pda);
|
UpdateAlertLevel(uid, pda);
|
||||||
UpdateStationName(uid, pda);
|
UpdateStationName(uid, pda);
|
||||||
|
|
||||||
if (_ui.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
|
|
||||||
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args)
|
protected override void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args)
|
||||||
@@ -116,55 +122,66 @@ namespace Content.Server.PDA
|
|||||||
_cartridgeLoader?.UpdateUiState(uid, state);
|
_cartridgeLoader?.UpdateUiState(uid, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDARequestUpdateInterfaceMessage msg)
|
||||||
{
|
{
|
||||||
var uid = pda.Owner;
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
// todo: move this to entity events
|
return;
|
||||||
switch (msg.Message)
|
|
||||||
{
|
|
||||||
case PDARequestUpdateInterfaceMessage _:
|
|
||||||
UpdatePdaUi(uid, pda);
|
UpdatePdaUi(uid, pda);
|
||||||
break;
|
}
|
||||||
case PDAToggleFlashlightMessage _:
|
|
||||||
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDAToggleFlashlightMessage msg)
|
||||||
{
|
{
|
||||||
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
|
return;
|
||||||
|
|
||||||
if (TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
if (TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
||||||
_unpoweredFlashlight.ToggleLight(uid, flashlight);
|
_unpoweredFlashlight.ToggleLight(uid, flashlight);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case PDAShowRingtoneMessage _:
|
|
||||||
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDAShowRingtoneMessage msg)
|
||||||
{
|
{
|
||||||
if (TryComp<RingerComponent>(uid, out var ringer))
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
_ringer.ToggleRingerUI(ringer, msg.Session);
|
return;
|
||||||
break;
|
|
||||||
|
if (HasComp<RingerComponent>(uid))
|
||||||
|
_ringer.ToggleRingerUI(uid, (IPlayerSession) msg.Session);
|
||||||
}
|
}
|
||||||
case PDAShowMusicMessage _:
|
|
||||||
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDAShowMusicMessage msg)
|
||||||
{
|
{
|
||||||
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
|
return;
|
||||||
|
|
||||||
if (TryComp<InstrumentComponent>(uid, out var instrument))
|
if (TryComp<InstrumentComponent>(uid, out var instrument))
|
||||||
_instrument.ToggleInstrumentUi(uid, msg.Session, instrument);
|
_instrument.ToggleInstrumentUi(uid, (IPlayerSession) msg.Session, instrument);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case PDAShowUplinkMessage _:
|
|
||||||
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDAShowUplinkMessage msg)
|
||||||
{
|
{
|
||||||
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
|
return;
|
||||||
|
|
||||||
// check if its locked again to prevent malicious clients opening locked uplinks
|
// check if its locked again to prevent malicious clients opening locked uplinks
|
||||||
if (TryComp<StoreComponent>(uid, out var store) && IsUnlocked(uid))
|
if (TryComp<StoreComponent>(uid, out var store) && IsUnlocked(uid))
|
||||||
_store.ToggleUi(msg.Session.AttachedEntity!.Value, uid, store);
|
_store.ToggleUi(msg.Session.AttachedEntity!.Value, uid, store);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case PDALockUplinkMessage _:
|
|
||||||
|
private void OnUiMessage(EntityUid uid, PDAComponent pda, PDALockUplinkMessage msg)
|
||||||
{
|
{
|
||||||
|
if (!PDAUiKey.Key.Equals(msg.UiKey))
|
||||||
|
return;
|
||||||
|
|
||||||
if (TryComp<RingerUplinkComponent>(uid, out var uplink))
|
if (TryComp<RingerUplinkComponent>(uid, out var uplink))
|
||||||
{
|
{
|
||||||
_ringer.LockUplink(uid, uplink);
|
_ringer.LockUplink(uid, uplink);
|
||||||
UpdatePdaUi(uid, pda);
|
UpdatePdaUi(uid, pda);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsUnlocked(EntityUid uid)
|
private bool IsUnlocked(EntityUid uid)
|
||||||
{
|
{
|
||||||
return TryComp<RingerUplinkComponent>(uid, out var uplink) ? uplink.Unlocked : true;
|
return !TryComp<RingerUplinkComponent>(uid, out var uplink) || uplink.Unlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStationName(EntityUid uid, PDAComponent pda)
|
private void UpdateStationName(EntityUid uid, PDAComponent pda)
|
||||||
|
|||||||
@@ -30,5 +30,7 @@ namespace Content.Server.PDA.Ringer
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class ActiveRingerComponent : Component {}
|
public sealed class ActiveRingerComponent : Component
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Server.Store.Components;
|
using Content.Server.Store.Components;
|
||||||
using Content.Server.Store.Systems;
|
using Content.Server.Store.Systems;
|
||||||
using Content.Server.UserInterface;
|
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.PDA.Ringer;
|
using Content.Shared.PDA.Ringer;
|
||||||
using Content.Shared.Store;
|
using Content.Shared.Store;
|
||||||
@@ -18,8 +17,8 @@ namespace Content.Server.PDA.Ringer
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly PDASystem _pda = default!;
|
[Dependency] private readonly PDASystem _pda = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly StoreSystem _store = default!;
|
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -49,12 +48,12 @@ namespace Content.Server.PDA.Ringer
|
|||||||
private void RingerPlayRingtone(EntityUid uid, RingerComponent ringer, RingerPlayRingtoneMessage args)
|
private void RingerPlayRingtone(EntityUid uid, RingerComponent ringer, RingerPlayRingtoneMessage args)
|
||||||
{
|
{
|
||||||
EnsureComp<ActiveRingerComponent>(uid);
|
EnsureComp<ActiveRingerComponent>(uid);
|
||||||
UpdateRingerUserInterface(ringer);
|
UpdateRingerUserInterface(uid, ringer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRingerUserInterfaceDriver(EntityUid uid, RingerComponent ringer, RingerRequestUpdateInterfaceMessage args)
|
private void UpdateRingerUserInterfaceDriver(EntityUid uid, RingerComponent ringer, RingerRequestUpdateInterfaceMessage args)
|
||||||
{
|
{
|
||||||
UpdateRingerUserInterface(ringer);
|
UpdateRingerUserInterface(uid, ringer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSetRingtone(EntityUid uid, RingerComponent ringer, RingerSetRingtoneMessage args)
|
private void OnSetRingtone(EntityUid uid, RingerComponent ringer, RingerSetRingtoneMessage args)
|
||||||
@@ -67,12 +66,12 @@ namespace Content.Server.PDA.Ringer
|
|||||||
if (ev.Handled)
|
if (ev.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateRingerRingtone(ringer, args.Ringtone);
|
UpdateRingerRingtone(uid, ringer, args.Ringtone);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSetUplinkRingtone(EntityUid uid, RingerUplinkComponent uplink, ref BeforeRingtoneSetEvent args)
|
private void OnSetUplinkRingtone(EntityUid uid, RingerUplinkComponent uplink, ref BeforeRingtoneSetEvent args)
|
||||||
{
|
{
|
||||||
if (uplink.Code.SequenceEqual(args.Ringtone) && TryComp<StoreComponent>(uid, out var store))
|
if (uplink.Code.SequenceEqual(args.Ringtone) && HasComp<StoreComponent>(uid))
|
||||||
{
|
{
|
||||||
uplink.Unlocked = !uplink.Unlocked;
|
uplink.Unlocked = !uplink.Unlocked;
|
||||||
if (TryComp<PDAComponent>(uid, out var pda))
|
if (TryComp<PDAComponent>(uid, out var pda))
|
||||||
@@ -104,7 +103,7 @@ namespace Content.Server.PDA.Ringer
|
|||||||
|
|
||||||
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args)
|
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args)
|
||||||
{
|
{
|
||||||
UpdateRingerRingtone(ringer, GenerateRingtone());
|
UpdateRingerRingtone(uid, ringer, GenerateRingtone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RandomizeUplinkCode(EntityUid uid, RingerUplinkComponent uplink, ComponentInit args)
|
public void RandomizeUplinkCode(EntityUid uid, RingerUplinkComponent uplink, ComponentInit args)
|
||||||
@@ -136,25 +135,25 @@ namespace Content.Server.PDA.Ringer
|
|||||||
return ringtone;
|
return ringtone;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateRingerRingtone(RingerComponent ringer, Note[] ringtone)
|
private bool UpdateRingerRingtone(EntityUid uid, RingerComponent ringer, Note[] ringtone)
|
||||||
{
|
{
|
||||||
// Assume validation has already happened.
|
// Assume validation has already happened.
|
||||||
ringer.Ringtone = ringtone;
|
ringer.Ringtone = ringtone;
|
||||||
UpdateRingerUserInterface(ringer);
|
UpdateRingerUserInterface(uid, ringer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRingerUserInterface(RingerComponent ringer)
|
private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer)
|
||||||
{
|
{
|
||||||
var ui = ringer.Owner.GetUIOrNull(RingerUiKey.Key);
|
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
|
||||||
ui?.SetState(new RingerUpdateState(HasComp<ActiveRingerComponent>(ringer.Owner), ringer.Ringtone));
|
_ui.SetUiState(bui, new RingerUpdateState(HasComp<ActiveRingerComponent>(uid), ringer.Ringtone));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToggleRingerUI(RingerComponent ringer, IPlayerSession session)
|
public bool ToggleRingerUI(EntityUid uid, IPlayerSession session)
|
||||||
{
|
{
|
||||||
var ui = ringer.Owner.GetUIOrNull(RingerUiKey.Key);
|
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
|
||||||
ui?.Toggle(session);
|
_ui.ToggleUi(bui, session);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,25 +161,31 @@ namespace Content.Server.PDA.Ringer
|
|||||||
{
|
{
|
||||||
var remove = new RemQueue<EntityUid>();
|
var remove = new RemQueue<EntityUid>();
|
||||||
|
|
||||||
foreach(var (_, ringer) in EntityManager.EntityQuery<ActiveRingerComponent, RingerComponent>())
|
var pdaQuery = EntityQueryEnumerator<RingerComponent, ActiveRingerComponent>();
|
||||||
|
while (pdaQuery.MoveNext(out var uid, out var ringer, out var _))
|
||||||
{
|
{
|
||||||
ringer.TimeElapsed += frameTime;
|
ringer.TimeElapsed += frameTime;
|
||||||
|
|
||||||
if (ringer.TimeElapsed < NoteDelay) continue;
|
if (ringer.TimeElapsed < NoteDelay)
|
||||||
|
continue;
|
||||||
|
|
||||||
ringer.TimeElapsed -= NoteDelay;
|
ringer.TimeElapsed -= NoteDelay;
|
||||||
var ringerXform = Transform(ringer.Owner);
|
var ringerXform = Transform(uid);
|
||||||
|
|
||||||
SoundSystem.Play(GetSound(ringer.Ringtone[ringer.NoteCount]),
|
_audio.Play(
|
||||||
|
GetSound(ringer.Ringtone[ringer.NoteCount]),
|
||||||
Filter.Empty().AddInRange(ringerXform.MapPosition, ringer.Range),
|
Filter.Empty().AddInRange(ringerXform.MapPosition, ringer.Range),
|
||||||
ringer.Owner, AudioParams.Default.WithMaxDistance(ringer.Range).WithVolume(ringer.Volume));
|
uid,
|
||||||
|
true,
|
||||||
|
AudioParams.Default.WithMaxDistance(ringer.Range).WithVolume(ringer.Volume)
|
||||||
|
);
|
||||||
|
|
||||||
ringer.NoteCount++;
|
ringer.NoteCount++;
|
||||||
|
|
||||||
if (ringer.NoteCount > 3)
|
if (ringer.NoteCount > 3)
|
||||||
{
|
{
|
||||||
remove.Add(ringer.Owner);
|
remove.Add(uid);
|
||||||
UpdateRingerUserInterface(ringer);
|
UpdateRingerUserInterface(uid, ringer);
|
||||||
ringer.TimeElapsed = 0;
|
ringer.TimeElapsed = 0;
|
||||||
ringer.NoteCount = 0;
|
ringer.NoteCount = 0;
|
||||||
break;
|
break;
|
||||||
@@ -193,12 +198,12 @@ namespace Content.Server.PDA.Ringer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetSound(Note note)
|
private static string GetSound(Note note)
|
||||||
{
|
{
|
||||||
return new ResPath("/Audio/Effects/RingtoneNotes/" + note.ToString().ToLower()) + ".ogg";
|
return new ResPath("/Audio/Effects/RingtoneNotes/" + note.ToString().ToLower()) + ".ogg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct BeforeRingtoneSetEvent(Note[] Ringtone, bool Handled = false);
|
public record struct BeforeRingtoneSetEvent(Note[] Ringtone, bool Handled = false);
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,15 +4,19 @@ namespace Content.Shared.PDA.Ringer
|
|||||||
{
|
{
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class RingerRequestUpdateInterfaceMessage : BoundUserInterfaceMessage {}
|
public sealed class RingerRequestUpdateInterfaceMessage : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class RingerPlayRingtoneMessage : BoundUserInterfaceMessage {}
|
public sealed class RingerPlayRingtoneMessage : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class RingerSetRingtoneMessage : BoundUserInterfaceMessage
|
public sealed class RingerSetRingtoneMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
public Note[] Ringtone {get;}
|
public Note[] Ringtone { get; }
|
||||||
|
|
||||||
public RingerSetRingtoneMessage(Note[] ringTone)
|
public RingerSetRingtoneMessage(Note[] ringTone)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Content.Shared.PDA
|
|||||||
public abstract class SharedPDASystem : EntitySystem
|
public abstract class SharedPDASystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] protected readonly ItemSlotsSystem ItemSlotsSystem = default!;
|
[Dependency] protected readonly ItemSlotsSystem ItemSlotsSystem = default!;
|
||||||
[Dependency] protected readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -55,8 +55,7 @@ namespace Content.Shared.PDA
|
|||||||
|
|
||||||
private void UpdatePdaAppearance(EntityUid uid, PDAComponent pda)
|
private void UpdatePdaAppearance(EntityUid uid, PDAComponent pda)
|
||||||
{
|
{
|
||||||
if (TryComp(pda.Owner, out AppearanceComponent ? appearance))
|
Appearance.SetData(uid, PDAVisuals.IDCardInserted, pda.ContainedID != null);
|
||||||
_appearance.SetData(uid, PDAVisuals.IDCardInserted, pda.ContainedID != null, appearance);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user