- Added a possibility to run the mobile-Forge-on-desktop installation windowed using an extra parameter in screen_resolution.ini (e.g. 1920x1080x1 runs full-screen, 1920x1080x0 runs windowed).

- The file "fullscreen_resolution.ini" was renamed to "screen_resolution.ini" due to the change in its purpose.
This commit is contained in:
Agetian
2017-05-08 06:00:22 +00:00
parent cfe2a7e98d
commit 83c7eee7c2

View File

@@ -43,21 +43,27 @@ public class Main {
// Fullscreen width and height for desktop mode (desktopMode = true) // Fullscreen width and height for desktop mode (desktopMode = true)
// Can be specified inside the file fullscreen_resolution.ini to override default (in the format WxH, e.g. 1920x1080) // Can be specified inside the file fullscreen_resolution.ini to override default (in the format WxH, e.g. 1920x1080)
int fullscreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width; int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
int fullscreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height; int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
if (FileUtil.doesFileExist(desktopModeAssetsDir + "fullscreen_resolution.ini")) { boolean fullscreenFlag = false;
String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "fullscreen_resolution.ini").split("x"); if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) {
if (res.length == 2) { String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x");
fullscreenWidth = Integer.parseInt(res[0].trim()); if (res.length == 3) {
fullscreenHeight = Integer.parseInt(res[1].trim()); fullscreenFlag = Integer.parseInt(res[2].trim()) > 0;
desktopScreenWidth = Integer.parseInt(res[0].trim());
desktopScreenHeight = Integer.parseInt(res[1].trim());
} else if (res.length == 2) {
fullscreenFlag = true;
desktopScreenWidth = Integer.parseInt(res[0].trim());
desktopScreenHeight = Integer.parseInt(res[1].trim());
} }
} }
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false; config.resizable = false;
config.width = desktopMode ? fullscreenWidth : screenWidth; config.width = desktopMode ? desktopScreenWidth : screenWidth;
config.height = desktopMode ? fullscreenHeight : screenHeight; config.height = desktopMode ? desktopScreenHeight : screenHeight;
config.fullscreen = desktopMode; config.fullscreen = desktopMode && fullscreenFlag;
config.title = "Forge"; config.title = "Forge";
config.useHDPI = desktopMode; // enable HiDPI on Mac OS config.useHDPI = desktopMode; // enable HiDPI on Mac OS