add fullscreen option, close #17

This commit is contained in:
yugecin 2016-10-11 11:22:32 +02:00
parent 3d3296f4ff
commit b1887b953b
2 changed files with 13 additions and 10 deletions

View File

@ -302,7 +302,7 @@ public class Options {
} catch (IllegalArgumentException ignored) {} } catch (IllegalArgumentException ignored) {}
} }
}, },
// FULLSCREEN ("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false), FULLSCREEN ("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false),
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; }
@ -1457,6 +1457,7 @@ public class Options {
try { try {
app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), false); app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), false);
app.setFullscreen(isFullscreen());
} catch (SlickException e) { } catch (SlickException e) {
ErrorHandler.error("Failed to set display mode.", e, true); ErrorHandler.error("Failed to set display mode.", e, true);
} }
@ -1464,16 +1465,18 @@ public class Options {
width = resolution.width; width = resolution.width;
height = resolution.height; height = resolution.height;
// set borderless window if dimensions match screen size if (!isFullscreen()) {
boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight()); // set borderless window if dimensions match screen size
System.setProperty("org.lwjgl.opengl.Window.undecorated", Boolean.toString(borderless)); boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight());
System.setProperty("org.lwjgl.opengl.Window.undecorated", Boolean.toString(borderless));
}
} }
// /** /**
// * Returns whether or not fullscreen mode is enabled. * Returns whether or not fullscreen mode is enabled.
// * @return true if enabled * @return true if enabled
// */ */
// public static boolean isFullscreen() { return fullscreen; } public static boolean isFullscreen() { return GameOption.FULLSCREEN.getBooleanValue(); }
/** /**
* Returns whether or not the FPS counter display is enabled. * Returns whether or not the FPS counter display is enabled.

View File

@ -56,7 +56,7 @@ public class OptionsMenu extends BasicGameState {
private enum OptionTab { private enum OptionTab {
DISPLAY ("Display", new GameOption[] { DISPLAY ("Display", new GameOption[] {
GameOption.SCREEN_RESOLUTION, GameOption.SCREEN_RESOLUTION,
// GameOption.FULLSCREEN, GameOption.FULLSCREEN,
GameOption.SKIN, GameOption.SKIN,
GameOption.TARGET_FPS, GameOption.TARGET_FPS,
GameOption.SHOW_FPS, GameOption.SHOW_FPS,