Hud refactor (#7202)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
Co-authored-by: Jezithyr <jmaster9999@gmail.com>
Co-authored-by: Jezithyr <Jezithyr@gmail.com>
Co-authored-by: Visne <39844191+Visne@users.noreply.github.com>
Co-authored-by: wrexbe <wrexbe@protonmail.com>
Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
This commit is contained in:
Jezithyr
2022-10-12 01:16:23 -07:00
committed by GitHub
parent d09fbc1849
commit 571dd4e6d5
168 changed files with 6940 additions and 7817 deletions

View File

@@ -1,84 +0,0 @@
using System;
using Content.Client.Resources;
using Content.Shared.Targeting;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Targeting
{
public sealed class TargetingDoll : BoxContainer
{
private TargetingZone _activeZone = TargetingZone.Middle;
public const string StyleClassTargetDollZone = "target-doll-zone";
private const string TextureHigh = "/Textures/Interface/target-doll-high.svg.96dpi.png";
private const string TextureMiddle = "/Textures/Interface/target-doll-middle.svg.96dpi.png";
private const string TextureLow = "/Textures/Interface/target-doll-low.svg.96dpi.png";
private readonly TextureButton _buttonHigh;
private readonly TextureButton _buttonMiddle;
private readonly TextureButton _buttonLow;
public TargetingZone ActiveZone
{
get => _activeZone;
set
{
if (_activeZone == value)
{
return;
}
_activeZone = value;
OnZoneChanged?.Invoke(value);
UpdateButtons();
}
}
public event Action<TargetingZone>? OnZoneChanged;
public TargetingDoll(IResourceCache resourceCache)
{
Orientation = LayoutOrientation.Vertical;
_buttonHigh = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureHigh),
StyleClasses = {StyleClassTargetDollZone},
HorizontalAlignment = HAlignment.Center
};
_buttonMiddle = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureMiddle),
StyleClasses = {StyleClassTargetDollZone},
HorizontalAlignment = HAlignment.Center
};
_buttonLow = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureLow),
StyleClasses = {StyleClassTargetDollZone},
HorizontalAlignment = HAlignment.Center
};
_buttonHigh.OnPressed += _ => ActiveZone = TargetingZone.High;
_buttonMiddle.OnPressed += _ => ActiveZone = TargetingZone.Middle;
_buttonLow.OnPressed += _ => ActiveZone = TargetingZone.Low;
AddChild(_buttonHigh);
AddChild(_buttonMiddle);
AddChild(_buttonLow);
UpdateButtons();
}
private void UpdateButtons()
{
_buttonHigh.Pressed = _activeZone == TargetingZone.High;
_buttonMiddle.Pressed = _activeZone == TargetingZone.Middle;
_buttonLow.Pressed = _activeZone == TargetingZone.Low;
}
}
}

View File

@@ -0,0 +1,18 @@
<targeting:TargetingDoll xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:vote="clr-namespace:Content.Client.Voting.UI"
xmlns:style="clr-namespace:Content.Client.Stylesheets"
xmlns:chatUi="clr-namespace:Content.Client.Chat.UI"
xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI"
xmlns:info="clr-namespace:Content.Client.Info"
xmlns:targeting="clr-namespace:Content.Client.Targeting.UI"
Orientation="Vertical"
>
<TextureButton Name = "ButtonHigh" TexturePath="/Textures/Interface/target-doll-high.svg.96dpi.png" HorizontalAlignment="Center" StyleIdentifier="target-doll-zone"/>
<TextureButton Name = "ButtonMedium" TexturePath="/Textures/Interface/target-doll-middle.svg.96dpi.png" HorizontalAlignment="Center" StyleIdentifier="target-doll-zone"/>
<TextureButton Name = "ButtonLow" TexturePath="/Textures/Interface/target-doll-low.svg.96dpi.png" HorizontalAlignment="Center" StyleIdentifier="target-doll-zone"/>
</targeting:TargetingDoll>

View File

@@ -0,0 +1,44 @@
using Content.Shared.Targeting;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Targeting.UI;
[GenerateTypedNameReferences]
public sealed partial class TargetingDoll : BoxContainer
{
public static readonly string StyleClassTargetDollZone = "target-doll-zone";
private TargetingZone _activeZone = TargetingZone.Middle;
public event Action<TargetingZone>? OnZoneChanged;
public TargetingDoll()
{
RobustXamlLoader.Load(this);
}
public TargetingZone ActiveZone
{
get => _activeZone;
set
{
if (_activeZone == value)
{
return;
}
_activeZone = value;
OnZoneChanged?.Invoke(value);
UpdateButtons();
}
}
private void UpdateButtons()
{
ButtonHigh.Pressed = _activeZone == TargetingZone.High;
ButtonMedium.Pressed = _activeZone == TargetingZone.Middle;
ButtonLow.Pressed = _activeZone == TargetingZone.Low;
}
}