Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions OpenDreamClient/Rendering/DreamIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private set {
//acts as a cache for the mutable appearance, so we don't have to ToMutable() every frame
private MutableAppearance? _animatedAppearance;
private AtomDirection _direction;
private string? _iconState;

// TODO: We could cache these per-appearance instead of per-atom
public IRenderTexture? CachedTexture {
Expand All @@ -75,8 +76,8 @@ private set {
private IRenderTexture? _cachedTexture;

public DreamIcon(RenderTargetPool renderTargetPool, IDreamInterfaceManager interfaceManager, IGameTiming gameTiming, IClyde clyde, ClientAppearanceSystem appearanceSystem, uint appearanceId,
AtomDirection? parentDir = null) : this(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem) {
SetAppearance(appearanceId, parentDir);
AtomDirection? parentDir = null, string? parentIconState = null) : this(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem) {
SetAppearance(appearanceId, parentDir, parentIconState);
}

public void Dispose() {
Expand All @@ -93,7 +94,7 @@ public void Dispose() {
return null;

var dmi = flick?.Icon ?? DMI;
var iconState = flick?.IconState ?? Appearance.IconState;
var iconState = flick?.IconState ?? _iconState;
var animationFrame = flick?.GetAnimationFrame(gameTiming) ?? AnimationFrame;
if (animationFrame == -1) // A flick returns -1 for a finished animation
animationFrame = AnimationFrame;
Expand Down Expand Up @@ -129,7 +130,7 @@ public void Dispose() {
return CachedTexture?.Texture;
}

public void SetAppearance(uint? appearanceId, AtomDirection? parentDir = null) {
public void SetAppearance(uint? appearanceId, AtomDirection? parentDir = null, string? parentIconState = null) {
// End any animations that are currently happening
// Note that this isn't faithful to the original behavior
EndAppearanceAnimation(null);
Expand All @@ -146,6 +147,7 @@ public void SetAppearance(uint? appearanceId, AtomDirection? parentDir = null) {
_direction = appearance.Direction;
}

_iconState = appearance.IconState ?? parentIconState;
Appearance = appearance;
});
}
Expand Down Expand Up @@ -223,7 +225,7 @@ private void UpdateAnimation() {
if(DMI == null || Appearance == null || _animationComplete)
return;

DMIParser.ParsedDMIState? dmiState = DMI.Description.GetStateOrDefault(Appearance.IconState);
DMIParser.ParsedDMIState? dmiState = DMI.Description.GetStateOrDefault(_iconState);
if(dmiState == null)
return;
DMIParser.ParsedDMIFrame[] frames = dmiState.GetFrames(_direction);
Expand Down Expand Up @@ -487,15 +489,15 @@ private void UpdateIcon() {

Overlays.Clear();
foreach (var overlayAppearance in Appearance.Overlays) {
DreamIcon overlay = new DreamIcon(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem, overlayAppearance.MustGetId(), _direction);
DreamIcon overlay = new DreamIcon(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem, overlayAppearance.MustGetId(), _direction, _iconState);
overlay.SizeChanged += CheckSizeChange;

Overlays.Add(overlay);
}

Underlays.Clear();
foreach (var underlayAppearance in Appearance.Underlays) {
DreamIcon underlay = new DreamIcon(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem, underlayAppearance.MustGetId(), _direction);
DreamIcon underlay = new DreamIcon(renderTargetPool, interfaceManager, gameTiming, clyde, appearanceSystem, underlayAppearance.MustGetId(), _direction, _iconState);
underlay.SizeChanged += CheckSizeChange;

Underlays.Add(underlay);
Expand Down
Loading