Fix hold_on_last_frame animation only playing once

Add additional event hooks
This commit is contained in:
JannisX11 2020-08-05 16:38:38 +02:00
parent 437c1cd782
commit cc25a0e637
3 changed files with 11 additions and 2 deletions

View File

@ -1265,7 +1265,7 @@ const Animator = {
Blockbench.dispatchEvent('display_animation_frame')
},
loadFile(file) {
var json = autoParseJSON(file.content)
var json = file.json || autoParseJSON(file.content);
if (json && typeof json.animations === 'object') {
for (var ani_name in json.animations) {
//Animation
@ -1910,6 +1910,9 @@ const Timeline = {
Timeline.playing = true
BarItems.play_animation.setIcon('pause')
Timeline.interval = setInterval(Timeline.loop, 100/6)
if (Animator.selected.loop == 'hold' && Timeline.time >= (Animator.selected.length||1e3)) {
Timeline.setTime(0)
}
Timeline.loop()
},
loop() {
@ -1920,8 +1923,8 @@ const Timeline = {
} else {
if (Animator.selected.loop == 'once') {
Timeline.setTime(0)
Timeline.pause()
Animator.preview()
Timeline.pause()
} else if (Animator.selected.loop == 'hold') {
Timeline.pause()
} else {

View File

@ -245,10 +245,13 @@ BARS.defineActions(function() {
Undo.finishEdit('change global UV')
}
Blockbench.dispatchEvent('update_project_settings', formResult);
BARS.updateConditions()
if (EditSession.active) {
EditSession.sendAll('change_project_meta', JSON.stringify(Project));
}
dialog.hide()
}
})

View File

@ -20,6 +20,7 @@ class Mode extends KeybindItem {
Modes.previous_id = Modes.selected.id;
}
if (typeof Modes.selected.onUnselect === 'function') {
Blockbench.dispatchEvent('unselect_mode', {mode: Modes.selected})
Modes.selected.onUnselect()
}
if (Modes.selected.selected) {
@ -27,6 +28,7 @@ class Mode extends KeybindItem {
}
this.selected = true;
Modes.id = this.id
Mode.selected = this;
Modes.selected = this;
Modes[Modes.selected.id] = true;
@ -54,6 +56,7 @@ class Mode extends KeybindItem {
BarItems.move_tool.select()
}
TickUpdates.selection = true;
Blockbench.dispatchEvent('select_mode', {mode: this})
}
trigger() {
if (Condition(this.condition)) {