Skip to content

Commit

Permalink
TargetDoll
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Nov 10, 2024
1 parent 7c4566f commit 4492af4
Show file tree
Hide file tree
Showing 49 changed files with 531 additions and 3 deletions.
55 changes: 55 additions & 0 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,61 @@ public StyleNano(IResourceCache resCache) : base(resCache)
.Prop(Label.StylePropertyFont, notoSans10)
.Prop(Label.StylePropertyFontColor, Color.FromHex("#333d3b")),

// WD EDIT START
// TargetDoll
Element<TextureButton>().Class("TargetDollButtonHead")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/head_hover.png")),

Element<TextureButton>().Class("TargetDollButtonChest")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/chest_hover.png")),

Element<TextureButton>().Class("TargetDollButtonGroin")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/groin_hover.png")),

Element<TextureButton>().Class("TargetDollButtonLeftArm")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/l_arm_hover.png")),

Element<TextureButton>().Class("TargetDollButtonLeftHand")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/l_hand_hover.png")),

Element<TextureButton>().Class("TargetDollButtonRightArm")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/r_arm_hover.png")),

Element<TextureButton>().Class("TargetDollButtonRightHand")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/r_hand_hover.png")),

Element<TextureButton>().Class("TargetDollButtonLeftLeg")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/l_leg_hover.png")),

Element<TextureButton>().Class("TargetDollButtonLeftFoot")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/l_foot_hover.png")),

Element<TextureButton>().Class("TargetDollButtonRightLeg")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/r_leg_hover.png")),

Element<TextureButton>().Class("TargetDollButtonRightFoot")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/r_foot_hover.png")),

Element<TextureButton>().Class("TargetDollButtonEyes")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/eyes_hover.png")),

Element<TextureButton>().Class("TargetDollButtonMouth")
.Pseudo(TextureButton.StylePseudoClassHover)
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/_White/Interface/TargetDoll/mouth_hover.png")),
// WD EDIT END

// Fancy Tree
Element<ContainerButton>().Identifier(TreeItem.StyleIdentifierTreeButton)
.Class(TreeItem.StyleClassEvenRow)
Expand Down
6 changes: 3 additions & 3 deletions Content.Client/UserInterface/Controls/RadialMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class RadialMenu : BaseWindow

/// <summary>
/// Set a style class to be applied to the contextual button when it is set to move the user back through previous layers of the radial menu
/// </summary>
/// </summary>
public string? BackButtonStyleClass
{
get
Expand Down Expand Up @@ -60,8 +60,8 @@ public string? CloseButtonStyleClass
/// A free floating menu which enables the quick display of one or more radial containers
/// </summary>
/// <remarks>
/// Only one radial container is visible at a time (each container forming a separate 'layer' within
/// the menu), along with a contextual button at the menu center, which will either return the user
/// Only one radial container is visible at a time (each container forming a separate 'layer' within
/// the menu), along with a contextual button at the menu center, which will either return the user
/// to the previous layer or close the menu if there are no previous layers left to traverse.
/// To create a functional radial menu, simply parent one or more named radial containers to it,
/// and populate the radial containers with RadialMenuButtons. Setting the TargetLayer field of these
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:hotbar="clr-namespace:Content.Client.UserInterface.Systems.Hotbar.Widgets"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:inventory="clr-namespace:Content.Client.UserInterface.Systems.Inventory.Widgets"
xmlns:targetDoll="clr-namespace:Content.Client._White.UI.Systems.TargetDoll.Widgets"
Name="DefaultHud"
VerticalExpand="False"
VerticalAlignment="Bottom"
Expand All @@ -30,4 +31,5 @@
<hotbar:HotbarGui Name="Hotbar" Access="Protected" />
<chat:ResizableChatBox Name="Chat" Access="Protected" />
<alerts:AlertsUI Name="Alerts" Access="Protected" />
<targetDoll:TargetDollGui Name="TargetDoll" Access="Protected" /> <!--WD EDIT-->
</screens:OverlayChatGameScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public OverlayChatGameScreen()
SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5);
SetAnchorAndMarginPreset(Chat, LayoutPreset.TopRight, margin: 10);
SetAnchorAndMarginPreset(Alerts, LayoutPreset.TopRight, margin: 10);
SetAnchorAndMarginPreset(TargetDoll, LayoutPreset.BottomRight, margin: 5); // WD EDIT

