Files
tbd-station-14/Content.Client/UserInterface/TargetingDoll.cs
AJCM-git ae41d03ec6 Re-organizing the Resources folder. Part 1. (#1234)
* First commit

* Lockers

* Lockers electric boogaloo

* Crates and Lockers

* Almost finishing the Textures folder

* Updating texture paths. Reminder to fix:
* Lockers
* Windows
* Vending Machines
* APC
* Catwalks
* Bedsheets and Cloaks
* Status effects

* dont know what happened here

* Commit before merge

* re-organizing

* Lockers broken

* Commit before merge

* Submodule

* renaming

* Fixing most issues

* forgot these ones

* Updating submodule

* typo

* Fixing some paths

* fixing some paths

* updating submodule

* (hopefully) fixing the submodule
2020-07-07 19:19:00 +02:00

83 lines
2.8 KiB
C#

using System;
using Content.Client.Utility;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface
{
public sealed class TargetingDoll : VBoxContainer
{
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)
{
_buttonHigh = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureHigh),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_buttonMiddle = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureMiddle),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_buttonLow = new TextureButton
{
TextureNormal = resourceCache.GetTexture(TextureLow),
StyleClasses = {StyleClassTargetDollZone},
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
};
_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;
}
}
}