From 0b124dc8a02c94eed5430d839f833a29055b6454 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Fri, 26 May 2023 23:47:52 +0200 Subject: [PATCH] Add option to duplicate texture --- js/interface/actions.js | 16 ++++++++++++++-- js/texturing/textures.js | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/js/interface/actions.js b/js/interface/actions.js index ef44d43a..9fa8c0ad 100644 --- a/js/interface/actions.js +++ b/js/interface/actions.js @@ -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}); diff --git a/js/texturing/textures.js b/js/texturing/textures.js index ff09402a..8fc86b32 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -1514,6 +1514,9 @@ class Texture { } }, '_', + 'copy', + 'duplicate', + '_', { icon: 'edit', name: 'menu.texture.edit_externally',