Musician PDA quick fix (#7018)

This commit is contained in:
Alex Evgrashin
2022-03-07 14:41:50 +03:00
committed by GitHub
parent c4ecb1678a
commit 5f632e20ad
8 changed files with 49 additions and 12 deletions

View File

@@ -48,6 +48,11 @@ namespace Content.Client.PDA
SendMessage(new PDAShowUplinkMessage());
};
_menu.ActivateMusicButton.OnPressed += _ =>
{
SendMessage(new PDAShowMusicMessage());
};
_menu.AccessRingtoneButton.OnPressed += _ =>
{
SendMessage(new PDAShowRingtoneMessage());
@@ -91,6 +96,7 @@ namespace Content.Client.PDA
_menu.EjectIdButton.Visible = msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null;
_menu.EjectPenButton.Visible = msg.HasPen;
_menu.ActivateUplinkButton.Visible = msg.HasUplink;
_menu.ActivateMusicButton.Visible = msg.CanPlayMusic;
break;
}

View File

@@ -37,6 +37,9 @@
<Button Name="ActivateUplinkButton"
Access="Public"
Text="{Loc 'pda-bound-user-interface-uplink-tab-title'}" />
<Button Name="ActivateMusicButton"
Access="Public"
Text="{Loc 'pda-bound-user-interface-music-button'}" />
</BoxContainer>
</TabContainer>
</DefaultWindow>

View File

@@ -5,6 +5,7 @@ using Content.Server.UserInterface;
using Content.Shared.Instruments;
using Content.Shared.Popups;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -181,4 +182,13 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
instrument.BatchesDropped = 0;
}
}
public void ToggleInstrumentUi(EntityUid uid, IPlayerSession session, InstrumentComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
var ui = uid.GetUIOrNull(InstrumentUiKey.Key);
ui?.Toggle(session);
}
}

View File

@@ -1,3 +1,4 @@
using Content.Server.Instruments;
using Content.Server.Light.Components;
using Content.Server.Light.EntitySystems;
using Content.Server.Light.Events;
@@ -7,6 +8,7 @@ using Content.Server.Traitor.Uplink.Components;
using Content.Server.PDA.Ringer;
using Content.Server.UserInterface;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Instruments;
using Content.Shared.Interaction;
using Content.Shared.PDA;
using Robust.Server.GameObjects;
@@ -22,6 +24,7 @@ namespace Content.Server.PDA
[Dependency] private readonly UplinkAccountsSystem _uplinkAccounts = default!;
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
[Dependency] private readonly RingerSystem _ringerSystem = default!;
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
public override void Initialize()
{
@@ -119,7 +122,9 @@ namespace Content.Server.PDA
if (ui == null)
return;
ui.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, ShouldShowUplink(pda.Owner, ui, user)));
ui.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo,
ShouldShowUplink(pda.Owner, ui, user),
HasComp<InstrumentComponent>(pda.Owner)));
}
/// <summary>
@@ -156,6 +161,7 @@ namespace Content.Server.PDA
if (msg.Session.AttachedEntity is not {Valid: true} playerUid)
return;
// todo: move this to entity events
switch (msg.Message)
{
case PDARequestUpdateInterfaceMessage _:
@@ -190,6 +196,12 @@ namespace Content.Server.PDA
_ringerSystem.ToggleRingerUI(ringer, msg.Session);
break;
}
case PDAShowMusicMessage _:
{
if (TryComp(pda.Owner, out InstrumentComponent? instrument))
_instrumentSystem.ToggleInstrumentUi(pda.Owner, msg.Session, instrument);
break;
}
}
}
}

View File

@@ -48,6 +48,14 @@ namespace Content.Shared.PDA
}
}
[Serializable, NetSerializable]
public sealed class PDAShowMusicMessage : BoundUserInterfaceMessage
{
public PDAShowMusicMessage()
{
}
}
[Serializable, NetSerializable]
public sealed class PDARequestUpdateInterfaceMessage : BoundUserInterfaceMessage

View File

@@ -13,13 +13,15 @@ namespace Content.Shared.PDA
public bool HasPen;
public PDAIdInfoText PDAOwnerInfo;
public bool HasUplink;
public bool CanPlayMusic;
public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pDAOwnerInfo, bool hasUplink = false)
public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pDAOwnerInfo, bool hasUplink = false, bool canPlayMusic = false)
{
FlashlightEnabled = flashlightEnabled;
HasPen = hasPen;
PDAOwnerInfo = pDAOwnerInfo;
HasUplink = hasUplink;
CanPlayMusic = canPlayMusic;
}
}

View File

@@ -21,3 +21,5 @@ comp-pda-ui-eject-pen-button = Eject Pen
comp-pda-ui-ringtone-button = Ringtone
comp-pda-ui-toggle-flashlight-button = Toggle Flashlight
pda-bound-user-interface-music-button = Music Instrument

View File

@@ -43,6 +43,8 @@
type: UplinkBoundUserInterface
- key: enum.RingerUiKey.Key
type: RingerBoundUserInterface
- key: enum.InstrumentUiKey.Key
type: InstrumentBoundUserInterface
- type: PDA
penSlot:
startingItem: Pen
@@ -59,6 +61,8 @@
- type: Tag
tags:
- DoorBumpOpener
- type: Input
context: "human"
- type: entity
parent: BasePDA
@@ -493,13 +497,3 @@
handheld: true
bank: 1
program: 2
- type: ActivatableUI
inHandsOnly: true
singleUser: true
key: enum.InstrumentUiKey.Key
- type: UserInterface
interfaces:
- key: enum.InstrumentUiKey.Key
type: InstrumentBoundUserInterface
- type: Input
context: "human"