Fix #1276 Button removes wrong data point

Fix #1275 new-line character in empty keyframe script fields
Fix gizmo not disappearing after unselecting
Resizing textures with multiple face-uv textures now adjusts mapping correctly
This commit is contained in:
JannisX11 2022-02-05 15:39:11 +01:00
parent 8eb959e660
commit b77ba2e90a
4 changed files with 51 additions and 7 deletions

View File

@ -267,12 +267,14 @@ class Keyframe {
scripts.push(...data_point.script.split('\n'));
}
})
scripts = scripts.filter(script => !!script.replace(/[\n\s;.]+/g, ''))
return scripts.length <= 1 ? scripts[0] : scripts;
} else {
let points = [];
this.data_points.forEach(data_point => {
if (data_point.effect) {
let script = data_point.script || undefined;
if (script && !script.replace(/[\n\s;.]+/g, '')) script = undefined;
if (script && !script.match(/;$/)) script += ';';
points.push({
effect: data_point.effect,
@ -980,11 +982,11 @@ Interface.definePanels(function() {
Animator.preview()
Undo.finishEdit('Add keyframe data point')
},
removeDataPoint(data_point) {
removeDataPoint(data_point_index) {
Undo.initEdit({keyframes: Timeline.selected})
Timeline.selected.forEach(kf => {
if (kf.data_points.length >= 2) {
kf.data_points.splice(data_point, 1);
kf.data_points.splice(data_point_index, 1);
}
})
Animator.preview()
@ -1045,7 +1047,7 @@ Interface.definePanels(function() {
<div class="keyframe_data_point_header" v-if="keyframes[0].data_points.length > 1">
<label>{{ keyframes[0].transform ? tl('panel.keyframe.' + (data_point_i ? 'post' : 'pre')) : (data_point_i + 1) }}</label>
<div class="flex_fill_line"></div>
<div class="in_list_button" v-on:click.stop="removeDataPoint(data_point)" title="${ tl('panel.keyframe.remove_data_point') }">
<div class="in_list_button" v-on:click.stop="removeDataPoint(data_point_i)" title="${ tl('panel.keyframe.remove_data_point') }">
<i class="material-icons">clear</i>
</div>
</div>

View File

@ -768,6 +768,7 @@
} else if (Group.selected && getRotationObject() == Group.selected) {
scope.attach(Group.selected)
} else {
this.update()
return this;
}
}

View File

@ -18,7 +18,7 @@ const Painter = {
var instance = Painter.current[options.method === 'jimp' ? 'image' : 'canvas']
Painter.current[options.method === 'jimp' ? 'canvas' : 'image'] = undefined
var edit_name = options.no_undo ? null : (options.edit_name || 'edit texture');
var edit_name = options.no_undo ? null : (options.edit_name || 'Edit texture');
if (options.use_cache &&
texture === Painter.current.texture &&

View File

@ -861,6 +861,22 @@ class Texture {
let old_width = scope.width;
let old_height = scope.height;
let elements_to_change = null;
if (formResult.fill !== 'stretch' && Texture.length >= 2 && !Format.single_texture) {
let elements = [...Cube.all, ...Mesh.all].filter(el => {
for (let fkey in el.faces) {
if (el.faces[fkey].texture == scope.uuid) return true;
}
})
if (elements.length) elements_to_change = elements;
}
Undo.initEdit({
textures: [scope],
bitmap: true,
elements: elements_to_change,
uv_only: true
})
scope.edit((canvas) => {
@ -907,13 +923,38 @@ class Texture {
Project.texture_width = Project.texture_width * (formResult.size[0] / old_width);
Project.texture_height = Project.texture_height * (formResult.size[1] / old_height);
Canvas.updateAllUVs()
} else if (formResult.fill !== 'stretch' && Texture.length >= 2 && elements_to_change) {
elements_to_change.forEach(element => {
if (element instanceof Cube) {
for (var key in element.faces) {
if (element.faces[key].texture !== scope.uuid) continue;
var uv = element.faces[key].uv;
uv[0] /= formResult.size[0] / old_width;
uv[2] /= formResult.size[0] / old_width;
uv[1] /= formResult.size[1] / old_height;
uv[3] /= formResult.size[1] / old_height;
}
} else if (element instanceof Mesh) {
for (var key in element.faces) {
if (element.faces[key].texture !== scope.uuid) continue;
var uv = element.faces[key].uv;
for (let vkey in uv) {
uv[vkey][0] /= formResult.size[0] / old_width;
uv[vkey][1] /= formResult.size[1] / old_height;
}
}
}
})
Canvas.updateView({elements: elements_to_change, element_aspects: {uv: true}})
}
return new_canvas
})
setTimeout(updateSelection, 100);
}, {no_undo: true})
dialog.hide()
Undo.finishEdit('Resize texture');
setTimeout(updateSelection, 100);
}
})
dialog.show()