From b8a2c211aa1c379cb6bbe96f71652ac43ac0ccf0 Mon Sep 17 00:00:00 2001 From: AwareFoxy Date: Sat, 9 Nov 2024 00:55:39 +0100 Subject: [PATCH 01/17] =?UTF-8?q?[Feature]=20=D0=A1=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B5=D0=BC=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=20=D0=B8=D0=B7=20=D1=80=D1=83=D0=BA=20=D0=B2=20=D1=80?= =?UTF-8?q?=D1=83=D0=BA=D0=B8=20(#780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * up 1 * refactor * Update alerts.yml * fix popups * Update SharedOfferItemSystem.cs --------- Co-authored-by: Zack Backmen --- .../OfferItem/OfferItemIndicatorsOverlay.cs | 72 ++++++ .../Backmen/OfferItem/OfferItemSystem.cs | 54 +++++ Content.Client/Input/ContentContexts.cs | 1 + .../Options/UI/Tabs/KeyRebindTab.xaml.cs | 2 +- Content.Client/Options/UI/Tabs/MiscTab.xaml | 1 + .../Options/UI/Tabs/MiscTab.xaml.cs | 3 +- .../Backmen/OfferItem/OfferItemSystem.cs | 58 +++++ .../Backmen/Alert/Click/AcceptingOffer.cs | 8 + .../Backmen/OfferItem/OfferItemComponent.cs | 26 ++ .../SharedOfferItemSystem.Interactions.cs | 76 ++++++ .../OfferItem/SharedOfferItemSystem.cs | 229 ++++++++++++++++++ Content.Shared/Input/ContentKeyFunctions.cs | 1 + Content.Shared/_CorvaxNext/NextVars.cs | 17 ++ Resources/Locale/ru-RU/alerts/alerts.ftl | 2 + .../ru-RU/escape-menu/ui/options-menu.ftl | 2 + .../ru-RU/interaction/offer-item-system.ftl | 13 + Resources/Prototypes/Alerts/alerts.yml | 10 + .../Prototypes/Entities/Mobs/Species/base.yml | 1 + .../Interface/Alerts/offer_item.rsi/meta.json | 14 ++ .../Alerts/offer_item.rsi/offer_item.png | Bin 0 -> 782 bytes .../Misc/give_item.rsi/give_item.png | Bin 0 -> 7276 bytes .../Interface/Misc/give_item.rsi/meta.json | 14 ++ Resources/keybinds.yml | 3 + 23 files changed, 605 insertions(+), 2 deletions(-) create mode 100644 Content.Client/Backmen/OfferItem/OfferItemIndicatorsOverlay.cs create mode 100644 Content.Client/Backmen/OfferItem/OfferItemSystem.cs create mode 100644 Content.Server/Backmen/OfferItem/OfferItemSystem.cs create mode 100644 Content.Shared/Backmen/Alert/Click/AcceptingOffer.cs create mode 100644 Content.Shared/Backmen/OfferItem/OfferItemComponent.cs create mode 100644 Content.Shared/Backmen/OfferItem/SharedOfferItemSystem.Interactions.cs create mode 100644 Content.Shared/Backmen/OfferItem/SharedOfferItemSystem.cs create mode 100644 Content.Shared/_CorvaxNext/NextVars.cs create mode 100644 Resources/Locale/ru-RU/interaction/offer-item-system.ftl create mode 100644 Resources/Textures/Interface/Alerts/offer_item.rsi/meta.json create mode 100644 Resources/Textures/Interface/Alerts/offer_item.rsi/offer_item.png create mode 100644 Resources/Textures/Interface/Misc/give_item.rsi/give_item.png create mode 100644 Resources/Textures/Interface/Misc/give_item.rsi/meta.json diff --git a/Content.Client/Backmen/OfferItem/OfferItemIndicatorsOverlay.cs b/Content.Client/Backmen/OfferItem/OfferItemIndicatorsOverlay.cs new file mode 100644 index 00000000000..1f09cfa41d7 --- /dev/null +++ b/Content.Client/Backmen/OfferItem/OfferItemIndicatorsOverlay.cs @@ -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.Backmen.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(); + _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); + } +} diff --git a/Content.Client/Backmen/OfferItem/OfferItemSystem.cs b/Content.Client/Backmen/OfferItem/OfferItemSystem.cs new file mode 100644 index 00000000000..92b489afaa0 --- /dev/null +++ b/Content.Client/Backmen/OfferItem/OfferItemSystem.cs @@ -0,0 +1,54 @@ +using Content.Shared.Backmen.OfferItem; +using Content.Shared._CorvaxNext.NextVars; +using Robust.Client.Graphics; +using Robust.Client.Input; +using Robust.Client.Player; +using Robust.Shared.Configuration; + +namespace Content.Client.Backmen.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() + { + base.Initialize(); + Subs.CVar(_cfg, NextVars.OfferModeIndicatorsPointShow, OnShowOfferIndicatorsChanged, true); + } + + + + public override void Shutdown() + { + _overlayManager.RemoveOverlay(); + 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(); + } +} diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 639f326f7f4..d90b0b5bda3 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -84,6 +84,7 @@ public static void SetupContexts(IInputContextContainer contexts) human.AddFunction(ContentKeyFunctions.Arcade1); human.AddFunction(ContentKeyFunctions.Arcade2); human.AddFunction(ContentKeyFunctions.Arcade3); + human.AddFunction(ContentKeyFunctions.OfferItem); // Corvax-Next-Offer // actions should be common (for ghosts, mobs, etc) common.AddFunction(ContentKeyFunctions.OpenActionsMenu); diff --git a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs index 24be904e061..fe5a7adafbb 100644 --- a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs @@ -184,7 +184,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action +