screenshot plugin: Capture screenshots to subdirectories
Closes #8711 Co-authored-by: Jordan Atwood <jordan.atwood423@gmail.com>
This commit is contained in:
@@ -160,7 +160,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
@Override
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
takeScreenshot("");
|
||||
manualScreenshot();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
.tab(false)
|
||||
.tooltip("Take screenshot")
|
||||
.icon(iconImage)
|
||||
.onClick(() -> takeScreenshot(""))
|
||||
.onClick(this::manualScreenshot)
|
||||
.popup(ImmutableMap
|
||||
.<String, Runnable>builder()
|
||||
.put("Open screenshot folder...", () ->
|
||||
@@ -222,26 +222,30 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
shouldTakeScreenshot = false;
|
||||
String screenshotSubDir = null;
|
||||
|
||||
String fileName = null;
|
||||
if (client.getWidget(WidgetInfo.LEVEL_UP_LEVEL) != null)
|
||||
{
|
||||
fileName = parseLevelUpWidget(WidgetInfo.LEVEL_UP_LEVEL);
|
||||
screenshotSubDir = "Levels";
|
||||
}
|
||||
else if (client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT) != null)
|
||||
{
|
||||
fileName = parseLevelUpWidget(WidgetInfo.DIALOG_SPRITE_TEXT);
|
||||
screenshotSubDir = "Levels";
|
||||
}
|
||||
else if (client.getWidget(WidgetInfo.QUEST_COMPLETED_NAME_TEXT) != null)
|
||||
{
|
||||
// "You have completed The Corsair Curse!"
|
||||
String text = client.getWidget(WidgetInfo.QUEST_COMPLETED_NAME_TEXT).getText();
|
||||
fileName = "Quest(" + text.substring(19, text.length() - 1) + ")";
|
||||
screenshotSubDir = "Quests";
|
||||
}
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, screenshotSubDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,11 +255,11 @@ public class ScreenshotPlugin extends Plugin
|
||||
Player player = playerDeath.getPlayer();
|
||||
if (player == client.getLocalPlayer() && config.screenshotPlayerDeath())
|
||||
{
|
||||
takeScreenshot("Death");
|
||||
takeScreenshot("Death", "Deaths");
|
||||
}
|
||||
else if ((player.isClanMember() || player.isFriend()) && config.screenshotFriendDeath() && player.getCanvasTilePoly() != null)
|
||||
{
|
||||
takeScreenshot("Death " + player.getName());
|
||||
takeScreenshot("Death " + player.getName(), "Deaths");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +271,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
final Player player = playerLootReceived.getPlayer();
|
||||
final String name = player.getName();
|
||||
String fileName = "Kill " + name;
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "PvP Kills");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +339,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
if (config.screenshotPet() && PET_MESSAGES.stream().anyMatch(chatMessage::contains))
|
||||
{
|
||||
String fileName = "Pet";
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Pets");
|
||||
}
|
||||
|
||||
if (config.screenshotBossKills() )
|
||||
@@ -346,7 +350,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
String bossName = m.group(1);
|
||||
String bossKillcount = m.group(2);
|
||||
String fileName = bossName + "(" + bossKillcount + ")";
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Boss Kills");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +361,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
{
|
||||
String valuableDropName = m.group(1);
|
||||
String fileName = "Valuable drop " + valuableDropName;
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Valuable Drops");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +372,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
{
|
||||
String untradeableDropName = m.group(1);
|
||||
String fileName = "Untradeable drop " + untradeableDropName;
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Untradeable Drops");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,7 +384,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
String result = m.group(1);
|
||||
String count = m.group(2);
|
||||
String fileName = "Duel " + result + " (" + count + ")";
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Duels");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,6 +393,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
public void onWidgetLoaded(WidgetLoaded event)
|
||||
{
|
||||
String fileName;
|
||||
String screenshotSubDir;
|
||||
int groupId = event.getGroupId();
|
||||
|
||||
switch (groupId)
|
||||
@@ -423,6 +428,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
case KINGDOM_GROUP_ID:
|
||||
{
|
||||
fileName = "Kingdom " + LocalDate.now();
|
||||
screenshotSubDir = "Kingdom Rewards";
|
||||
break;
|
||||
}
|
||||
case CHAMBERS_OF_XERIC_REWARD_GROUP_ID:
|
||||
@@ -430,12 +436,14 @@ public class ScreenshotPlugin extends Plugin
|
||||
if (chambersOfXericNumber != null)
|
||||
{
|
||||
fileName = "Chambers of Xeric(" + chambersOfXericNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
chambersOfXericNumber = null;
|
||||
break;
|
||||
}
|
||||
else if (chambersOfXericChallengeNumber != null)
|
||||
{
|
||||
fileName = "Chambers of Xeric Challenge Mode(" + chambersOfXericChallengeNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
chambersOfXericChallengeNumber = null;
|
||||
break;
|
||||
}
|
||||
@@ -452,6 +460,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
fileName = "Theatre of Blood(" + theatreOfBloodNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
theatreOfBloodNumber = null;
|
||||
break;
|
||||
}
|
||||
@@ -463,6 +472,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
fileName = "Barrows(" + barrowsNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
barrowsNumber = null;
|
||||
break;
|
||||
}
|
||||
@@ -482,6 +492,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
fileName = Character.toUpperCase(clueType.charAt(0)) + clueType.substring(1) + "(" + clueNumber + ")";
|
||||
screenshotSubDir = "Clue Scroll Rewards";
|
||||
clueType = null;
|
||||
clueNumber = null;
|
||||
break;
|
||||
@@ -490,7 +501,12 @@ public class ScreenshotPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, screenshotSubDir);
|
||||
}
|
||||
|
||||
private void manualScreenshot()
|
||||
{
|
||||
takeScreenshot("", null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -525,8 +541,9 @@ public class ScreenshotPlugin extends Plugin
|
||||
* and optionally uploads it to an image-hosting service.
|
||||
*
|
||||
* @param fileName Filename to use, without file extension.
|
||||
* @param subDir Subdirectory to store the captured screenshot in.
|
||||
*/
|
||||
private void takeScreenshot(String fileName)
|
||||
private void takeScreenshot(String fileName, String subDir)
|
||||
{
|
||||
if (client.getGameState() == GameState.LOGIN_SCREEN)
|
||||
{
|
||||
@@ -538,7 +555,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
Consumer<Image> imageCallback = (img) ->
|
||||
{
|
||||
// This callback is on the game thread, move to executor thread
|
||||
executor.submit(() -> takeScreenshot(fileName, img));
|
||||
executor.submit(() -> takeScreenshot(fileName, subDir, img));
|
||||
};
|
||||
|
||||
if (config.displayDate())
|
||||
@@ -551,7 +568,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void takeScreenshot(String fileName, Image image)
|
||||
private void takeScreenshot(String fileName, String subDir, Image image)
|
||||
{
|
||||
BufferedImage screenshot = config.includeFrame()
|
||||
? new BufferedImage(clientUi.getWidth(), clientUi.getHeight(), BufferedImage.TYPE_INT_ARGB)
|
||||
@@ -582,7 +599,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
|
||||
// Draw the game onto the screenshot
|
||||
graphics.drawImage(image, gameOffsetX, gameOffsetY, null);
|
||||
imageCapture.takeScreenshot(screenshot, fileName, config.notifyWhenTaken(), config.uploadScreenshot());
|
||||
imageCapture.takeScreenshot(screenshot, fileName, subDir, config.notifyWhenTaken(), config.uploadScreenshot());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user