Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/blood-cult
Browse files Browse the repository at this point in the history
# Conflicts:
#	Content.Client/RadialSelector/RadialSelectorMenuBUI.cs
#	Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs
  • Loading branch information
Remuchi committed Oct 24, 2024
2 parents 5b6981b + 85a770c commit f5b7dd9
Show file tree
Hide file tree
Showing 283 changed files with 6,482 additions and 1,121 deletions.
5 changes: 5 additions & 0 deletions Content.Client/Chapel/SacrificialAltarSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Chapel;

namespace Content.Client.Chapel;

public sealed class SacrificialAltarSystem : SharedSacrificialAltarSystem;
14 changes: 5 additions & 9 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ public void SetProfile(HumanoidCharacterProfile? profile, int? slot)
UpdateGenderControls();
UpdateSkinColor();
UpdateSpawnPriorityControls();
UpdateFlavorTextEdit();
UpdateCustomSpecieNameEdit();
UpdateAgeEdit();
UpdateEyePickers();
UpdateSaveButton();
Expand Down Expand Up @@ -1205,15 +1207,9 @@ private void UpdateNameEdit()

private void UpdateCustomSpecieNameEdit()
{
if (Profile == null)
return;

_customspecienameEdit.Text = Profile.Customspeciename ?? "";

if (!_prototypeManager.TryIndex<SpeciesPrototype>(Profile.Species, out var speciesProto))
return;

_ccustomspecienamecontainerEdit.Visible = speciesProto.CustomName;
var species = _species.Find(x => x.ID == Profile?.Species) ?? _species.First();
_customspecienameEdit.Text = string.IsNullOrEmpty(Profile?.Customspeciename) ? Loc.GetString(species.Name) : Profile.Customspeciename;
_ccustomspecienamecontainerEdit.Visible = species.CustomName;
}

private void UpdateFlavorTextEdit()
Expand Down
63 changes: 63 additions & 0 deletions Content.Client/Overlays/ColorTintOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Shadowkin;

namespace Content.Client.Overlays;

/// <summary>
/// A simple overlay that applies a colored tint to the screen.
/// </summary>
public sealed class ColorTintOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] IEntityManager _entityManager = default!;

public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;

/// <summary>
/// The color to tint the screen to as RGB on a scale of 0-1.
/// </summary>
public Vector3? TintColor = null;
/// <summary>
/// The percent to tint the screen by on a scale of 0-1.
/// </summary>
public float? TintAmount = null;

public ColorTintOverlay()
{
IoCManager.InjectDependencies(this);
_shader = _prototype.Index<ShaderPrototype>("ColorTint").InstanceUnique();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_player.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<ShadowkinComponent>(player))
return false;

return base.BeforeDraw(in args);
}
protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
if (TintColor != null)
_shader.SetParameter("tint_color", (Vector3) TintColor);
if (TintAmount != null)
_shader.SetParameter("tint_amount", (float) TintAmount);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
worldHandle.UseShader(_shader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null);
}
}
48 changes: 48 additions & 0 deletions Content.Client/Overlays/EtherealOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Shadowkin;

namespace Content.Client.Overlays;

public sealed class EtherealOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] IEntityManager _entityManager = default!;

public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
private readonly ShaderInstance _shader;

public EtherealOverlay()
{
IoCManager.InjectDependencies(this);
_shader = _prototype.Index<ShaderPrototype>("Ethereal").InstanceUnique();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_player.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<EtherealComponent>(player))
return false;

return base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
worldHandle.UseShader(_shader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null);
}
}
144 changes: 95 additions & 49 deletions Content.Client/RadialSelector/RadialSelectorMenuBUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Construction.Prototypes;
using Content.Shared.RadialSelector;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
Expand All @@ -18,13 +19,15 @@ public sealed class RadialSelectorMenuBUI : BoundUserInterface
{
[Dependency] private readonly IClyde _displayManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;

private readonly SpriteSystem _spriteSystem;

private readonly RadialMenu _menu;
private readonly RadialContainer _mainContainer;

// Used to clearing on state changing
private readonly HashSet<RadialContainer> _cachedContainers = new();

private bool _openCentered;

Expand All @@ -38,38 +41,28 @@ public RadialSelectorMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
BackButtonStyleClass = "RadialMenuBackButton",
CloseButtonStyleClass = "RadialMenuCloseButton"
};

