Removed all UI builders / Updated uCore and functional interfaces
This commit is contained in:
@@ -2,16 +2,15 @@ package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
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){
|
||||
public MenuButton(String icon, String text, Runnable clicked){
|
||||
this(icon, text, null, clicked);
|
||||
}
|
||||
|
||||
public MenuButton(String icon, String text, String description, Listenable clicked){
|
||||
public MenuButton(String icon, String text, String description, Runnable clicked){
|
||||
super("default");
|
||||
float s = 66f;
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
|
||||
public class MobileButton extends ImageButton{
|
||||
|
||||
public MobileButton(String icon, float isize, String text, Listenable listener){
|
||||
public MobileButton(String icon, float isize, String text, Runnable listener){
|
||||
super(icon);
|
||||
resizeImage(isize);
|
||||
clicked(listener);
|
||||
|
||||
@@ -2,8 +2,6 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -81,43 +79,28 @@ public class PausedDialog extends FloatingDialog{
|
||||
});
|
||||
|
||||
}else{
|
||||
build.begin(content());
|
||||
|
||||
content().defaults().size(120f).pad(5);
|
||||
float isize = 14f * 4;
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> {
|
||||
content().addRowImageTextButton("$text.back", "icon-play-2", isize, () -> {
|
||||
hide();
|
||||
if(!wasPaused && !state.is(State.menu))
|
||||
state.set(State.playing);
|
||||
}).text("$text.back").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
|
||||
|
||||
imagebutton sa = new imagebutton("icon-save", isize, save::show);
|
||||
sa.text("$text.save").padTop(4f);
|
||||
});
|
||||
content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show);
|
||||
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show);
|
||||
|
||||
content().row();
|
||||
|
||||
imagebutton lo = new imagebutton("icon-load", isize, load::show);
|
||||
lo.text("$text.load").padTop(4f);
|
||||
lo.cell.disabled(b -> Net.active());
|
||||
|
||||
imagebutton ho = new imagebutton("icon-host", isize, () -> {
|
||||
ui.host.show();
|
||||
});
|
||||
ho.text("$text.host").padTop(4f);
|
||||
ho.cell.disabled(b -> Net.active());
|
||||
|
||||
new imagebutton("icon-quit", isize, () -> {
|
||||
content().addRowImageTextButton("$text.load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||
content().addRowImageTextButton("$text.host", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||
content().addRowImageTextButton("$text.quit", "icon-quit", isize, () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
if(Net.client()) netClient.disconnectQuietly();
|
||||
runExitSave();
|
||||
hide();
|
||||
});
|
||||
}).text("Quit").padTop(4f);
|
||||
|
||||
build.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BlockConsumeFragment extends Fragment{
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
table = new Table();
|
||||
table.setVisible(() -> !state.is(State.menu) && visible);
|
||||
table.visible(() -> !state.is(State.menu) && visible);
|
||||
table.setTransform(true);
|
||||
parent.setTransform(true);
|
||||
parent.addChild(table);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
table = new Table();
|
||||
table.setVisible(() -> !state.is(State.menu));
|
||||
table.visible(() -> !state.is(State.menu));
|
||||
table.setTransform(true);
|
||||
parent.setTransform(true);
|
||||
parent.addChild(table);
|
||||
|
||||
@@ -16,7 +16,6 @@ import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
@@ -37,60 +36,37 @@ public class BlocksFragment extends Fragment{
|
||||
private static final float size = 48;
|
||||
//maximum recipe rows
|
||||
private static final int maxrow = 3;
|
||||
/**
|
||||
* Table containing description that is shown on top.
|
||||
*/
|
||||
/** Table containing description that is shown on top.*/
|
||||
private Table descTable;
|
||||
/**
|
||||
* Main table containing the whole menu.
|
||||
*/
|
||||
/** Main table containing the whole menu.*/
|
||||
private Table mainTable;
|
||||
/**
|
||||
* Table for all section buttons and blocks.
|
||||
*/
|
||||
/** Table for all section buttons and blocks.*/
|
||||
private Table selectTable;
|
||||
/**
|
||||
* Whether the whole thing is shown or hidden by the popup button.
|
||||
*/
|
||||
/** Whether the whole thing is shown or hidden by the popup button.*/
|
||||
private boolean shown = true;
|
||||
/**
|
||||
* Recipe currently hovering over.
|
||||
*/
|
||||
/** Recipe currently hovering over.*/
|
||||
private Recipe hoverRecipe;
|
||||
/**
|
||||
* Last category selected.
|
||||
*/
|
||||
/** Last category selected.*/
|
||||
private Category lastCategory;
|
||||
/**
|
||||
* Last block pane scroll Y position.
|
||||
*/
|
||||
/** Last block pane scroll Y position.*/
|
||||
private float lastScroll;
|
||||
/**
|
||||
* Temporary recipe array for storage
|
||||
*/
|
||||
/** Temporary recipe array for storage*/
|
||||
private Array<Recipe> recipes = new Array<>();
|
||||
|
||||
public void build(Group parent){
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
//create container table
|
||||
new table(){{
|
||||
abottom();
|
||||
aright();
|
||||
parent.fill(container -> {
|
||||
container.bottom().right().visible(() -> !state.is(State.menu));
|
||||
|
||||
//make it only be shown when needed.
|
||||
visible(() -> !state.is(State.menu));
|
||||
|
||||
//create the main blocks table
|
||||
mainTable = new table(){{
|
||||
mainTable = container.table(main -> {
|
||||
|
||||
//add top description table
|
||||
descTable = new Table("button");
|
||||
descTable.setVisible(() -> hoverRecipe != null || input.recipe != null); //make sure it's visible when necessary
|
||||
descTable.visible(() -> hoverRecipe != null || input.recipe != null); //make sure it's visible when necessary
|
||||
descTable.update(() -> {
|
||||
// note: This is required because there is no direct connection between
|
||||
// input.recipe and the description ui. If input.recipe gets set to null
|
||||
// a proper cleanup of the ui elements is required.
|
||||
// note: This is required because there is no direct connection between input.recipe and the description ui.
|
||||
// If input.recipe gets set to null, a proper cleanup of the ui elements is required.
|
||||
boolean anyRecipeShown = input.recipe != null || hoverRecipe != null;
|
||||
boolean descriptionTableClean = descTable.getChildren().size == 0;
|
||||
boolean cleanupRequired = !anyRecipeShown && !descriptionTableClean;
|
||||
@@ -99,26 +75,17 @@ public class BlocksFragment extends Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
add(descTable).fillX().uniformX();
|
||||
container.add(descTable).fillX().uniformX();
|
||||
|
||||
row();
|
||||
container.row();
|
||||
|
||||
//now add the block selection menu
|
||||
selectTable = new table("pane"){{
|
||||
touchable(Touchable.enabled);
|
||||
selectTable = main.table("pane", select -> {})
|
||||
.margin(10f).marginLeft(0f).marginRight(0f).marginTop(-5)
|
||||
.touchable(Touchable.enabled).right().bottom().get();
|
||||
|
||||
margin(10f);
|
||||
marginLeft(0f);
|
||||
marginRight(0f);
|
||||
marginTop(-5);
|
||||
|
||||
}}.right().bottom().end().get();
|
||||
|
||||
visible(() -> !state.is(State.menu));
|
||||
|
||||
}}.end().get();
|
||||
|
||||
}}.end();
|
||||
}).bottom().right().get();
|
||||
});
|
||||
|
||||
rebuild();
|
||||
}
|
||||
@@ -178,7 +145,7 @@ public class BlocksFragment extends Fragment{
|
||||
//scrollpane for recipes
|
||||
ScrollPane pane = new ScrollPane(recipeTable, "clear-black");
|
||||
pane.setOverscroll(false, false);
|
||||
pane.setVisible(catb::isChecked);
|
||||
pane.visible(catb::isChecked);
|
||||
pane.setScrollYForce(lastScroll);
|
||||
pane.update(() -> {
|
||||
Element e = Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true);
|
||||
@@ -288,7 +255,7 @@ public class BlocksFragment extends Fragment{
|
||||
selectTable.add(stack).growX().left().top().colspan(Category.values().length).padBottom(-5).height((size + 12) * rowsUsed);
|
||||
}
|
||||
|
||||
void toggle(boolean show, float t, Interpolation ip){
|
||||
void toggle(float t, Interpolation ip){
|
||||
if(shown){
|
||||
shown = false;
|
||||
mainTable.actions(Actions.translateBy(0, mainTable.getTranslation().y + (-mainTable.getHeight() - descTable.getHeight()), t, ip));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ChatFragment extends Table{
|
||||
setFillParent(true);
|
||||
font = Core.skin.getFont("default-font");
|
||||
|
||||
setVisible(() -> !state.is(State.menu) && Net.active());
|
||||
visible(() -> !state.is(State.menu) && Net.active());
|
||||
|
||||
update(() -> {
|
||||
if(!Net.active() && chatOpen){
|
||||
|
||||
@@ -14,12 +14,8 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Log.LogHandler;
|
||||
@@ -43,10 +39,6 @@ public class DebugFragment extends Fragment{
|
||||
});
|
||||
}
|
||||
|
||||
public static void printDebugInfo(){
|
||||
Gdx.app.error("Minudstry Info Dump", debugInfo());
|
||||
}
|
||||
|
||||
public static String debugInfo(){
|
||||
int totalUnits = 0;
|
||||
for(EntityGroup<?> group : unitGroups){
|
||||
@@ -120,43 +112,41 @@ public class DebugFragment extends Fragment{
|
||||
public void build(Group parent){
|
||||
|
||||
Player player = players[0];
|
||||
new table(){{
|
||||
visible(() -> debug);
|
||||
parent.fill(c -> {
|
||||
c.bottom().left().visible(() -> debug);
|
||||
|
||||
abottom().aleft();
|
||||
c.table("pane", t -> {
|
||||
t.defaults().fillX().width(100f);
|
||||
|
||||
new table("pane"){{
|
||||
defaults().fillX().width(100f);
|
||||
t.label(() -> Gdx.app.getJavaHeap() / 1024 / 1024 + "MB");
|
||||
t.row();
|
||||
|
||||
new label(() -> Gdx.app.getJavaHeap() / 1024 / 1024 + "MB");
|
||||
row();
|
||||
|
||||
new label("Debug");
|
||||
row();
|
||||
new button("noclip", "toggle", () -> noclip = !noclip);
|
||||
row();
|
||||
new button("items", () -> {
|
||||
t.add("Debug");
|
||||
t.row();
|
||||
t.addButton("noclip", "toggle", () -> noclip = !noclip);
|
||||
t.row();
|
||||
t.addButton("items", () -> {
|
||||
for(int i = 0; i < 10; i++){
|
||||
ItemDrop.create(Item.all().random(), 5, player.x, player.y, Mathf.random(360f));
|
||||
}
|
||||
});
|
||||
row();
|
||||
new button("team", "toggle", player::toggleTeam);
|
||||
row();
|
||||
new button("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
|
||||
row();
|
||||
new button("fog", () -> showFog = !showFog);
|
||||
row();
|
||||
new button("gameover", () -> {
|
||||
t.row();
|
||||
t.addButton("team", "toggle", player::toggleTeam);
|
||||
t.row();
|
||||
t.addButton("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
|
||||
t.row();
|
||||
t.addButton("fog", () -> showFog = !showFog);
|
||||
t.row();
|
||||
t.addButton("gameover", () -> {
|
||||
state.teams.get(Team.blue).cores.get(0).entity.health = 0;
|
||||
state.teams.get(Team.blue).cores.get(0).entity.damage(1);
|
||||
});
|
||||
row();
|
||||
new button("wave", () -> state.wavetime = 0f);
|
||||
row();
|
||||
new button("death", () -> player.damage(99999, true));
|
||||
row();
|
||||
new button("spawn", () -> {
|
||||
t.row();
|
||||
t.addButton("wave", () -> state.wavetime = 0f);
|
||||
t.row();
|
||||
t.addButton("death", () -> player.damage(99999, true));
|
||||
t.row();
|
||||
t.addButton("spawn", () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("debug spawn");
|
||||
for(UnitType type : UnitType.all()){
|
||||
dialog.content().addImageButton("white", 40, () -> {
|
||||
@@ -171,27 +161,20 @@ public class DebugFragment extends Fragment{
|
||||
dialog.setFillParent(false);
|
||||
dialog.show();
|
||||
});
|
||||
row();
|
||||
}}.end();
|
||||
|
||||
row();
|
||||
|
||||
}}.end();
|
||||
t.row();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
new table(){{
|
||||
visible(() -> console);
|
||||
parent.fill(t -> {
|
||||
t.top().left().visible(() -> console);
|
||||
|
||||
atop().aleft();
|
||||
t.table("pane", p -> {
|
||||
p.defaults().fillX();
|
||||
|
||||
new table("pane"){{
|
||||
defaults().fillX();
|
||||
|
||||
ScrollPane pane = new ScrollPane(new Label(DebugFragment::debugInfo), "clear");
|
||||
|
||||
add(pane);
|
||||
row();
|
||||
new button("dump", () -> {
|
||||
p.pane("clear", new Label(DebugFragment::debugInfo));
|
||||
p.row();
|
||||
p.addButton("dump", () -> {
|
||||
try{
|
||||
FileHandle file = Gdx.files.local("packet-dump.txt");
|
||||
file.writeString("--INFO--\n", false);
|
||||
@@ -202,20 +185,16 @@ public class DebugFragment extends Fragment{
|
||||
ui.showError("Error dumping log.");
|
||||
}
|
||||
});
|
||||
}}.end();
|
||||
}}.end();
|
||||
});
|
||||
});
|
||||
|
||||
new table(){{
|
||||
visible(() -> console);
|
||||
|
||||
atop();
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> console);
|
||||
|
||||
Table table = new Table("pane");
|
||||
table.label(() -> log.toString());
|
||||
|
||||
ScrollPane pane = new ScrollPane(table, "clear");
|
||||
|
||||
get().add(pane);
|
||||
}}.end();
|
||||
t.pane("clear", table);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -20,9 +19,6 @@ import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
@@ -37,7 +33,6 @@ public class HudFragment extends Fragment{
|
||||
public final BlocksFragment blockfrag = new BlocksFragment();
|
||||
|
||||
private ImageButton menu, flip;
|
||||
private Table respawntable;
|
||||
private Table wavetable;
|
||||
private Table infolabel;
|
||||
private Table lastUnlockTable;
|
||||
@@ -49,124 +44,93 @@ public class HudFragment extends Fragment{
|
||||
public void build(Group parent){
|
||||
|
||||
//menu at top left
|
||||
new table(){{
|
||||
atop();
|
||||
aleft();
|
||||
parent.fill(cont -> {
|
||||
|
||||
new table(){{
|
||||
cont.top().left().visible(() -> !state.is(State.menu));
|
||||
|
||||
new table(){{
|
||||
left();
|
||||
defaults().size(dsize).left();
|
||||
cont.table(select -> {
|
||||
select.left();
|
||||
select.defaults().size(dsize).left();
|
||||
|
||||
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
|
||||
flip = new imagebutton("icon-arrow-up", isize, () -> toggleMenus()).get();
|
||||
menu = select.addImageButton("icon-menu", isize, ui.paused::show).get();
|
||||
flip = select.addImageButton("icon-arrow-up", isize, this::toggleMenus).get();
|
||||
|
||||
update(t -> {
|
||||
if(Inputs.keyTap("toggle_menus") && !ui.chatfrag.chatOpen()){
|
||||
toggleMenus();
|
||||
}
|
||||
});
|
||||
select.update(() -> {
|
||||
if(Inputs.keyTap("toggle_menus") && !ui.chatfrag.chatOpen()){
|
||||
toggleMenus();
|
||||
}
|
||||
});
|
||||
|
||||
new imagebutton("icon-pause", isize, () -> {
|
||||
if(Net.active()){
|
||||
ui.listfrag.toggle();
|
||||
select.addImageButton("icon-pause", isize, () -> {
|
||||
if(Net.active()){
|
||||
ui.listfrag.toggle();
|
||||
}else{
|
||||
state.set(state.is(State.paused) ? State.playing : State.paused);
|
||||
}
|
||||
}).update(i -> {
|
||||
if(Net.active()){
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
|
||||
}else{
|
||||
i.setDisabled(Net.active());
|
||||
i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
}
|
||||
}).get();
|
||||
|
||||
select.addImageButton("icon-settings", isize, () -> {
|
||||
if(Net.active() && mobile){
|
||||
if(ui.chatfrag.chatOpen()){
|
||||
ui.chatfrag.hide();
|
||||
}else{
|
||||
state.set(state.is(State.paused) ? State.playing : State.paused);
|
||||
ui.chatfrag.toggle();
|
||||
}
|
||||
}).update(i -> {
|
||||
if(Net.active()){
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
|
||||
}else{
|
||||
i.setDisabled(Net.active());
|
||||
i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
}
|
||||
}).get();
|
||||
}else{
|
||||
ui.settings.show();
|
||||
}
|
||||
}).update(i -> {
|
||||
if(Net.active() && mobile){
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
|
||||
}else{
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
|
||||
}
|
||||
}).get();
|
||||
});
|
||||
|
||||
new imagebutton("icon-settings", isize, () -> {
|
||||
if(Net.active() && mobile){
|
||||
if(ui.chatfrag.chatOpen()){
|
||||
ui.chatfrag.hide();
|
||||
}else{
|
||||
ui.chatfrag.toggle();
|
||||
}
|
||||
}else{
|
||||
ui.settings.show();
|
||||
}
|
||||
}).update(i -> {
|
||||
if(Net.active() && mobile){
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
|
||||
}else{
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
|
||||
}
|
||||
}).get();
|
||||
cont.row();
|
||||
|
||||
}}.end();
|
||||
cont.table(this::addWaveTable).touchable(Touchable.enabled).fillX().height(66f);
|
||||
|
||||
row();
|
||||
cont.row();
|
||||
|
||||
new table(){{
|
||||
touchable(Touchable.enabled);
|
||||
addWaveTable();
|
||||
}}.fillX().end();
|
||||
//fps display
|
||||
infolabel = cont.table(t -> {
|
||||
IntFormat fps = new IntFormat("text.fps");
|
||||
IntFormat tps = new IntFormat("text.tps");
|
||||
IntFormat ping = new IntFormat("text.ping");
|
||||
t.label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10);
|
||||
t.label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
|
||||
t.row();
|
||||
t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
|
||||
}).size(-1).visible(() -> Settings.getBool("fps")).get();
|
||||
|
||||
row();
|
||||
//make wave box appear below rest of menu
|
||||
cont.swapActor(wavetable, menu.getParent());
|
||||
});
|
||||
|
||||
visible(() -> !state.is(State.menu));
|
||||
row();
|
||||
new table(){{
|
||||
IntFormat fps = new IntFormat("text.fps");
|
||||
IntFormat tps = new IntFormat("text.tps");
|
||||
IntFormat ping = new IntFormat("text.ping");
|
||||
new label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10);
|
||||
new label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
|
||||
row();
|
||||
new label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
|
||||
|
||||
infolabel = get();
|
||||
}}.size(-1).end().visible(() -> Settings.getBool("fps"));
|
||||
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
visible(() -> !state.is(State.menu));
|
||||
atop();
|
||||
aright();
|
||||
|
||||
Minimap minimap = new Minimap();
|
||||
|
||||
add(minimap).visible(() -> Settings.getBool("minimap"));
|
||||
}}.end();
|
||||
//minimap
|
||||
parent.fill(t -> t.top().right().add(new Minimap())
|
||||
.visible(() -> !state.is(State.menu) && Settings.getBool("minimap")));
|
||||
|
||||
//paused table
|
||||
new table(){{
|
||||
visible(() -> state.is(State.paused) && !Net.active());
|
||||
atop();
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.is(State.paused) && !Net.active());
|
||||
t.table(top -> top.add("[orange]< " + Bundles.get("text.paused") + " >").pad(6).get().setFontScale(fontScale * 0.75f));
|
||||
});
|
||||
|
||||
new table("pane"){{
|
||||
new label("[orange]< " + Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
//respawn background table
|
||||
new table("white"){{
|
||||
respawntable = get();
|
||||
respawntable.setColor(Color.CLEAR);
|
||||
update(t -> {
|
||||
if(state.is(State.menu)){
|
||||
respawntable.setColor(Color.CLEAR);
|
||||
}
|
||||
});
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
abottom();
|
||||
visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||
|
||||
new label("$text.saveload");
|
||||
|
||||
}}.end();
|
||||
//'saving' indicator
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||
t.add("$text.saveload");
|
||||
});
|
||||
|
||||
blockfrag.build(Core.scene.getRoot());
|
||||
}
|
||||
@@ -281,12 +245,12 @@ public class HudFragment extends Fragment{
|
||||
|
||||
if(shown){
|
||||
shown = false;
|
||||
blockfrag.toggle(false, dur, in);
|
||||
blockfrag.toggle(dur, in);
|
||||
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + dsize) - wavetable.getTranslation().y, dur, in));
|
||||
infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in));
|
||||
}else{
|
||||
shown = true;
|
||||
blockfrag.toggle(true, dur, in);
|
||||
blockfrag.toggle(dur, in);
|
||||
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
|
||||
infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in));
|
||||
}
|
||||
@@ -301,40 +265,30 @@ public class HudFragment extends Fragment{
|
||||
}
|
||||
}
|
||||
|
||||
private void addWaveTable(){
|
||||
private void addWaveTable(Table table){
|
||||
wavetable = table;
|
||||
float uheight = 66f;
|
||||
|
||||
IntFormat wavef = new IntFormat("text.wave");
|
||||
IntFormat timef = new IntFormat("text.wave.waiting");
|
||||
|
||||
wavetable = new table("button"){{
|
||||
aleft();
|
||||
new table(){{
|
||||
aleft();
|
||||
table.background("button");
|
||||
table.left().table(text -> {
|
||||
text.left();
|
||||
text.label(() -> wavef.get(state.wave)).left().get().setFontScale(fontScale * 1.5f);
|
||||
text.row();
|
||||
text.label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
|
||||
getEnemiesRemaining() : (state.mode.disableWaveTimer) ? "$text.waiting" :
|
||||
timef.get((int) (state.wavetime / 60f))).minWidth(126).left();
|
||||
});
|
||||
|
||||
new label(() -> wavef.get(state.wave)).scale(fontScale * 1.5f).left().padLeft(-6);
|
||||
table.add().growX();
|
||||
|
||||
row();
|
||||
|
||||
new label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
|
||||
getEnemiesRemaining() :
|
||||
(state.mode.disableWaveTimer) ? "$text.waiting"
|
||||
: timef.get((int) (state.wavetime / 60f)))
|
||||
.minWidth(126).padLeft(-6).left();
|
||||
|
||||
margin(10f);
|
||||
get().marginLeft(6);
|
||||
}}.left().end();
|
||||
|
||||
add().growX();
|
||||
|
||||
playButton(uheight);
|
||||
}}.height(uheight).fillX().expandX().end().get();
|
||||
wavetable.getParent().getParent().swapActor(wavetable.getParent(), menu.getParent());
|
||||
playButton(uheight);
|
||||
}
|
||||
|
||||
private void playButton(float uheight){
|
||||
new imagebutton("icon-play", 30f, () -> {
|
||||
wavetable.addImageButton("icon-play", 30f, () -> {
|
||||
if(Net.client() && players[0].isAdmin){
|
||||
Call.onAdminRequest(players[0], AdminAction.wave);
|
||||
}else{
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
@@ -16,32 +13,24 @@ public class LoadingFragment extends Fragment{
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.fill("loadDim", t -> {
|
||||
t.setVisible(false);
|
||||
t.setTouchable(Touchable.enabled);
|
||||
t.add().height(70f).row();
|
||||
|
||||
table = new table("loadDim"){{
|
||||
add().height(70f).row();
|
||||
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||
t.row();
|
||||
t.add("$text.loading").name("namelabel").pad(10f);
|
||||
t.row();
|
||||
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||
t.row();
|
||||
|
||||
touchable(Touchable.enabled);
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||
row();
|
||||
new label("$text.loading"){{
|
||||
get().setName("namelabel");
|
||||
}}.pad(10);
|
||||
row();
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||
|
||||
row();
|
||||
|
||||
button = get().addButton("$text.cancel", () -> {
|
||||
}).pad(20).size(250f, 70f).get();
|
||||
button.setVisible(false);
|
||||
}}.end().get();
|
||||
|
||||
table.setVisible(false);
|
||||
button = t.addButton("$text.cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
|
||||
table = t;
|
||||
});
|
||||
}
|
||||
|
||||
public void setButton(Listenable listener){
|
||||
public void setButton(Runnable listener){
|
||||
button.setVisible(true);
|
||||
button.getListeners().removeIndex(button.getListeners().size - 1);
|
||||
button.clicked(listener);
|
||||
|
||||
@@ -10,65 +10,49 @@ import io.anuke.mindustry.ui.MobileButton;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment extends Fragment{
|
||||
private Table mobileContainer;
|
||||
private Table container;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
new table(){{
|
||||
visible(() -> state.is(State.menu));
|
||||
parent.fill(c -> {
|
||||
container = c;
|
||||
container.visible(() -> state.is(State.menu));
|
||||
|
||||
if(!mobile){
|
||||
buildDesktop();
|
||||
}else{
|
||||
buildMobile();
|
||||
|
||||
Events.on(ResizeEvent.class, () -> buildMobile());
|
||||
Events.on(ResizeEvent.class, this::buildMobile);
|
||||
}
|
||||
}}.end();
|
||||
});
|
||||
|
||||
//discord icon in top right
|
||||
if(Platform.instance.hasDiscord()){
|
||||
new table(){{
|
||||
abottom().atop().aright();
|
||||
get().addButton("", "discord", ui.discord::show).size(81, 42);
|
||||
}}.end().visible(() -> state.is(State.menu));
|
||||
}
|
||||
parent.fill(c -> c.top().right().addButton("", "discord", ui.discord::show).size(81, 42)
|
||||
.visible(() -> state.is(State.menu)));
|
||||
|
||||
//info icon
|
||||
if(mobile){
|
||||
new table(){{
|
||||
abottom().atop().aleft();
|
||||
get().addButton("", "info", ui.about::show).size(81, 42);
|
||||
}}.end().visible(() -> state.is(State.menu));
|
||||
parent.fill(c -> c.top().left().addButton("", "info", ui.about::show).size(81, 42)
|
||||
.visible(() -> state.is(State.menu)));
|
||||
}
|
||||
|
||||
//version info
|
||||
new table(){{
|
||||
visible(() -> state.is(State.menu));
|
||||
abottom().aleft();
|
||||
new label("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName);
|
||||
}}.end();
|
||||
parent.fill(c -> c.bottom().left().add("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName)
|
||||
.visible(() -> state.is(State.menu)));
|
||||
}
|
||||
|
||||
private void buildMobile(){
|
||||
if(mobileContainer == null){
|
||||
mobileContainer = build.getTable();
|
||||
}
|
||||
|
||||
mobileContainer.clear();
|
||||
mobileContainer.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
container.clear();
|
||||
container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
float size = 120f;
|
||||
float isize = 14f * 4;
|
||||
mobileContainer.defaults().size(size).pad(5).padTop(4f);
|
||||
container.defaults().size(size).pad(5).padTop(4f);
|
||||
|
||||
MobileButton
|
||||
play = new MobileButton("icon-play-2", isize, "$text.play", ui.levels::show),
|
||||
@@ -81,14 +65,14 @@ public class MenuFragment extends Fragment{
|
||||
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
||||
|
||||
if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()){
|
||||
mobileContainer.add(play);
|
||||
mobileContainer.add(join);
|
||||
mobileContainer.add(load);
|
||||
mobileContainer.add(maps);
|
||||
mobileContainer.row();
|
||||
container.add(play);
|
||||
container.add(join);
|
||||
container.add(load);
|
||||
container.add(maps);
|
||||
container.row();
|
||||
|
||||
mobileContainer.table(table -> {
|
||||
table.defaults().set(mobileContainer.defaults());
|
||||
container.table(table -> {
|
||||
table.defaults().set(container.defaults());
|
||||
|
||||
table.add(editor);
|
||||
table.add(tools);
|
||||
@@ -97,18 +81,18 @@ public class MenuFragment extends Fragment{
|
||||
if(Platform.instance.canDonate()) table.add(donate);
|
||||
}).colspan(4);
|
||||
}else{
|
||||
mobileContainer.add(play);
|
||||
mobileContainer.add(maps);
|
||||
mobileContainer.row();
|
||||
mobileContainer.add(load);
|
||||
mobileContainer.add(join);
|
||||
mobileContainer.row();
|
||||
mobileContainer.add(editor);
|
||||
mobileContainer.add(tools);
|
||||
mobileContainer.row();
|
||||
container.add(play);
|
||||
container.add(maps);
|
||||
container.row();
|
||||
container.add(load);
|
||||
container.add(join);
|
||||
container.row();
|
||||
container.add(editor);
|
||||
container.add(tools);
|
||||
container.row();
|
||||
|
||||
mobileContainer.table(table -> {
|
||||
table.defaults().set(mobileContainer.defaults());
|
||||
container.table(table -> {
|
||||
table.defaults().set(container.defaults());
|
||||
|
||||
table.add(unlocks);
|
||||
|
||||
@@ -118,41 +102,40 @@ public class MenuFragment extends Fragment{
|
||||
}
|
||||
|
||||
private void buildDesktop(){
|
||||
new table(){{
|
||||
container.table(out -> {
|
||||
|
||||
float w = 200f;
|
||||
float bw = w * 2f + 10f;
|
||||
|
||||
defaults().size(w, 66f).padTop(5).padRight(5);
|
||||
out.margin(16);
|
||||
out.defaults().size(w, 66f).padTop(5).padRight(5);
|
||||
|
||||
add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
||||
out.add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
||||
|
||||
row();
|
||||
out.row();
|
||||
|
||||
add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
||||
out.add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
||||
|
||||
add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
||||
out.add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
||||
|
||||
row();
|
||||
out.row();
|
||||
|
||||
add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
||||
out.add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
||||
|
||||
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||
out.add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||
|
||||
row();
|
||||
out.row();
|
||||
|
||||
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
||||
out.add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
||||
|
||||
add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
||||
out.add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
||||
|
||||
row();
|
||||
out.row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||
out.add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||
}
|
||||
|
||||
get().margin(16);
|
||||
}}.end();
|
||||
});
|
||||
}
|
||||
|
||||
private void showPlaySelect(){
|
||||
|
||||
@@ -10,12 +10,8 @@ import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
@@ -24,44 +20,14 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PlayerListFragment extends Fragment{
|
||||
private boolean visible = false;
|
||||
private Table content = new Table();
|
||||
private Table content = new Table().marginRight(13f).marginLeft(13f);
|
||||
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
touchable(Touchable.enabled);
|
||||
margin(14f);
|
||||
new label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" :
|
||||
"text.players", playerGroup.size()));
|
||||
row();
|
||||
content.marginRight(13f).marginLeft(13f);
|
||||
ScrollPane pane = new ScrollPane(content, "clear");
|
||||
pane.setScrollingDisabled(true, false);
|
||||
pane.setFadeScrollBars(false);
|
||||
add(pane).grow();
|
||||
row();
|
||||
new table("pane"){{
|
||||
margin(0f);
|
||||
defaults().growX().height(50f).fillY();
|
||||
|
||||
//get().addCheck("$text.server.friendlyfire", b -> {
|
||||
// CallClient.friendlyFireChange(b);
|
||||
//}).left().padLeft(-12).pad(0).update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
|
||||
|
||||
new button("$text.server.bans", () -> {
|
||||
ui.bans.show();
|
||||
}).cell.disabled(b -> Net.client());
|
||||
|
||||
new button("$text.server.admins", () -> {
|
||||
ui.admins.show();
|
||||
}).cell.disabled(b -> Net.client());
|
||||
|
||||
}}.pad(10f).growX().end();
|
||||
}}.end();
|
||||
|
||||
update(t -> {
|
||||
parent.fill(cont -> {
|
||||
cont.visible(() -> visible);
|
||||
cont.update(() -> {
|
||||
if(!(Net.active() && !state.is(State.menu))){
|
||||
visible = false;
|
||||
}
|
||||
@@ -85,8 +51,22 @@ public class PlayerListFragment extends Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
visible(() -> visible);
|
||||
}}.end();
|
||||
cont.table("pane", pane -> {
|
||||
pane.label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" : "text.players", playerGroup.size()));
|
||||
pane.row();
|
||||
pane.pane("clear", content)
|
||||
.grow().get().setScrollingDisabled(true, false);
|
||||
pane.row();
|
||||
|
||||
pane.table("pane", menu -> {
|
||||
menu.defaults().growX().height(50f).fillY();
|
||||
|
||||
menu.addButton("$text.server.bans", ui.bans::show).disabled(b -> Net.client());
|
||||
menu.addButton("$text.server.admins", ui.admins::show).disabled(b -> Net.client());
|
||||
}).margin(0f).pad(10f).growX();
|
||||
|
||||
}).touchable(Touchable.enabled).margin(14f);
|
||||
});
|
||||
|
||||
rebuild();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user