Rename Animator.selected to Animation.selected

This commit is contained in:
JannisX11 2020-09-15 14:21:04 +02:00
parent 1b0f67f11c
commit 84255bfde4
9 changed files with 72 additions and 70 deletions

View File

@ -241,7 +241,7 @@ class Animation {
select() {
var scope = this;
Prop.active_panel = 'animations';
if (this == Animator.selected) return;
if (this == Animation.selected) return;
var selected_bone = Group.selected;
Animator.animations.forEach(function(a) {
a.selected = a.playing = false;
@ -252,7 +252,7 @@ class Animation {
Timeline.vue._data.animation_length = this.length;
this.selected = true;
this.playing = true;
Animator.selected = this;
Animation.selected = this;
unselectAll();
BarItems.slider_animation_length.update();
@ -269,7 +269,7 @@ class Animation {
setLength(len) {
len = limitNumber(len, 0, 1e4)
this.length = len;
if (Animator.selected == this) {
if (Animation.selected == this) {
Timeline.vue._data.animation_length = this.length;
BarItems.slider_animation_length.update()
}
@ -377,8 +377,8 @@ class Animation {
if (undo) {
Undo.initEdit({animations: [this]})
}
if (Animator.selected === this) {
Animator.selected = false
if (Animation.selected === this) {
Animation.selected = null
}
Animator.animations.remove(this)
if (undo) {
@ -418,7 +418,7 @@ class Animation {
}
}
this.setLength(len)
if (this == Animator.selected) {
if (this == Animation.selected) {
BarItems.slider_animation_length.update()
}
return len
@ -535,6 +535,7 @@ class Animation {
}
}
Animation.all = [];
Animation.selected = null;
Animation.prototype.menu = new Menu([
{name: 'menu.animation.loop', icon: 'loop', children: [
{name: 'menu.animation.loop.once', icon: animation => (animation.loop == 'once' ? 'radio_button_checked' : 'radio_button_unchecked'), click(animation) {animation.setLoop('once', true)}},
@ -598,8 +599,8 @@ class GeneralAnimator {
select() {
var scope = this;
TickUpdates.keyframes = true;
for (var key in Animator.selected.animators) {
Animator.selected.animators[key].selected = false;
for (var key in Animation.selected.animators) {
Animation.selected.animators[key].selected = false;
}
this.selected = true;
Timeline.selected_animator = this;
@ -1043,7 +1044,7 @@ Object.assign(Clipbench, {
}
if (Clipbench.keyframes && Clipbench.keyframes.length) {
if (!Animator.selected) return;
if (!Animation.selected) return;
var keyframes = [];
Undo.initEdit({keyframes});
Timeline.selected.empty();
@ -1053,7 +1054,7 @@ Object.assign(Clipbench, {
Clipbench.keyframes.forEach(function(data, i) {
if (data.animator) {
var animator = Animator.selected.animators[data.animator];
var animator = Animation.selected.animators[data.animator];
if (animator && !Timeline.animators.includes(animator)) {
animator.addToTimeline();
}
@ -1080,6 +1081,7 @@ const Animator = {
possible_channels: {rotation: true, position: true, scale: true, sound: true, particle: true, timeline: true},
open: false,
animations: Animation.all,
get selected() {return Animation.selected},
frame: 0,
interval: false,
join() {
@ -1108,7 +1110,7 @@ const Animator = {
outlines.children.empty()
Canvas.updateAllPositions()
}
if (!Animator.selected && Animator.animations.length) {
if (!Animation.selected && Animator.animations.length) {
Animator.animations[0].select()
}
Animator.preview()
@ -1261,7 +1263,7 @@ const Animator = {
}
}
animation.calculateSnappingFromKeyframes();
if (!Animator.selected) {
if (!Animation.selected) {
animation.select()
}
new_animations.push(animation)

View File

@ -225,7 +225,7 @@ class Keyframe {
}
}
Timeline.selected.safePush(this);
if (Timeline.selected.length == 1 && Timeline.selected[0].animator.selected == false) {
if (Timeline.selected.length == 1 && Timeline.selected[0].Animation.selected == false) {
Timeline.selected[0].animator.select()
}
@ -366,7 +366,7 @@ function updateKeyframeSelection() {
Blockbench.dispatchEvent('update_keyframe_selection');
}
function selectAllKeyframes() {
if (!Animator.selected) return;
if (!Animation.selected) return;
var state = Timeline.selected.length !== Timeline.keyframes.length
Timeline.keyframes.forEach((kf) => {
if (state && !kf.selected) {
@ -517,19 +517,19 @@ BARS.defineActions(function() {
new NumSlider('slider_animation_length', {
category: 'animation',
condition: () => Animator.open && Animator.selected,
condition: () => Animator.open && Animation.selected,
getInterval(event) {
if (event && event.shiftKey) return 1;
return Timeline.getStep()
},
get: function() {
return Animator.selected.length
return Animation.selected.length
},
change: function(modify) {
Animator.selected.setLength(limitNumber(modify(Animator.selected.length), 0, 1e4))
Animation.selected.setLength(limitNumber(modify(Animation.selected.length), 0, 1e4))
},
onBefore: function() {
Undo.initEdit({animations: [Animator.selected]});
Undo.initEdit({animations: [Animation.selected]});
},
onAfter: function() {
Undo.finishEdit('Change Animation Length')

View File

@ -30,7 +30,7 @@ TimelineMarker.prototype.menu = new Menu([
{icon: 'flag', color: markerColors[6].standard, name: 'cube.color.'+markerColors[6].name, click: function(marker) {marker.color = 6;}},
{icon: 'flag', color: markerColors[7].standard, name: 'cube.color.'+markerColors[7].name, click: function(marker) {marker.color = 7;}},
{icon: 'delete', name: 'generic.delete', click: function(marker) {
if (Animator.selected) Animator.selected.markers.remove(marker);
if (Animation.selected) Animation.selected.markers.remove(marker);
}}
])
@ -41,7 +41,7 @@ const Timeline = {
playback_speed: 100,
time: 0,
get second() {return Timeline.time},
get animation_length() {return Animator.selected ? Animator.selected.length : 0;},
get animation_length() {return Animation.selected ? Animation.selected.length : 0;},
playing: false,
selector: {
start: [0, 0],
@ -195,12 +195,12 @@ const Timeline = {
if (time == undefined || isNaN(time)) {
time = Timeline.time;
}
if (!animation) animation = Animator.selected;
if (!animation) animation = Animation.selected;
var fps = Math.clamp(animation ? animation.snapping : settings.animation_snap.value, 1, 120);
return Math.clamp(Math.round(time*fps)/fps, 0);
},
getStep() {
return 1/Math.clamp(Animator.selected ? Animator.selected.snapping : settings.animation_snap.value, 1, 120);
return 1/Math.clamp(Animation.selected ? Animation.selected.snapping : settings.animation_snap.value, 1, 120);
},
setup() {
$('#timeline_body').mousedown(Timeline.selector.down)
@ -211,9 +211,9 @@ const Timeline = {
if (e.target.id == 'timeline_endbracket') {
if (Animator.selected) {
if (Animation.selected) {
Timeline.dragging_endbracket = true;
Undo.initEdit({animations: [Animator.selected]});
Undo.initEdit({animations: [Animation.selected]});
} else {
Blockbench.showQuickMessage('message.no_animation_selected');
}
@ -245,7 +245,7 @@ const Timeline = {
let offset = e.clientX - $('#timeline_time').offset().left;
let time = Timeline.snapTime(offset / Timeline.vue._data.size)
Animator.selected.setLength(time)
Animation.selected.setLength(time)
Timeline.revealTime(time)
}
@ -477,7 +477,7 @@ const Timeline = {
$('#timeline_time').css('left', -scroll_amount+'px')
},
unselect(e) {
if (!Animator.selected) return;
if (!Animation.selected) return;
Timeline.keyframes.forEach((kf) => {
if (kf.selected) {
Timeline.selected.remove(kf)
@ -487,13 +487,13 @@ const Timeline = {
TickUpdates.keyframe_selection = true;
},
start() {
if (!Animator.selected) return;
Animator.selected.getMaxLength()
if (!Animation.selected) return;
Animation.selected.getMaxLength()
Timeline.pause()
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)) {
if (Animation.selected.loop == 'hold' && Timeline.time >= (Animation.selected.length||1e3)) {
Timeline.setTime(0)
}
if (Timeline.time > 0) {
@ -507,19 +507,19 @@ const Timeline = {
},
loop() {
Animator.preview()
if (Animator.selected && Timeline.time < (Animator.selected.length||1e3)) {
if (Animation.selected && Timeline.time < (Animation.selected.length||1e3)) {
let new_time = (Animator.selected && Animator.selected.anim_time_update)
? Molang.parse(Animator.selected.anim_time_update)
let new_time = (Animation.selected && Animation.selected.anim_time_update)
? Molang.parse(Animation.selected.anim_time_update)
: Timeline.time + (1/60);
Timeline.setTime(Timeline.time + (new_time - Timeline.time) * (Timeline.playback_speed/100));
} else {
if (Animator.selected.loop == 'once') {
if (Animation.selected.loop == 'once') {
Timeline.setTime(0)
Animator.preview()
Timeline.pause()
} else if (Animator.selected.loop == 'hold') {
} else if (Animation.selected.loop == 'hold') {
Timeline.pause()
} else {
Timeline.setTime(0)
@ -652,7 +652,7 @@ BARS.defineActions(function() {
condition: {modes: ['animate']},
click: function () {
if (!Animator.selected) {
if (!Animation.selected) {
Blockbench.showQuickMessage('message.no_animation_selected')
return;
}
@ -720,7 +720,7 @@ BARS.defineActions(function() {
condition: {modes: ['animate']},
keybind: new Keybind({key: 35}),
click: function () {
Timeline.setTime(Animator.selected ? Animator.selected.length : 0)
Timeline.setTime(Animation.selected ? Animation.selected.length : 0)
Animator.preview()
}
})
@ -730,9 +730,9 @@ BARS.defineActions(function() {
category: 'animation',
condition: {modes: ['animate']},
click: function () {
if (!Animator.selected) return;
for (var uuid in Animator.selected.animators) {
var ba = Animator.selected.animators[uuid]
if (!Animation.selected) return;
for (var uuid in Animation.selected.animators) {
var ba = Animation.selected.animators[uuid]
if (ba && ba.keyframes.length) {
ba.addToTimeline();
}
@ -765,11 +765,11 @@ BARS.defineActions(function() {
category: 'animation',
condition: {modes: ['animate']},
click: function () {
if (!Animator.selected) return;
if (!Animator.selected.animators.effects) {
var ea = Animator.selected.animators.effects = new EffectAnimator(Animator.selected);
if (!Animation.selected) return;
if (!Animation.selected.animators.effects) {
var ea = Animation.selected.animators.effects = new EffectAnimator(Animation.selected);
}
Animator.selected.animators.effects.select()
Animation.selected.animators.effects.select()
}
})
new BarSelect('timeline_focus', {
@ -791,23 +791,23 @@ BARS.defineActions(function() {
condition: {modes: ['animate']},
keybind: new Keybind({ctrl: true, key: 77}),
click: function (event) {
if (!Animator.selected) {
if (!Animation.selected) {
Blockbench.showQuickMessage('message.no_animation_selected')
return;
}
var time = Timeline.snapTime();
var original_marker;
for (var m of Animator.selected.markers) {
for (var m of Animation.selected.markers) {
if (Math.abs(m.time - time) < 0.01) {
original_marker = m;
break;
}
}
if (original_marker) {
Animator.selected.markers.remove(original_marker);
Animation.selected.markers.remove(original_marker);
} else {
let marker = new TimelineMarker({time});
Animator.selected.markers.push(marker);
Animation.selected.markers.push(marker);
}
}
})

View File

@ -1282,8 +1282,8 @@ const BARS = {
click: function () {
if (Modes.edit || Modes.paint) {
renameOutliner()
} else if (Prop.active_panel == 'animations' && Animator.selected) {
Animator.selected.rename()
} else if (Prop.active_panel == 'animations' && Animation.selected) {
Animation.selected.rename()
}
}
})
@ -1320,8 +1320,8 @@ const BARS = {
TickUpdates.selection = true;
Undo.finishEdit('delete elements')
} else if (Prop.active_panel == 'animations' && Animator.selected) {
Animator.selected.remove(true)
} else if (Prop.active_panel == 'animations' && Animation.selected) {
Animation.selected.remove(true)
} else if (Animator.open) {
removeSelectedKeyframes()
@ -1331,15 +1331,15 @@ const BARS = {
new Action('duplicate', {
icon: 'content_copy',
category: 'edit',
condition: () => (Animator.selected && Modes.animate) || (Modes.edit && (selected.length || Group.selected)),
condition: () => (Animation.selected && Modes.animate) || (Modes.edit && (selected.length || Group.selected)),
keybind: new Keybind({key: 68, ctrl: true}),
click: function () {
if (Modes.animate) {
if (Animator.selected && Prop.active_panel == 'animations') {
var copy = Animator.selected.getUndoCopy();
if (Animation.selected && Prop.active_panel == 'animations') {
var copy = Animation.selected.getUndoCopy();
var animation = new Animation(copy);
animation.createUniqueName();
Animator.animations.splice(Animator.animations.indexOf(Animator.selected)+1, 0, animation)
Animator.animations.splice(Animator.animations.indexOf(Animation.selected)+1, 0, animation)
animation.add(true).select();
}
} else if (Group.selected && (Group.selected.matchesSelection() || selected.length === 0)) {

View File

@ -76,7 +76,7 @@ class ModelProject {
Painter.current = {};
Animator.animations.purge();
Timeline.animators.purge();
Animator.selected = undefined;
Animation.selected = undefined;
$('#var_placeholder_area').val('');
}
}

View File

@ -101,8 +101,8 @@ class Group extends OutlinerElement {
})
}
if (Animator.open) {
if (Animator.selected) {
Animator.selected.getBoneAnimator().select(true)
if (Animation.selected) {
Animation.selected.getBoneAnimator().select(true)
}
}
updateSelection()
@ -145,8 +145,8 @@ class Group extends OutlinerElement {
}
unselect() {
if (this.selected === false) return;
if (Animator.open && Animator.selected) {
var ba = Animator.selected.animators[this.uuid];
if (Animator.open && Animation.selected) {
var ba = Animation.selected.animators[this.uuid];
if (ba) {
ba.selected = false
}

View File

@ -1198,7 +1198,7 @@ const Screencam = {
if (!options.length) options.length = 1;
var preview = quad_previews.current;
var animation = Animator.selected;
var animation = Animation.selected;
var interval = options.fps ? (1000/options.fps) : 100;
var frames = 0;
const gif = new GIF({

View File

@ -1048,14 +1048,14 @@
}
scope.keyframes = [];
var undo_keyframes = [];
var animator = Animator.selected.getBoneAnimator();
var animator = Animation.selected.getBoneAnimator();
if (animator && Toolbox.selected.id === 'move_tool' && Group.selected.ik_enabled && Group.selected.ik_chain_length) {
/*
var bone = Group.selected;
for (var i = Group.selected.ik_chain_length; i > 0; i--) {
bone = bone.parent;
if (bone instanceof Group) {
var animator = Animator.selected.getBoneAnimator(bone);
var animator = Animation.selected.getBoneAnimator(bone);
animator.addToTimeline();
var {before, result} = animator.getOrMakeKeyframe('rotation');
scope.keyframes[i-1] = result;
@ -1346,7 +1346,7 @@
}
} else if (Modes.animate) {
if (!Animator.selected) {
if (!Animation.selected) {
Blockbench.showQuickMessage('message.no_animation_selected')
}
if (Toolbox.selected.id === 'rotate_tool') {
@ -1367,7 +1367,7 @@
originalValue = value;
}
if (value !== previousValue && Animator.selected && Animator.selected.getBoneAnimator()) {
if (value !== previousValue && Animation.selected && Animation.selected.getBoneAnimator()) {
beforeFirstChange(event)
var difference = value - (previousValue||0)
if (Toolbox.selected.id === 'rotate_tool' && Math.abs(difference) > 120) {
@ -1399,7 +1399,7 @@
var keyframe = scope.keyframes[i];
if (keyframe) {
var bone = copy_bone.original;
var animator = Animator.selected.getBoneAnimator(bone);
var animator = Animation.selected.getBoneAnimator(bone);
keyframe.offset('x', Math.radToDeg(copy_bone.last_rotation.x - copy_bone.rotation.x));
keyframe.offset('y', Math.radToDeg(copy_bone.last_rotation.y - copy_bone.rotation.y));

View File

@ -65,7 +65,7 @@ var Undo = {
if (!arr || arr.length == 0) return;
if (!Undo.current_save.keyframes) {
Undo.current_save.keyframes = {
animation: Animator.selected.uuid
animation: Animation.selected.uuid
}
}
arr.forEach(kf => {
@ -192,9 +192,9 @@ var Undo = {
scope.animations[a.uuid] = a.getUndoCopy();
})
}
if (aspects.keyframes && Animator.selected && Timeline.animators.length) {
if (aspects.keyframes && Animation.selected && Timeline.animators.length) {
this.keyframes = {
animation: Animator.selected.uuid
animation: Animation.selected.uuid
}
aspects.keyframes.forEach(kf => {
scope.keyframes[kf.uuid] = kf.getUndoCopy()
@ -385,7 +385,7 @@ var Undo = {
}
if (save.keyframes) {
var animation = Animator.selected;
var animation = Animation.selected;
if (!animation || animation.uuid !== save.keyframes.animation) {
animation = Animator.animations.findInArray('uuid', save.keyframes.animation)
if (animation.select && Animator.open && is_session) {