add "(borderless)" next to the native resolution in the list of resolutions

This commit is contained in:
yugecin 2017-05-01 23:12:58 +02:00
parent 102338f65b
commit acd27b1743

View File

@ -272,7 +272,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
width = height = -1; width = height = -1;
Input.disableControllers(); Input.disableControllers();
Display.setTitle("opsu!dance"); Display.setTitle("opsu!dance");
OPTION_SCREEN_RESOLUTION.getListItems()[0] = nativeDisplayMode.getWidth() + "x" + nativeDisplayMode.getHeight(); setupResolutionOptionlist(nativeDisplayMode.getWidth(), nativeDisplayMode.getHeight());
updateDisplayMode(OPTION_SCREEN_RESOLUTION.getValueString()); updateDisplayMode(OPTION_SCREEN_RESOLUTION.getValueString());
Display.create(); Display.create();
GLHelper.setIcons(new String[] { "icon16.png", "icon32.png" }); GLHelper.setIcons(new String[] { "icon16.png", "icon32.png" });
@ -282,6 +282,20 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
GLHelper.hideNativeCursor(); GLHelper.hideNativeCursor();
} }
// TODO: move this elsewhere
private void setupResolutionOptionlist(int width, int height) {
final Object[] resolutions = OPTION_SCREEN_RESOLUTION.getListItems();
final String nativeRes = width + "x" + height;
resolutions[0] = nativeRes;
OPTION_SCREEN_RESOLUTION.getListItems()[0] = width + "x" + height;
for (int i = 0; i < resolutions.length; i++) {
if (nativeRes.equals(resolutions[i].toString())) {
resolutions[i] = resolutions[i] + " (borderless)";
}
}
}
public void teardown() { public void teardown() {
destroyImages(); destroyImages();
CurveRenderState.shutdown(); CurveRenderState.shutdown();
@ -335,9 +349,14 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
int screenWidth = nativeDisplayMode.getWidth(); int screenWidth = nativeDisplayMode.getWidth();
int screenHeight = nativeDisplayMode.getHeight(); int screenHeight = nativeDisplayMode.getHeight();
int eos = resolutionString.indexOf(' ');
if (eos > -1) {
resolutionString = resolutionString.substring(0, eos);
}
int width = screenWidth; int width = screenWidth;
int height = screenHeight; int height = screenHeight;
if (resolutionString != null && resolutionString.matches("^[0-9]+x[0-9]+$")) { if (resolutionString.matches("^[0-9]+x[0-9]+$")) {
String[] res = resolutionString.split("x"); String[] res = resolutionString.split("x");
width = Integer.parseInt(res[0]); width = Integer.parseInt(res[0]);
height = Integer.parseInt(res[1]); height = Integer.parseInt(res[1]);