diff --git a/Content.Client/Crayon/CrayonSystem.cs b/Content.Client/Crayon/CrayonSystem.cs index c0d127dd40..6291a898b1 100644 --- a/Content.Client/Crayon/CrayonSystem.cs +++ b/Content.Client/Crayon/CrayonSystem.cs @@ -4,6 +4,9 @@ using Content.Client.Stylesheets; using Content.Shared.Charges.Components; using Content.Shared.Charges.Systems; using Content.Shared.Crayon; +using Content.Shared.Hands; +using Robust.Client.GameObjects; // Corvax-Wega-Add +using Robust.Client.Graphics; // Corvax-Wega-Add using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Shared.Timing; @@ -14,12 +17,33 @@ public sealed class CrayonSystem : SharedCrayonSystem { [Dependency] private readonly SharedChargesSystem _charges = default!; [Dependency] private readonly EntityManager _entityManager = default!; + [Dependency] private readonly IOverlayManager _overlay = default!; // Corvax-Wega-Add + [Dependency] private readonly SpriteSystem _sprite = default!; // Corvax-Wega-Add + + private CrayonPreviewOverlay? _previewOverlay; // Corvax-Wega-Add public override void Initialize() { base.Initialize(); Subs.ItemStatus(ent => new StatusControl(ent, _charges, _entityManager)); + SubscribeLocalEvent(OnCrayonSelected); + SubscribeLocalEvent(OnCrayonDeselected); + } + + private void OnCrayonSelected(EntityUid uid, CrayonComponent component, HandSelectedEvent args) + { + _previewOverlay ??= new CrayonPreviewOverlay(_sprite); + _overlay.AddOverlay(_previewOverlay); + } + + private void OnCrayonDeselected(EntityUid uid, CrayonComponent component, HandDeselectedEvent args) + { + if (_previewOverlay != null) + { + _overlay.RemoveOverlay(_previewOverlay); + _previewOverlay = null; + } } private sealed class StatusControl : Control @@ -29,11 +53,11 @@ public sealed class CrayonSystem : SharedCrayonSystem private readonly RichTextLabel _label; private readonly int _capacity; - public StatusControl(Entity crayon, SharedChargesSystem charges, EntityManager entityManage) + public StatusControl(Entity crayon, SharedChargesSystem charges, EntityManager entityManager) { _crayon = crayon; _charges = charges; - _capacity = entityManage.GetComponent(_crayon.Owner).MaxCharges; + _capacity = entityManager.GetComponent(_crayon.Owner).MaxCharges; _label = new RichTextLabel { StyleClasses = { StyleClass.ItemStatus } }; AddChild(_label); } @@ -43,8 +67,8 @@ public sealed class CrayonSystem : SharedCrayonSystem base.FrameUpdate(args); _label.SetMarkup(Robust.Shared.Localization.Loc.GetString("crayon-drawing-label", - ("color",_crayon.Comp.Color), - ("state",_crayon.Comp.SelectedState), + ("color", _crayon.Comp.Color), + ("state", _crayon.Comp.SelectedState), ("charges", _charges.GetCurrentCharges(_crayon.Owner)), ("capacity", _capacity))); } diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 2f74d04ca5..23201fed42 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -81,6 +81,8 @@ namespace Content.Client.Input human.AddFunction(ContentKeyFunctions.OpenBackpack); human.AddFunction(ContentKeyFunctions.OpenBelt); human.AddFunction(ContentKeyFunctions.MouseMiddle); + human.AddFunction(ContentKeyFunctions.MouseWheelUp); // Corvax-Wega-Add + human.AddFunction(ContentKeyFunctions.MouseWheelDown); // Corvax-Wega-Add human.AddFunction(ContentKeyFunctions.RotateObjectClockwise); human.AddFunction(ContentKeyFunctions.RotateObjectCounterclockwise); human.AddFunction(ContentKeyFunctions.FlipObject); diff --git a/Content.Client/Viewport/ScalingViewport.cs b/Content.Client/Viewport/ScalingViewport.cs index d9548d0f02..90fc0261c7 100644 --- a/Content.Client/Viewport/ScalingViewport.cs +++ b/Content.Client/Viewport/ScalingViewport.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Numerics; +using Content.Shared.Input; // Corvax-Wega-Add using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.UserInterface; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Graphics; +using Robust.Shared.Input; // Corvax-Wega-Add using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -124,6 +126,33 @@ namespace Content.Client.Viewport RectClipContent = true; } + // Corvax-Wega-Add-start + protected override void MouseWheel(GUIMouseWheelEventArgs args) + { + base.MouseWheel(args); + + if (args.Handled) + return; + + var key = args.Delta.Y > 0 ? ContentKeyFunctions.MouseWheelUp : ContentKeyFunctions.MouseWheelDown; + + SendKeyEvent(key, BoundKeyState.Down, args); + SendKeyEvent(key, BoundKeyState.Up, args); + } + + private void SendKeyEvent(BoundKeyFunction key, BoundKeyState state, GUIMouseWheelEventArgs args) + { + var keyEvent = new BoundKeyEventArgs( + key, + state, + args.GlobalPixelPosition, + false + ); + + _inputManager.ViewportKeyEvent(this, keyEvent); + } + // Corvax-Wega-Add-end + protected override void KeyBindDown(GUIBoundKeyEventArgs args) { base.KeyBindDown(args); diff --git a/Content.Client/_Wega/Botany/PlantAnalyzerBoundUserInterface.cs b/Content.Client/_Wega/Botany/PlantAnalyzerBoundUserInterface.cs new file mode 100644 index 0000000000..225db86bc6 --- /dev/null +++ b/Content.Client/_Wega/Botany/PlantAnalyzerBoundUserInterface.cs @@ -0,0 +1,42 @@ +using Content.Shared.Botany.PlantAnalyzer; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client._Wega.Botany; + +[UsedImplicitly] +public sealed class PlantAnalyzerBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + private PlantAnalyzerWindow? _window; + + public PlantAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + _window = this.CreateWindow(); + _window.Title = EntMan.GetComponent(Owner).EntityName; + _window.Print.OnPressed += _ => Print(); + } + + protected override void ReceiveMessage(BoundUserInterfaceMessage message) + { + if (_window == null) + return; + + if (message is not PlantAnalyzerScannedUserMessage cast) + return; + + _window.Populate(cast); + } + + private void Print() + { + SendMessage(new PlantAnalyzerPrintMessage()); + if (_window != null) + _window.Print.Disabled = true; + } +} diff --git a/Content.Client/_Wega/Botany/PlantAnalyzerSystem.cs b/Content.Client/_Wega/Botany/PlantAnalyzerSystem.cs new file mode 100644 index 0000000000..4308445499 --- /dev/null +++ b/Content.Client/_Wega/Botany/PlantAnalyzerSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.Botany.Systems; + +namespace Content.Client.Botany.Systems; + +public sealed class PlantAnalyzerSystem : SharedPlantAnalyzerSystem +{ +} diff --git a/Content.Client/_Wega/Botany/PlantAnalyzerWindow.xaml b/Content.Client/_Wega/Botany/PlantAnalyzerWindow.xaml new file mode 100644 index 0000000000..734f51e8eb --- /dev/null +++ b/Content.Client/_Wega/Botany/PlantAnalyzerWindow.xaml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +