better way to check if display settings changed

This commit is contained in:
yugecin 2016-10-11 11:51:29 +02:00
parent 4d16508625
commit 97dd34cfc3
2 changed files with 9 additions and 19 deletions

View File

@ -134,8 +134,6 @@ public class Options {
/** Port binding. */
private static int port = 49250;
public static boolean wasResolutionChanged;
/**
* Returns whether the XDG flag in the manifest (if any) is set to "true".
* @return true if XDG directories are enabled, false otherwise
@ -311,20 +309,8 @@ public class Options {
return resolutionIdx + "";
}
},
ALLOW_LARGER_RESOLUTIONS ("Allow large resolutions", "AllowLargeRes", "Allow resolutions larger than the native resolution", 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;
}
},
ALLOW_LARGER_RESOLUTIONS ("Allow large resolutions", "AllowLargeRes", "Allow resolutions larger than the native resolution", false),
FULLSCREEN ("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false),
SKIN ("Skin", "Skin", "Restart (Ctrl+Shift+F5) to apply skin changes.") {
@Override
public String getValueString() { return skinName; }
@ -1360,6 +1346,10 @@ public class Options {
return resolutionIdx;
}
public static boolean allowLargeResolutions() {
return GameOption.ALLOW_LARGER_RESOLUTIONS.getBooleanValue();
}
/**
* Returns the target frame rate.
* @return the target FPS

View File

@ -509,19 +509,19 @@ public class OptionsMenu extends BasicGameState {
}
}
private int lastResIdx;
private String resolutionOptions;
@Override
public void enter(GameContainer container, StateBasedGame game)
throws SlickException {
UI.enter();
currentTab = OptionTab.DANCE;
lastResIdx = Options.getResolutionIdx();
resolutionOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions();
}
@Override
public void leave(GameContainer container, StateBasedGame game) throws SlickException {
if (Options.wasResolutionChanged || Options.getResolutionIdx() != lastResIdx) {
if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions()).equals(resolutionOptions)) {
container.setForceExit(false);
container.exit();
}