From 93d7348344d51ea637cced0c970a2877a029059e Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Fri, 5 May 2023 20:05:07 +0200 Subject: [PATCH] Animation controller fixes Fix #1862 Animation controllers with particles and sounds don't load Fix cannot open context menu for controller particles and sounds Fix #1861 Ctrl + S does not save single animation controller --- js/animations/animation.js | 4 ++-- js/animations/animation_controllers.js | 20 ++++++++++++-------- js/io/io.js | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/js/animations/animation.js b/js/animations/animation.js index ada8dd19..bc952f74 100644 --- a/js/animations/animation.js +++ b/js/animations/animation.js @@ -959,8 +959,8 @@ const Animator = { Canvas.outlines.children.empty() Canvas.updateAllPositions() } - if (Animation.all.length && !Animation.all.includes(Animation.selected)) { - Animation.all[0].select(); + if (AnimationItem.all.length && !AnimationItem.all.includes(Animation.selected)) { + AnimationItem.all[0].select(); } else if (!Animation.all.length) { Timeline.selected.empty(); } diff --git a/js/animations/animation_controllers.js b/js/animations/animation_controllers.js index 1854f10f..2733d39e 100644 --- a/js/animations/animation_controllers.js +++ b/js/animations/animation_controllers.js @@ -104,7 +104,7 @@ class AnimationControllerState { // From Bedrock if (data.particle_effects instanceof Array) { this.particles.empty(); - data.particles.forEach(effect => { + data.particle_effects.forEach(effect => { let particle = { uuid: guid(), effect: effect.effect || '', @@ -118,7 +118,7 @@ class AnimationControllerState { } if (data.sound_effects instanceof Array) { this.sounds.empty(); - data.sounds.forEach(effect => { + data.sound_effects.forEach(effect => { let sound = { uuid: guid(), effect: effect.effect || '', @@ -1064,7 +1064,8 @@ Interface.definePanels(() => { let menu = new Menu('controller_state_transitions', list, {searchable: list.length > 9}); menu.open(event.target); }, - openParticleMenu(state, particle) { + openParticleMenu(state, particle, event) { + if (getFocusedTextInput()) return; new Menu('controller_state_particle', [ { name: 'generic.remove', @@ -1075,9 +1076,11 @@ Interface.definePanels(() => { Undo.finishEdit('Remove particle from controller state'); } } - ]) + ]).open(event); + event.stopPropagation(); }, - openSoundMenu(state, sound) { + openSoundMenu(state, sound, event) { + if (getFocusedTextInput()) return; new Menu('controller_state_sound', [ { name: 'generic.remove', @@ -1088,7 +1091,8 @@ Interface.definePanels(() => { Undo.finishEdit('Remove sound from controller state'); } } - ]) + ]).open(event); + event.stopPropagation(); }, addAnimationButton(state, event) { state.select(); @@ -1568,7 +1572,7 @@ Interface.definePanels(() => {