Merge pull request #10858 from Nightfirecat/screenshot-dirs
Add screenshot subdirectories
This commit is contained in:
@@ -159,7 +159,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void hotkeyPressed()
|
public void hotkeyPressed()
|
||||||
{
|
{
|
||||||
takeScreenshot("");
|
manualScreenshot();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -182,7 +182,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...", () ->
|
||||||
@@ -214,26 +214,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,11 +247,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +263,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +331,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() )
|
||||||
@@ -338,7 +342,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +353,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +364,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +376,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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,6 +385,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)
|
||||||
@@ -415,6 +420,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:
|
||||||
@@ -422,12 +428,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;
|
||||||
}
|
}
|
||||||
@@ -444,6 +452,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;
|
||||||
}
|
}
|
||||||
@@ -455,6 +464,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileName = "Barrows(" + barrowsNumber + ")";
|
fileName = "Barrows(" + barrowsNumber + ")";
|
||||||
|
screenshotSubDir = "Boss Kills";
|
||||||
barrowsNumber = null;
|
barrowsNumber = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -474,6 +484,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;
|
||||||
@@ -482,7 +493,12 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
takeScreenshot(fileName);
|
takeScreenshot(fileName, screenshotSubDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void manualScreenshot()
|
||||||
|
{
|
||||||
|
takeScreenshot("", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -517,8 +533,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)
|
||||||
{
|
{
|
||||||
@@ -530,7 +547,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())
|
||||||
@@ -543,7 +560,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)
|
||||||
@@ -574,7 +591,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
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.util;
|
package net.runelite.client.util;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
@@ -40,6 +41,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -80,10 +82,11 @@ public class ImageCapture
|
|||||||
*
|
*
|
||||||
* @param screenshot BufferedImage to capture.
|
* @param screenshot BufferedImage to capture.
|
||||||
* @param fileName Filename to use, without file extension.
|
* @param fileName Filename to use, without file extension.
|
||||||
|
* @param subDir Directory within the player screenshots dir to store the captured screenshot to.
|
||||||
* @param notify Send a notification to the system tray when the image is captured.
|
* @param notify Send a notification to the system tray when the image is captured.
|
||||||
* @param imageUploadStyle which method to use to upload the screenshot (Imgur or directly to clipboard).
|
* @param imageUploadStyle which method to use to upload the screenshot (Imgur or directly to clipboard).
|
||||||
*/
|
*/
|
||||||
public void takeScreenshot(BufferedImage screenshot, String fileName, boolean notify, ImageUploadStyle imageUploadStyle)
|
public void takeScreenshot(BufferedImage screenshot, String fileName, @Nullable String subDir, boolean notify, ImageUploadStyle imageUploadStyle)
|
||||||
{
|
{
|
||||||
if (client.getGameState() == GameState.LOGIN_SCREEN)
|
if (client.getGameState() == GameState.LOGIN_SCREEN)
|
||||||
{
|
{
|
||||||
@@ -106,6 +109,12 @@ public class ImageCapture
|
|||||||
{
|
{
|
||||||
playerDir += "-League";
|
playerDir += "-League";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Strings.isNullOrEmpty(subDir))
|
||||||
|
{
|
||||||
|
playerDir += File.separator + subDir;
|
||||||
|
}
|
||||||
|
|
||||||
playerFolder = new File(SCREENSHOT_DIR, playerDir);
|
playerFolder = new File(SCREENSHOT_DIR, playerDir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -157,6 +166,20 @@ public class ImageCapture
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
||||||
|
* and optionally uploads it to an image-hosting service.
|
||||||
|
*
|
||||||
|
* @param screenshot BufferedImage to capture.
|
||||||
|
* @param fileName Filename to use, without file extension.
|
||||||
|
* @param notify Send a notification to the system tray when the image is captured.
|
||||||
|
* @param imageUploadStyle which method to use to upload the screenshot (Imgur or directly to clipboard).
|
||||||
|
*/
|
||||||
|
public void takeScreenshot(BufferedImage screenshot, String fileName, boolean notify, ImageUploadStyle imageUploadStyle)
|
||||||
|
{
|
||||||
|
takeScreenshot(screenshot, fileName, null, notify, imageUploadStyle);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads a screenshot to the Imgur image-hosting service,
|
* Uploads a screenshot to the Imgur image-hosting service,
|
||||||
* and copies the image link to the clipboard.
|
* and copies the image link to the clipboard.
|
||||||
|
|||||||
Reference in New Issue
Block a user