Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

дэржи жъжьжь #905

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Content.Client/ADT/Research/UI/DraggableResearchPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace Content.Client.ADT.Research.UI;

public sealed partial class DraggablePanel : LayoutContainer
{
private bool _isDragging;
private Vector2 _dragStartPosition;
private Vector2 _originalPosition;

// Список дочерних элементов панели
private List<Control> _children;

public DraggablePanel()
{
_isDragging = false;
_children = new List<Control>();
}

protected override void Draw(DrawingHandleScreen handle)
{
foreach (var child in Children)
{
if (child is not ResearchConsoleItem item)
continue;

if (item.Prototype.RequiredTech.Count <= 0)
continue;

var list = Children.Where(x => x is ResearchConsoleItem second && item.Prototype.RequiredTech.Contains(second.Prototype.ID));

foreach (var second in list)
{
var leftOffset = second.PixelPosition.Y;
var rightOffset = item.PixelPosition.Y;

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);
}
}
}
}
}
27 changes: 27 additions & 0 deletions Content.Client/ADT/Research/UI/MiniRecipeCardControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Control xmlns="https://spacestation14.io">
<BoxContainer Orientation="Horizontal">
<PanelContainer Name="Background"
Access="Public"
StyleClasses="PdaBackground"
VerticalExpand="False"
HorizontalExpand="False"
MaxWidth="10"
Margin="0 0 -5 0"/>
<Button Name="Main"
Disabled="True"
HorizontalExpand="True"
VerticalExpand="False"
StyleClasses="ButtonSquare"
Margin="0">
<BoxContainer Orientation="Horizontal" Margin="0">
<TextureRect Name="Showcase"
HorizontalExpand="False"
VerticalExpand="False"
Margin="1"
TextureScale="1 1"/>
<Control MinWidth="5"/>
<RichTextLabel Name="NameLabel" StyleClasses="LabelSubText" VerticalAlignment="Center"/>
</BoxContainer>
</Button>
</BoxContainer>
</Control>
36 changes: 36 additions & 0 deletions Content.Client/ADT/Research/UI/MiniRecipeCardControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Content.Client.Lathe;
using Content.Shared.Lathe;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Client.ADT.Research.UI;

[GenerateTypedNameReferences]
public sealed partial class MiniRecipeCardControl : Control
{
public MiniRecipeCardControl(TechnologyPrototype technology, LatheRecipePrototype proto, IPrototypeManager prototypeManager, SpriteSystem sprite, LatheSystem lathe)
{
RobustXamlLoader.Load(this);

var discipline = prototypeManager.Index(technology.Discipline);
Background.ModulateSelfOverride = discipline.Color;
NameLabel.SetMessage(lathe.GetRecipeName(proto));

if (proto.Result.HasValue)
Showcase.Texture = sprite.Frame0(prototypeManager.Index(proto.Result.Value));

if (proto.Description.HasValue)
{
var tooltip = new Tooltip();
tooltip.SetMessage(FormattedMessage.FromUnformatted(lathe.GetRecipeDescription(proto)));
Main.TooltipSupplier = _ => tooltip;
}
}
}
25 changes: 25 additions & 0 deletions Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Control xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Margin="5"
HorizontalExpand="False">
<BoxContainer Orientation="Vertical">
<Button Name="Buy"
Text="{Loc 'analysis-console-print-button'}"
ToolTip="{Loc 'analysis-console-print-tooltip-info'}"
VerticalExpand="False"
HorizontalExpand="False"
SetSize="80 80"
StyleClasses="ButtonSquare">
<PanelContainer Name="Main" Margin="5" SetSize="64 64" Access="Public">
<BoxContainer VerticalExpand="False" Orientation="Vertical" MaxSize="64 64">
<TextureRect
Name="ResearchDisplay"
TextureScale="2 2"
SetSize="64 64"
Stretch="KeepAspectCentered">
</TextureRect>
</BoxContainer>
</PanelContainer>
</Button>
</BoxContainer>
</Control>
49 changes: 49 additions & 0 deletions Content.Client/ADT/Research/UI/ResearchConsoleItem.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Research.Prototypes;
using Content.Shared.Xenoarchaeology.Equipment;
using Microsoft.VisualBasic;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.ADT.Research.UI;

[GenerateTypedNameReferences]
public sealed partial class ResearchConsoleItem : Control
{
[Dependency] private readonly IEntityManager _ent = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;

public TechnologyPrototype Prototype;
public Action<TechnologyPrototype>? BuyAction;
public bool Allowed;
public ResearchConsoleItem(TechnologyPrototype proto, SpriteSystem sprite, bool allowed)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
Allowed = allowed;
Prototype = proto;
Buy.OnPressed += Selected;
ResearchDisplay.Texture = sprite.Frame0(proto.Icon);

Main.PanelOverride = new StyleBoxFlat(Color.Black);
}

protected override void Dispose(bool disposing)
{
Buy.OnPressed -= Selected;
base.Dispose(disposing);
}

private void Selected(BaseButton.ButtonEventArgs args)
{
BuyAction?.Invoke(Prototype);
}
}
73 changes: 73 additions & 0 deletions Content.Client/ADT/Research/UI/ResearchConsoleMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
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="1260 850"
SetSize="1260 850"> <!-- Corvax-Localization -->
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<controls:StripeBack Name="StationNameContainer" MinSize="52 52">
<BoxContainer Name="DisciplinesContainer"
Orientation="Horizontal"
HorizontalAlignment="Stretch"
MinSize="52 52"
Margin="5"/>
<!--Disciplines populated in .cs-->
</controls:StripeBack>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="False"
MinHeight="85"
Margin="10">
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ResearchAmountLabel"/>
<RichTextLabel Name="MainDisciplineLabel"/>
<Control VerticalExpand="True"/>
<BoxContainer Name="TierDisplayContainer" Orientation="Horizontal" HorizontalExpand="True" VerticalAlignment="Bottom"/>
<!-- This is where we put all of the little graphics that display discipline tiers!-->
</BoxContainer>
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalAlignment="Right">
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" MinHeight="40"/>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
SizeFlagsStretchRatio="3"
Margin="0 0 10 10">
<PanelContainer Name="ResearchesContainer" VerticalExpand="True" MinSize="0 200">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />
</PanelContainer.PanelOverride>
<adt:DraggablePanel
HorizontalExpand="True"
SizeFlagsStretchRatio="1"
VerticalExpand="True"
Name="DragContainer"
MouseFilter="Pass"
RectClipContent="True">
</adt:DraggablePanel>
<Button Name="RecenterButton" Text="{Loc 'research-console-menu-recenter-button'}" MinHeight="40" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5 5"/>
</PanelContainer>
</BoxContainer>
<PanelContainer VerticalExpand="True" Margin="10">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<BoxContainer Name="InfoContainer"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
SizeFlagsStretchRatio="5"
Margin="0 0 10 10"/>
</PanelContainer>

</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Loading
Loading