anonl / nvlist
Showing 1 of 4 files from the diff.

@@ -4,6 +4,8 @@
Loading
4 4
import java.io.IOException;
5 5
import java.util.List;
6 6
7 +
import javax.annotation.CheckForNull;
8 +
7 9
import org.slf4j.Logger;
8 10
import org.slf4j.LoggerFactory;
9 11
@@ -32,7 +34,7 @@
Loading
32 34
    }
33 35
34 36
    static void setWindowIcon(IFileSystem fileSystem) {
35 -
        Lwjgl3Window window = getCurrentWindow();
37 +
        Lwjgl3Window window = getCurrentWindow(Gdx.graphics);
36 38
37 39
        // Try to load icons in various sizes
38 40
        List<Pixmap> pixmaps = Lists.newArrayList();
@@ -74,10 +76,13 @@
Loading
74 76
        }
75 77
    }
76 78
77 -
    private static Lwjgl3Window getCurrentWindow() {
79 +
    @CheckForNull
80 +
    private static Lwjgl3Window getCurrentWindow(Graphics graphics) {
81 +
        if (!(graphics instanceof Lwjgl3Graphics)) {
82 +
            return null;
83 +
        }
78 84
        // Oddly, the only public way to get a reference to the main window is through the graphics object...
79 -
        Lwjgl3Graphics graphics = (Lwjgl3Graphics)Gdx.graphics;
80 -
        return graphics.getWindow();
85 +
        return ((Lwjgl3Graphics)Gdx.graphics).getWindow();
81 86
    }
82 87
83 88
    /**
@@ -86,26 +91,24 @@
Loading
86 91
    public static Dim limitInitialWindowSize(Graphics graphics) {
87 92
        if (graphics.isFullscreen()) {
88 93
            // If fullscreen, we fill the entire screen already so nothing needs to be done
89 -
        } else {
90 -
            // Width/height of the window in physical pixels
91 -
            int w = graphics.getBackBufferWidth();
92 -
            int h = graphics.getBackBufferHeight();
93 -
94 -
            // Limit window size so it fits inside the current monitor (with a margin for OS bars/decorations)
95 -
            DisplayMode displayMode = graphics.getDisplayMode();
96 -
            int maxW = displayMode.width - 100;
97 -
            int maxH = displayMode.height - 150;
98 -
99 -
            int dw = Math.min(0, maxW - w);
100 -
            int dh = Math.min(0, maxH - h);
101 -
            graphics.setWindowedMode(w + dw, h + dh);
102 -
103 -
            // Also change the window's position so it's centered on its previous location
104 -
            Lwjgl3Window window = getCurrentWindow();
105 -
            window.setPosition(window.getPositionX() - dw / 2, window.getPositionY() - dh /  2);
94 +
            return Dim.of(graphics.getBackBufferWidth(), graphics.getBackBufferHeight());
106 95
        }
107 96
108 -
        return Dim.of(graphics.getBackBufferWidth(), graphics.getBackBufferHeight());
97 +
        // Width/height of the window in physical pixels
98 +
        int w = graphics.getBackBufferWidth();
99 +
        int h = graphics.getBackBufferHeight();
100 +
101 +
        // Limit window size so it fits inside the current monitor (with a margin for OS bars/decorations)
102 +
        DisplayMode displayMode = graphics.getDisplayMode();
103 +
        int targetW = Math.min(w, displayMode.width - 100);
104 +
        int targetH = Math.min(h, displayMode.height - 150);
105 +
106 +
        float scale = Math.min(targetW / (float)w, targetH / (float)h);
107 +
        targetW = Math.round(w * scale);
108 +
        targetH = Math.round(h * scale);
109 +
        graphics.setWindowedMode(targetW, targetH);
110 +
111 +
        return Dim.of(targetW, targetH);
109 112
    }
110 113
111 114
}
Files Complexity Coverage
api/src/main/java/nl/weeaboo/vn 91.53% 96.76%
buildtools/src/main/java/nl/weeaboo/vn/buildtools 83.33% 89.43%
core/src/main/java/nl/weeaboo/vn 82.37% 86.62%
desktop/src/main/java/nl/weeaboo/vn/desktop 1.52% 2.26%
Project Totals (381 files) 81.00% 84.34%
1
codecov:
2
  status:
3
    project: yes
4
    patch: no
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading