Skip to content

Commit

Permalink
radial container modified
Browse files Browse the repository at this point in the history
  • Loading branch information
modern-nm committed May 4, 2024
1 parent bec70b4 commit cf07e22
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 68 deletions.
70 changes: 13 additions & 57 deletions Content.Client/ADT/Changeling/ChangelingPanelSystem.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/// Made for Adventure Time Project by ModerN. https://github.com/modern-nm mailto:[email protected]
/// see also https://github.com/DocNITE/liebendorf-station/tree/feature/emote-radial-panel
using Content.Client.Language.Systems;
using Content.Client.Humanoid;
using Content.Client.UserInterface.Systems.Radial;
using Content.Client.UserInterface.Systems.Radial.Controls;
using Content.Shared.Changeling;
using Content.Shared.Changeling.Components;
using Content.Shared.Polymorph;
using Content.Shared.Humanoid.Prototypes;
using FastAccessors;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Numerics;

namespace Content.Client.ADT.Language;

Expand All @@ -24,6 +26,8 @@ public sealed class ChangelingPanelSystem : EntitySystem
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IPlayerManager _playerMan = default!;
[Dependency] private readonly SpriteSystem _spriteSystem = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly HumanoidAppearanceSystem _appearanceSystem = default!;

/// <summary>
/// We should enable radial for single target
Expand Down Expand Up @@ -59,17 +63,16 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args

foreach (var humanoid in args.HumanoidData)
{
var dummy = _entManager.SpawnEntity(_proto.Index<SpeciesPrototype>(humanoid.Species).DollPrototype, MapCoordinates.Nullspace);
//var humanoidEntityUid = GetEntity(humanoid); // Entities on the client outside of the FOV are nonexistant. You can see that if you zoom out. //So it'll give you UID 0 which is EntityUid.Invalid.
_appearanceSystem.LoadProfile(dummy, humanoid.Profile);
var face = new SpriteView();
face.SetEntity(dummy);

// foreach (var humanoidData in args.ChangelingComponent.StoredDNA)
// {
// if (humanoidData.EntityUid == humanoidEntityUid)
// {
//
var actionName = humanoid.Name;
var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon)));

var emoteButton = _openedMenu.AddButton(actionName, texturePath);
var emoteButton = _openedMenu.AddButton(actionName, texturePath, face);
emoteButton.Opacity = 210;
emoteButton.Tooltip = null;
emoteButton.Controller.OnPressed += (_) =>
Expand All @@ -78,8 +81,6 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args
RaiseNetworkEvent(ev);
_openedMenu.Dispose();
};
// }
// }
}
_openedMenu.OnClose += (_) =>
{
Expand All @@ -90,58 +91,13 @@ private void HandleChangelingFormsMenuEvent(RequestChangelingFormsMenuEvent args

}

// private void HandleLanguageMenuEvent(RequestLanguageMenuEvent args)
// {
// if (_openedMenu != null)
// return;
// if (_playerMan.LocalEntity == null)
// {
// return;
// }
// TryComp<LanguageSpeakerComponent>(_playerMan.LocalEntity.Value, out var languageSpeakerComponent);

// _openedMenu = _userInterfaceManager.GetUIController<RadialUiController>()
// .CreateRadialContainer();

// foreach (var protoId in args.Languages)
// {
// var prototype = _languageSystem.GetLanguage(protoId);
// if (prototype == null)
// {
// continue;
// }
// var actionName = prototype.LocalizedName;
// var texturePath = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath(DefaultIcon)));
// if (prototype.Icon != null)
// texturePath = _spriteSystem.Frame0(prototype.Icon);

// var languageButton = _openedMenu.AddButton(actionName, texturePath);
// languageButton.Opacity = 210;
// languageButton.Tooltip = null;
// languageButton.Controller.OnPressed += (_) =>
// {
// var ev = new SelectLanguageEvent(args.Target, protoId);
// RaiseNetworkEvent(ev);
// _openedMenu.Dispose();
// };
// }

// _openedMenu.OnClose += (_) =>
// {
// _openedMenu = null;
// };
// if (_playerMan.LocalEntity != null)
// _openedMenu.OpenAttached(_playerMan.LocalEntity.Value);

// }

private void OnPlayerAttached(PlayerAttachedEvent args)
{
_openedMenu?.Dispose();
}

private void OnPlayerDetached(PlayerDetachedEvent args)
{
_openedMenu?.Dispose();
_openedMenu?.Dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void OpenCentered()
if (Parent == null)
return;

LayoutContainer.SetPosition(this, (Parent.Size/2) - (Size/2));
LayoutContainer.SetPosition(this, (Parent.Size / 2) - (Size / 2));
UpdateButtons();
}

Expand All @@ -156,7 +156,7 @@ public void OpenCenteredAt(Vector2 position)
if (Parent == null)
return;

LayoutContainer.SetPosition(this, (Parent.Size * position) - (Size/2));
LayoutContainer.SetPosition(this, (Parent.Size * position) - (Size / 2));
UpdateButtons();
}

