Add option to duplicate texture

This commit is contained in:
JannisX11 2023-05-26 23:47:52 +02:00
parent dc7f4b3ffc
commit 0b124dc8a0
2 changed files with 17 additions and 2 deletions

View File

@ -1981,9 +1981,13 @@ const BARS = {
new Action('duplicate', {
icon: 'content_copy',
category: 'edit',
condition: () => (AnimationItem.selected && Modes.animate && ['animations', 'animation_controllers'].includes(Prop.active_panel)) || (Modes.edit && (selected.length || Group.selected)),
condition: () => {
return (AnimationItem.selected && Modes.animate && ['animations', 'animation_controllers'].includes(Prop.active_panel))
|| (Prop.active_panel == 'textures' && Texture.selected)
|| (Modes.edit && (selected.length || Group.selected));
},
keybind: new Keybind({key: 'd', ctrl: true}),
click: function () {
click() {
if (Modes.animate) {
if (Animation.selected && Prop.active_panel == 'animations') {
var copy = Animation.selected.getUndoCopy();
@ -2012,6 +2016,14 @@ const BARS = {
Undo.finishEdit('Duplicate animation controller state');
}
} else if (Prop.active_panel == 'textures' && Texture.selected) {
let copy = Texture.selected.getUndoCopy();
delete copy.path;
copy.mode = 'bitmap';
copy.saved = false;
copy.source = 'data:image/png;base64,'+Texture.selected.getBase64();
new Texture(copy).fillParticle().load().add(true);
} else if (Group.selected && (Group.selected.matchesSelection() || selected.length === 0)) {
var cubes_before = elements.length;
Undo.initEdit({outliner: true, elements: [], selection: true});

View File

@ -1514,6 +1514,9 @@ class Texture {
}
},
'_',
'copy',
'duplicate',
'_',
{
icon: 'edit',
name: 'menu.texture.edit_externally',