diff --git a/forge-gui-mobile-dev/src/forge/app/GameLauncher.java b/forge-gui-mobile-dev/src/forge/app/GameLauncher.java index 1e47f29cab0..e7f07cf3569 100644 --- a/forge-gui-mobile-dev/src/forge/app/GameLauncher.java +++ b/forge-gui-mobile-dev/src/forge/app/GameLauncher.java @@ -56,16 +56,51 @@ public GameLauncher(final String versionString, final String[] args) { } catch (Exception e) { e.printStackTrace(); } - ApplicationListener start = Forge.getApp(hw, new Lwjgl3Clipboard(), new Main.DesktopAdapter(switchOrientationFile), - assetsDir, false, false, totalRAM, false, 0); - int windowWidth = Config.instance().getSettingData().width; - int windowHeight = Config.instance().getSettingData().height; + // Retrieve command line parameters + int windowHeight = 0; + int windowWidth = 0; + boolean isPortrait = false; + boolean manualWindowSize = false; for(String arg : args) { - if(arg.startsWith("width=")) + if(arg.startsWith("width=")) { windowWidth = Integer.parseInt(arg.substring(6)); - if(arg.startsWith("height=")) + manualWindowSize = true; + } + if(arg.startsWith("height=")) { windowHeight = Integer.parseInt(arg.substring(7)); + manualWindowSize = true; + } + if(arg.equalsIgnoreCase("portrait")) { + isPortrait = true; + } + } + + // Check if the manually supplied window size indicates portrait mode + if ((windowHeight > 0) && (windowWidth > 0)) { + if (windowHeight > windowWidth) { + isPortrait = true; + } + } + + ApplicationListener start = Forge.getApp(hw, new Lwjgl3Clipboard(), new Main.DesktopAdapter(switchOrientationFile), + assetsDir, false, isPortrait, totalRAM, false, 0); + + // If no manual window size is supplied, use the configured one (and adjust for portrait mode if needed) + if (!manualWindowSize) { + windowWidth = Config.instance().getSettingData().width; + windowHeight = Config.instance().getSettingData().height; + if (isPortrait && (windowHeight < windowWidth)) { + // swap width/height + int tmp = windowHeight; + windowHeight = windowWidth; + windowWidth = tmp; + } else if (!isPortrait && (windowWidth < windowHeight)) { + // swap width/height + int tmp = windowHeight; + windowHeight = windowWidth; + windowWidth = tmp; + } } if (Config.instance().getSettingData().fullScreen) { diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 0bce5c13ae5..5e63584398b 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -202,7 +202,7 @@ the app again (seems it doesnt dispose correctly...?!?) destroyThis = true; //Prevent back() if (Files.exists(Paths.get(ForgeConstants.DEFAULT_SKINS_DIR+ForgeConstants.ADV_TEXTURE_BG_FILE))) selector = getForgePreferences().getPref(FPref.UI_SELECTOR_MODE); - boolean landscapeMode = GuiBase.isAndroid() ? !isPortraitMode : screenWidth > screenHeight; + boolean landscapeMode = !isPortraitMode; //update landscape mode preference if it doesn't match what the app loaded as if (getForgePreferences().getPrefBoolean(FPref.UI_LANDSCAPE_MODE) != landscapeMode) { getForgePreferences().setPref(FPref.UI_LANDSCAPE_MODE, landscapeMode); @@ -726,9 +726,7 @@ public static boolean isTextureFilteringEnabled() { } public static boolean isLandscapeMode() { - if (GuiBase.isAndroid()) - return !isPortraitMode; - return screenWidth > screenHeight; + return !isPortraitMode; } public static boolean isLoadingaMatch() {