mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-24 14:47:58 +07:00
Main menu rework [currently incomplete]
This commit is contained in:
@ -56,7 +56,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;
|
||||
|
32
core/src/io/anuke/mindustry/ui/Links.java
Normal file
32
core/src/io/anuke/mindustry/ui/Links.java
Normal file
@ -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("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("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")),
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +1,25 @@
|
||||
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 class MenuButton extends TextButton{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
public MenuButton(String icon, String text, Listenable clicked){
|
||||
super("default");
|
||||
float s = 70f;
|
||||
|
||||
clicked(clicked);
|
||||
group.add(this);
|
||||
}
|
||||
|
||||
@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);
|
||||
clearChildren();
|
||||
|
||||
if(hasInvalid){
|
||||
row();
|
||||
add(text, style, scale).padTop(Unit.dp.scl(-Core.font.getData().lineHeight * scale * 2f - 4f)).color(Color.WHITE);
|
||||
}
|
||||
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);
|
||||
|
||||
add(text).padLeft(5).growX();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,56 @@
|
||||
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.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();
|
||||
}
|
||||
|
||||
content().add(pane).growX();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
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.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
@ -21,36 +19,44 @@ 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", ui.levels::show)).width(bw).colspan(2);
|
||||
|
||||
row();
|
||||
|
||||
if(Platform.instance.canJoinGame()) {
|
||||
add(new MenuButton("$text.joingame", group, ui.join::show));
|
||||
//TODO submenu!
|
||||
|
||||
/*if(Platform.instance.canJoinGame()) {
|
||||
add(new MenuButton("icon-add", "$text.joingame", ui.join::show));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||
row();
|
||||
add(new MenuButton("icon-tutorial", "$text.tutorial", ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||
|
||||
add(new MenuButton("$text.loadgame", group, ui.load::show));
|
||||
row();
|
||||
add(new MenuButton("icon-load", "$text.loadgame", ui.load::show));
|
||||
*/
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("$text.editor", group, ui.editor::show));
|
||||
row();
|
||||
}
|
||||
add(new MenuButton("icon-editor", "$text.editor", ui.editor::show));
|
||||
|
||||
add(new MenuButton("$text.settings", group, ui.settings::show));
|
||||
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||
|
||||
row();
|
||||
|
||||
add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
||||
|
||||
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::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();
|
||||
|
||||
@ -82,14 +88,15 @@ public class MenuFragment implements Fragment{
|
||||
|
||||
//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);
|
||||
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));
|
||||
|
||||
//version info
|
||||
|
Reference in New Issue
Block a user