Raids: Enable screenshotting of scouting overlay
This commit is contained in:
@@ -27,6 +27,8 @@ package net.runelite.client.plugins.raids;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Keybind;
|
||||
import net.runelite.client.util.ImageUploadStyle;
|
||||
|
||||
@ConfigGroup("raids")
|
||||
public interface RaidsConfig extends Config
|
||||
@@ -175,7 +177,7 @@ public interface RaidsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 12,
|
||||
position = 13,
|
||||
keyName = "showLootValue",
|
||||
name = "Show Loot Value",
|
||||
description = "Shows the value of your loot at the end of a raid"
|
||||
@@ -184,4 +186,26 @@ public interface RaidsConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "screenshotHotkey",
|
||||
name = "Scouter screenshot hotkey",
|
||||
description = "Hotkey used to screenshot the scouting overlay"
|
||||
)
|
||||
default Keybind screenshotHotkey()
|
||||
{
|
||||
return Keybind.NOT_SET;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 15,
|
||||
keyName = "uploadScreenshot",
|
||||
name = "Upload scouting screenshot",
|
||||
description = "Uploads the scouting screenshot to Imgur or the clipboard"
|
||||
)
|
||||
default ImageUploadStyle uploadScreenshot()
|
||||
{
|
||||
return ImageUploadStyle.CLIPBOARD;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.ClanMemberManager;
|
||||
import net.runelite.api.Client;
|
||||
@@ -49,12 +50,14 @@ public class RaidsOverlay extends Overlay
|
||||
{
|
||||
private static final int OLM_PLANE = 0;
|
||||
static final String BROADCAST_ACTION = "Broadcast layout";
|
||||
static final String SCREENSHOT_ACTION = "Screenshot";
|
||||
|
||||
private Client client;
|
||||
private RaidsPlugin plugin;
|
||||
private RaidsConfig config;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean scoutOverlayShown = false;
|
||||
|
||||
@@ -69,6 +72,7 @@ public class RaidsOverlay extends Overlay
|
||||
this.config = config;
|
||||
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Raids overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY, BROADCAST_ACTION, "Raids overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY, SCREENSHOT_ACTION, "Raids overlay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,10 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
@@ -69,12 +73,14 @@ import net.runelite.client.chat.ChatMessageBuilder;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.chat.QueuedMessage;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ChatInput;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.events.OverlayMenuClicked;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.raids.solver.Layout;
|
||||
@@ -82,6 +88,8 @@ import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.QuantityFormatter;
|
||||
import net.runelite.client.util.HotkeyListener;
|
||||
import net.runelite.client.util.ImageCapture;
|
||||
import net.runelite.client.util.Text;
|
||||
import static net.runelite.client.util.Text.sanitize;
|
||||
import net.runelite.client.ws.PartyMember;
|
||||
@@ -108,6 +116,9 @@ public class RaidsPlugin extends Plugin
|
||||
private static final String LAYOUT_COMMAND = "!layout";
|
||||
private static final int MAX_LAYOUT_LEN = 300;
|
||||
|
||||
@Inject
|
||||
private RuneLiteConfig runeLiteConfig;
|
||||
|
||||
@Inject
|
||||
private ChatMessageManager chatMessageManager;
|
||||
|
||||
@@ -153,6 +164,12 @@ public class RaidsPlugin extends Plugin
|
||||
@Inject
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
@Inject
|
||||
private ImageCapture imageCapture;
|
||||
|
||||
@Getter
|
||||
private final Set<String> roomWhitelist = new HashSet<String>();
|
||||
|
||||
@@ -195,6 +212,7 @@ public class RaidsPlugin extends Plugin
|
||||
updateLists();
|
||||
clientThread.invokeLater(() -> checkRaidPresence(true));
|
||||
chatCommandManager.registerCommandAsync(LAYOUT_COMMAND, this::lookupRaid, this::submitRaid);
|
||||
keyManager.registerKeyListener(screenshotHotkeyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,6 +225,7 @@ public class RaidsPlugin extends Plugin
|
||||
raid = null;
|
||||
timer = null;
|
||||
chestOpened = false;
|
||||
keyManager.unregisterKeyListener(screenshotHotkeyListener);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -334,12 +353,20 @@ public class RaidsPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onOverlayMenuClicked(final OverlayMenuClicked event)
|
||||
{
|
||||
if (event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY &&
|
||||
event.getEntry().getOption().equals(RaidsOverlay.BROADCAST_ACTION) &&
|
||||
event.getOverlay() == overlay)
|
||||
if (!(event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY
|
||||
&& event.getOverlay() == overlay))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntry().getOption().equals(RaidsOverlay.BROADCAST_ACTION))
|
||||
{
|
||||
sendRaidLayoutMessage();
|
||||
}
|
||||
else if (event.getEntry().getOption().equals(RaidsOverlay.SCREENSHOT_ACTION))
|
||||
{
|
||||
screenshotScoutOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRaidPresence(boolean force)
|
||||
@@ -752,4 +779,32 @@ public class RaidsPlugin extends Plugin
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private final HotkeyListener screenshotHotkeyListener = new HotkeyListener(() -> config.screenshotHotkey())
|
||||
{
|
||||
@Override
|
||||
public void hotkeyPressed()
|
||||
{
|
||||
screenshotScoutOverlay();
|
||||
}
|
||||
};
|
||||
|
||||
private void screenshotScoutOverlay()
|
||||
{
|
||||
if (!overlay.isScoutOverlayShown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle overlayDimensions = overlay.getBounds();
|
||||
BufferedImage overlayImage = new BufferedImage(overlayDimensions.width, overlayDimensions.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphic = overlayImage.createGraphics();
|
||||
graphic.setFont(runeLiteConfig.interfaceFontType().getFont());
|
||||
graphic.setColor(Color.BLACK);
|
||||
graphic.fillRect(0, 0, overlayDimensions.width, overlayDimensions.height);
|
||||
overlay.render(graphic);
|
||||
|
||||
imageCapture.takeScreenshot(overlayImage, "CoX_scout-", false, config.uploadScreenshot());
|
||||
graphic.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import net.runelite.client.game.ItemManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.util.ImageCapture;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -81,6 +83,14 @@ public class RaidsPluginTest
|
||||
@Bind
|
||||
ChatMessageManager chatMessageManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ImageCapture imageCapture;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Notifier notifier;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
RaidsConfig raidsConfig;
|
||||
|
||||
Reference in New Issue
Block a user