Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "Randomize Marker Color" option from #2210 #2333

Merged
25 changes: 25 additions & 0 deletions js/interface/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,31 @@ const BARS = {
modes: ['edit'],
keybind: new Keybind({key: 's', alt: true}),
})
new Action('randomize_marker_colors', {
icon: 'fa-shuffle',
category: 'edit',
condition: {modes: ['edit' ], project: true},
click: function() {
let randomColor = function() { return Math.floor(Math.random() * markerColors.length)}
let elements = Outliner.selected.filter(element => element.setColor)
Undo.initEdit({outliner: true, elements: elements, selection: true})
Group.all.forEach(group => {
if (group.selected) {
let lastColor = group.color
// Ensure chosen group color is never the same as before
do group.color = randomColor();
while (group.color === lastColor)
}
})
elements.forEach(element => {
let lastColor = element.color
// Ensure chosen element color is never the same as before
do element.setColor(randomColor())
while (element.color === lastColor)
})
Undo.finishEdit('Change marker color')
}
})

//File
new Action('new_window', {
Expand Down
1 change: 1 addition & 0 deletions js/outliner/cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ class Cube extends OutlinerElement {
}
}});
}},
"randomize_marker_colors",
{name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture && !Format.per_group_texture, children: function() {
var arr = [
{icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(cube) {
Expand Down
1 change: 1 addition & 0 deletions js/outliner/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class Group extends OutlinerNode {
}
}})
}},
"randomize_marker_colors",
{name: 'menu.cube.texture', icon: 'collections', condition: () => Format.per_group_texture, children() {
function applyTexture(texture_value, undo_message) {
let affected_groups = Group.all.filter(g => g.selected);
Expand Down
1 change: 1 addition & 0 deletions js/outliner/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ class Mesh extends OutlinerElement {
}
}})
}},
"randomize_marker_colors",
{name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture, children() {
var arr = [
{icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(mesh) {
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@
"action.cube_counter.desc": "Displays the current number of elements and other statistics",
"action.search_outliner": "Search Outliner",
"action.search_outliner.desc": "Search for specific element names in the outliner",
"action.randomize_marker_colors": "Randomize Marker Colors",

"action.duplicate": "Duplicate",
"action.duplicate.desc": "Duplicates the selected elements or group",
Expand Down