Change labels of "Use as particle" and "use as default" when already enabled

Allow context menu entries to be functions
This commit is contained in:
JannisX11 2024-05-08 20:22:02 +02:00
parent 7d9e214b8c
commit eaab6eb305
3 changed files with 11 additions and 6 deletions

View File

@ -313,6 +313,9 @@ class Menu {
if (typeof s == 'string' && BarItems[s]) { if (typeof s == 'string' && BarItems[s]) {
s = BarItems[s]; s = BarItems[s];
} }
if (typeof s === 'function') {
s = s(scope_context);
}
if (!Condition(s.condition, scope_context)) return; if (!Condition(s.condition, scope_context)) return;
if (s instanceof Action) { if (s instanceof Action) {

View File

@ -1785,9 +1785,9 @@ class Texture {
} }
Texture.prototype.menu = new Menu([ Texture.prototype.menu = new Menu([
new MenuSeparator('apply'), new MenuSeparator('apply'),
{ tex => ({
icon: 'star', 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']}, condition: {features: ['single_texture_default']},
click(texture) { click(texture) {
if (texture.use_as_default) { if (texture.use_as_default) {
@ -1796,7 +1796,7 @@ class Texture {
texture.setAsDefaultTexture(); texture.setAsDefaultTexture();
} }
} }
}, }),
{ {
icon: 'crop_original', icon: 'crop_original',
name: 'menu.texture.face', name: 'menu.texture.face',
@ -1815,9 +1815,9 @@ class Texture {
condition() {return !Format.single_texture && Outliner.selected.length > 0}, condition() {return !Format.single_texture && Outliner.selected.length > 0},
click(texture) {texture.apply(true)} click(texture) {texture.apply(true)}
}, },
{ tex => ({
icon: 'bubble_chart', icon: 'bubble_chart',
name: 'menu.texture.particle', name: tex.particle ? 'menu.texture.particle.clear' : 'menu.texture.particle',
condition: {features: ['select_texture_for_particles']}, condition: {features: ['select_texture_for_particles']},
click(texture) { click(texture) {
if (texture.particle) { if (texture.particle) {
@ -1826,7 +1826,7 @@ class Texture {
texture.enableParticle() texture.enableParticle()
} }
} }
}, }),
new MenuSeparator('settings'), new MenuSeparator('settings'),
{ {
icon: 'list', icon: 'list',

View File

@ -1999,7 +1999,9 @@
"menu.texture.edit_externally": "Edit Externally", "menu.texture.edit_externally": "Edit Externally",
"menu.texture.edit_in_blockbench": "Edit in Blockbench", "menu.texture.edit_in_blockbench": "Edit in Blockbench",
"menu.texture.particle": "Use for Particles", "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": "Set as Default",
"menu.texture.use_as_default.clear": "Unassign as Default",
"menu.texture.export": "Save As", "menu.texture.export": "Save As",
"menu.texture.save": "Save", "menu.texture.save": "Save",
"menu.texture.properties": "Properties...", "menu.texture.properties": "Properties...",