_mainContainer = new RadialContainer
{
Radius = 64f
};

_menu.AddChild(_mainContainer);
}

protected override void Open()
{
_menu.OnClose += Close;

if (_openCentered)
{
_menu.OpenCentered();
}
else
{
_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / _displayManager.ScreenSize);
}
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is RadialSelectorState radialSelectorState)
{
PopulateMenu(radialSelectorState.Items);
_openCentered = radialSelectorState.OpenCentered;
}
if (state is not RadialSelectorState radialSelectorState)
return;

ClearExistingContainers();
CreateMenu(radialSelectorState.Entries);
_openCentered = radialSelectorState.OpenCentered;
}

protected override void Dispose(bool disposing)
Expand All @@ -79,44 +72,97 @@ protected override void Dispose(bool disposing)
_menu.Dispose();
}

private void PopulateMenu(List<EntProtoId> items)
private void CreateMenu(List<RadialSelectorEntry> entries, string parentCategory = "")
{
_mainContainer.Children.Clear();
_mainContainer.Radius = 48f + 24f * MathF.Log(items.Count);

foreach (var protoId in items)
var container = new RadialContainer
{
if (!_protoManager.TryIndex(protoId, out var proto))
continue;
Name = !string.IsNullOrEmpty(parentCategory) ? parentCategory : "Main",
Radius = 48f + 24f * MathF.Log(entries.Count),
};

_menu.AddChild(container);
_cachedContainers.Add(container);

var itemSize = new Vector2(64f, 64f);
var button = new RadialMenuTextureButton
foreach (var entry in entries)
{
if (entry.Category != null)
{
ToolTip = Loc.GetString(proto.Name),
StyleClasses = { "RadialMenuButton" },
SetSize = itemSize
};
var icon = _spriteSystem.Frame0(proto);
var iconScale = itemSize / icon.Size;

var texture = new TextureRect
var button = CreateButton(entry.Category.Name, _spriteSystem.Frame0(entry.Category.Icon));
button.TargetLayer = entry.Category.Name;
CreateMenu(entry.Category.Entries, entry.Category.Name);
container.AddChild(button);
}
else if (entry.Prototype != null)
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = icon,
TextureScale = iconScale
};
var name = GetName(entry.Prototype);
var icon = GetIcon(entry);
if (icon is null)
return;

var button = CreateButton(name, icon);
button.OnButtonUp += _ =>
{
var msg = new RadialSelectorSelectedMessage(entry.Prototype);
SendPredictedMessage(msg);
};

container.AddChild(button);
}
}
}

private string GetName(string proto)
{
if (_protoManager.TryIndex(proto, out var prototype))
return prototype.Name;
if (_protoManager.TryIndex(proto, out ConstructionPrototype? constructionPrototype))
return constructionPrototype.Name;
return proto;
}

button.AddChild(texture);
private Texture? GetIcon(RadialSelectorEntry entry)
{
if (_protoManager.TryIndex(entry.Prototype!, out var prototype))
return _spriteSystem.Frame0(prototype);

button.OnButtonUp += _ =>
{
var msg = new RadialSelectorSelectedMessage(protoId);
SendMessage(msg);
Close();
};
if (_protoManager.TryIndex(entry.Prototype!, out ConstructionPrototype? constructionProto))
return _spriteSystem.Frame0(constructionProto.Icon);

_mainContainer.AddChild(button);
}
if (entry.Icon is not null)
return _spriteSystem.Frame0(entry.Icon);

// No icons provided and no icons found in prototypes. There's nothing we can do.
return null;
}

private RadialMenuTextureButton CreateButton(string name, Texture icon)
{
var itemSize = new Vector2(64f, 64f);
var button = new RadialMenuTextureButton
{
ToolTip = Loc.GetString(name),
StyleClasses = { "RadialMenuButton" },
SetSize = itemSize
};

var iconScale = itemSize / icon.Size;
var texture = new TextureRect
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = icon,
TextureScale = iconScale
};

button.AddChild(texture);
return button;
}

private void ClearExistingContainers()
{
foreach (var container in _cachedContainers)
_menu.RemoveChild(container);

_cachedContainers.Clear();
}
}
Loading

0 comments on commit f5b7dd9

Please sign in to comment.