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
This commit is contained in:
JannisX11 2023-05-05 20:05:07 +02:00
parent 680db62587
commit 93d7348344
3 changed files with 15 additions and 11 deletions

View File

@ -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();
}

View File

@ -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(() => {
</div>
</div>
<ul v-if="!state.fold.particles">
<li v-for="particle in state.particles" :key="particle.uuid" class="controller_particle" @contextmenu="openParticleMenu(state, particle)">
<li v-for="particle in state.particles" :key="particle.uuid" class="controller_particle" @contextmenu="openParticleMenu(state, particle, $event)">
<div class="bar flex">
<label>${tl('data.effect')}</label>
<input type="text" class="dark_bordered tab_target animation_controller_text_input" v-model="particle.effect">
@ -1612,7 +1616,7 @@ Interface.definePanels(() => {
</div>
</div>
<ul v-if="!state.fold.sounds">
<li v-for="sound in state.sounds" :key="sound.uuid" class="controller_sound" @contextmenu="openSoundMenu(state, sound)">
<li v-for="sound in state.sounds" :key="sound.uuid" class="controller_sound" @contextmenu="openSoundMenu(state, sound, $event)">
<div class="bar flex">
<label>${tl('data.effect')}</label>
<input type="text" class="dark_bordered tab_target animation_controller_text_input" v-model="sound.effect">

View File

@ -671,7 +671,7 @@ BARS.defineActions(function() {
}
}
}
if (Format.animation_mode && Format.animation_files && Animation.all.length) {
if (Format.animation_mode && Format.animation_files && AnimationItem.all.length) {
BarItems.save_all_animations.trigger();
}
} else {