@@ -267,7 +267,7 @@ class CharacterAnimButton extends UIButton {
267267 var flxAnimation : FlxAnimation = __getFlxAnimation ();
268268 flxAnimation .prefix = newAnim ;
269269
270- refreshFlxAnimationFrames ( flxAnimation , animData );
270+ refreshAnimation ( __getFlxAnimation (), data );
271271
272272 if (valid ) {
273273 parent .buildAnimDisplay (anim , data );
@@ -378,32 +378,6 @@ class CharacterAnimButton extends UIButton {
378378 CharacterEditor .undos .addToUndo (CAnimEditIndices (ID , oldIndices , indicies ));
379379 }
380380
381-
382- public inline function refreshFlxAnimationFrames (flxAnimation : FlxAnimation , animData : AnimData ) @:privateAccess {
383- try {
384- if (animData .indices .length > 0 ) {
385- var frameIndices : Array <Int > = new Array <Int >();
386- parent .character .animation .byIndicesHelper (frameIndices , flxAnimation .prefix , animData .indices , " " );
387-
388- flxAnimation .frames = frameIndices ;
389- } else {
390- final animFrames : Array <FlxFrame > = new Array <FlxFrame >();
391- parent .character .animation .findByPrefix (animFrames , flxAnimation .prefix );
392-
393- final frameIndices : Array <Int > = [];
394- parent .character .animation .byPrefixHelper (frameIndices , animFrames , flxAnimation .prefix );
395-
396- flxAnimation .frames = frameIndices ;
397- }
398-
399- if (flxAnimation .frames .length <= 0 ) invalidate ();
400- else validate ();
401- } catch (e ) {
402- trace (' ERROR REFRESHING FLXANIMATION FRAMES: $e ' );
403- invalidate ();
404- }
405- }
406-
407381 public function toggleGhost () {
408382 if (valid && parent .ghosts .indexOf (anim ) == - 1 ) {
409383 FlxG .sound .play (Paths .sound (Flags .DEFAULT_CHARACTER_GHOSTENABLE_SOUND ));
@@ -422,6 +396,9 @@ class CharacterAnimButton extends UIButton {
422396 updateButtonsPos ();
423397 super .draw ();
424398
399+ if (parent .character .isAnimate ) // TODO: displayWindowSprite for atlases
400+ return ;
401+
425402 if (! closed && parent .displayAnimsFramesList .exists (anim )) {
426403 var displayData : {frame : Int , scale : Float , animBounds : Rectangle } = parent .displayAnimsFramesList .get (anim );
427404 parent .displayWindowSprite .frame = parent .displayWindowSprite .frames .frames [displayData .frame ];
@@ -478,9 +455,28 @@ class CharacterAnimButton extends UIButton {
478455 return parent .character .animation ._animations [anim ];
479456 }
480457
458+ public inline function refreshAnimation (anim : FlxAnimation , animData : AnimData ) @:privateAccess {
459+ var refreshed : Bool = false ;
460+
461+ parent .character .animation .remove (animData .name );
462+ parent .character .animation ._curAnim = null ;
463+
464+ XMLUtil .addAnimToSprite (parent .character , animData );
465+
466+ var anim = parent .character .animation .getByName (animData .name );
467+
468+ if (anim != null && anim .frames .length > 0 ) {
469+ validate ();
470+ parent .character .animation .play (animData .name );
471+ }
472+ else
473+ invalidate ();
474+ }
475+
481476 @:noCompletion function __refreshAnimation () @:privateAccess {
482- refreshFlxAnimationFrames (__getFlxAnimation (), data );
477+ refreshAnimation (__getFlxAnimation (), data );
483478
479+ // TODO: displayWindowSprite for atlases
484480 if (valid ) {
485481 parent .buildAnimDisplay (anim , data );
486482 animationDisplayBG .alpha = 1 ;
0 commit comments