mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
Use correct directory for screenshots
This commit is contained in:
parent
dc8462dd55
commit
4a5085380e
2 changed files with 40 additions and 5 deletions
|
|
@ -492,6 +492,43 @@ public final class client extends GameShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveScreenshot(String filename) {
|
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 width = client.canvasWidth;
|
||||||
int height = client.canvasHeight;
|
int height = client.canvasHeight;
|
||||||
if (GlRenderer.enabled) {
|
if (GlRenderer.enabled) {
|
||||||
|
|
@ -519,9 +556,8 @@ public final class client extends GameShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the BufferedImage
|
// Save the BufferedImage
|
||||||
File outputFile = new File(filename);
|
File outputFile = new File(outputFolder, filename);
|
||||||
ImageIO.write(image, "png", outputFile);
|
ImageIO.write(image, "png", outputFile);
|
||||||
System.out.println("Screenshot captured: " + filename);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -538,9 +574,8 @@ public final class client extends GameShell {
|
||||||
BufferedImage image = robot.createScreenCapture(captureSize);
|
BufferedImage image = robot.createScreenCapture(captureSize);
|
||||||
|
|
||||||
// Save the BufferedImage
|
// Save the BufferedImage
|
||||||
File outputFile = new File(filename);
|
File outputFile = new File(outputFolder, filename);
|
||||||
ImageIO.write(image, "png", outputFile);
|
ImageIO.write(image, "png", outputFile);
|
||||||
System.out.println("Screenshot captured: " + filename);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (AWTException e) {
|
} catch (AWTException e) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class plugin : Plugin() {
|
||||||
override fun keyPressed(e: KeyEvent) {
|
override fun keyPressed(e: KeyEvent) {
|
||||||
if (e.keyCode == KeyEvent.VK_PRINTSCREEN && e.isControlDown) {
|
if (e.keyCode == KeyEvent.VK_PRINTSCREEN && e.isControlDown) {
|
||||||
API.Screenshot()
|
API.Screenshot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue