Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions forge-gui-mobile-dev/src/forge/app/GameLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions forge-gui-mobile/src/forge/Forge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down