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