Merge remote-tracking branch 'upstream/stable' into ed-27-05-2025-upstream-sync
# Conflicts: # .github/CODEOWNERS # Content.Client/Guidebook/Controls/GuideReagentReaction.xaml.cs # Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs # Content.Server/Procedural/DungeonJob/DungeonJob.OreDunGen.cs # Resources/Prototypes/Entities/Effects/chemistry_effects.yml # Resources/Prototypes/Entities/Mobs/Customization/Markings/human_hair.yml # Resources/Prototypes/GameRules/meteorswarms.yml # Resources/Prototypes/Procedural/dungeon_configs.yml
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Client.Guidebook.Controls;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -68,6 +70,52 @@ public static class ControlExtension
|
||||
return controlList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search the control’s tree for a parent node of type T
|
||||
/// E.g. to find the control implementing some event handling interface.
|
||||
/// </summary>
|
||||
public static bool TryGetParentHandler<T>(this Control child, [NotNullWhen(true)] out T? result)
|
||||
{
|
||||
for (var control = child; control is not null; control = control.Parent)
|
||||
{
|
||||
if (control is not T handler)
|
||||
continue;
|
||||
|
||||
result = handler;
|
||||
return true;
|
||||
}
|
||||
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the control’s offset relative to its closest ScrollContainer
|
||||
/// Returns null if the control is not in the tree or not visible.
|
||||
/// </summary>
|
||||
public static Vector2? GetControlScrollPosition(this Control child)
|
||||
{
|
||||
if (!child.VisibleInTree)
|
||||
return null;
|
||||
|
||||
var position = new Vector2();
|
||||
var control = child;
|
||||
|
||||
while (control is not null)
|
||||
{
|
||||
// The scroll container's direct child is re-positioned while scrolling,
|
||||
// so we need to ignore its position.
|
||||
if (control.Parent is ScrollContainer)
|
||||
break;
|
||||
|
||||
position += control.Position;
|
||||
|
||||
control = control.Parent;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
public static bool ChildrenContainText(this Control parent, string search)
|
||||
{
|
||||
var labels = parent.GetControlOfType<Label>();
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private readonly SpriteSystem _sprite;
|
||||
|
||||
public AlertPrototype Alert { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -52,6 +54,7 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
|
||||
MuteSounds = true;
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
_sprite = _entityManager.System<SpriteSystem>();
|
||||
TooltipSupplier = SupplyTooltip;
|
||||
Alert = alert;
|
||||
_severity = severity;
|
||||
@@ -74,7 +77,7 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
|
||||
{
|
||||
var msg = FormattedMessage.FromMarkupOrThrow(Loc.GetString(Alert.Name));
|
||||
var desc = FormattedMessage.FromMarkupOrThrow(Loc.GetString(Alert.Description));
|
||||
return new ActionAlertTooltip(msg, desc) {Cooldown = Cooldown};
|
||||
return new ActionAlertTooltip(msg, desc) { Cooldown = Cooldown };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,8 +92,8 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
|
||||
if (!_entityManager.TryGetComponent<SpriteComponent>(_spriteViewEntity, out var sprite))
|
||||
return;
|
||||
var icon = Alert.GetIcon(_severity);
|
||||
if (sprite.LayerMapTryGet(AlertVisualLayers.Base, out var layer))
|
||||
sprite.LayerSetSprite(layer, icon);
|
||||
if (_sprite.LayerMapTryGet((_spriteViewEntity, sprite), AlertVisualLayers.Base, out var layer, false))
|
||||
_sprite.LayerSetSprite((_spriteViewEntity, sprite), layer, icon);
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
@@ -117,8 +120,8 @@ namespace Content.Client.UserInterface.Systems.Alerts.Controls
|
||||
if (_entityManager.TryGetComponent<SpriteComponent>(_spriteViewEntity, out var sprite))
|
||||
{
|
||||
var icon = Alert.GetIcon(_severity);
|
||||
if (sprite.LayerMapTryGet(AlertVisualLayers.Base, out var layer))
|
||||
sprite.LayerSetSprite(layer, icon);
|
||||
if (_sprite.LayerMapTryGet((_spriteViewEntity, sprite), AlertVisualLayers.Base, out var layer, false))
|
||||
_sprite.LayerSetSprite((_spriteViewEntity, sprite), layer, icon);
|
||||
}
|
||||
|
||||
_icon.SetEntity(_spriteViewEntity);
|
||||
|
||||
@@ -26,7 +26,7 @@ public sealed class OptionsUIController : UIController
|
||||
|
||||
if (!int.TryParse(args[0], out var tab))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("cmd-parse-failure-int", ("arg", args[0])));
|
||||
shell.WriteError(Loc.GetString("cmd-parse-failure-integer", ("arg", args[0])));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Client.Inventory.ClientInventorySystem;
|
||||
|
||||
@@ -35,6 +34,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
||||
[UISystemDependency] private readonly ClientInventorySystem _inventorySystem = default!;
|
||||
[UISystemDependency] private readonly HandsSystem _handsSystem = default!;
|
||||
[UISystemDependency] private readonly ContainerSystem _container = default!;
|
||||
[UISystemDependency] private readonly SpriteSystem _sprite = default!;
|
||||
|
||||
private EntityUid? _playerUid;
|
||||
private InventorySlotsComponent? _playerInventory;
|
||||
@@ -364,8 +364,8 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
||||
}
|
||||
}
|
||||
|
||||
hoverSprite.CopyFrom(sprite);
|
||||
hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127);
|
||||
_sprite.CopySprite((held, sprite), (hoverEntity, hoverSprite));
|
||||
_sprite.SetColor((hoverEntity, hoverSprite), fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127));
|
||||
|
||||
control.HoverSpriteView.SetEntity(hoverEntity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user