From 18d6a7bf91b4eda23854119e344e7c96c5e42974 Mon Sep 17 00:00:00 2001 From: Caio Raphael Date: Fri, 27 Sep 2024 00:08:33 -0300 Subject: [PATCH] UV Overlay tool rework (part 2), with small revert from 'part 1' # Conflicts: # lang/vi.json # lang/zh.json # lang/zh_tw.json --- js/interface/settings.js | 9 +++++++ js/texturing/uv.js | 52 +++++++++++++++++++++++++++++----------- lang/cz.json | 2 +- lang/de.json | 2 +- lang/en.json | 3 ++- lang/es.json | 2 +- lang/fr.json | 2 +- lang/it.json | 2 +- lang/ja.json | 2 +- lang/ko.json | 2 +- lang/nl.json | 2 +- lang/pl.json | 2 +- lang/pt.json | 2 +- lang/ru.json | 2 +- lang/sv.json | 2 +- lang/uk.json | 2 +- 16 files changed, 62 insertions(+), 28 deletions(-) diff --git a/js/interface/settings.js b/js/interface/settings.js index d7e048cb..9a6e9a61 100644 --- a/js/interface/settings.js +++ b/js/interface/settings.js @@ -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'}); diff --git a/js/texturing/uv.js b/js/texturing/uv.js index 52bd936a..4983e545 100644 --- a/js/texturing/uv.js +++ b/js/texturing/uv.js @@ -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(); + } } }}) }}, @@ -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', @@ -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() { @@ -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', { @@ -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 []; } @@ -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()}) } @@ -4511,5 +4536,4 @@ Interface.definePanels(function() { onAfter }).toElement(slider_bar); - BarItems.edit_mode_uv_overlay.toElement(slider_bar); }) diff --git a/lang/cz.json b/lang/cz.json index 35e00b37..f8329955 100644 --- a/lang/cz.json +++ b/lang/cz.json @@ -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.", diff --git a/lang/de.json b/lang/de.json index 3db94ee4..97e45bf9 100644 --- a/lang/de.json +++ b/lang/de.json @@ -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", diff --git a/lang/en.json b/lang/en.json index 25be2867..fc4cca47 100644 --- a/lang/en.json +++ b/lang/en.json @@ -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", diff --git a/lang/es.json b/lang/es.json index 9480e985..b147f36a 100644 --- a/lang/es.json +++ b/lang/es.json @@ -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.", diff --git a/lang/fr.json b/lang/fr.json index 830fb98e..e70d754e 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -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.", diff --git a/lang/it.json b/lang/it.json index aa063a74..175a16d6 100644 --- a/lang/it.json +++ b/lang/it.json @@ -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.", diff --git a/lang/ja.json b/lang/ja.json index 9ac1cc69..ba70955a 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -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": "現在表示されているアニメーションフレームをモデルにベイク処理します。回転と位置のみを適用し、スケールは無視されます。", diff --git a/lang/ko.json b/lang/ko.json index 59380890..e2e2cf12 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -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": "현재 표시된 애니메이션 프레임을 모델로 만듭니다. 회전 및 위치만 적용하고 크기는 무시됩니다.", diff --git a/lang/nl.json b/lang/nl.json index 5d29a9c7..44cf3f50 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -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.", diff --git a/lang/pl.json b/lang/pl.json index d1ad536a..28980c92 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -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.", diff --git a/lang/pt.json b/lang/pt.json index 4d128e2a..695c248f 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -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.", diff --git a/lang/ru.json b/lang/ru.json index 5256b039..9c7ce9d7 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -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": "Запеките текущий отображаемый кадр анимации в модель. Применяется только вращение и положение, масштаб игнорируется.", diff --git a/lang/sv.json b/lang/sv.json index 92b36a3c..cc7f6a44 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -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.", diff --git a/lang/uk.json b/lang/uk.json index 491a4aec..b4fa395c 100644 --- a/lang/uk.json +++ b/lang/uk.json @@ -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.",