From eedbaa20c16895203f218e497335dd19dd2d3c85 Mon Sep 17 00:00:00 2001 From: FaDeOkno Date: Sat, 14 Dec 2024 22:30:42 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D1=85.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/Research/UI/DraggableResearchPanel.cs | 70 +++++------ .../ADT/Research/UI/ResearchConsoleItem.xaml | 40 +++--- .../Research/UI/ResearchConsoleItem.xaml.cs | 9 +- .../ADT/Research/UI/ResearchConsoleMenu.xaml | 69 +++------- .../Research/UI/ResearchConsoleMenu.xaml.cs | 119 ++++++++++++------ .../ADT/Research/UI/TechnologyInfoPanel.xaml | 44 +++++++ .../Research/UI/TechnologyInfoPanel.xaml.cs | 41 ++++++ .../UI/ResearchConsoleBoundUserInterface.cs | 4 +- .../Systems/ResearchSystem.Console.cs | 30 ++++- .../Interaction/SharedInteractionSystem.cs | 20 +-- .../SharedResearchConsoleComponent.cs | 6 +- .../Prototypes/TechDisciplinePrototype.cs | 3 + .../Prototypes/TechnologyPrototype.cs | 3 + Resources/Prototypes/ADT/Research/arsenal.yml | 13 -- .../ADT/Research/civilianservices.yml | 3 + .../Prototypes/ADT/Research/industrial.yml | 39 ++++++ .../Prototypes/ADT/Research/translators.yml | 6 + Resources/Prototypes/Research/arsenal.yml | 42 ++++++- .../Prototypes/Research/civilianservices.yml | 32 +++++ Resources/Prototypes/Research/disciplines.yml | 4 + .../Prototypes/Research/experimental.yml | 30 +++++ Resources/Prototypes/Research/industrial.yml | 65 +++++++--- 22 files changed, 498 insertions(+), 194 deletions(-) create mode 100644 Content.Client/ADT/Research/UI/TechnologyInfoPanel.xaml create mode 100644 Content.Client/ADT/Research/UI/TechnologyInfoPanel.xaml.cs diff --git a/Content.Client/ADT/Research/UI/DraggableResearchPanel.cs b/Content.Client/ADT/Research/UI/DraggableResearchPanel.cs index d45b675e691..f90958cd8d1 100644 --- a/Content.Client/ADT/Research/UI/DraggableResearchPanel.cs +++ b/Content.Client/ADT/Research/UI/DraggableResearchPanel.cs @@ -1,5 +1,6 @@ using Content.Client.UserInterface.Fragments; using Robust.Client.AutoGenerated; +using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -10,6 +11,7 @@ using Robust.Shared.Utility; using System; using System.Collections.Generic; +using System.Linq; using System.Numerics; namespace Content.Client.ADT.Research.UI; @@ -27,51 +29,47 @@ public DraggablePanel() { _isDragging = false; _children = new List(); - - this.OnKeyBindDown += args => OnKeybindDown(args); - this.OnKeyBindUp += args => OnKeybindUp(args); } - public void AddChildElement(Control child) + protected override void Draw(DrawingHandleScreen handle) { - // Добавляем дочерний элемент в панель - _children.Add(child); - this.AddChild(child); // Также добавляем его в UI панель - } - - private void OnKeybindDown(GUIBoundKeyEventArgs args) - { - if (args.Function == EngineKeyFunctions.Use) + foreach (var child in Children) { - // Начинаем перетаскивание - _isDragging = true; - _dragStartPosition = args.PointerLocation.Position; - _originalPosition = this.Position; // Сохраняем исходную позицию панели - } - } + if (child is not ResearchConsoleItem item) + continue; - protected override void MouseMove(GUIMouseMoveEventArgs args) - { - base.MouseMove(args); + if (item.Prototype.RequiredTech.Count <= 0) + continue; - if (_isDragging) - { - // Перемещаем все дочерние элементы, вычисляя разницу между начальной и текущей позицией мыши - var delta = args.RelativePosition - _dragStartPosition; + var list = Children.Where(x => x is ResearchConsoleItem second && item.Prototype.RequiredTech.Contains(second.Prototype.ID)); - foreach (var child in _children) + foreach (var second in list) { - SetPosition(child, child.Position + delta); // Перемещаем каждого дочернего элемента - } - } - } + var leftOffset = second.PixelPosition.Y; + var rightOffset = item.PixelPosition.Y; - private void OnKeybindUp(GUIBoundKeyEventArgs args) - { - if (args.Function == EngineKeyFunctions.Use) - { - // Завершаем перетаскивание - _isDragging = false; + var y1 = second.PixelPosition.Y + second.PixelHeight / 2 + leftOffset; + var y2 = item.PixelPosition.Y + item.PixelHeight / 2 + rightOffset; + + if (second == item) + { + handle.DrawLine(new Vector2(0, y1), new Vector2(PixelWidth, y2), Color.Cyan); + continue; + } + var startCoords = new Vector2(item.PixelPosition.X + 40, item.PixelPosition.Y + 40); + var endCoords = new Vector2(second.PixelPosition.X + 40, second.PixelPosition.Y + 40); + + if (second.PixelPosition.Y != item.PixelPosition.Y) + { + + handle.DrawLine(startCoords, new(endCoords.X, startCoords.Y), Color.White); + handle.DrawLine(new(endCoords.X, startCoords.Y), endCoords, Color.White); + } + else + { + handle.DrawLine(startCoords, endCoords, Color.White); + } + } } } } diff --git a/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml b/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml index 776c8fbb63d..ce07c573e10 100644 --- a/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml +++ b/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml @@ -3,24 +3,26 @@ Margin="5" HorizontalExpand="False"> - - - - - - - - - - + diff --git a/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml.cs b/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml.cs index f88a4b04942..8de000d2686 100644 --- a/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml.cs +++ b/Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml.cs @@ -20,16 +20,15 @@ public sealed partial class ResearchConsoleItem : Control [Dependency] private readonly IEntityManager _ent = default!; [Dependency] private readonly IPrototypeManager _proto = default!; - public ProtoId Prototype; - public Action>? BuyAction; - public ResearchConsoleItem(ProtoId proto, SpriteSystem sprite) + public TechnologyPrototype Prototype; + public Action? BuyAction; + public ResearchConsoleItem(TechnologyPrototype proto, SpriteSystem sprite) { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); Prototype = proto; Buy.OnPressed += _ => BuyAction?.Invoke(Prototype); - var tech = _proto.Index(proto); - ResearchDisplay.Texture = sprite.Frame0(tech.Icon); + ResearchDisplay.Texture = sprite.Frame0(proto.Icon); } } diff --git a/Content.Client/ADT/Research/UI/ResearchConsoleMenu.xaml b/Content.Client/ADT/Research/UI/ResearchConsoleMenu.xaml index 73a9a23ca1e..23ce171b157 100644 --- a/Content.Client/ADT/Research/UI/ResearchConsoleMenu.xaml +++ b/Content.Client/ADT/Research/UI/ResearchConsoleMenu.xaml @@ -2,12 +2,21 @@ xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" + xmlns:adt="clr-namespace:Content.Client.ADT.Research.UI" Title="{Loc 'research-console-menu-title'}" - MinSize="625 400" - SetSize="760 550"> + MinSize="1260 850" + SetSize="1260 850"> + + + + - - - + - - + Name="DragContainer" + MouseFilter="Pass" + RectClipContent="True"> + +