Log errors for failed screenshots

This commit is contained in:
Anuken
2026-06-14 02:36:19 -04:00
parent 0eec03c366
commit 99faf69fca
2 changed files with 38 additions and 30 deletions
+1
View File
@@ -19,6 +19,7 @@ clipboardcopy = This server wants to copy text to your clipboard. Are you sure y
linkfail = Failed to open link!\nThe URL has been copied to your clipboard.
screenshot = Screenshot saved to {0}
screenshot.invalid = Map too large, potentially not enough memory for screenshot.
screenshot.error = Failed to take screenshot. Your device likely does not support screenshots this large.
gameover = Game Over
gameover.disconnect = Disconnect
gameover.pvp = The[accent] {0}[] team is victorious!
+37 -30
View File
@@ -579,39 +579,46 @@ public class Renderer implements ApplicationListener{
ui.showInfo("@screenshot.invalid");
return;
}
try{
FrameBuffer buffer = new FrameBuffer(w, h);
drawWeather = false;
float vpW = camera.width, vpH = camera.height, px = camera.position.x, py = camera.position.y;
disableUI = true;
camera.width = w;
camera.height = h;
camera.position.x = w / 2f + tilesize / 2f;
camera.position.y = h / 2f + tilesize / 2f;
buffer.begin(Color.clear);
draw();
Draw.flush();
byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true);
buffer.end();
disableUI = false;
camera.width = vpW;
camera.height = vpH;
camera.position.set(px, py);
drawWeather = true;
buffer.dispose();
FrameBuffer buffer = new FrameBuffer(w, h);
drawWeather = false;
float vpW = camera.width, vpH = camera.height, px = camera.position.x, py = camera.position.y;
disableUI = true;
camera.width = w;
camera.height = h;
camera.position.x = w / 2f + tilesize / 2f;
camera.position.y = h / 2f + tilesize / 2f;
buffer.begin(Color.clear);
draw();
Draw.flush();
byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true);
buffer.end();
disableUI = false;
camera.width = vpW;
camera.height = vpH;
camera.position.set(px, py);
drawWeather = true;
buffer.dispose();
Threads.thread(() -> {
for(int i = 0; i < lines.length; i += 4){
lines[i + 3] = (byte)255;
}
Pixmap fullPixmap = new Pixmap(w, h);
Buffers.copy(lines, 0, fullPixmap.pixels, lines.length);
Fi file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png");
PixmapIO.writePng(file, fullPixmap);
fullPixmap.dispose();
app.post(() -> ui.showInfoFade(bundle.format("screenshot", file.toString())));
});
}catch(Throwable e){
Log.err(e);
Vars.ui.showException("@screenshot.error", e);
}
Threads.thread(() -> {
for(int i = 0; i < lines.length; i += 4){
lines[i + 3] = (byte)255;
}
Pixmap fullPixmap = new Pixmap(w, h);
Buffers.copy(lines, 0, fullPixmap.pixels, lines.length);
Fi file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png");
PixmapIO.writePng(file, fullPixmap);
fullPixmap.dispose();
app.post(() -> ui.showInfoFade(bundle.format("screenshot", file.toString())));
});
}
public static class EnvRenderer{