From d3367d176cfbc7dc58be6f599eb5481cbbb51574 Mon Sep 17 00:00:00 2001 From: jSdCool <37940266+jSdCool@users.noreply.github.com> Date: Thu, 23 Nov 2023 12:51:10 -0500 Subject: [PATCH] added the ability to set custom app icons for windows / macos simply add a line in sketch.properties icon.windows= or icon.macos= folow the = with the relative path to the icon file that you wish to use --- java/src/processing/mode/java/JavaBuild.java | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index b367e2c8f..a76a3f819 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -735,7 +735,18 @@ protected boolean exportApplication(File destFolder, File resourcesFolder = new File(contentsFolder, "Resources"); Util.copyDir(new File(contentsOrig, "Resources/en.lproj"), new File(resourcesFolder, "en.lproj")); - Util.copyFile(mode.getContentFile("application/application.icns"), + + Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties")); + String iconPath = sketchProperties.get("icon");//icon.macos + File iconFile; + if(iconPath == null || iconPath.isEmpty()){ + iconFile = mode.getContentFile("application/application.icns"); + System.out.println("using default icon"); + }else { + iconFile = new File(sketch.getFolder(), iconPath); + System.out.println("found custom icon: "+iconPath); + } + Util.copyFile(iconFile, new File(resourcesFolder, "application.icns")); } else if (exportPlatform == PConstants.LINUX) { @@ -958,7 +969,17 @@ protected boolean exportApplication(File destFolder, File exeFile = new File(destFolder, sketch.getName() + ".exe"); config.addChild("outfile").setContent(exeFile.getAbsolutePath()); - File iconFile = mode.getContentFile("application/application.ico"); + //check sketch.properties to see if an icon was set + Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties")); + String iconPath = sketchProperties.get("icon");//icon.windows + File iconFile; + if(iconPath == null || iconPath.isEmpty()){ + iconFile = mode.getContentFile("application/application.ico"); + System.out.println("using default icon"); + }else { + iconFile = new File(sketch.getFolder(), iconPath); + System.out.println("found custom icon: "+iconPath); + } config.addChild("icon").setContent(iconFile.getAbsolutePath()); XML clazzPath = config.addChild("classPath");