Merge pull request #622 from devLotto/issue-602
Fix the game freezing when screenshots are being taken
This commit is contained in:
@@ -46,6 +46,7 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -120,6 +121,9 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayRenderer overlayRenderer;
|
private OverlayRenderer overlayRenderer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
private JButton titleBarButton;
|
private JButton titleBarButton;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -397,34 +401,40 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File playerFolder = RuneLite.SCREENSHOT_DIR;
|
File playerFolder;
|
||||||
|
|
||||||
if (client.getLocalPlayer() != null)
|
if (client.getLocalPlayer() != null)
|
||||||
{
|
{
|
||||||
playerFolder = new File(RuneLite.SCREENSHOT_DIR, client.getLocalPlayer().getName());
|
playerFolder = new File(RuneLite.SCREENSHOT_DIR, client.getLocalPlayer().getName());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerFolder = RuneLite.SCREENSHOT_DIR;
|
||||||
|
}
|
||||||
|
|
||||||
playerFolder.mkdirs();
|
playerFolder.mkdirs();
|
||||||
|
|
||||||
try
|
executor.execute(() ->
|
||||||
{
|
{
|
||||||
File screenshotFile = new File(playerFolder, fileName + ".png");
|
try
|
||||||
|
|
||||||
ImageIO.write(screenshot, "PNG", screenshotFile);
|
|
||||||
|
|
||||||
if (config.uploadScreenshot())
|
|
||||||
{
|
{
|
||||||
uploadScreenshot(screenshotFile);
|
File screenshotFile = new File(playerFolder, fileName + ".png");
|
||||||
|
|
||||||
|
ImageIO.write(screenshot, "PNG", screenshotFile);
|
||||||
|
|
||||||
|
if (config.uploadScreenshot())
|
||||||
|
{
|
||||||
|
uploadScreenshot(screenshotFile);
|
||||||
|
}
|
||||||
|
else if (config.notifyWhenTaken())
|
||||||
|
{
|
||||||
|
notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (config.notifyWhenTaken())
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO);
|
log.warn("error writing screenshot", ex);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
log.warn("error writing screenshot", ex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user