Added subfolders option

This allows for much greater flexibility of screenshotting, we can now pass in any number of levels of subfolders for our preferred directory depth for storing images.
This commit is contained in:
ipkpjersi 2023-12-29 12:45:24 -05:00
parent 4a5085380e
commit 6d2d8ad36d
2 changed files with 10 additions and 4 deletions

View file

@ -273,10 +273,10 @@ public class API {
Cheat.sendCheatPacket(JagString.of(command)); Cheat.sendCheatPacket(JagString.of(command));
} }
public static void Screenshot() { public static void Screenshot(String... subfolders) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
String dateTime = dateFormat.format(new Date()); String dateTime = dateFormat.format(new Date());
client.instance.saveScreenshot(PlayerList.self.username.toString() + "_" + dateTime + ".png"); client.instance.saveScreenshot(PlayerList.self.username.toString() + "_" + dateTime + ".png", subfolders);
} }
public static void PlaySound(int volume, int trackId, int delay) { public static void PlaySound(int volume, int trackId, int delay) {

View file

@ -491,7 +491,7 @@ public final class client extends GameShell {
arg0.pdata(local15, 24); arg0.pdata(local15, 24);
} }
public void saveScreenshot(String filename) { public void saveScreenshot(String filename, String... subfolders) {
String homeDirOverride = System.getProperty("clientHomeOverride"); String homeDirOverride = System.getProperty("clientHomeOverride");
String homeDir = null; String homeDir = null;
String osNameRaw = ""; String osNameRaw = "";
@ -525,7 +525,13 @@ public final class client extends GameShell {
} catch (Exception ex) { } catch (Exception ex) {
} }
} }
File outputFolder = new File(homeDir + File.separatorChar + "screenshots" + File.separatorChar);
String subfolderPath = String.join(File.separator, subfolders);
if (!subfolderPath.isEmpty()) {
subfolderPath += File.separator;
}
File outputFolder = new File(homeDir + File.separatorChar + "screenshots" + File.separatorChar + subfolderPath);
if (!outputFolder.exists()){ if (!outputFolder.exists()){
outputFolder.mkdirs(); outputFolder.mkdirs();
} }