screenshot plugin: add combat achievements
Co-authored-by: Evan <55665020+EvanDeadlySins@users.noreply.github.com>
This commit is contained in:
@@ -626,6 +626,14 @@ public enum Varbits
|
|||||||
*/
|
*/
|
||||||
COLLECTION_LOG_NOTIFICATION(11959),
|
COLLECTION_LOG_NOTIFICATION(11959),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combat Achievements popup settings whenever a new task is completed
|
||||||
|
*
|
||||||
|
* 0 = popup notification enabled
|
||||||
|
* 1 = popup notification disabled
|
||||||
|
*/
|
||||||
|
COMBAT_ACHIEVEMENTS_POPUP(12455),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show boss health overlay setting
|
* Show boss health overlay setting
|
||||||
* 0 = on
|
* 0 = on
|
||||||
|
|||||||
@@ -287,4 +287,16 @@ public interface ScreenshotConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "combatAchievements",
|
||||||
|
name = "Screenshot combat achievements",
|
||||||
|
description = "Take a screenshot when completing a combat achievement task",
|
||||||
|
position = 20,
|
||||||
|
section = whatSection
|
||||||
|
)
|
||||||
|
default boolean screenshotCombatAchievements()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private static final Pattern DUEL_END_PATTERN = Pattern.compile("You have now (won|lost) ([0-9,]+) duels?\\.");
|
private static final Pattern DUEL_END_PATTERN = Pattern.compile("You have now (won|lost) ([0-9,]+) duels?\\.");
|
||||||
private static final Pattern QUEST_PATTERN_1 = Pattern.compile(".+?ve\\.*? (?<verb>been|rebuilt|.+?ed)? ?(?:the )?'?(?<quest>.+?)'?(?: [Qq]uest)?[!.]?$");
|
private static final Pattern QUEST_PATTERN_1 = Pattern.compile(".+?ve\\.*? (?<verb>been|rebuilt|.+?ed)? ?(?:the )?'?(?<quest>.+?)'?(?: [Qq]uest)?[!.]?$");
|
||||||
private static final Pattern QUEST_PATTERN_2 = Pattern.compile("'?(?<quest>.+?)'?(?: [Qq]uest)? (?<verb>[a-z]\\w+?ed)?(?: f.*?)?[!.]?$");
|
private static final Pattern QUEST_PATTERN_2 = Pattern.compile("'?(?<quest>.+?)'?(?: [Qq]uest)? (?<verb>[a-z]\\w+?ed)?(?: f.*?)?[!.]?$");
|
||||||
|
private static final Pattern COMBAT_ACHIEVEMENTS_PATTERN = Pattern.compile("Congratulations, you've completed an? (?<tier>\\w+) combat task: <col=[0-9a-f]+>(?<task>(.+))</col>\\.");
|
||||||
private static final ImmutableList<String> RFD_TAGS = ImmutableList.of("Another Cook", "freed", "defeated", "saved");
|
private static final ImmutableList<String> RFD_TAGS = ImmutableList.of("Another Cook", "freed", "defeated", "saved");
|
||||||
private static final ImmutableList<String> WORD_QUEST_IN_NAME_TAGS = ImmutableList.of("Another Cook", "Doric", "Heroes", "Legends", "Observatory", "Olaf", "Waterfall");
|
private static final ImmutableList<String> WORD_QUEST_IN_NAME_TAGS = ImmutableList.of("Another Cook", "Doric", "Heroes", "Legends", "Observatory", "Olaf", "Waterfall");
|
||||||
private static final ImmutableList<String> PET_MESSAGES = ImmutableList.of("You have a funny feeling like you're being followed",
|
private static final ImmutableList<String> PET_MESSAGES = ImmutableList.of("You have a funny feeling like you're being followed",
|
||||||
@@ -134,6 +135,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private static final String SD_COLLECTION_LOG = "Collection Log";
|
private static final String SD_COLLECTION_LOG = "Collection Log";
|
||||||
private static final String SD_PVP_KILLS = "PvP Kills";
|
private static final String SD_PVP_KILLS = "PvP Kills";
|
||||||
private static final String SD_DEATHS = "Deaths";
|
private static final String SD_DEATHS = "Deaths";
|
||||||
|
private static final String SD_COMBAT_ACHIEVEMENTS = "Combat Achievements";
|
||||||
|
|
||||||
private String clueType;
|
private String clueType;
|
||||||
private Integer clueNumber;
|
private Integer clueNumber;
|
||||||
@@ -494,6 +496,15 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
String fileName = "Collection log (" + entry + ")";
|
String fileName = "Collection log (" + entry + ")";
|
||||||
takeScreenshot(fileName, SD_COLLECTION_LOG);
|
takeScreenshot(fileName, SD_COLLECTION_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatMessage.contains("combat task") && config.screenshotCombatAchievements() && client.getVar(Varbits.COMBAT_ACHIEVEMENTS_POPUP) == 1)
|
||||||
|
{
|
||||||
|
String fileName = parseCombatAchievementWidget(chatMessage);
|
||||||
|
if (!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
takeScreenshot(fileName, SD_COMBAT_ACHIEVEMENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -652,6 +663,12 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
String fileName = "Collection log (" + entry + ")";
|
String fileName = "Collection log (" + entry + ")";
|
||||||
takeScreenshot(fileName, SD_COLLECTION_LOG);
|
takeScreenshot(fileName, SD_COLLECTION_LOG);
|
||||||
}
|
}
|
||||||
|
if (topText.equalsIgnoreCase("Combat Task Completed!") && config.screenshotCombatAchievements() && client.getVar(Varbits.COMBAT_ACHIEVEMENTS_POPUP) == 0)
|
||||||
|
{
|
||||||
|
String entry = Text.removeTags(bottomText).substring("Task Completed: ".length());
|
||||||
|
String fileName = "Combat task (" + entry.replaceAll("[:?]", "") + ")";
|
||||||
|
takeScreenshot(fileName, SD_COMBAT_ACHIEVEMENTS);
|
||||||
|
}
|
||||||
notificationStarted = false;
|
notificationStarted = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -752,6 +769,24 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
return "High Gamble(count not found)";
|
return "High Gamble(count not found)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a combat achievement success chat message into a filename-safe string.
|
||||||
|
*
|
||||||
|
* @param text A received chat message which may or may not be from completing a combat achievement.
|
||||||
|
* @return A formatted string of the achieved combat task name, or the empty string if the passed message
|
||||||
|
* is not a combat achievement completion message.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
static String parseCombatAchievementWidget(final String text)
|
||||||
|
{
|
||||||
|
final Matcher m = COMBAT_ACHIEVEMENTS_PATTERN.matcher(text);
|
||||||
|
if (m.matches())
|
||||||
|
{
|
||||||
|
String task = m.group("task").replaceAll("[:?]", "");
|
||||||
|
return "Combat task (" + task + ")";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
||||||
|
|||||||
@@ -353,6 +353,17 @@ public class ScreenshotPluginTest
|
|||||||
assertEquals("Quest(quest not found)", ScreenshotPlugin.parseQuestCompletedWidget("Sins of the Father forgiven!"));
|
assertEquals("Quest(quest not found)", ScreenshotPlugin.parseQuestCompletedWidget("Sins of the Father forgiven!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCombatAchievementsParsing()
|
||||||
|
{
|
||||||
|
assertEquals("Combat task (Into the Den of Giants)", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed an easy combat task: <col=06600c>Into the Den of Giants</col>."));
|
||||||
|
assertEquals("Combat task (I'd Rather Not Learn)", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed a medium combat task: <col=06600c>I'd Rather Not Learn</col>."));
|
||||||
|
assertEquals("Combat task (Why Cook)", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed a hard combat task: <col=0cc919>Why Cook?</col>."));
|
||||||
|
assertEquals("Combat task (From Dusk...)", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed an elite combat task: <col=06600c>From Dusk...</col>."));
|
||||||
|
assertEquals("Combat task (Perfect Olm (Trio))", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed a master combat task: <col=0cc919>Perfect Olm (Trio)</col>."));
|
||||||
|
assertEquals("Combat task (Chambers of Xeric CM (5-Scale) Speed-Runner)", ScreenshotPlugin.parseCombatAchievementWidget("Congratulations, you've completed a grandmaster combat task: <col=0cc919>Chambers of Xeric: CM (5-Scale) Speed-Runner</col>."));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBAHighGambleRewardParsing()
|
public void testBAHighGambleRewardParsing()
|
||||||
{
|
{
|
||||||
@@ -455,4 +466,35 @@ public class ScreenshotPluginTest
|
|||||||
|
|
||||||
verify(drawManager).requestNextFrameListener(any(Consumer.class));
|
verify(drawManager).requestNextFrameListener(any(Consumer.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCombatAchievementsPopup()
|
||||||
|
{
|
||||||
|
when(screenshotConfig.screenshotCombatAchievements()).thenReturn(true);
|
||||||
|
|
||||||
|
ScriptPreFired notificationStart = new ScriptPreFired(ScriptID.NOTIFICATION_START);
|
||||||
|
screenshotPlugin.onScriptPreFired(notificationStart);
|
||||||
|
|
||||||
|
when(client.getVar(VarClientStr.NOTIFICATION_TOP_TEXT)).thenReturn("Combat Task Completed!");
|
||||||
|
when(client.getVar(VarClientStr.NOTIFICATION_BOTTOM_TEXT)).thenReturn("Task Completed: <col=ffffff>Handyman</col>");
|
||||||
|
|
||||||
|
ScriptPreFired notificationDelay = new ScriptPreFired(ScriptID.NOTIFICATION_DELAY);
|
||||||
|
screenshotPlugin.onScriptPreFired(notificationDelay);
|
||||||
|
|
||||||
|
verify(drawManager).requestNextFrameListener(any(Consumer.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCombatAchievementsChat()
|
||||||
|
{
|
||||||
|
when(screenshotConfig.screenshotCombatAchievements()).thenReturn(true);
|
||||||
|
|
||||||
|
when(client.getVar(Varbits.COMBAT_ACHIEVEMENTS_POPUP)).thenReturn(1);
|
||||||
|
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "",
|
||||||
|
"Congratulations, you've completed an easy combat task: <col=06600c>Handyman</col>.", null, 0);
|
||||||
|
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
verify(drawManager).requestNextFrameListener(any(Consumer.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user