diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java index 48d22fb10..34daca432 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java @@ -433,7 +433,8 @@ public class SPDSettings extends GameSettings { public static final String KEY_WINDOW_WIDTH = "window_width"; public static final String KEY_WINDOW_HEIGHT = "window_height"; public static final String KEY_WINDOW_MAXIMIZED = "window_maximized"; - + public static final String KEY_FULLSCREEN_MONITOR = "fullscreen_monitor"; + public static void windowResolution( Point p ){ put(KEY_WINDOW_WIDTH, p.x); put(KEY_WINDOW_HEIGHT, p.y); @@ -453,4 +454,12 @@ public class SPDSettings extends GameSettings { public static boolean windowMaximized(){ return getBoolean( KEY_WINDOW_MAXIMIZED, false ); } + + public static void fulLScreenMonitor( int value ){ + put( KEY_FULLSCREEN_MONITOR, value); + } + + public static int fulLScreenMonitor(){ + return getInt( KEY_FULLSCREEN_MONITOR, 0 ); + } } diff --git a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopPlatformSupport.java b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopPlatformSupport.java index e4cdf762e..3add2bf86 100644 --- a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopPlatformSupport.java +++ b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopPlatformSupport.java @@ -22,6 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.desktop; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Graphics; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.g2d.PixmapPacker; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; @@ -55,17 +57,38 @@ public class DesktopPlatformSupport extends PlatformSupport { } } + private static boolean first = false; + @Override public void updateSystemUI() { Gdx.app.postRunnable( new Runnable() { @Override public void run () { if (SPDSettings.fullscreen()){ - Gdx.graphics.setFullscreenMode( Gdx.graphics.getDisplayMode() ); + int monitorNum = 0; + if (!first){ + Graphics.Monitor[] monitors = Gdx.graphics.getMonitors(); + for (int i = 0; i < monitors.length; i++){ + if (((Lwjgl3Graphics.Lwjgl3Monitor)Gdx.graphics.getMonitor()).getMonitorHandle() + == ((Lwjgl3Graphics.Lwjgl3Monitor)monitors[i]).getMonitorHandle()) { + monitorNum = i; + } + } + } else { + monitorNum = SPDSettings.fulLScreenMonitor(); + } + + Graphics.Monitor[] monitors = Gdx.graphics.getMonitors(); + if (monitors.length <= monitorNum) { + monitorNum = 0; + } + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode(monitors[monitorNum])); + SPDSettings.fulLScreenMonitor(monitorNum); } else { Point p = SPDSettings.windowResolution(); Gdx.graphics.setWindowedMode( p.x, p.y ); } + first = false; } } ); }