From eaab6eb3054a83e0f0a03b7b0537d4c845ce2840 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Wed, 8 May 2024 20:22:02 +0200 Subject: [PATCH] Change labels of "Use as particle" and "use as default" when already enabled Allow context menu entries to be functions --- js/interface/menu.js | 3 +++ js/texturing/textures.js | 12 ++++++------ lang/en.json | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/js/interface/menu.js b/js/interface/menu.js index 5d935f07..9b5d9ab0 100644 --- a/js/interface/menu.js +++ b/js/interface/menu.js @@ -313,6 +313,9 @@ class Menu { if (typeof s == 'string' && BarItems[s]) { s = BarItems[s]; } + if (typeof s === 'function') { + s = s(scope_context); + } if (!Condition(s.condition, scope_context)) return; if (s instanceof Action) { diff --git a/js/texturing/textures.js b/js/texturing/textures.js index ae87793e..2a47bdda 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -1785,9 +1785,9 @@ class Texture { } Texture.prototype.menu = new Menu([ new MenuSeparator('apply'), - { + tex => ({ icon: 'star', - name: 'menu.texture.use_as_default', + name: tex.use_as_default ? 'menu.texture.use_as_default.clear' : 'menu.texture.use_as_default', condition: {features: ['single_texture_default']}, click(texture) { if (texture.use_as_default) { @@ -1796,7 +1796,7 @@ class Texture { texture.setAsDefaultTexture(); } } - }, + }), { icon: 'crop_original', name: 'menu.texture.face', @@ -1815,9 +1815,9 @@ class Texture { condition() {return !Format.single_texture && Outliner.selected.length > 0}, click(texture) {texture.apply(true)} }, - { + tex => ({ icon: 'bubble_chart', - name: 'menu.texture.particle', + name: tex.particle ? 'menu.texture.particle.clear' : 'menu.texture.particle', condition: {features: ['select_texture_for_particles']}, click(texture) { if (texture.particle) { @@ -1826,7 +1826,7 @@ class Texture { texture.enableParticle() } } - }, + }), new MenuSeparator('settings'), { icon: 'list', diff --git a/lang/en.json b/lang/en.json index a4f072c8..90dbcf4c 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1999,7 +1999,9 @@ "menu.texture.edit_externally": "Edit Externally", "menu.texture.edit_in_blockbench": "Edit in Blockbench", "menu.texture.particle": "Use for Particles", + "menu.texture.particle.clear": "Stop using for Particles", "menu.texture.use_as_default": "Set as Default", + "menu.texture.use_as_default.clear": "Unassign as Default", "menu.texture.export": "Save As", "menu.texture.save": "Save", "menu.texture.properties": "Properties...",