diff --git a/client/src/main/java/rt4/client.java b/client/src/main/java/rt4/client.java index f1cca1a..ff40855 100644 --- a/client/src/main/java/rt4/client.java +++ b/client/src/main/java/rt4/client.java @@ -492,6 +492,43 @@ public final class client extends GameShell { } public void saveScreenshot(String filename) { + String homeDirOverride = System.getProperty("clientHomeOverride"); + String homeDir = null; + String osNameRaw = ""; + String osName = ""; + try { + osNameRaw = System.getProperty("os.name"); + } catch (Exception local48) { + osNameRaw = "Unknown"; + } + osName = osNameRaw.toLowerCase(); + if (homeDirOverride != null) { + homeDir = homeDirOverride; + } else { + try { + if (homeDir == null) + homeDir = System.getProperty("user.home") + File.separatorChar; + + if (osName.startsWith("linux")) { + String xdgHome = System.getenv("XDG_DATA_HOME"); + + if (xdgHome != null) { + homeDir = xdgHome + "/2009scape/"; + } else { + homeDir += ".local/share/2009scape/"; + } + } else if (osName.startsWith("mac")) { + homeDir += "Library/Application Support/2009scape/"; + } else if (osName.startsWith("windows")) { + homeDir += "2009scape\\"; + } + } catch (Exception ex) { + } + } + File outputFolder = new File(homeDir + File.separatorChar + "screenshots" + File.separatorChar); + if (!outputFolder.exists()){ + outputFolder.mkdirs(); + } int width = client.canvasWidth; int height = client.canvasHeight; if (GlRenderer.enabled) { @@ -519,9 +556,8 @@ public final class client extends GameShell { } // Save the BufferedImage - File outputFile = new File(filename); + File outputFile = new File(outputFolder, filename); ImageIO.write(image, "png", outputFile); - System.out.println("Screenshot captured: " + filename); } catch (IOException e) { e.printStackTrace(); } @@ -538,9 +574,8 @@ public final class client extends GameShell { BufferedImage image = robot.createScreenCapture(captureSize); // Save the BufferedImage - File outputFile = new File(filename); + File outputFile = new File(outputFolder, filename); ImageIO.write(image, "png", outputFile); - System.out.println("Screenshot captured: " + filename); } catch (IOException e) { e.printStackTrace(); } catch (AWTException e) { diff --git a/plugin-playground/src/main/kotlin/TakeScreenshot/plugin.kt b/plugin-playground/src/main/kotlin/TakeScreenshot/plugin.kt index d250c18..174200a 100644 --- a/plugin-playground/src/main/kotlin/TakeScreenshot/plugin.kt +++ b/plugin-playground/src/main/kotlin/TakeScreenshot/plugin.kt @@ -17,7 +17,7 @@ class plugin : Plugin() { override fun keyPressed(e: KeyEvent) { if (e.keyCode == KeyEvent.VK_PRINTSCREEN && e.isControlDown) { API.Screenshot() - } + } } }) }