diff --git a/main/src/com/miloshpetrov/sol2/GameOptions.java b/main/src/com/miloshpetrov/sol2/GameOptions.java index 7586a79a1..667666c48 100644 --- a/main/src/com/miloshpetrov/sol2/GameOptions.java +++ b/main/src/com/miloshpetrov/sol2/GameOptions.java @@ -4,6 +4,9 @@ import com.badlogic.gdx.Graphics; import com.badlogic.gdx.Input; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; public class GameOptions { public static final String FILE_NAME = "settings.ini"; @@ -36,8 +39,8 @@ public class GameOptions { private String keyChangeShipMenuName; private String keyHireShipMenuName; - - private int resPos = -1; + private SortedSet supportedResolutions = new TreeSet(); + private Iterator resolutionIterator = null; public GameOptions(boolean mobile, SolFileReader reader) { IniReader r = new IniReader(FILE_NAME, reader, false); @@ -68,18 +71,29 @@ public GameOptions(boolean mobile, SolFileReader reader) { } public void advanceReso() { - // Get the resolutions that are supported - Graphics.DisplayMode displayModes[] = Gdx.graphics.getDisplayModes(); + if (resolutionIterator == null) { + // Initialize resolution choices - get the resolutions that are supported + Graphics.DisplayMode displayModes[] = Gdx.graphics.getDisplayModes(); + + for (Graphics.DisplayMode d : displayModes) { + supportedResolutions.add(d.width + "x" + d.height); + } - // resPos is static, so increment to display next resolution - resPos++; - if (resPos >= displayModes.length) { - resPos = 0; + resolutionIterator = supportedResolutions.iterator(); + } + + String nextResolution; + if (resolutionIterator.hasNext()) { + nextResolution = resolutionIterator.next(); + } else { + // Probably somehow possible to get no entries at all which would crash, but then we're doomed anyway + resolutionIterator = supportedResolutions.iterator(); + nextResolution = resolutionIterator.next(); } - // display the next supported resolution - x = displayModes[resPos].width; - y = displayModes[resPos].height; + // TODO: Probably should validate, but then there are still many things we should probably add! :-) + x = Integer.parseInt(nextResolution.substring(0, nextResolution.indexOf("x"))); + y = Integer.parseInt(nextResolution.substring(nextResolution.indexOf("x") + 1, nextResolution.length())); save(); } diff --git a/main/src/com/miloshpetrov/sol2/menu/ResolutionScreen.java b/main/src/com/miloshpetrov/sol2/menu/ResolutionScreen.java index c4a8a929a..bbb585d46 100644 --- a/main/src/com/miloshpetrov/sol2/menu/ResolutionScreen.java +++ b/main/src/com/miloshpetrov/sol2/menu/ResolutionScreen.java @@ -69,7 +69,7 @@ public void drawImgs(UiDrawer uiDrawer, SolApplication cmp) { @Override public void drawText(UiDrawer uiDrawer, SolApplication cmp) { - uiDrawer.drawString("Please restart to apply changes", .5f * uiDrawer.r, .3f, FontSize.MENU, true, SolColor.W); + uiDrawer.drawString("Click 'Back' to apply changes", .5f * uiDrawer.r, .3f, FontSize.MENU, true, SolColor.W); } @Override