Skip to content

Commit

Permalink
UV Overlay tool rework (part 2), with small revert from 'part 1'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lang/vi.json
#	lang/zh.json
#	lang/zh_tw.json
  • Loading branch information
caioraphael1 committed Sep 29, 2024
1 parent bfe956c commit 18d6a7b
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 28 deletions.
9 changes: 9 additions & 0 deletions js/interface/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,17 @@ const Settings = {
new Setting('display_uv', {category: 'defaults', value: 'none', type: 'select', description: '', options: {
'selected_faces': tl('menu.uv.display_uv.selected_faces'),
'selected_elements': tl('menu.uv.display_uv.selected_elements'),
'all_elements': tl('menu.uv.display_uv.all_elements'),
}, onChange(value) {
Project.display_uv = UVEditor.vue.display_uv = value;
// Affect other tools.
BarItems.edit_mode_uv_overlay.value = value == 'all_elements';
BarItems.edit_mode_uv_overlay.updateEnabledState();
if (BarItems.paint_mode_uv_overlay.value && value == 'selected_faces') {
UVEditor.vue.uv_overlay = false;
BarItems.paint_mode_uv_overlay.value = false;
BarItems.paint_mode_uv_overlay.updateEnabledState();
}
}});
new Setting('default_path', {category: 'defaults', value: false, type: 'click', condition: isApp, icon: 'burst_mode', click: function() { openDefaultTexturePath() }});
new Setting('animation_snap', {category: 'defaults', value: 24, type: 'number'});
Expand Down
52 changes: 38 additions & 14 deletions js/texturing/uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,16 +1404,25 @@ const UVEditor = {
'zoom_reset'
]},
{name: 'menu.uv.display_uv', id: 'display_uv', icon: 'visibility', condition: () => (!Format.image_editor), children: () => {
let options = ['selected_faces', 'selected_elements'];
let options = ['selected_faces', 'selected_elements', 'all_elements'];
return options.map(option => {return {
id: option,
name: `menu.uv.display_uv.${option}`,
icon: UVEditor.vue.display_uv == option ? 'far.fa-dot-circle' : 'far.fa-circle',
icon: UVEditor.vue.display_uv == option ? 'far.fa-dot-circle' : 'far.fa-circle', // Affected by current.
condition: !(option == 'selected_faces' && UVEditor.isBoxUV() && !Mesh.selected.length),
click() {
Project.display_uv = UVEditor.vue.display_uv = option;
// Affect settings.
settings.display_uv.set(option);
Settings.saveLocalStorages();
// Affect other tools.
BarItems.edit_mode_uv_overlay.value = option == 'all_elements';
BarItems.edit_mode_uv_overlay.updateEnabledState();
if (BarItems.paint_mode_uv_overlay.value && option == 'selected_faces') {
UVEditor.vue.uv_overlay = false;
BarItems.paint_mode_uv_overlay.value = false;
BarItems.paint_mode_uv_overlay.updateEnabledState();
}
}
}})
}},
Expand All @@ -1439,6 +1448,7 @@ const UVEditor = {
'uv_maximize',
'uv_auto',
'uv_rel_auto',
'unwrap_mesh_faces',
'uv_project_from_view',
'connect_uv_faces',
'merge_uv_vertices',
Expand Down Expand Up @@ -1698,7 +1708,7 @@ BARS.defineActions(function() {
}
})
new Action('unwrap_mesh_faces', {
icon: 'view_in_ar',
icon: 'map',
category: 'uv',
condition: () => Mesh.selected.length,
click() {
Expand Down Expand Up @@ -2171,24 +2181,35 @@ BARS.defineActions(function() {
value: true
})
new Toggle('edit_mode_uv_overlay', {
name: 'action.paint_mode_uv_overlay',
icon: 'stack',
category: 'uv',
condition: {modes: ['edit']},
condition: {modes: ['edit', 'paint']},
onChange(value) {
if (value) {
Project.display_uv = UVEditor.vue.display_uv = 'all_elements';
// Affect settings.
settings.display_uv.set('all_elements');
Settings.saveLocalStorages();
} else {
Project.display_uv = UVEditor.vue.display_uv = settings.display_uv.value;
Project.display_uv = UVEditor.vue.display_uv = 'selected_elements';
// Affect settings.
settings.display_uv.set('selected_elements');
Settings.saveLocalStorages();
}
}
})
new Toggle('paint_mode_uv_overlay', {
icon: 'stack',
icon: 'preview',
category: 'uv',
condition: {modes: ['paint'], method: () => !Format.image_editor},
onChange(value) {
UVEditor.vue.uv_overlay = value;
if (value && UVEditor.vue.display_uv == 'selected_faces') {
Project.display_uv = UVEditor.vue.display_uv = 'selected_elements';
// Affect settings.
settings.display_uv.set('selected_elements');
Settings.saveLocalStorages();
}
}
})
new Toggle('move_texture_with_uv', {
Expand Down Expand Up @@ -3455,10 +3476,14 @@ Interface.definePanels(function() {
}
},
getDisplayedUVElements() {
if (this.mode == 'uv' || this.uv_overlay) {
return (this.display_uv === 'all_elements' || this.mode == 'paint')
? this.all_mappable_elements
: this.mappable_elements;
if (this.mode == 'uv') {
return (this.display_uv === 'all_elements')
? this.all_mappable_elements
: this.mappable_elements;
} else if (this.mode == 'paint' && this.uv_overlay) {
return (this.display_uv === 'all_elements')
? this.all_mappable_elements
: this.mappable_elements;
} else {
return [];
}
Expand Down Expand Up @@ -4373,11 +4398,11 @@ Interface.definePanels(function() {

Toolbars.uv_editor.toPlace()

// Force show tool in the 'locked toolbar'.
BarItems.paint_mode_uv_overlay.toElement('#toggle_uv_overlay_anchor');
BarItems.edit_mode_uv_overlay.toElement('#toggle_edit_uv_overlay_anchor');

let {slider_bar} = UVEditor.vue.$refs;

let {slider_bar} = UVEditor.vue.$refs;
var onBefore = function() {
Undo.initEdit({elements: UVEditor.getMappableElements()})
}
Expand Down Expand Up @@ -4511,5 +4536,4 @@ Interface.definePanels(function() {
onAfter

}).toElement(slider_bar);
BarItems.edit_mode_uv_overlay.toElement(slider_bar);
})
2 changes: 1 addition & 1 deletion lang/cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Opens a new Blockbench window",
"action.export_collada": "Export Collada Model (dae)",
"action.export_collada.desc": "Export model and animations as dae file to use it in other 3D applications",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down
2 changes: 1 addition & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Öffnet ein neues Blockbench-Fenster",
"action.export_collada": "Collada-Modell (dae) exportieren",
"action.export_collada.desc": "Exportiert das Modell als dae-Datei zur Weiterverwendung in anderen 3D-Programmen",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Überlagert die UV-Maps der Elemente im Malen-Modus",
"action.bake_animation_into_model": "Animationen auf Modell anwenden",
"action.bake_animation_into_model.desc": "Wendet die aktuell angezeigte Animation auf das Modell an. Nur Position und Drehung werden verwendet, Größe wird ignoriert",
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,8 @@
"action.uv_cycle.desc": "Cycle through the order of UV vertices without changing the UV positions",
"action.uv_cycle_invert": "Cycle Invert UV",
"action.uv_cycle_invert.desc": "Reverse the order of UV vertices without changing the UV positions",
"action.paint_mode_uv_overlay": "UV Show All",
"action.edit_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.snap_uv_to_image_bounds": "Snap UV to image bounds",
"action.remove_blank_faces": "Remove Blank Faces",
Expand Down
2 changes: 1 addition & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Abrir una nueva ventana en Blockbench",
"action.export_collada": "Exportar modelo Collada (dae)",
"action.export_collada.desc": "Exportar modelo y animaciones como archivo dae para usarlo en otras aplicaciones 3D",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Muestra el mapa UV como una superposición en el modo de pintura",
"action.bake_animation_into_model": "Hornear animación en modelo",
"action.bake_animation_into_model.desc": "Hornea la animación mostrada actualmente al modelo. Solo aplica a la rotación y la posición, se ignora la escala.",
Expand Down
2 changes: 1 addition & 1 deletion lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Ouvre une nouvelle fenêtre Blockbench",
"action.export_collada": "Exporter modèle Collada (dae)",
"action.export_collada.desc": "Exporte le modèle et les animations dans un fichier dae pour l'utiliser dans d'autres logiciels 3D",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Affiche la carte UV sous forme d'overlay en mode Dessin",
"action.bake_animation_into_model": "Intégrer l'animation au modèle",
"action.bake_animation_into_model.desc": "Intègre l'image d'animation actuellement affichée au modèle. Seules la rotation et la position s'appliquent, la mise à l'échelle est ignorée.",
Expand Down
2 changes: 1 addition & 1 deletion lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Opens a new Blockbench window",
"action.export_collada": "Export Collada Model (dae)",
"action.export_collada.desc": "Export model and animations as dae file to use it in other 3D applications",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down
2 changes: 1 addition & 1 deletion lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "新しい Blockbench ウィンドウを開きます",
"action.export_collada": "Collada Model (dae)",
"action.export_collada.desc": "モデルとアニメーションを dae ファイルとして書き出します",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "ペイントモードで UV マップをオーバーレイとして表示します",
"action.bake_animation_into_model": "アニメーションをモデルに焼き付ける",
"action.bake_animation_into_model.desc": "現在表示されているアニメーションフレームをモデルにベイク処理します。回転と位置のみを適用し、スケールは無視されます。",
Expand Down
2 changes: 1 addition & 1 deletion lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "새로운 Blockbench 창 열기",
"action.export_collada": "Collada 모델 (dae) 내보내기",
"action.export_collada.desc": "모델 및 애니메이션을 dae 파일로 내보내서 다른 3D 응용 프로그램에서 사용",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "페인트 모드에서 UV 맵을 오버레이로 표시",
"action.bake_animation_into_model": "애니메이션을 모델로 만들기",
"action.bake_animation_into_model.desc": "현재 표시된 애니메이션 프레임을 모델로 만듭니다. 회전 및 위치만 적용하고 크기는 무시됩니다.",
Expand Down
2 changes: 1 addition & 1 deletion lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Opent een nieuw Blockbench venster",
"action.export_collada": "Exporteer Collada Model (dae)",
"action.export_collada.desc": "Exporteer modellen en animaties als .dae-bestand voor gebruik in andere 3D-applicaties",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "De UV-map weergeven als een overlay in verfmodus",
"action.bake_animation_into_model": "Bak Animatie in Model",
"action.bake_animation_into_model.desc": "Bak het huidig weergegeven animatieframe in het model. Past alleen rotatie en positie toe, schaal wordt genegeerd.",
Expand Down
2 changes: 1 addition & 1 deletion lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Otwiera nowe okno Blockbencha",
"action.export_collada": "Eksportuj model Collada (dae)",
"action.export_collada.desc": "Eksportuj model i animacje jako plik dae, aby używać ich w innych programach 3D",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down
2 changes: 1 addition & 1 deletion lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@
"action.new_window.desc": "abrir nova aba do blockbench",
"action.export_collada": "exportar collada modelo (dae)",
"action.export_collada.desc": "exportar collada modelo (dae) para usar em outras aplicações",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down
2 changes: 1 addition & 1 deletion lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Открывает новое окно Blockbench",
"action.export_collada": "Экспортировать Collada модель (dae)",
"action.export_collada.desc": "Экспортировать модель или анимацию в dae файл, что бы использовать в других редакторах 3D",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Отображение UV-карты в виде наложения в режиме рисования",
"action.bake_animation_into_model": "Запечь анимацию в модель",
"action.bake_animation_into_model.desc": "Запеките текущий отображаемый кадр анимации в модель. Применяется только вращение и положение, масштаб игнорируется.",
Expand Down
2 changes: 1 addition & 1 deletion lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Opens a new Blockbench window",
"action.export_collada": "Export Collada Model (dae)",
"action.export_collada.desc": "Export model and animations as dae file to use it in other 3D applications",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Display the UV map as an overlay in paint mode",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down
2 changes: 1 addition & 1 deletion lang/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"action.new_window.desc": "Відкриває нове вікно Blockbench",
"action.export_collada": "Експортувати модель Collada (DAE)",
"action.export_collada.desc": "Експортувати модель і анімацію як файл DAE, щоб використовувати його в інших 3D-застосунках",
"action.paint_mode_uv_overlay": "UV Show All",
"action.paint_mode_uv_overlay": "UV Show in Paint Mode",
"action.paint_mode_uv_overlay.desc": "Показати мапу UV як накладання в режимі малювання",
"action.bake_animation_into_model": "Bake Animation into Model",
"action.bake_animation_into_model.desc": "Bake the currently displayed animation frame into the model. Only applies rotation and position, scale is ignored.",
Expand Down

0 comments on commit 18d6a7b

Please sign in to comment.