automatically restart when display settings changed

This commit is contained in:
yugecin 2016-10-11 11:47:46 +02:00
parent 0e43e6f938
commit 4d16508625
2 changed files with 31 additions and 2 deletions

View File

@ -134,6 +134,8 @@ public class Options {
/** Port binding. */ /** Port binding. */
private static int port = 49250; private static int port = 49250;
public static boolean wasResolutionChanged;
/** /**
* Returns whether the XDG flag in the manifest (if any) is set to "true". * Returns whether the XDG flag in the manifest (if any) is set to "true".
* @return true if XDG directories are enabled, false otherwise * @return true if XDG directories are enabled, false otherwise
@ -309,8 +311,20 @@ public class Options {
return resolutionIdx + ""; return resolutionIdx + "";
} }
}, },
ALLOW_LARGER_RESOLUTIONS ("Allow large resolutions", "AllowLargeRes", "Allow resolutions larger than the native resolution", false), ALLOW_LARGER_RESOLUTIONS ("Allow large resolutions", "AllowLargeRes", "Allow resolutions larger than the native resolution", false) {
FULLSCREEN ("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false), @Override
public void click(GameContainer container) {
super.click(container);
wasResolutionChanged = true;
}
},
FULLSCREEN ("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false) {
@Override
public void click(GameContainer container) {
super.click(container);
wasResolutionChanged = true;
}
},
SKIN ("Skin", "Skin", "Restart (Ctrl+Shift+F5) to apply skin changes.") { SKIN ("Skin", "Skin", "Restart (Ctrl+Shift+F5) to apply skin changes.") {
@Override @Override
public String getValueString() { return skinName; } public String getValueString() { return skinName; }
@ -1342,6 +1356,10 @@ public class Options {
// This class should not be instantiated. // This class should not be instantiated.
private Options() {} private Options() {}
public static int getResolutionIdx() {
return resolutionIdx;
}
/** /**
* Returns the target frame rate. * Returns the target frame rate.
* @return the target FPS * @return the target FPS

View File

@ -509,11 +509,22 @@ public class OptionsMenu extends BasicGameState {
} }
} }
private int lastResIdx;
@Override @Override
public void enter(GameContainer container, StateBasedGame game) public void enter(GameContainer container, StateBasedGame game)
throws SlickException { throws SlickException {
UI.enter(); UI.enter();
currentTab = OptionTab.DANCE; currentTab = OptionTab.DANCE;
lastResIdx = Options.getResolutionIdx();
}
@Override
public void leave(GameContainer container, StateBasedGame game) throws SlickException {
if (Options.wasResolutionChanged || Options.getResolutionIdx() != lastResIdx) {
container.setForceExit(false);
container.exit();
}
} }
/** /**