Expand Down Expand Up @@ -211,12 +211,13 @@ public RadialItem AddButton(string action, string? texturePath = null)
/// <param name="action">Item content text</param>
/// <param name="texture">Item's icon texture</param>
/// <returns></returns>
public RadialItem AddButton(string action, Texture? texture)
public RadialItem AddButton(string action, Texture? texture, SpriteView spriteView = default!)
{
var button = new RadialItem();
button.Content = action;
button.Controller.TexturePath = ItemBackgroundTexturePath;

if (spriteView != null)
button.EntityView.SetEntity(spriteView.NetEnt != null ? spriteView.NetEnt.Value : NetEntity.Invalid);
if (texture != null)
button.Icon.Texture = texture;

Expand All @@ -229,13 +230,13 @@ private void UpdateButtons()
{
Visible = true;

var angleDegrees = 360/Layout.ChildCount;
var angleDegrees = 360 / Layout.ChildCount;
var stepAngle = -angleDegrees + -90;
var distance = GetDistance();

foreach (var child in Layout.Children)
{
var button = (RadialItem)child;
var button = (RadialItem) child;
button.ButtonSize = new Vector2(NormalSize, NormalSize);
stepAngle += angleDegrees;
var pos = GetPointFromPolar(stepAngle, distance);
Expand Down Expand Up @@ -329,8 +330,8 @@ protected override void Draw(DrawingHandleScreen handle)

foreach (var child in Layout.Children)
{
var button = (RadialItem)child;
LayoutContainer.SetPosition(child, button.Offset - (button.Size/2));
var button = (RadialItem) child;
LayoutContainer.SetPosition(child, button.Offset - (button.Size / 2));
}

// FIXME: We use item's offset like "local item position" for animation. Need make some better way to do it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
Access="Public"
VerticalExpand="True"
HorizontalExpand="True">
<SpriteView Access="Public" Name="EntityView"
SetSize="64 64"
OverrideDirection="South">
</SpriteView>
<TextureRect Access="Public" Name="Icon"
VerticalExpand="True"
HorizontalExpand="True"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Numerics;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Animations;

Expand Down
22 changes: 20 additions & 2 deletions Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
using Content.Shared.Effects;
using System.Linq;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Preferences;
using Content.Server.Database;
using Content.Server.Humanoid;


namespace Content.Server.Changeling.EntitySystems;
Expand Down Expand Up @@ -66,6 +69,7 @@ public sealed partial class ChangelingSystem : EntitySystem
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly FlashSystem _flashSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -328,13 +332,27 @@ public void OnCycleDNA(EntityUid uid, ChangelingComponent component, ChangelingC
var netEntity = GetNetEntity(item.EntityUid);
if (netEntity == null)
continue;
if(item.EntityUid ==null)
if (item.EntityUid == null)
continue;
//ev.HumanoidData.Add(netEntity.Value);
HumanoidCharacterAppearance hca = new();
if (item.HumanoidAppearanceComponent == null)
continue;
hca.WithEyeColor(item.HumanoidAppearanceComponent.EyeColor)
.WithSkinColor(item.HumanoidAppearanceComponent.SkinColor)
.WithHairColor(item.HumanoidAppearanceComponent.CachedHairColor != null ? item.HumanoidAppearanceComponent.CachedHairColor.Value : Color.Black);
foreach (var layer in item.HumanoidAppearanceComponent.BaseLayers)
{

}
// WithHairColor(item.HumanoidAppearanceComponent.BaseLayers.)
// WithFacialHairColor(item.HumanoidAppearanceComponent.CachedFacialHairColor)
ev.HumanoidData.Add(new()
{
NetEntity = netEntity.Value,
Name = Name(item.EntityUid.Value)
Name = Name(item.EntityUid.Value),
Species = item.HumanoidAppearanceComponent.Species.Id,
Profile = new HumanoidCharacterProfile().WithCharacterAppearance(hca).WithSpecies(item.HumanoidAppearanceComponent.Species.Id)
});
}

Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/ADT/Changeling/SharedChangeling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Changeling.Components;
using Content.Shared.DoAfter;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;

Expand Down Expand Up @@ -141,8 +142,8 @@ public struct HDATA
{
public NetEntity NetEntity;
public string Name;

public string Species;
public HumanoidCharacterProfile Profile;
}
public RequestChangelingFormsMenuEvent(NetEntity target)
{
Expand Down

0 comments on commit cf07e22

Please sign in to comment.