mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-01 07:04:32 +02:00
When java disappoints try C++
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
3c17f606ed
commit
1be29076ea
@ -91,6 +91,9 @@
|
|||||||
#include "tools/BaseProfiler.h"
|
#include "tools/BaseProfiler.h"
|
||||||
|
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
#include "MangoHud.h"
|
#include "MangoHud.h"
|
||||||
@ -752,11 +755,29 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftT
|
|||||||
// window size, title and state, legacy
|
// window size, title and state, legacy
|
||||||
{
|
{
|
||||||
QString windowParams;
|
QString windowParams;
|
||||||
if (settings()->get("LaunchMaximized").toBool())
|
if (settings()->get("LaunchMaximized").toBool()) {
|
||||||
|
// FIXME doesn't support maximisation
|
||||||
|
if (getLauncher() == "standard") {
|
||||||
|
auto screen = QGuiApplication::primaryScreen();
|
||||||
|
auto screenGeometry = screen->availableSize();
|
||||||
|
|
||||||
|
// small hack to get the widow decorations
|
||||||
|
for (auto w : QApplication::topLevelWidgets()) {
|
||||||
|
auto mainWindow = qobject_cast<QMainWindow*>(w);
|
||||||
|
if (mainWindow) {
|
||||||
|
screenGeometry = screenGeometry.shrunkBy(mainWindow->windowHandle()->frameMargins());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
windowParams = QString("%1x%2").arg(screenGeometry.width()).arg(screenGeometry.height());
|
||||||
|
} else {
|
||||||
windowParams = "maximized";
|
windowParams = "maximized";
|
||||||
else
|
}
|
||||||
|
} else {
|
||||||
windowParams =
|
windowParams =
|
||||||
QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt());
|
QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt());
|
||||||
|
}
|
||||||
launchScript += "windowTitle " + windowTitle() + "\n";
|
launchScript += "windowTitle " + windowTitle() + "\n";
|
||||||
launchScript += "windowParams " + windowParams + "\n";
|
launchScript += "windowParams " + windowParams + "\n";
|
||||||
}
|
}
|
||||||
|
@ -57,13 +57,6 @@ package org.prismlauncher.launcher.impl;
|
|||||||
import org.prismlauncher.utils.Parameters;
|
import org.prismlauncher.utils.Parameters;
|
||||||
import org.prismlauncher.utils.ReflectionUtils;
|
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.lang.invoke.MethodHandle;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -83,25 +76,10 @@ public final class StandardLauncher extends AbstractLauncher {
|
|||||||
@Override
|
@Override
|
||||||
public void launch() throws Throwable {
|
public void launch() throws Throwable {
|
||||||
// window size, title and state
|
// window size, title and state
|
||||||
// FIXME doesn't support maximisation
|
|
||||||
if (!maximize) {
|
|
||||||
gameArgs.add("--width");
|
gameArgs.add("--width");
|
||||||
gameArgs.add(Integer.toString(width));
|
gameArgs.add(Integer.toString(width));
|
||||||
gameArgs.add("--height");
|
gameArgs.add("--height");
|
||||||
gameArgs.add(Integer.toString(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) {
|
if (serverAddress != null) {
|
||||||
if (quickPlayMultiplayerSupported) {
|
if (quickPlayMultiplayerSupported) {
|
||||||
@ -123,18 +101,4 @@ public final class StandardLauncher extends AbstractLauncher {
|
|||||||
MethodHandle method = ReflectionUtils.findMainMethod(mainClassName);
|
MethodHandle method = ReflectionUtils.findMainMethod(mainClassName);
|
||||||
method.invokeExact(gameArgs.toArray(new String[0]));
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user