forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1313 from Darkmajia/signatures
robust signatures (plus syndicate recruiter fixes)
- Loading branch information
Showing
55 changed files
with
1,306 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Content.Server.Crayon; | ||
using Content.Shared.DV.Paper; | ||
using Content.Shared.DV.Traits; | ||
using Content.Shared.Paper; | ||
using Content.Shared.Popups; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.ContentPack; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server.DV.Paper; | ||
|
||
public sealed class SignatureSystem : SharedSignatureSystem | ||
{ | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly PaperSystem _paper = default!; | ||
[Dependency] private readonly IResourceManager _resourceManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SignatureWriterComponent, SignAttemptEvent>(OnSignAttempt); | ||
} | ||
|
||
private void OnSignAttempt(Entity<SignatureWriterComponent> ent, ref SignAttemptEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
var paper = args.Paper; | ||
var signer = args.User; | ||
var pen = args.Pen; | ||
var paperComp = args.Paper.Comp; | ||
var signatureComp = ent.Comp; | ||
|
||
var signatureName = DetermineEntitySignature(signer); | ||
var signatureColor = signatureComp.Color; | ||
var signatureFont = "/Fonts/NotoSans/NotoSans-Regular.ttf"; // Noto Sans as fallback | ||
|
||
if (signatureComp.Font is { } penFont) | ||
signatureFont = penFont; | ||
else if (TryComp<SignatureFontComponent>(signer, out var signerComp) && signerComp.Font is { } signerFont) | ||
signatureFont = signerFont; | ||
|
||
if (!_resourceManager.TryContentFileRead(signatureFont, out _)) | ||
signatureFont = "/Fonts/NotoSans/NotoSans-Regular.ttf"; // The font failed to read, so reset to Noto Sans | ||
|
||
if (TryComp<CrayonComponent>(pen, out var crayon)) | ||
signatureColor = crayon.Color; | ||
|
||
var stampInfo = new StampDisplayInfo() | ||
{ | ||
StampedName = signatureName, | ||
StampedColor = signatureColor, | ||
HasIcon = false, | ||
StampFont = signatureFont | ||
}; | ||
|
||
// TODO: remove redunant contains check when TryStamp isnt a meme | ||
if (paperComp.StampedBy.Contains(stampInfo) || !_paper.TryStamp(paper, stampInfo, SignatureStampState)) | ||
{ | ||
// Show an error popup. | ||
_popup.PopupEntity(Loc.GetString("paper-signed-failure", ("target", paper.Owner)), signer, signer, PopupType.SmallCaution); | ||
|
||
args.Cancelled = true; | ||
return; | ||
} | ||
|
||
// Show popups and play a paper writing sound | ||
var signedOtherMessage = Loc.GetString("paper-signed-other", ("user", signer), ("target", paper.Owner)); | ||
_popup.PopupEntity(signedOtherMessage, signer, Filter.PvsExcept(signer, entityManager: EntityManager), true); | ||
|
||
var signedSelfMessage = Loc.GetString("paper-signed-self", ("target", paper.Owner)); | ||
_popup.PopupEntity(signedSelfMessage, signer, signer); | ||
|
||
_audio.PlayEntity(paperComp.Sound, Filter.Pvs(signer), signer, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Content.Shared.Crayon; | ||
namespace Content.Shared.Crayon; | ||
|
||
[Virtual] | ||
public abstract class SharedCrayonSystem : EntitySystem { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Content.Shared/_DV/Paper/ItemToggleSignatureWriterComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace Content.Shared.DV.Paper; | ||
|
||
[RegisterComponent] | ||
public sealed partial class ItemToggleSignatureWriterComponent : Component | ||
{ | ||
/// <summary> | ||
/// The font used when this item is activated. | ||
/// </summary> | ||
[DataField("activatedFont")] | ||
public string? ActivatedFont; | ||
|
||
/// <summary> | ||
/// The list of fonts used when this item is activated. | ||
/// </summary> | ||
[DataField("activatedFontList")] | ||
public Dictionary<string, string> ActivatedFontList = new(); | ||
|
||
/// <summary> | ||
/// The color used when this item is activated. | ||
/// </summary> | ||
[DataField("activatedColor")] | ||
public Color? ActivatedColor; | ||
|
||
/// <summary> | ||
/// The list of colors used when this item is activated. | ||
/// </summary> | ||
[DataField("activatedColorList")] | ||
public Dictionary<string, Color> ActivatedColorList = new(); | ||
|
||
/// <summary> | ||
/// The font used when this item is deactivated. | ||
/// </summary> | ||
[DataField("deactivatedFont")] | ||
public string? DeactivatedFont; | ||
|
||
/// <summary> | ||
/// The list of fonts used when this item is deactivated. | ||
/// </summary> | ||
[DataField("deactivatedFontList")] | ||
public Dictionary<string, string> DeactivatedFontList = new(); | ||
|
||
/// <summary> | ||
/// The color used when this item is deactivated. | ||
/// </summary> | ||
[DataField("deactivatedColor")] | ||
public Color? DeactivatedColor; | ||
|
||
/// <summary> | ||
/// The list of colors used when this item is deactivated. | ||
/// </summary> | ||
[DataField("deactivatedColorList")] | ||
public Dictionary<string, Color> DeactivatedColorList = new(); | ||
} |
Oops, something went wrong.