Skip to content

Commit

Permalink
Fixed re-rescaling after screenshot on MacOS
Browse files Browse the repository at this point in the history
based on PR #32
  • Loading branch information
Minenash committed Apr 22, 2021
1 parent d8ca4d9 commit bdde0b4
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.realms.gui.screen.RealmsMainScreen;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.ScreenshotUtils;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
Expand All @@ -32,6 +33,7 @@ public FinishQuit() {
private static boolean stop = false;
private static ClientPlayNetworkHandler serverOrderedDisconnectHandler = null;
private static Text serverOrderedDisconnectReason = null;
private static int prevWidth, prevHeight;

public static void run(ClientPlayNetworkHandler screen, Text reason) {
FinishQuit.serverOrderedDisconnectHandler = screen;
Expand Down Expand Up @@ -59,6 +61,8 @@ else if (serverOrderedDisconnectHandler != null)
FinishQuit.stop = stop;

if(Config.resolution != Config.ScreenshotResolution.Native) {
prevWidth = client.getWindow().getFramebufferWidth();
prevHeight = client.getWindow().getFramebufferHeight();
resizeScreen(client, Config.resolution.width, Config.resolution.height);
}
client.openScreen(new FinishQuit());
Expand Down Expand Up @@ -86,7 +90,7 @@ public void render(MatrixStack matrices, int _mouseX, int _mouseY, float _delta)

client.options.hudHidden = hudHidden;
if(Config.resolution != Config.ScreenshotResolution.Native)
resizeScreen(client, client.getWindow().getWidth(), client.getWindow().getHeight());
resizeScreen(client, prevWidth, prevHeight);

SeamlessLoadingScreen.isDisconnecting = true; //Fapi 0.30.0 compat

Expand All @@ -100,10 +104,10 @@ else if (serverOrderedDisconnectHandler != null)
}

private static void resizeScreen(MinecraftClient client, int width, int height) {
WindowAccessor window = (WindowAccessor) (Object) client.getWindow();
Window window = client.getWindow();

window.setFramebufferWidth(width);
window.setFramebufferHeight(height);
((WindowAccessor)(Object)window).setFramebufferWidth(width);
((WindowAccessor)(Object)window).setFramebufferHeight(height);

client.onResolutionChanged();
}
Expand Down

0 comments on commit bdde0b4

Please sign in to comment.