@@ -52,6 +52,7 @@ private set {
5252 //acts as a cache for the mutable appearance, so we don't have to ToMutable() every frame
5353 private MutableAppearance ? _animatedAppearance ;
5454 private AtomDirection _direction ;
55+ private string ? _iconState ;
5556
5657 // TODO: We could cache these per-appearance instead of per-atom
5758 public IRenderTexture ? CachedTexture {
@@ -75,8 +76,8 @@ private set {
7576 private IRenderTexture ? _cachedTexture ;
7677
7778 public DreamIcon ( RenderTargetPool renderTargetPool , IDreamInterfaceManager interfaceManager , IGameTiming gameTiming , IClyde clyde , ClientAppearanceSystem appearanceSystem , uint appearanceId ,
78- AtomDirection ? parentDir = null ) : this ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem ) {
79- SetAppearance ( appearanceId , parentDir ) ;
79+ AtomDirection ? parentDir = null , string ? parentIconState = null ) : this ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem ) {
80+ SetAppearance ( appearanceId , parentDir , parentIconState ) ;
8081 }
8182
8283 public void Dispose ( ) {
@@ -93,7 +94,7 @@ public void Dispose() {
9394 return null ;
9495
9596 var dmi = flick ? . Icon ?? DMI ;
96- var iconState = flick ? . IconState ?? Appearance . IconState ;
97+ var iconState = flick ? . IconState ?? _iconState ;
9798 var animationFrame = flick ? . GetAnimationFrame ( gameTiming ) ?? AnimationFrame ;
9899 if ( animationFrame == - 1 ) // A flick returns -1 for a finished animation
99100 animationFrame = AnimationFrame ;
@@ -129,7 +130,7 @@ public void Dispose() {
129130 return CachedTexture ? . Texture ;
130131 }
131132
132- public void SetAppearance ( uint ? appearanceId , AtomDirection ? parentDir = null ) {
133+ public void SetAppearance ( uint ? appearanceId , AtomDirection ? parentDir = null , string ? parentIconState = null ) {
133134 // End any animations that are currently happening
134135 // Note that this isn't faithful to the original behavior
135136 EndAppearanceAnimation ( null ) ;
@@ -145,6 +146,11 @@ public void SetAppearance(uint? appearanceId, AtomDirection? parentDir = null) {
145146 } else {
146147 _direction = appearance . Direction ;
147148 }
149+ if ( parentIconState != null && appearance . IconState == null ) {
150+ _iconState = parentIconState ;
151+ } else {
152+ _iconState = appearance . IconState ;
153+ }
148154
149155 Appearance = appearance ;
150156 } ) ;
@@ -223,7 +229,7 @@ private void UpdateAnimation() {
223229 if ( DMI == null || Appearance == null || _animationComplete )
224230 return ;
225231
226- DMIParser . ParsedDMIState ? dmiState = DMI . Description . GetStateOrDefault ( Appearance . IconState ) ;
232+ DMIParser . ParsedDMIState ? dmiState = DMI . Description . GetStateOrDefault ( _iconState ) ;
227233 if ( dmiState == null )
228234 return ;
229235 DMIParser . ParsedDMIFrame [ ] frames = dmiState . GetFrames ( _direction ) ;
@@ -487,15 +493,15 @@ private void UpdateIcon() {
487493
488494 Overlays . Clear ( ) ;
489495 foreach ( var overlayAppearance in Appearance . Overlays ) {
490- DreamIcon overlay = new DreamIcon ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem , overlayAppearance . MustGetId ( ) , _direction ) ;
496+ DreamIcon overlay = new DreamIcon ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem , overlayAppearance . MustGetId ( ) , _direction , _iconState ) ;
491497 overlay . SizeChanged += CheckSizeChange ;
492498
493499 Overlays . Add ( overlay ) ;
494500 }
495501
496502 Underlays . Clear ( ) ;
497503 foreach ( var underlayAppearance in Appearance . Underlays ) {
498- DreamIcon underlay = new DreamIcon ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem , underlayAppearance . MustGetId ( ) , _direction ) ;
504+ DreamIcon underlay = new DreamIcon ( renderTargetPool , interfaceManager , gameTiming , clyde , appearanceSystem , underlayAppearance . MustGetId ( ) , _direction , _iconState ) ;
499505 underlay . SizeChanged += CheckSizeChange ;
500506
501507 Underlays . Add ( underlay ) ;
0 commit comments