mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
Patched the maximized option on the newer Minecraft versions
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -57,6 +57,13 @@ package org.prismlauncher.launcher.impl;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.ReflectionUtils;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -82,6 +89,18 @@ public final class StandardLauncher extends AbstractLauncher {
|
||||
gameArgs.add(Integer.toString(width));
|
||||
gameArgs.add("--height");
|
||||
gameArgs.add(Integer.toString(height));
|
||||
} else {
|
||||
try {
|
||||
// Dimension rct = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Rectangle rct = getDefaultDeviceBounds();
|
||||
|
||||
gameArgs.add("--width");
|
||||
gameArgs.add(Integer.toString(rct.width));
|
||||
gameArgs.add("--height");
|
||||
gameArgs.add(Integer.toString(rct.height));
|
||||
} catch (Exception e) {
|
||||
// If for some reason the get fails just continue without seting the dimensions
|
||||
}
|
||||
}
|
||||
|
||||
if (serverAddress != null) {
|
||||
@ -104,4 +123,18 @@ public final class StandardLauncher extends AbstractLauncher {
|
||||
MethodHandle method = ReflectionUtils.findMainMethod(mainClassName);
|
||||
method.invokeExact(gameArgs.toArray(new String[0]));
|
||||
}
|
||||
|
||||
private static Rectangle getDefaultDeviceBounds() {
|
||||
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
|
||||
Rectangle bounds = gc.getBounds();
|
||||
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= (insets.left + insets.right);
|
||||
bounds.height -= (insets.top + insets.bottom);
|
||||
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user