Fix rsi sprite access for verbs (#14284)

This commit is contained in:
metalgearsloth
2023-02-26 18:48:57 +11:00
committed by GitHub
parent a6d0c9b129
commit 44fb8a9e2d
53 changed files with 313 additions and 271 deletions

View File

@@ -6,6 +6,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.Cabinet;
@@ -105,12 +106,14 @@ public abstract class SharedItemCabinetSystem : EntitySystem
if (cabinet.Opened)
{
toggleVerb.Text = Loc.GetString("verb-common-close");
toggleVerb.IconTexture = "/Textures/Interface/VerbIcons/close.svg.192dpi.png";
toggleVerb.Icon =
new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/close.svg.192dpi.png"));
}
else
{
toggleVerb.Text = Loc.GetString("verb-common-open");
toggleVerb.IconTexture = "/Textures/Interface/VerbIcons/open.svg.192dpi.png";
toggleVerb.Icon =
new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/open.svg.192dpi.png"));
}
args.Verbs.Add(toggleVerb);
}

View File

@@ -499,14 +499,18 @@ namespace Content.Shared.Containers.ItemSlots
if (slot.InsertVerbText != null)
{
insertVerb.Text = Loc.GetString(slot.InsertVerbText);
insertVerb.IconTexture = "/Textures/Interface/VerbIcons/insert.svg.192dpi.png";
insertVerb.Icon =
new SpriteSpecifier.Texture(
new ResourcePath("/Textures/Interface/VerbIcons/insert.svg.192dpi.png"));
}
else if(slot.EjectOnInteract)
{
// Inserting/ejecting is a primary interaction for this entity. Instead of using the insert
// category, we will use a single "Place <item>" verb.
insertVerb.Text = Loc.GetString("place-item-verb-text", ("subject", verbSubject));
insertVerb.IconTexture = "/Textures/Interface/VerbIcons/drop.svg.192dpi.png";
insertVerb.Icon =
new SpriteSpecifier.Texture(
new ResourcePath("/Textures/Interface/VerbIcons/drop.svg.192dpi.png"));
}
else
{

View File

@@ -38,7 +38,7 @@ namespace Content.Shared.Examine
Text = group.ContextText,
Message = group.HoverMessage,
Category = VerbCategory.Examine,
IconTexture = group.Icon
Icon = new SpriteSpecifier.Texture(new ResourcePath(group.Icon)),
};
args.Verbs.Add(examineVerb);
@@ -149,7 +149,7 @@ namespace Content.Shared.Examine
Text = verbText,
Message = hoverMessage,
Category = VerbCategory.Examine,
IconTexture = iconTexture
Icon = new SpriteSpecifier.Texture(new ResourcePath(iconTexture)),
};
verbsEvent.Verbs.Add(examineVerb);

View File

@@ -32,24 +32,25 @@ public abstract class SharedFoldableSystem : EntitySystem
return;
if (state.IsFolded != component.IsFolded)
SetFolded(component, state.IsFolded);
SetFolded(uid, component, state.IsFolded);
}
private void OnFoldableInit(EntityUid uid, FoldableComponent component, ComponentInit args)
{
SetFolded(component, component.IsFolded);
SetFolded(uid, component, component.IsFolded);
}
/// <summary>
/// Set the folded state of the given <see cref="FoldableComponent"/>
/// </summary>
/// <param name="component"></param>
/// <param name="folded">If true, the component will become folded, else unfolded</param>
public virtual void SetFolded(FoldableComponent component, bool folded)
public virtual void SetFolded(EntityUid uid, FoldableComponent component, bool folded)
{
if (component.IsFolded == folded)
return;
component.IsFolded = folded;
Dirty(component);
Appearance.SetData(component.Owner, FoldedVisuals.State, folded);
Appearance.SetData(uid, FoldedVisuals.State, folded);
}
private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args)

View File

@@ -4,6 +4,7 @@ using Content.Shared.Ghost;
using Content.Shared.Movement.Events;
using Content.Shared.Verbs;
using Robust.Shared.Map;
using Robust.Shared.Utility;
namespace Content.Shared.Follower;
@@ -37,7 +38,7 @@ public sealed class FollowerSystem : EntitySystem
}),
Impact = LogImpact.Low,
Text = Loc.GetString("verb-follow-text"),
IconTexture = "/Textures/Interface/VerbIcons/open.svg.192dpi.png",
Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/open.svg.192dpi.png")),
};
ev.Verbs.Add(verb);

View File

@@ -5,6 +5,7 @@ using Content.Shared.Inventory.Events;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Utility;
namespace Content.Shared.Item;
@@ -118,7 +119,7 @@ public abstract class SharedItemSystem : EntitySystem
InteractionVerb verb = new();
verb.Act = () => _handsSystem.TryPickupAnyHand(args.User, args.Target, checkActionBlocker: false,
handsComp: args.Hands, item: component);
verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
verb.Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/pickup.svg.192dpi.png"));
// if the item already in a container (that is not the same as the user's), then change the text.
// this occurs when the item is in their inventory or in an open backpack

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.Lock;
@@ -224,7 +225,9 @@ public sealed class LockSystem : EntitySystem
() => TryUnlock(uid, args.User, component) :
() => TryLock(uid, args.User, component),
Text = Loc.GetString(component.Locked ? "toggle-lock-verb-unlock" : "toggle-lock-verb-lock"),
IconTexture = component.Locked ? "/Textures/Interface/VerbIcons/unlock.svg.192dpi.png" : "/Textures/Interface/VerbIcons/lock.svg.192dpi.png"
Icon = component.Locked ?
new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/unlock.svg.192dpi.png")) :
new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/lock.svg.192dpi.png")),
};
args.Verbs.Add(verb);
}

View File

@@ -71,14 +71,7 @@ namespace Content.Shared.Verbs
/// <summary>
/// Sprite of the icon that the user sees on the verb button.
/// </summary>
public SpriteSpecifier? Icon
{
get => _icon ??=
IconTexture == null ? null : new SpriteSpecifier.Texture(new ResourcePath(IconTexture));
set => _icon = value;
}
[NonSerialized]
private SpriteSpecifier? _icon;
public SpriteSpecifier? Icon;
/// <summary>
/// Name of the category this button is under. Used to group verbs in the context menu.
@@ -114,11 +107,6 @@ namespace Content.Shared.Verbs
/// </remarks>
public int Priority;
/// <summary>
/// Raw texture path used to load the <see cref="Icon"/> for displaying on the client.
/// </summary>
public string? IconTexture;
/// <summary>
/// If this is not null, and no icon or icon texture were specified, a sprite view of this entity will be
/// used as the icon for this verb.
@@ -211,7 +199,7 @@ namespace Content.Shared.Verbs
}
// Finally, compare icon texture paths. Note that this matters for verbs that don't have any text (e.g., the rotate-verbs)
return string.Compare(IconTexture, otherVerb.IconTexture, StringComparison.CurrentCulture);
return string.Compare(Icon?.ToString(), otherVerb.Icon?.ToString(), StringComparison.CurrentCulture);
}
/// <summary>

View File

@@ -35,7 +35,7 @@ public abstract partial class SharedGunSystem
{
Act = () => SelectFire(component, nextMode, args.User),
Text = Loc.GetString("gun-selector-verb", ("mode", GetLocSelector(nextMode))),
IconTexture = "/Textures/Interface/VerbIcons/fold.svg.192dpi.png",
Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/fold.svg.192dpi.png")),
};
args.Verbs.Add(verb);