From 9b078273dceb32f1fa7e142117acd84c18b716a1 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Wed, 30 Dec 2020 22:30:43 +0100 Subject: [PATCH] Apply "Rename new cube" setting to all elements --- js/outliner/cube.js | 1 - js/outliner/group.js | 63 ++++++++++++++++++++---------------------- js/outliner/locator.js | 5 ++++ 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/js/outliner/cube.js b/js/outliner/cube.js index ac9ea3ce..7b0f2788 100644 --- a/js/outliner/cube.js +++ b/js/outliner/cube.js @@ -857,7 +857,6 @@ BARS.defineActions(function() { Blockbench.dispatchEvent( 'add_cube', {object: base_cube} ) Vue.nextTick(function() { - updateSelection() if (settings.create_rename.value) { base_cube.rename() } diff --git a/js/outliner/group.js b/js/outliner/group.js index 0479087d..a91226f5 100644 --- a/js/outliner/group.js +++ b/js/outliner/group.js @@ -500,38 +500,6 @@ function getAllGroups() { iterate(Outliner.root) return ta; } -function addGroup() { - Undo.initEdit({outliner: true}); - var add_group = Group.selected - if (!add_group && selected.length) { - add_group = Cube.selected.last() - } - var base_group = new Group({ - origin: add_group ? add_group.origin : undefined - }) - base_group.addTo(add_group) - base_group.isOpen = true - - if (Format.bone_rig) { - base_group.createUniqueName() - } - if (add_group instanceof NonGroup && selected.length > 1) { - selected.forEach(function(s, i) { - s.addTo(base_group) - }) - } - base_group.init().select() - Undo.finishEdit('add_group'); - loadOutlinerDraggable() - Vue.nextTick(function() { - updateSelection() - if (settings.create_rename.value) { - base_group.rename() - } - base_group.showInOutliner() - Blockbench.dispatchEvent( 'add_group', {object: base_group} ) - }) -} window.__defineGetter__('selected_group', () => { console.warn('selected_group is deprecated. Please use Group.selected instead.') return Group.selected @@ -545,7 +513,36 @@ BARS.defineActions(function() { condition: () => Modes.edit, keybind: new Keybind({key: 71, ctrl: true}), click: function () { - addGroup(); + Undo.initEdit({outliner: true}); + var add_group = Group.selected + if (!add_group && selected.length) { + add_group = Cube.selected.last() + } + var base_group = new Group({ + origin: add_group ? add_group.origin : undefined + }) + base_group.addTo(add_group) + base_group.isOpen = true + + if (Format.bone_rig) { + base_group.createUniqueName() + } + if (add_group instanceof NonGroup && selected.length > 1) { + selected.forEach(function(s, i) { + s.addTo(base_group) + }) + } + base_group.init().select() + Undo.finishEdit('add_group'); + loadOutlinerDraggable() + Vue.nextTick(function() { + updateSelection() + if (settings.create_rename.value) { + base_group.rename() + } + base_group.showInOutliner() + Blockbench.dispatchEvent( 'add_group', {object: base_group} ) + }) } }) new Action({ diff --git a/js/outliner/locator.js b/js/outliner/locator.js index e59d63c5..5950c8b4 100644 --- a/js/outliner/locator.js +++ b/js/outliner/locator.js @@ -107,6 +107,11 @@ BARS.defineActions(function() { locator.select().createUniqueName(); objs.push(locator); Undo.finishEdit('add locator'); + Vue.nextTick(function() { + if (settings.create_rename.value) { + locator.rename(); + } + }) } }) })