1- import { electron , app , fs , PathModule , currentwindow , shell , ipcRenderer , process , nativeImage } from './native_apis' ;
1+ import { electron , app , fs , PathModule , currentwindow , shell , ipcRenderer , process , nativeImage , SystemInfo } from './native_apis' ;
22
33export const recent_projects = ( function ( ) {
44 let array = [ ] ;
@@ -304,24 +304,84 @@ currentwindow.on('enter-full-screen', e => updateWindowState(e, 'screen'));
304304currentwindow . on ( 'leave-full-screen' , e => updateWindowState ( e , 'screen' ) ) ;
305305currentwindow . on ( 'ready-to-show' , e => updateWindowState ( e , 'load' ) ) ;
306306
307+ const ImageEditorPresets = {
308+ aseprite : {
309+ name : 'Aseprite' ,
310+ paths : {
311+ win32 : 'C:\\Program Files\\Aseprite\\Aseprite.exe' ,
312+ darwin : '/Applications/Aseprite.app' ,
313+ linux : '/usr/share/applications//aseprite.desktop' ,
314+ }
315+ } ,
316+ pixieditor : {
317+ name : 'PixiEditor' ,
318+ paths : {
319+ win32 : 'C:\\Program Files\\PixiEditor\\PixiEditor.exe' ,
320+ darwin : '/Applications/PixiEditor.app' ,
321+ linux : '/usr/share/applications//pixieditor.desktop' ,
322+ }
323+ } ,
324+ ps : {
325+ name : 'Photoshop' ,
326+ paths : {
327+ win32 : 'C:\\Program Files\\Adobe\\Adobe Photoshop 2026\\Photoshop.exe' ,
328+ darwin : '/Applications/Adobe Photoshop 2026/Adobe Photoshop 2026.app' ,
329+ linux : '/usr/share/applications//photoshop.desktop'
330+ }
331+ } ,
332+ gimp : {
333+ name : 'GIMP' ,
334+ paths : {
335+ win32 : 'C:\\Program Files\\GIMP 3\\bin\\gimp-3.exe' ,
336+ darwin : '/Applications/Gimp-3.app' ,
337+ linux : '/usr/share/applications//gimp.desktop' ,
338+ }
339+ } ,
340+ pdn : {
341+ name : 'Paint.NET' ,
342+ paths : {
343+ win32 : 'C:\\Program Files\\paint.net\\PaintDotNet.exe'
344+ }
345+ } ,
346+ affinity : {
347+ name : 'Affinity' ,
348+ paths : {
349+ win32 : ( ) => PathModule . join ( SystemInfo . appdata_directory , '..\\Local\\Microsoft\\WindowsApps\\Affinity.exe' ) ,
350+ darwin : '/Applications/Affinity.app'
351+ }
352+ }
353+ } ;
354+
307355//Image Editor
356+ export function isImageEditorValid ( path ) {
357+ if ( ! path ) return false ;
358+ try {
359+ fs . accessSync ( path ) ;
360+ return true ;
361+ } catch ( err ) {
362+ return false ;
363+ }
364+ }
308365export function changeImageEditor ( texture , not_found ) {
309366 let app_file_extension = {
310367 'win32' : [ 'exe' ] ,
311368 'linux' : [ ] ,
312369 'darwin' : [ 'app' ] ,
313370 } ;
371+ let options = { } ;
372+ for ( let key in ImageEditorPresets ) {
373+ let entry = ImageEditorPresets [ key ] ;
374+ if ( ! entry . paths [ SystemInfo . platform ] ) continue ;
375+ options [ key ] = entry . name ;
376+ }
377+ options . other = 'message.image_editor.file' ;
378+
314379 new Dialog ( {
315380 title : tl ( 'message.image_editor.title' ) ,
316381 id : 'image_editor' ,
317382 form : {
318383 not_found_text : { type : 'info' , text : 'message.image_editor.not_found' , condition : not_found == true } ,
319- editor : { type : 'select' , full_width : true , options : {
320- ps : Blockbench . platform == 'win32' ? 'Photoshop' : undefined ,
321- gimp : 'GIMP' ,
322- pdn : Blockbench . platform == 'win32' ? 'Paint.NET' : undefined ,
323- other : 'message.image_editor.file'
324- } } ,
384+ editor : { type : 'select' , full_width : true , options} ,
325385 file : {
326386 label : 'message.image_editor.file' ,
327387 type : 'file' ,
@@ -337,27 +397,14 @@ export function changeImageEditor(texture, not_found) {
337397 let path ;
338398 if ( id == 'other' ) {
339399 path = result . file ;
340-
341- } else if ( Blockbench . platform == 'darwin' ) {
342- switch ( id ) {
343- case 'ps' : path = '/Applications/Adobe Photoshop 2024/Adobe Photoshop 2024.app' ; break ;
344- case 'gimp' :path = '/Applications/Gimp-2.10.app' ; break ;
345- }
346- } else if ( Blockbench . platform == 'linux' ) {
347- switch ( id ) {
348- case 'ps' : path = '/usr/share/applications//photoshop.desktop' ; break ;
349- case 'gimp' :path = '/usr/share/applications//gimp.desktop' ; break ;
350- }
351400 } else {
352- switch ( id ) {
353- case 'ps' : path = 'C:\\Program Files\\Adobe\\Adobe Photoshop 2024\\Photoshop.exe' ; break ;
354- case 'gimp' :path = 'C:\\Program Files\\GIMP 2\\bin\\gimp-2.10.exe' ; break ;
355- case 'pdn' : path = 'C:\\Program Files\\paint.net\\PaintDotNet.exe' ; break ;
356- }
401+ path = ImageEditorPresets [ result . editor ] . paths [ SystemInfo . platform ] ;
402+ if ( typeof path == 'function' ) path = path ( ) ;
357403 }
358- if ( path && fs . existsSync ( path ) ) {
404+ if ( isImageEditorValid ( path ) ) {
359405 settings . image_editor . value = path
360406 ipcRenderer . send ( 'edit-launch-setting' , { key : 'image_editor' , value : path } ) ;
407+ Settings . save ( ) ;
361408 if ( texture ) {
362409 texture . openEditor ( )
363410 }
0 commit comments