mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-30 15:42:42 +08:00
Update Select Image Editor dialog
Add missing select dropdown class
This commit is contained in:
parent
8178e8939d
commit
ca09cf3d3b
@ -319,66 +319,62 @@ currentwindow.on('leave-full-screen', e => updateWindowState(e, 'screen'));
|
||||
currentwindow.on('ready-to-show', e => updateWindowState(e, 'load'));
|
||||
|
||||
//Image Editor
|
||||
function changeImageEditor(texture, from_settings) {
|
||||
var dialog = new Dialog({
|
||||
function changeImageEditor(texture, not_found) {
|
||||
new Dialog({
|
||||
title: tl('message.image_editor.title'),
|
||||
id: 'image_editor',
|
||||
lines: ['<div class="dialog_bar"><select class="input_wide">'+
|
||||
'<option id="ps">Photoshop</option>'+
|
||||
'<option id="gimp">Gimp</option>'+
|
||||
(Blockbench.platform == 'win32' ? '<option id="pdn">Paint.NET</option>' : '')+
|
||||
'<option id="other">'+tl('message.image_editor.file')+'</option>'+
|
||||
'</select></div>'],
|
||||
draggable: true,
|
||||
onConfirm() {
|
||||
var id = $('.dialog#image_editor option:selected').attr('id')
|
||||
var path;
|
||||
if (Blockbench.platform == 'darwin') {
|
||||
form: {
|
||||
not_found_text: {type: 'info', text: 'message.image_editor.not_found', condition: not_found == true},
|
||||
editor: {type: 'select', full_width: true, options: {
|
||||
ps: Blockbench.platform == 'win32' ? 'Photoshop' : undefined,
|
||||
gimp: 'GIMP',
|
||||
pdn: Blockbench.platform == 'win324' ? 'Paint.NET' : undefined,
|
||||
other: 'message.image_editor.file'
|
||||
}},
|
||||
file: {
|
||||
label: 'message.image_editor.file',
|
||||
nocolon: true,
|
||||
type: 'file',
|
||||
file_type: 'Program',
|
||||
extensions: ['exe', 'app', 'desktop', 'appimage'],
|
||||
description: 'message.image_editor.exe',
|
||||
condition: result => result.editor == 'other'
|
||||
}
|
||||
},
|
||||
onConfirm(result) {
|
||||
let id = result.editor;
|
||||
let path;
|
||||
if (id == 'other') {
|
||||
path = result.file;
|
||||
|
||||
} else if (Blockbench.platform == 'darwin') {
|
||||
switch (id) {
|
||||
case 'ps': path = '/Applications/Adobe Photoshop 2021/Adobe Photoshop 2021.app'; break;
|
||||
case 'ps': path = '/Applications/Adobe Photoshop 2024/Adobe Photoshop 2024.app'; break;
|
||||
case 'gimp':path = '/Applications/Gimp-2.10.app'; break;
|
||||
}
|
||||
} else if (Blockbench.platform == 'linux') {
|
||||
switch (id) {
|
||||
case 'ps': path = '/usr/share/applications//photoshop.desktop'; break;
|
||||
case 'gimp':path = '/usr/share/applications//gimp.desktop'; break;
|
||||
}
|
||||
} else {
|
||||
switch (id) {
|
||||
case 'ps': path = 'C:\\Program Files\\Adobe\\Adobe Photoshop 2021\\Photoshop.exe'; break;
|
||||
case 'ps': path = 'C:\\Program Files\\Adobe\\Adobe Photoshop 2024\\Photoshop.exe'; break;
|
||||
case 'gimp':path = 'C:\\Program Files\\GIMP 2\\bin\\gimp-2.10.exe'; break;
|
||||
case 'pdn': path = 'C:\\Program Files\\paint.net\\PaintDotNet.exe'; break;
|
||||
}
|
||||
}
|
||||
if (id === 'other') {
|
||||
selectImageEditorFile(texture)
|
||||
|
||||
} else if (path) {
|
||||
if (path && fs.existsSync(path)) {
|
||||
settings.image_editor.value = path
|
||||
if (texture) {
|
||||
texture.openEditor()
|
||||
}
|
||||
}
|
||||
dialog.hide()
|
||||
if (from_settings) {
|
||||
BarItems.settings_window.click()
|
||||
} else {
|
||||
changeImageEditor(texture, true);
|
||||
}
|
||||
},
|
||||
onCancel() {
|
||||
dialog.hide()
|
||||
if (from_settings) {
|
||||
BarItems.settings_window.click()
|
||||
}
|
||||
}
|
||||
}).show()
|
||||
}
|
||||
function selectImageEditorFile(texture) {
|
||||
let filePaths = electron.dialog.showOpenDialogSync(currentwindow, {
|
||||
title: tl('message.image_editor.exe'),
|
||||
filters: [{name: 'Executable Program', extensions: ['exe', 'app', 'desktop', 'appimage']}]
|
||||
})
|
||||
if (filePaths) {
|
||||
settings.image_editor.value = filePaths[0]
|
||||
if (texture) {
|
||||
texture.openEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Default Pack
|
||||
function openDefaultTexturePath() {
|
||||
let detail = tl('message.default_textures.detail');
|
||||
|
@ -528,7 +528,7 @@ const Settings = {
|
||||
'tilt': tl('settings.brush_modifier.tilt'),
|
||||
'none': tl('settings.brush_modifier.none'),
|
||||
}});
|
||||
new Setting('image_editor', {category: 'paint', value: false, type: 'click', condition: isApp, icon: 'fas.fa-pen-square', click: function() {changeImageEditor(null, true) }});
|
||||
new Setting('image_editor', {category: 'paint', value: false, type: 'click', condition: isApp, icon: 'fas.fa-pen-square', click: function() {changeImageEditor(null) }});
|
||||
|
||||
//Defaults
|
||||
new Setting('default_cube_size', {category: 'defaults', value: 2, type: 'number', min: 0, max: 32});
|
||||
|
@ -69,7 +69,7 @@ Vue.component('select-input', {
|
||||
}
|
||||
}
|
||||
}
|
||||
let menu = new Menu(this.id, items, {searchable: items.length > 16});
|
||||
let menu = new Menu(this.id, items, {searchable: items.length > 16, class: 'select_menu'});
|
||||
menu.node.style['min-width'] = this.$el.clientWidth+'px';
|
||||
menu.open(event.target, this);
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ class Texture {
|
||||
buttons: ['dialog.ok', 'dialog.cancel']
|
||||
}, (result) => {
|
||||
if (result == 1) return;
|
||||
selectImageEditorFile(scope)
|
||||
changeImageEditor(scope);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -313,6 +313,7 @@
|
||||
"message.image_editor.title": "Select an image editor",
|
||||
"message.image_editor.file": "Select File...",
|
||||
"message.image_editor.exe": "Select image editor executable",
|
||||
"message.image_editor.not_found": "Could not find the selected image editor. Please select a different option.",
|
||||
"message.image_editor_missing.title": "Default Image Editor",
|
||||
"message.image_editor_missing.message": "Select the executable file of your image editor.",
|
||||
"message.image_editor_missing.detail": "Blockbench couldn't find an image editor on your computer. Select the executable file of your preferred image editor.",
|
||||
|
Loading…
Reference in New Issue
Block a user