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
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
takeScreenshot("");
|
||||
manualScreenshot();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -182,7 +182,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...", () ->
|
||||
@@ -214,26 +214,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,11 +247,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +263,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +331,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() )
|
||||
@@ -338,7 +342,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +353,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
{
|
||||
String valuableDropName = m.group(1);
|
||||
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 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 count = m.group(2);
|
||||
String fileName = "Duel " + result + " (" + count + ")";
|
||||
takeScreenshot(fileName);
|
||||
takeScreenshot(fileName, "Duels");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,6 +385,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
public void onWidgetLoaded(WidgetLoaded event)
|
||||
{
|
||||
String fileName;
|
||||
String screenshotSubDir;
|
||||
int groupId = event.getGroupId();
|
||||
|
||||
switch (groupId)
|
||||
@@ -415,6 +420,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:
|
||||
@@ -422,12 +428,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;
|
||||
}
|
||||
@@ -444,6 +452,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
fileName = "Theatre of Blood(" + theatreOfBloodNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
theatreOfBloodNumber = null;
|
||||
break;
|
||||
}
|
||||
@@ -455,6 +464,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
fileName = "Barrows(" + barrowsNumber + ")";
|
||||
screenshotSubDir = "Boss Kills";
|
||||
barrowsNumber = null;
|
||||
break;
|
||||
}
|
||||
@@ -474,6 +484,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;
|
||||
@@ -482,7 +493,12 @@ public class ScreenshotPlugin extends Plugin
|
||||
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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@@ -530,7 +547,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())
|
||||
@@ -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()
|
||||
? 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
|
||||
graphics.drawImage(image, gameOffsetX, gameOffsetY, null);
|
||||
imageCapture.takeScreenshot(screenshot, fileName, config.notifyWhenTaken(), config.uploadScreenshot());
|
||||
imageCapture.takeScreenshot(screenshot, fileName, subDir, config.notifyWhenTaken(), config.uploadScreenshot());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
@@ -40,6 +41,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@@ -80,10 +82,11 @@ public class ImageCapture
|
||||
*
|
||||
* @param screenshot BufferedImage to capture.
|
||||
* @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 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)
|
||||
{
|
||||
@@ -106,6 +109,12 @@ public class ImageCapture
|
||||
{
|
||||
playerDir += "-League";
|
||||
}
|
||||
|
||||
if (!Strings.isNullOrEmpty(subDir))
|
||||
{
|
||||
playerDir += File.separator + subDir;
|
||||
}
|
||||
|
||||
playerFolder = new File(SCREENSHOT_DIR, playerDir);
|
||||
}
|
||||
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,
|
||||
* and copies the image link to the clipboard.
|
||||
|
||||
Reference in New Issue
Block a user