Visual changes #2

Fill bg image to screen while keeping aspec ratio
Added a few more resolutions
This commit is contained in:
fd 2015-02-14 14:10:47 -05:00
parent 597c4bfb19
commit 8c3604d4db
2 changed files with 12 additions and 2 deletions

View File

@ -418,8 +418,10 @@ public class Options {
RES_800_600 (800, 600), RES_800_600 (800, 600),
RES_1024_600 (1024, 600), RES_1024_600 (1024, 600),
RES_1024_768 (1024, 768), RES_1024_768 (1024, 768),
RES_1280_720 (1280, 720),
RES_1280_800 (1280, 800), RES_1280_800 (1280, 800),
RES_1280_960 (1280, 960), RES_1280_960 (1280, 960),
RES_1280_1024 (1280, 1024),
RES_1366_768 (1366, 768), RES_1366_768 (1366, 768),
RES_1440_900 (1440, 900), RES_1440_900 (1440, 900),
RES_1600_900 (1600, 900), RES_1600_900 (1600, 900),
@ -428,7 +430,9 @@ public class Options {
RES_1920_1080 (1920, 1080), RES_1920_1080 (1920, 1080),
RES_1920_1200 (1920, 1200), RES_1920_1200 (1920, 1200),
RES_2560_1440 (2560, 1440), RES_2560_1440 (2560, 1440),
RES_2560_1600 (2560, 1600); RES_2560_1600 (2560, 1600),
RES_3840_2160 (3840, 2160);
/** Screen dimensions. */ /** Screen dimensions. */
private int width, height; private int width, height;

View File

@ -268,14 +268,20 @@ public class OsuFile implements Comparable<OsuFile> {
bgImageMap.put(this, bgImage); bgImageMap.put(this, bgImage);
} }
// fit image to screen
int swidth = width; int swidth = width;
int sheight = height; int sheight = height;
if (!stretch) { if (!stretch) {
// fit image to screen
if (bgImage.getWidth() / (float) bgImage.getHeight() > width / (float) height) // x > y if (bgImage.getWidth() / (float) bgImage.getHeight() > width / (float) height) // x > y
sheight = (int) (width * bgImage.getHeight() / (float) bgImage.getWidth()); sheight = (int) (width * bgImage.getHeight() / (float) bgImage.getWidth());
else else
swidth = (int) (height * bgImage.getWidth() / (float) bgImage.getHeight()); swidth = (int) (height * bgImage.getWidth() / (float) bgImage.getHeight());
} else {
//fill image to screen while keeping aspect ratio
if (bgImage.getWidth() / (float) bgImage.getHeight() > width / (float) height) // x > y
swidth = (int) (height * bgImage.getWidth() / (float) bgImage.getHeight());
else
sheight = (int) (width * bgImage.getHeight() / (float) bgImage.getWidth());
} }
bgImage = bgImage.getScaledCopy(swidth, sheight); bgImage = bgImage.getScaledCopy(swidth, sheight);