diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index e553c66f19..1ff07758f9 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -538,6 +538,7 @@ keybind.press.axis = Press an axis or key... keybind.screenshot.name = Map Screenshot keybind.move_x.name = Move x keybind.move_y.name = Move y +keybind.fullscreen.name = Toggle Fullscreen keybind.select.name = Select/Shoot keybind.diagonal_placement.name = Diagonal Placement keybind.pick.name = Pick Block diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 2406ca7556..5ba2ea9e08 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -396,6 +396,17 @@ public class Control implements ApplicationListener{ music.update(); loops.update(); + if(Core.input.keyTap(Binding.fullscreen)){ + boolean full = settings.getBool("fullscreen"); + if(full){ + graphics.setWindowedMode(graphics.getWidth(), graphics.getHeight()); + }else{ + graphics.setFullscreenMode(graphics.getDisplayMode()); + } + settings.put("fullscreen", !full); + settings.save(); + } + if(!state.is(State.menu)){ input.update(); diff --git a/core/src/io/anuke/mindustry/input/Binding.java b/core/src/io/anuke/mindustry/input/Binding.java index a2953a0dea..1eb5da1875 100644 --- a/core/src/io/anuke/mindustry/input/Binding.java +++ b/core/src/io/anuke/mindustry/input/Binding.java @@ -21,6 +21,7 @@ public enum Binding implements KeyBind{ zoom_hold(KeyCode.CONTROL_LEFT, "view"), zoom(new Axis(KeyCode.SCROLL)), menu(Core.app.getType() == ApplicationType.Android ? KeyCode.BACK : KeyCode.ESCAPE), + fullscreen(KeyCode.F11), pause(KeyCode.SPACE), minimap(KeyCode.M), toggle_menus(KeyCode.C), diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index 21cd40a5dd..66a12ed80c 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -198,7 +198,7 @@ public class SettingsMenuDialog extends SettingsDialog{ } return s + "%"; }); - graphics.sliderPref("fpscap", 241, 5, 241, 5, s -> (s > 240 ? Core.bundle.get("setting.fpscap.none") : Core.bundle.format("setting.fpscap.text", s))); + graphics.sliderPref("fpscap", 240, 5, 245, 5, s -> (s > 240 ? Core.bundle.get("setting.fpscap.none") : Core.bundle.format("setting.fpscap.text", s))); graphics.sliderPref("chatopacity", 100, 0, 100, 5, s -> s + "%"); if(!mobile){ @@ -207,7 +207,7 @@ public class SettingsMenuDialog extends SettingsDialog{ if(b){ Core.graphics.setFullscreenMode(Core.graphics.getDisplayMode()); }else{ - Core.graphics.setWindowedMode(600, 480); + Core.graphics.setWindowedMode(Core.graphics.getWidth(), Core.graphics.getHeight()); } }); diff --git a/tests/src/test/java/WorldTests.java b/tests/src/test/java/WorldTests.java deleted file mode 100644 index 5809b24c20..0000000000 --- a/tests/src/test/java/WorldTests.java +++ /dev/null @@ -1,112 +0,0 @@ -import io.anuke.arc.util.Time; -import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.world.Tile; -import org.junit.jupiter.api.*; - -import static io.anuke.mindustry.Vars.*; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class WorldTests{ - static Tile[][] tiles; - - @BeforeAll - static void launchApplication(){ - ApplicationTests.launchApplication(); - world.createTiles(10, 10); - tiles = world.getTiles(); - } - - @BeforeEach - void resetWorld(){ - Time.setDeltaProvider(() -> 1f); - logic.reset(); - state.set(State.menu); - } - - @Test - void addDarknessAllSolidMaxDarkness(){ - fillWith(Blocks.rocks.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - assertEquals(4, tiles[x][y].rotation()); - } - } - } - - @Test - void addDarknessAllSyntethicNoDarkness(){ - fillWith(Blocks.copperWall.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - assertEquals(0, tiles[x][y].rotation()); - } - } - } - - @Test - void addDarknessAllNotSolidNoDarkness(){ - fillWith(Blocks.air.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - assertEquals(0, tiles[x][y].rotation()); - } - } - } - - @Test - void addDarknessAllNotFilledNoDarkness(){ - fillWith(Blocks.cliffs.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - assertEquals(0, tiles[x][y].rotation()); - } - } - } - - private static void fillWith(short tileID){ - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - tiles[x][y] = new Tile(x, y, (short)0, (short)0, tileID); - } - } - } - - @Test - void addDarknessOneNotSolidMiddleNoDarkness(){ - fillWith(Blocks.rocks.id); - tiles[5][5] = new Tile(5, 5, (byte)0, (byte)0, Blocks.copperWall.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - byte darkness = tiles[x][y].rotation(); - int distance = Math.abs(x - 5) + Math.abs(y - 5); - assertEquals(Math.min(Math.max(distance - 1, 0), 4), darkness); - } - } - } - - @Test - void addDarknessOneNotSolidCornerNoDarkness(){ - fillWith(Blocks.rocks.id); - tiles[7][7] = new Tile(5, 5, (byte)0, (byte)0, Blocks.copperWall.id); - world.addDarkness(tiles); - - for(int x = 0; x < tiles.length; x++){ - for(int y = 0; y < tiles[0].length; y++){ - byte darkness = tiles[x][y].rotation(); - int distance = Math.abs(x - 7) + Math.abs(y - 7); - assertEquals(Math.min(Math.max(distance - 1, 0), 4), darkness); - } - } - } -}