diff --git a/build.gradle b/build.gradle index e7ad56538a..84899de744 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' aiVersion = '1.8.1' - uCoreVersion = '0176aaa' + uCoreVersion = '872bce6' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/assets-raw/sprites/backgrounds/background.png b/core/assets-raw/sprites/backgrounds/background.png index 8b42400042..016328304f 100644 Binary files a/core/assets-raw/sprites/backgrounds/background.png and b/core/assets-raw/sprites/backgrounds/background.png differ diff --git a/core/assets-raw/sprites/ui/discord-banner-over.png b/core/assets-raw/sprites/ui/discord-banner-over.png new file mode 100644 index 0000000000..87a8ab0504 Binary files /dev/null and b/core/assets-raw/sprites/ui/discord-banner-over.png differ diff --git a/core/assets-raw/sprites/ui/discord-banner.png b/core/assets-raw/sprites/ui/discord-banner.png new file mode 100644 index 0000000000..39248244a8 Binary files /dev/null and b/core/assets-raw/sprites/ui/discord-banner.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-dev-builds.png b/core/assets-raw/sprites/ui/icons/icon-dev-builds.png new file mode 100644 index 0000000000..f845d619d4 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-dev-builds.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-exit.png b/core/assets-raw/sprites/ui/icons/icon-exit.png new file mode 100644 index 0000000000..13d45d242f Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-exit.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-github.png b/core/assets-raw/sprites/ui/icons/icon-github.png new file mode 100644 index 0000000000..4eebcb7ec4 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-github.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-google-play.png b/core/assets-raw/sprites/ui/icons/icon-google-play.png new file mode 100644 index 0000000000..944fd50253 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-google-play.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-itch.io.png b/core/assets-raw/sprites/ui/icons/icon-itch.io.png new file mode 100644 index 0000000000..0bf3a6e71c Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-itch.io.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-link.png b/core/assets-raw/sprites/ui/icons/icon-link.png new file mode 100644 index 0000000000..3a0e25bf29 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-link.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-trello.png b/core/assets-raw/sprites/ui/icons/icon-trello.png new file mode 100644 index 0000000000..c1184271b9 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-trello.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-wiki.png b/core/assets-raw/sprites/ui/icons/icon-wiki.png new file mode 100644 index 0000000000..6bd8d29014 Binary files /dev/null and b/core/assets-raw/sprites/ui/icons/icon-wiki.png differ diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 586af52ac5..178741165e 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1,6 +1,17 @@ -text.about=Created by [ROYAL]Anuken.[]\nOriginally an entry in the [orange]GDL[] MM Jam.\n\nCredits:\n- SFX made with [YELLOW]bfxr[]\n- Music made by [GREEN]RoccoW[] / found on [lime]FreeMusicArchive.org[]\n\nSpecial thanks to:\n- [coral]MitchellFJN[]: extensive playtesting and feedback\n- [sky]Luxray5474[]: wiki work, code contributions\n- [lime]Epowerj[]: code build system, icon\n- All the beta testers on itch.io and Google Play\n +text.about=Created by [ROYAL]Anuken[] - [SKY]anukendev@gmail.com[]\nOriginally an entry in the [orange]GDL[] Metal Monstrosity Jam.\n\nCredits:\n- SFX made with [YELLOW]bfxr[]\n- Music made by [GREEN]RoccoW[] / found on [lime]FreeMusicArchive.org[]\n\nSpecial thanks to:\n- [coral]MitchellFJN[]: extensive playtesting and feedback\n- [sky]Luxray5474[]: wiki work, code contributions\n- [lime]Epowerj[]: code build system, icon\n- All the beta testers on itch.io and Google Play\n +text.credits=Credits text.discord=Join the mindustry discord! text.changes=[SCARLET]Attention!\n[]Some important game mechanics have been changed.\n\n- [accent]Teleporters[] now use power.\n- [accent]Smelteries[] and [accent]crucibles[] now have a maximum item capacity.\n- [accent]Crucibles[] now require coal as fuel. +text.link.discord.description=the official Mindustry discord chatroom +text.link.github.description=Game source code +text.link.dev-builds.description=Unstable development builds +text.link.trello.description=Official trello board for planned features +text.link.itch.io.description=itch.io page with PC downloads and web version +text.link.google-play.description=Google Play store listing +text.link.wiki.description=official Mindustry wiki +text.linkfail=Failed to open link!\nThe URL has been copied to your cliboard. +text.editor.web=The web version does not support the editor!\nDownload the game to use it. +text.multiplayer.web=This version of the game does not support multiplayer!\nTo play multiplayer from your browser, use the "multiplayer web version" link at the itch.io page. text.gameover=The core was destroyed. text.highscore=[YELLOW]New highscore! text.lasted=You lasted until wave @@ -12,6 +23,7 @@ text.level.mode=Gamemode: text.savegame=Save Game text.loadgame=Load Game text.joingame=Join Game +text.newgame=New Game text.quit=Quit text.about.button=About text.name=Name: @@ -113,6 +125,7 @@ text.ok=OK text.open=Open text.cancel=Cancel text.openlink=Open Link +text.copylink=Copy Link text.back=Back text.quit.confirm=Are you sure you want to quit? text.changelog.title=Changelog @@ -339,9 +352,13 @@ keybind.weapon_3.name=weapon_3 keybind.weapon_4.name=weapon_4 keybind.weapon_5.name=weapon_5 keybind.weapon_6.name=weapon_6 +mode.text.help.title=Description of modes mode.waves.name=waves +mode.waves.description=the normal mode. limited resources and automatic incoming waves. mode.sandbox.name=sandbox +mode.sandbox.description=infinite resources and no timer for waves. mode.freebuild.name=freebuild +mode.freebuild.description=limited resources and no timer for waves. upgrade.standard-mech.name=standard upgrade.standard-mech.description=The standard mech. upgrade.standard-ship.name=standard ship diff --git a/core/assets/cursors/cursor.png b/core/assets/cursors/cursor.png new file mode 100644 index 0000000000..ece5696be0 Binary files /dev/null and b/core/assets/cursors/cursor.png differ diff --git a/core/assets/cursors/hand.png b/core/assets/cursors/hand.png new file mode 100644 index 0000000000..1613b1eac3 Binary files /dev/null and b/core/assets/cursors/hand.png differ diff --git a/core/assets/cursors/ibar.png b/core/assets/cursors/ibar.png new file mode 100644 index 0000000000..61ddc4b423 Binary files /dev/null and b/core/assets/cursors/ibar.png differ diff --git a/core/assets/ui/uiskin.json b/core/assets/ui/uiskin.json index f6fe02ba53..6da4b2bc62 100644 --- a/core/assets/ui/uiskin.json +++ b/core/assets/ui/uiskin.json @@ -52,6 +52,7 @@ io.anuke.ucore.scene.ui.Button$ButtonStyle: { }, io.anuke.ucore.scene.ui.TextButton$TextButtonStyle: { default: {over: button-over, disabled: button, font: default-font, fontColor: white, disabledFontColor: grey, down: button-down, up: button, transition: 0 }, + discord: {over: discord-banner-over, font: default-font, fontColor: white, up: discord-banner}, clear: {down: clear-down, up: clear, over: clear-over, font: default-font, fontColor: white, disabledFontColor: grey }, empty: {font: default-font}, toggle: {font: default-font, fontColor: white, checked: button-down, down: button-down, up: button, over: button-over, disabled: button, disabledFontColor: grey } diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 3fb550a3ae..2aa22bbcbe 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -57,7 +57,7 @@ public class Vars{ public static float fontscale = Math.max(Unit.dp.scl(1f)/2f, 0.5f); //camera zoom displayed on startup public static final int baseCameraScale = Math.round(Unit.dp.scl(4)); - //how much the zoom changes every zoom button press + //how much the zoom changes every zoom button press (unused?) public static final int zoomScale = Math.round(Unit.dp.scl(1)); //if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available public static boolean debug = false; diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 97ac9f0fbf..8c79129f77 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -35,6 +35,8 @@ import io.anuke.ucore.function.Callable; import io.anuke.ucore.graphics.*; import io.anuke.ucore.modules.RendererModule; import io.anuke.ucore.scene.ui.layout.Unit; +import io.anuke.ucore.scene.utils.Cursors; +import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; @@ -69,6 +71,12 @@ public class Renderer extends RendererModule{ } }); + Cursors.cursorScaling = 3; + Cursors.outlineColor = Color.valueOf("444444"); + Cursors.arrow = Cursors.loadCursor("cursor"); + Cursors.hand = Cursors.loadCursor("hand"); + Cursors.ibeam = Cursors.loadCursor("ibar"); + clearColor = Hue.lightness(0.4f); clearColor.a = 1f; @@ -426,7 +434,8 @@ public class Renderer extends RendererModule{ if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android) && control.input().drawPlace())){ - input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), control.input().getBlockEndX(), control.input().getBlockEndY()); + input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), + control.input().getBlockEndX(), control.input().getBlockEndY()); Lines.stroke(1f); Draw.color(Color.SCARLET); @@ -442,9 +451,15 @@ public class Renderer extends RendererModule{ if(input.breakMode == PlaceMode.holdDelete) input.breakMode.draw(tilex, tiley, 0, 0); - }else if(input.breakMode.delete && control.input().drawPlace() && input.recipe == null){ - input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(), - control.input().getBlockEndX(), control.input().getBlockEndY()); + }else if(input.breakMode.delete && control.input().drawPlace() + && (input.recipe == null || !state.inventory.hasItems(input.recipe.requirements)) + && (input.placeMode.delete || input.breakMode.both || !android)){ + + if(input.breakMode == PlaceMode.holdDelete) + input.breakMode.draw(tilex, tiley, 0, 0); + else + input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(), + control.input().getBlockEndX(), control.input().getBlockEndY()); } if(ui.toolfrag.confirming){ diff --git a/core/src/io/anuke/mindustry/game/GameMode.java b/core/src/io/anuke/mindustry/game/GameMode.java index 4d102a0ac9..8481f1a97f 100644 --- a/core/src/io/anuke/mindustry/game/GameMode.java +++ b/core/src/io/anuke/mindustry/game/GameMode.java @@ -18,6 +18,10 @@ public enum GameMode{ public boolean infiniteResources; public boolean disableWaveTimer; + public String description(){ + return Bundles.get("mode."+name()+".description"); + } + @Override public String toString(){ return Bundles.get("mode."+name()+".name"); diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index 704705bb4e..7a859da9f1 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -20,9 +20,9 @@ public class AndroidInput extends InputHandler{ public float lmousex, lmousey; public float mousex, mousey; public boolean brokeBlock = false; + public boolean placing = false; private boolean enableHold = false; - private boolean placing = false; private float warmup; private float warmupDelay = 20; @@ -48,6 +48,7 @@ public class AndroidInput extends InputHandler{ }else if(pointer == 0 && !breakMode.pan && breaking() && drawPlace()){ breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); } + placing = false; return false; } diff --git a/core/src/io/anuke/mindustry/input/GestureHandler.java b/core/src/io/anuke/mindustry/input/GestureHandler.java index 558f5afd93..dc1fbdbfca 100644 --- a/core/src/io/anuke/mindustry/input/GestureHandler.java +++ b/core/src/io/anuke/mindustry/input/GestureHandler.java @@ -47,7 +47,7 @@ public class GestureHandler extends GestureAdapter{ if(control.showCursor() && !Inputs.keyDown("select")) return false; if(!control.showCursor() && !(control.input().recipe != null - && state.inventory.hasItems(control.input().recipe.requirements) && control.input().placeMode.lockCamera) && + && control.input().placeMode.lockCamera) && !(control.input().recipe == null && control.input().breakMode.lockCamera)){ float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale; player.x -= dx; diff --git a/core/src/io/anuke/mindustry/input/PlaceMode.java b/core/src/io/anuke/mindustry/input/PlaceMode.java index 44558814ac..48039b889e 100644 --- a/core/src/io/anuke/mindustry/input/PlaceMode.java +++ b/core/src/io/anuke/mindustry/input/PlaceMode.java @@ -164,7 +164,6 @@ public enum PlaceMode{ } public void released(int tilex, int tiley, int endx, int endy){ - process(tilex, tiley, endx, endy); tilex = this.tilex; tiley = this.tiley; endx = this.endx; endy = this.endy; diff --git a/core/src/io/anuke/mindustry/ui/Links.java b/core/src/io/anuke/mindustry/ui/Links.java new file mode 100644 index 0000000000..facbcf45e7 --- /dev/null +++ b/core/src/io/anuke/mindustry/ui/Links.java @@ -0,0 +1,32 @@ +package io.anuke.mindustry.ui; + +import com.badlogic.gdx.graphics.Color; +import io.anuke.ucore.util.Bundles; + +public class Links { + private static final LinkEntry[] links = { + new LinkEntry("discord", "https://discord.gg/BKADYds", Color.valueOf("7289da")), + new LinkEntry("trello", "https://trello.com/b/aE2tcUwF", Color.valueOf("026aa7")), + new LinkEntry("wiki", "http://mindustry.wikia.com/wiki/Mindustry_Wiki", Color.valueOf("0f142f")), + new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Color.valueOf("fa5c5c")), + new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Color.valueOf("689f38")), + new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Color.valueOf("24292e")), + new LinkEntry("dev-builds", "https://github.com/Anuken/Mindustry/wiki", Color.valueOf("fafbfc")), + }; + + public static LinkEntry[] getLinks(){ + return links; + } + + public static class LinkEntry{ + public final String name, description, link; + public final Color color; + + public LinkEntry(String name, String link, Color color) { + this.name = name; + this.color = color; + this.description = Bundles.getNotNull("text.link." + name +".description"); + this.link = link; + } + } +} diff --git a/core/src/io/anuke/mindustry/ui/MenuButton.java b/core/src/io/anuke/mindustry/ui/MenuButton.java index f6d4a06d43..e01f9aeb8b 100644 --- a/core/src/io/anuke/mindustry/ui/MenuButton.java +++ b/core/src/io/anuke/mindustry/ui/MenuButton.java @@ -1,49 +1,37 @@ package io.anuke.mindustry.ui; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import io.anuke.ucore.core.Core; import io.anuke.ucore.function.Listenable; -import io.anuke.ucore.scene.ui.Button; -import io.anuke.ucore.scene.ui.layout.Unit; -import io.anuke.ucore.util.Bundles; +import io.anuke.ucore.scene.ui.TextButton; -public class MenuButton extends Button{ - private static boolean hasInvalid = false; - private String text; - private boolean added = false; - - public MenuButton(String text, PressGroup group, Listenable clicked){ - super("menu"); - this.text = text; - BitmapFont font = Core.skin.getFont("title"); - for(char c : Bundles.get(text.substring(1)).toCharArray()){ - if(!font.getData().hasGlyph(c)){ - hasInvalid = true; - break; - } - } - clicked(clicked); - group.add(this); +public class MenuButton extends TextButton{ + + public MenuButton(String icon, String text, Listenable clicked){ + this(icon, text, null, clicked); } + + public MenuButton(String icon, String text, String description, Listenable clicked){ + super("default"); + float s = 70f; - @Override - public void layout() { - super.layout(); - if(added) - return; - added = true; - String style = "title"; - float scale = 4f; - if(hasInvalid){ - style = "default"; - scale = Unit.dp.scl(1f); - } - add(text, style, scale).color(hasInvalid ? Color.DARK_GRAY : Color.WHITE); + clicked(clicked); - if(hasInvalid){ - row(); - add(text, style, scale).padTop(Unit.dp.scl(-Core.font.getData().lineHeight * scale * 2f - 4f)).color(Color.WHITE); - } + clearChildren(); + + margin(0); + + table(t -> { + t.addImage(icon).size(14*3); + t.update(() -> t.setBackground(getClickListener().isOver() || getClickListener().isVisualPressed() ? "button-over" : "button")); + }).size(s - 5, s); + + + table(t -> { + t.add(text); + if(description != null){ + t.row(); + t.add(description).color(Color.LIGHT_GRAY); + } + }).padLeft(5).growX(); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java index 94234a385c..56ca6fab5f 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java @@ -1,11 +1,69 @@ package io.anuke.mindustry.ui.dialogs; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.ui.Links; +import io.anuke.mindustry.ui.Links.LinkEntry; +import io.anuke.ucore.core.Core; +import io.anuke.ucore.core.Timers; +import io.anuke.ucore.scene.ui.ScrollPane; +import io.anuke.ucore.scene.ui.layout.Table; + public class AboutDialog extends FloatingDialog { public AboutDialog(){ super("$text.about.button"); addCloseButton(); - content().add("$text.about"); + + float h = 80f; + float w = 600f; + + Table in = new Table(); + ScrollPane pane = new ScrollPane(in, "clear"); + + for(LinkEntry link : Links.getLinks()){ + Table table = new Table("button"); + table.margin(0); + table.table(img -> { + img.addImage("white").height(h - 5).width(40f).color(link.color); + img.row(); + img.addImage("white").height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f)); + }).expandY(); + + table.table(i -> { + i.background("button"); + i.addImage("icon-" + link.name).size(14*3f); + }).size(h-5, h); + + table.table(inset -> { + inset.add("[accent]"+link.name.replace("-", " ")).growX().left(); + inset.row(); + inset.labelWrap(link.description).width(w - 100f).color(Color.LIGHT_GRAY).growX(); + }).padLeft(8); + + table.addImageButton("icon-link", 14*3, () -> { + if(!Gdx.net.openURI(link.link)){ + Vars.ui.showError("$text.linkfail"); + Gdx.app.getClipboard().setContents(link.link); + } + }).size(h-5, h); + + in.add(table).size(w, h).padTop(5).row(); + } + + shown(() -> Timers.run(1f, () -> Core.scene.setScrollFocus(pane))); + + content().add(pane).growX(); + + buttons().addButton("$text.credits", this::showCredits).size(200f, 64f); + } + + private void showCredits(){ + FloatingDialog dialog = new FloatingDialog("$text.credits"); + dialog.addCloseButton(); + dialog.content().add("$text.about"); + dialog.show(); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java index c94c3e1ae6..b92a7ff5e1 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java @@ -1,20 +1,52 @@ package io.anuke.mindustry.ui.dialogs; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Colors; import io.anuke.ucore.scene.ui.Dialog; import static io.anuke.mindustry.Vars.discordURL; +import static io.anuke.mindustry.Vars.ui; public class DiscordDialog extends Dialog { public DiscordDialog(){ - super("Discord", "dialog"); + super("", "dialog"); + + float h = 70f; + content().margin(12f); - content().add("$text.discord"); - content().row(); - content().add("[orange]"+ discordURL); - buttons().defaults().size(200f, 50); - buttons().addButton("$text.openlink", () -> Gdx.net.openURI(discordURL)); + + Color color = Color.valueOf("7289da"); + + content().table(t -> { + t.background("button").margin(0); + + t.table(img -> { + img.addImage("white").height(h - 5).width(40f).color(color); + img.row(); + img.addImage("white").height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f)); + }).expandY(); + + t.table(i -> { + i.background("button"); + i.addImage("icon-discord").size(14 * 3); + }).size(h).left(); + + t.add("$text.discord").color(Colors.get("accent")).growX().padLeft(10f); + }).size(470f, h).pad(10f); + + buttons().defaults().size(170f, 50); + buttons().addButton("$text.back", this::hide); + buttons().addButton("$text.copylink", () ->{ + Gdx.app.getClipboard().setContents(discordURL); + }); + buttons().addButton("$text.openlink", () ->{ + if(!Gdx.net.openURI(discordURL)){ + ui.showError("$text.linkfail"); + Gdx.app.getClipboard().setContents(discordURL); + } + }); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java index 9a7c8d4424..612945183e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java @@ -22,7 +22,6 @@ import static io.anuke.mindustry.Vars.*; public class LevelDialog extends FloatingDialog{ private Map selectedMap = world.maps().getMap(0); - private TextureRegion region = new TextureRegion(); private ScrollPane pane; public LevelDialog(){ @@ -56,6 +55,7 @@ public class LevelDialog extends FloatingDialog{ group.add(b[0]); selmode.add(b[0]).size(130f, 54f); } + selmode.addButton("?", this::displayGameModeHelp).size(50f, 54f).padLeft(18f); content().add(selmode); content().row(); @@ -171,4 +171,23 @@ public class LevelDialog extends FloatingDialog{ }); }); } + + private void displayGameModeHelp() { + FloatingDialog d = new FloatingDialog(Bundles.get("mode.text.help.title")); + d.setFillParent(false); + Table table = new Table(); + table.defaults().pad(1f); + ScrollPane pane = new ScrollPane(table, "clear"); + pane.setFadeScrollBars(false); + table.row(); + for(GameMode mode : GameMode.values()){ + table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(600f); + table.row(); + } + + d.content().add(pane); + d.buttons().addButton("$text.ok", d::hide).size(110, 50).pad(10f); + d.show(); + } + } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java index 8cd8abbb6e..e8ae0e4d3b 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java @@ -20,8 +20,8 @@ public class BackgroundFragment implements Fragment { TextureRegion back = Draw.region("background"); float backscl = Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f)); - Draw.alpha(0.7f); - Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2 +240f, h/2 - back.getRegionHeight()*backscl/2 + 250f, + Draw.alpha(0.5f); + Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2, back.getRegionWidth()*backscl, back.getRegionHeight()*backscl); boolean portrait = Gdx.graphics.getWidth() < Gdx.graphics.getHeight(); @@ -31,7 +31,7 @@ public class BackgroundFragment implements Fragment { float logoh = logo.getRegionHeight()*logoscl; Draw.color(); - Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15 + (portrait ? -Unit.dp.scl(30f) : 0f), logow, logoh); + Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 30), logow, logoh); }).visible(() -> state.is(State.menu)).grow(); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 817b3b5c79..a4133b9122 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -1,12 +1,11 @@ package io.anuke.mindustry.ui.fragments; import com.badlogic.gdx.Gdx; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.io.Platform; import io.anuke.mindustry.io.Version; import io.anuke.mindustry.ui.MenuButton; -import io.anuke.mindustry.ui.PressGroup; +import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; @@ -21,36 +20,38 @@ public class MenuFragment implements Fragment{ if(!android){ new table(){{ - PressGroup group = new PressGroup(); - - float scale = 4f; - defaults().size(140*scale, 21*scale).pad(-10f); - add(new MenuButton("$text.play", group, ui.levels::show)); + float w = 200f; + float bw = w * 2f + 10f; + + defaults().size(w, 70f).padTop(5).padRight(5); + + add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2); + row(); - if(Platform.instance.canJoinGame()) { - add(new MenuButton("$text.joingame", group, ui.join::show)); - row(); - } + add(new MenuButton("icon-editor", "$text.editor", () -> { + if(gwt){ + ui.showInfo("$text.editor.web"); + }else{ + ui.editor.show(); + } + })); - add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial")))); + add(new MenuButton("icon-tools", "$text.settings", ui.settings::show)); + row(); - add(new MenuButton("$text.loadgame", group, ui.load::show)); - row(); + add(new MenuButton("icon-info", "$text.about.button", ui.about::show)); + + add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show)); - if(!gwt){ - add(new MenuButton("$text.editor", group, ui.editor::show)); - row(); - } - - add(new MenuButton("$text.settings", group, ui.settings::show)); row(); if(!gwt){ - add(new MenuButton("$text.quit", group, Gdx.app::exit)); + add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2); } + get().margin(16); }}.end(); @@ -79,18 +80,14 @@ public class MenuFragment implements Fragment{ }}.end(); } }}.end(); - - //extra icons in top right - new table(){{ - atop().aright(); - if(Platform.instance.hasDiscord()){ - new imagebutton("icon-discord", 30f, ui.discord::show).margin(14); - } - if(!Vars.android) { - new imagebutton("icon-info", 30f, ui.about::show).margin(14); - } - new imagebutton("icon-menu", 30f, ui.changelog::show).margin(14); - }}.end().visible(()->state.is(State.menu)); + + //discord icon in top right + if(Platform.instance.hasDiscord()) { + new table() {{ + abottom().atop().aright(); + get().addButton("", "discord", ui.discord::show); + }}.end().visible(() -> state.is(State.menu)); + } //version info new table(){{ @@ -99,4 +96,41 @@ public class MenuFragment implements Fragment{ new label("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName); }}.end(); } + + private void showPlaySelect(){ + float w = 200f; + float bw = w * 2f + 10f; + + FloatingDialog dialog = new FloatingDialog("$text.play"); + dialog.addCloseButton(); + dialog.content().defaults().height(70f).width(w).padRight(5f); + + dialog.content().add(new MenuButton("icon-play-2", "$text.newgame", () -> { + dialog.hide(); + ui.levels.show(); + })).width(bw).colspan(2); + dialog.content().row(); + + dialog.content().add(new MenuButton("icon-add", "$text.joingame", () -> { + if(Platform.instance.canJoinGame()){ + ui.join.show(); + dialog.hide(); + }else{ + ui.showInfo("$text.multiplayer.web"); + } + })); + dialog.content().add(new MenuButton("icon-tutorial", "$text.tutorial", ()-> { + control.playMap(world.maps().getMap("tutorial")); + dialog.hide(); + })); + + dialog.content().row(); + + dialog.content().add(new MenuButton("icon-load", "$text.loadgame", () -> { + ui.load.show(); + dialog.hide(); + })).width(bw).colspan(2); + + dialog.show(); + } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 39427f4cf3..c25fa3a103 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.utils.Align; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.core.Core; @@ -128,7 +129,7 @@ public class PlacementFragment implements Fragment{ defaults().padBottom(-5.5f); - new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { + ImageButton button = new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { control.input().resetCursor(); input.breakMode = mode; input.lastBreakMode = mode; @@ -138,7 +139,15 @@ public class PlacementFragment implements Fragment{ input.placeMode = input.lastPlaceMode; } modeText(Bundles.format("text.mode.break", mode.toString())); - }).group(breakGroup).get().setName(mode.name()); + }).group(breakGroup).get(); + + button.setName(mode.name()); + button.released(() -> { + //TODO hack + if(mode == PlaceMode.areaDelete){ + ((AndroidInput)input).placing = false; + } + }); } }}.end().get(); @@ -215,6 +224,7 @@ public class PlacementFragment implements Fragment{ if(!show){ control.input().breakMode = PlaceMode.none; + if(control.input().placeMode.delete) control.input().placeMode = PlaceMode.none; breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false)); }else{ shown = true;