From e08491f22fb7b8549c507d73a040e5dfe6a8b492 Mon Sep 17 00:00:00 2001 From: Caio Raphael Date: Thu, 18 Jul 2024 12:14:47 -0300 Subject: [PATCH] UV Overlay tool rework (part 2), with small revert from 'part 1' --- 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 +- lang/vi.json | 2 +- lang/zh.json | 2 +- lang/zh_tw.json | 2 +- 19 files changed, 65 insertions(+), 31 deletions(-) diff --git a/js/interface/settings.js b/js/interface/settings.js index b499392f..73d6a239 100644 --- a/js/interface/settings.js +++ b/js/interface/settings.js @@ -534,8 +534,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 5c932fa2..916ec34d 100644 --- a/js/texturing/uv.js +++ b/js/texturing/uv.js @@ -1314,16 +1314,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(); + } } }}) }}, @@ -1349,6 +1358,7 @@ const UVEditor = { 'uv_maximize', 'uv_auto', 'uv_rel_auto', + 'unwrap_mesh_faces', 'uv_project_from_view', 'connect_uv_faces', 'merge_uv_vertices', @@ -1589,7 +1599,7 @@ BARS.defineActions(function() { } }) new Action('unwrap_mesh_faces', { - icon: 'view_in_ar', + icon: 'map', category: 'uv', condition: () => Mesh.selected.length, click() { @@ -2014,24 +2024,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', { @@ -3285,10 +3306,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 []; } @@ -4197,11 +4222,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()}) } @@ -4335,5 +4360,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 4382f2d4..b411bcd7 100644 --- a/lang/cz.json +++ b/lang/cz.json @@ -1407,7 +1407,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 c6536b79..0145af89 100644 --- a/lang/de.json +++ b/lang/de.json @@ -1407,7 +1407,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 5c9c0217..b69879f1 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1741,7 +1741,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 edc5b706..c5bac02a 100644 --- a/lang/es.json +++ b/lang/es.json @@ -1407,7 +1407,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 26e888e3..fb93c5cb 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -1407,7 +1407,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 dfdbf9cc..dca9355d 100644 --- a/lang/it.json +++ b/lang/it.json @@ -1407,7 +1407,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 131c7c5c..75a3b0e6 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -1407,7 +1407,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 91b6f1f6..698fa375 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -1407,7 +1407,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 8e07ede9..c78efaef 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -1407,7 +1407,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 dfc0748b..1d032c11 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -1407,7 +1407,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 cf73badc..c0089263 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -1408,7 +1408,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 91925ab6..ab2671b9 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -1407,7 +1407,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 7f442d7a..e8f3361e 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -1407,7 +1407,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 85c49213..f9391a8f 100644 --- a/lang/uk.json +++ b/lang/uk.json @@ -1407,7 +1407,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.", diff --git a/lang/vi.json b/lang/vi.json index 41f84fcb..a61fdc7f 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -1407,7 +1407,7 @@ "action.new_window.desc": "Mở một cửa sổ Blockbench mới", "action.export_collada": "Xuất mô hình Collada (dae)", "action.export_collada.desc": "Xuất mô hình và hoạt ảnh dưới dạng tệp dae để sử dụng nó trong các ứng dụng 3D khác", - "action.paint_mode_uv_overlay": "UV Show All", + "action.paint_mode_uv_overlay": "UV Show in Paint Mode", "action.paint_mode_uv_overlay.desc": "Hiển thị bản đồ UV dưới dạng lớp phủ trong chế độ sơn", "action.bake_animation_into_model": "Đưa hoạt ảnh vào mô hình", "action.bake_animation_into_model.desc": "Đưa khung hoạt ảnh hiện đang hiển thị vào mô hình. Chỉ áp dụng xoay và vị trí, bỏ qua tỷ lệ.", diff --git a/lang/zh.json b/lang/zh.json index 91b6148e..650e167b 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -1407,7 +1407,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/zh_tw.json b/lang/zh_tw.json index b27d6abb..b2715a61 100644 --- a/lang/zh_tw.json +++ b/lang/zh_tw.json @@ -1407,7 +1407,7 @@ "action.new_window.desc": "開啟新Blockbench視窗", "action.export_collada": "匯出為Collada Model (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": "將目前的動畫關鍵影格烘焙至模型上。僅包含旋轉和位置,不包含比例。",