-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Languages_Markers
Signed-off-by: FoxxoTrystan <[email protected]>
- Loading branch information
Showing
96 changed files
with
2,920 additions
and
296 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Numerics; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Input; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.OfferItem; | ||
|
||
public sealed class OfferItemIndicatorsOverlay : Overlay | ||
{ | ||
private readonly IInputManager _inputManager; | ||
private readonly IEntityManager _entMan; | ||
private readonly IEyeManager _eye; | ||
private readonly OfferItemSystem _offer; | ||
|
||
private readonly Texture _sight; | ||
|
||
public override OverlaySpace Space => OverlaySpace.ScreenSpace; | ||
|
||
private readonly Color _mainColor = Color.White.WithAlpha(0.3f); | ||
private readonly Color _strokeColor = Color.Black.WithAlpha(0.5f); | ||
private readonly float _scale = 0.6f; // 1 is a little big | ||
|
||
public OfferItemIndicatorsOverlay(IInputManager input, IEntityManager entMan, | ||
IEyeManager eye, OfferItemSystem offerSys) | ||
{ | ||
_inputManager = input; | ||
_entMan = entMan; | ||
_eye = eye; | ||
_offer = offerSys; | ||
|
||
var spriteSys = _entMan.EntitySysManager.GetEntitySystem<SpriteSystem>(); | ||
_sight = spriteSys.Frame0(new SpriteSpecifier.Rsi(new ResPath("/Textures/Interface/Misc/give_item.rsi"), | ||
"give_item")); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (!_offer.IsInOfferMode()) | ||
return false; | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
var mouseScreenPosition = _inputManager.MouseScreenPosition; | ||
var mousePosMap = _eye.PixelToMap(mouseScreenPosition); | ||
if (mousePosMap.MapId != args.MapId) | ||
return; | ||
|
||
|
||
var mousePos = mouseScreenPosition.Position; | ||
var uiScale = (args.ViewportControl as Control)?.UIScale ?? 1f; | ||
var limitedScale = uiScale > 1.25f ? 1.25f : uiScale; | ||
|
||
DrawSight(_sight, args.ScreenHandle, mousePos, limitedScale * _scale); | ||
} | ||
|
||
private void DrawSight(Texture sight, DrawingHandleScreen screen, Vector2 centerPos, float scale) | ||
{ | ||
var sightSize = sight.Size * scale; | ||
var expandedSize = sightSize + new Vector2(7f, 7f); | ||
|
||
screen.DrawTextureRect(sight, | ||
UIBox2.FromDimensions(centerPos - sightSize * 0.5f, sightSize), _strokeColor); | ||
screen.DrawTextureRect(sight, | ||
UIBox2.FromDimensions(centerPos - expandedSize * 0.5f, expandedSize), _mainColor); | ||
} | ||
} |
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,51 @@ | ||
using Content.Shared.CCVar; | ||
using Content.Shared.OfferItem; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Input; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Configuration; | ||
|
||
namespace Content.Client.OfferItem; | ||
|
||
public sealed class OfferItemSystem : SharedOfferItemSystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly IInputManager _inputManager = default!; | ||
[Dependency] private readonly IEyeManager _eye = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
Subs.CVar(_cfg, CCVars.OfferModeIndicatorsPointShow, OnShowOfferIndicatorsChanged, true); | ||
} | ||
public override void Shutdown() | ||
{ | ||
_overlayManager.RemoveOverlay<OfferItemIndicatorsOverlay>(); | ||
|
||
base.Shutdown(); | ||
} | ||
|
||
public bool IsInOfferMode() | ||
{ | ||
var entity = _playerManager.LocalEntity; | ||
|
||
if (entity == null) | ||
return false; | ||
|
||
return IsInOfferMode(entity.Value); | ||
} | ||
private void OnShowOfferIndicatorsChanged(bool isShow) | ||
{ | ||
if (isShow) | ||
{ | ||
_overlayManager.AddOverlay(new OfferItemIndicatorsOverlay( | ||
_inputManager, | ||
EntityManager, | ||
_eye, | ||
this)); | ||
} | ||
else | ||
_overlayManager.RemoveOverlay<OfferItemIndicatorsOverlay>(); | ||
} | ||
} |
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
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,24 @@ | ||
using Content.Shared.OfferItem; | ||
using Content.Server.OfferItem; | ||
using Content.Shared.Alert; | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Server.Alert.Click; | ||
|
||
/// <summary> | ||
/// Accepting the offer and receive item | ||
/// </summary> | ||
[UsedImplicitly] | ||
[DataDefinition] | ||
public sealed partial class AcceptOffer : IAlertClick | ||
{ | ||
public void AlertClicked(EntityUid player) | ||
{ | ||
var entManager = IoCManager.Resolve<IEntityManager>(); | ||
|
||
if (entManager.TryGetComponent(player, out OfferItemComponent? offerItem)) | ||
{ | ||
entManager.System<OfferItemSystem>().Receive(player, offerItem); | ||
} | ||
} | ||
} |
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,8 @@ | ||
namespace Content.Server.DeltaV.Paper; | ||
|
||
/// <summary> | ||
/// Raised on the pen when trying to sign a paper. | ||
/// If it's cancelled the signature wasn't made. | ||
/// </summary> | ||
[ByRefEvent] | ||
public record struct SignAttemptEvent(EntityUid Paper, EntityUid User, bool Cancelled = false); |
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,104 @@ | ||
using Content.Server.Access.Systems; | ||
using Content.Server.Paper; | ||
using Content.Server.Popups; | ||
using Content.Shared.Paper; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Tag; | ||
using Content.Shared.Verbs; | ||
using Robust.Server.Audio; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server.DeltaV.Paper; | ||
|
||
public sealed class SignatureSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly AudioSystem _audio = default!; | ||
[Dependency] private readonly IdCardSystem _idCard = default!; | ||
[Dependency] private readonly PaperSystem _paper = default!; | ||
[Dependency] private readonly PopupSystem _popup = default!; | ||
[Dependency] private readonly TagSystem _tags = default!; | ||
|
||
// The sprite used to visualize "signatures" on paper entities. | ||
private const string SignatureStampState = "paper_stamp-signature"; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<PaperComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs); | ||
} | ||
|
||
private void OnGetAltVerbs(Entity<PaperComponent> ent, ref GetVerbsEvent<AlternativeVerb> args) | ||
{ | ||
if (!args.CanAccess || !args.CanInteract) | ||
return; | ||
|
||
if (args.Using is not {} pen || !_tags.HasTag(pen, "Write")) | ||
return; | ||
|
||
var user = args.User; | ||
AlternativeVerb verb = new() | ||
{ | ||
Act = () => | ||
{ | ||
TrySignPaper(ent, user, pen); | ||
}, | ||
Text = Loc.GetString("paper-sign-verb"), | ||
DoContactInteraction = true, | ||
Priority = 10 | ||
}; | ||
args.Verbs.Add(verb); | ||
} | ||
|
||
/// <summary> | ||
/// Tries add add a signature to the paper with signer's name. | ||
/// </summary> | ||
public bool TrySignPaper(Entity<PaperComponent> paper, EntityUid signer, EntityUid pen) | ||
{ | ||
var comp = paper.Comp; | ||
|
||
var ev = new SignAttemptEvent(paper, signer); | ||
RaiseLocalEvent(pen, ref ev); | ||
if (ev.Cancelled) | ||
return false; | ||
|
||
var signatureName = DetermineEntitySignature(signer); | ||
|
||
var stampInfo = new StampDisplayInfo() | ||
{ | ||
StampedName = signatureName, | ||
StampedColor = Color.DarkSlateGray, //TODO Make this configurable depending on the pen. | ||
}; | ||
|
||
if (!comp.StampedBy.Contains(stampInfo) && _paper.TryStamp(paper, stampInfo, SignatureStampState, comp)) | ||
{ | ||
// 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.PlayPvs(comp.Sound, signer); | ||
|
||
_paper.UpdateUserInterface(paper, comp); | ||
|
||
return true; | ||
} | ||
else | ||
{ | ||
// Show an error popup | ||
_popup.PopupEntity(Loc.GetString("paper-signed-failure", ("target", paper.Owner)), signer, signer, PopupType.SmallCaution); | ||
|
||
return false; | ||
} | ||
} | ||
|
||
private string DetermineEntitySignature(EntityUid uid) | ||
{ | ||
// If the entity has an ID, use the name on it. | ||
if (_idCard.TryFindIdCard(uid, out var id) && !string.IsNullOrWhiteSpace(id.Comp.FullName)) | ||
return id.Comp.FullName; | ||
|
||
// Alternatively, return the entity name | ||
return Name(uid); | ||
} | ||
} |
Oops, something went wrong.