v2.5.0: added better multi-monitor fullscreen support
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user