From 5846af94530a13224edb304085f7598e00d4fa3d Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 16 Mar 2018 19:36:44 -0400 Subject: [PATCH] Finished new menu layout, added submenu for playing --- core/assets/bundles/bundle.properties | 6 +- core/assets/version.properties | 2 +- core/src/io/anuke/mindustry/ui/Links.java | 6 +- .../src/io/anuke/mindustry/ui/MenuButton.java | 16 +++- .../mindustry/ui/dialogs/AboutDialog.java | 9 +++ .../mindustry/ui/fragments/MenuFragment.java | 81 ++++++++++++------- 6 files changed, 86 insertions(+), 34 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 10a8fe0186..e8502e988d 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1,4 +1,5 @@ -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 @@ -9,6 +10,8 @@ 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 @@ -20,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: diff --git a/core/assets/version.properties b/core/assets/version.properties index 85efa404c1..0bcc070f09 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,5 +1,5 @@ #Autogenerated file. Do not modify. -#Fri Mar 16 16:59:13 EDT 2018 +#Fri Mar 16 19:36:00 EDT 2018 version=release androidBuildCode=443 name=Mindustry diff --git a/core/src/io/anuke/mindustry/ui/Links.java b/core/src/io/anuke/mindustry/ui/Links.java index f24076a115..facbcf45e7 100644 --- a/core/src/io/anuke/mindustry/ui/Links.java +++ b/core/src/io/anuke/mindustry/ui/Links.java @@ -6,12 +6,12 @@ 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("github", "https://github.com/Anuken/Mindustry/", Color.valueOf("24292e")), - new LinkEntry("dev-builds", "https://github.com/Anuken/Mindustry/wiki", Color.valueOf("fafbfc")), 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("wiki", "http://mindustry.wikia.com/wiki/Mindustry_Wiki", Color.valueOf("0f142f")), + 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(){ diff --git a/core/src/io/anuke/mindustry/ui/MenuButton.java b/core/src/io/anuke/mindustry/ui/MenuButton.java index d282cc3d17..e01f9aeb8b 100644 --- a/core/src/io/anuke/mindustry/ui/MenuButton.java +++ b/core/src/io/anuke/mindustry/ui/MenuButton.java @@ -1,11 +1,16 @@ package io.anuke.mindustry.ui; +import com.badlogic.gdx.graphics.Color; import io.anuke.ucore.function.Listenable; import io.anuke.ucore.scene.ui.TextButton; 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; @@ -20,6 +25,13 @@ public class MenuButton extends TextButton{ t.update(() -> t.setBackground(getClickListener().isOver() || getClickListener().isVisualPressed() ? "button-over" : "button")); }).size(s - 5, s); - add(text).padLeft(5).growX(); + + 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 60c3d86751..af129402f6 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java @@ -52,5 +52,14 @@ public class AboutDialog extends FloatingDialog { } 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/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 35c864438e..a4133b9122 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -5,6 +5,7 @@ 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.dialogs.FloatingDialog; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; @@ -25,23 +26,17 @@ public class MenuFragment implements Fragment{ defaults().size(w, 70f).padTop(5).padRight(5); - add(new MenuButton("icon-play-2", "$text.play", ui.levels::show)).width(bw).colspan(2); + add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2); row(); - //TODO submenu! - - /*if(Platform.instance.canJoinGame()) { - add(new MenuButton("icon-add", "$text.joingame", ui.join::show)); - row(); - } - - add(new MenuButton("icon-tutorial", "$text.tutorial", ()-> control.playMap(world.maps().getMap("tutorial")))); - - add(new MenuButton("icon-load", "$text.loadgame", ui.load::show)); - */ - - add(new MenuButton("icon-editor", "$text.editor", ui.editor::show)); + add(new MenuButton("icon-editor", "$text.editor", () -> { + if(gwt){ + ui.showInfo("$text.editor.web"); + }else{ + ui.editor.show(); + } + })); add(new MenuButton("icon-tools", "$text.settings", ui.settings::show)); @@ -85,19 +80,14 @@ public class MenuFragment implements Fragment{ }}.end(); } }}.end(); - - //extra icons in top right - new table(){{ - abottom().atop().aright(); - get().addButton("", "discord", ui.discord::show); - //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(){{ @@ -106,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(); + } }