Chat.OnResized += ChatOnResized;
Chat.OnChatResizeFinish += ChatOnResizeFinish;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:inventory="clr-namespace:Content.Client.UserInterface.Systems.Inventory.Widgets"
xmlns:targetDoll="clr-namespace:Content.Client._White.UI.Systems.TargetDoll.Widgets"
Name="SeparatedChatHud"
VerticalExpand="False"
VerticalAlignment="Bottom"
Expand All @@ -20,6 +21,7 @@
<widgets:GhostGui Name="Ghost" Access="Protected" />
<inventory:InventoryGui Name="Inventory" Access="Protected"/>
<hotbar:HotbarGui Name="Hotbar" Access="Protected"/>
<targetDoll:TargetDollGui Name="TargetDoll" Access="Protected" /> <!--WD EDIT-->
<BoxContainer Name="TopLeftContainer" Orientation="Vertical">
<actions:ActionsBar Name="Actions" Access="Protected" />
<BoxContainer Name="VoteMenu" Access="Public" Orientation="Vertical"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public SeparatedChatGameScreen()
SetAnchorAndMarginPreset(Ghost, LayoutPreset.BottomWide, margin: 80);
SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5);
SetAnchorAndMarginPreset(Alerts, LayoutPreset.CenterRight, margin: 10);
SetAnchorAndMarginPreset(TargetDoll, LayoutPreset.BottomRight, margin: 5); // WD EDIT

ScreenContainer.OnSplitResizeFinished += () =>
OnChatResized?.Invoke(new Vector2(ScreenContainer.SplitFraction, 0));
Expand Down
43 changes: 43 additions & 0 deletions Content.Client/_White/TargetDoll/TargetDollSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Shared._White.TargetDoll;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client._White.TargetDoll;

public sealed class TargetDollSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _playerManager = default!;

public event Action<TargetDollComponent>? TargetDollStartup;
public event Action? TargetDollShutdown;

public override void Initialize()
{
SubscribeLocalEvent<TargetDollComponent, LocalPlayerAttachedEvent>(HandlePlayerAttached);
SubscribeLocalEvent<TargetDollComponent, LocalPlayerDetachedEvent>(HandlePlayerDetached);
SubscribeLocalEvent<TargetDollComponent, ComponentStartup>(OnTargetingStartup);
SubscribeLocalEvent<TargetDollComponent, ComponentShutdown>(OnTargetingShutdown);
}

private void HandlePlayerAttached(EntityUid uid, TargetDollComponent component, LocalPlayerAttachedEvent args)
{
TargetDollStartup?.Invoke(component);
}

private void HandlePlayerDetached(EntityUid uid, TargetDollComponent component, LocalPlayerDetachedEvent args)
{
TargetDollShutdown?.Invoke();
}

private void OnTargetingStartup(EntityUid uid, TargetDollComponent component, ComponentStartup args)
{
if (_playerManager.LocalEntity == uid)
TargetDollStartup?.Invoke(component);
}

private void OnTargetingShutdown(EntityUid uid, TargetDollComponent component, ComponentShutdown args)
{
if (_playerManager.LocalEntity == uid)
TargetDollShutdown?.Invoke();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Content.Client.Gameplay;
using Content.Client._White.TargetDoll;
using Content.Client._White.UI.Systems.TargetDoll.Widgets;
using Content.Shared._White.TargetDoll;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.Player;

namespace Content.Client._White.UI.Systems.TargetDoll;

public sealed class TargetDollUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<TargetDollSystem>
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IEntityNetworkManager _net = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

private TargetDollComponent? _targetingComponent;
private TargetDollGui? TargetDollGui => UIManager.GetActiveUIWidgetOrNull<TargetDollGui>();

public void OnSystemLoaded(TargetDollSystem system)
{
system.TargetDollStartup += AddTargetingControl;
system.TargetDollShutdown += RemoveTargetingControl;
}

public void OnSystemUnloaded(TargetDollSystem system)
{
system.TargetDollStartup -= AddTargetingControl;
system.TargetDollShutdown -= RemoveTargetingControl;
}

public void OnStateEntered(GameplayState state)
{
if (TargetDollGui == null)
return;

TargetDollGui.SetTargetDollVisible(_targetingComponent != null);

if (_targetingComponent != null)
TargetDollGui.SetBodyPartsVisible(_targetingComponent.Target);
}

public void AddTargetingControl(TargetDollComponent component)
{
_targetingComponent = component;

if (TargetDollGui == null)
return;

TargetDollGui.SetTargetDollVisible(_targetingComponent != null);

if (_targetingComponent != null)
TargetDollGui.SetBodyPartsVisible(_targetingComponent.Target);

}

public void RemoveTargetingControl()
{
if (TargetDollGui != null)
TargetDollGui.SetTargetDollVisible(false);

_targetingComponent = null;
}

public void CycleTarget(BodyPart bodyPart)
{
if (_playerManager.LocalEntity is not { } user
|| _entManager.GetComponent<TargetDollComponent>(user) is not { } targetingComponent
|| TargetDollGui == null)
return;

var player = _entManager.GetNetEntity(user);

if (bodyPart == targetingComponent.Target)
return;

var msg = new TargetDollChangeEvent(player, bodyPart);
_net.SendSystemNetworkMessage(msg);
TargetDollGui?.SetBodyPartsVisible(bodyPart);
}
}
Loading

0 comments on commit 4492af4

Please sign in to comment.