Removed all UI builders / Updated uCore and functional interfaces

This commit is contained in:
Anuken
2018-07-14 22:06:03 -04:00
parent 7dc33111fc
commit 37b9df3202
20 changed files with 366 additions and 672 deletions

View File

@@ -11,102 +11,45 @@ import java.util.Date;
import java.util.Locale;
import java.util.Random;
public abstract class Platform{
/**
* Each separate game platform should set this instance to their own implementation.
*/
public static Platform instance = new Platform(){
};
public abstract class Platform {
/**Each separate game platform should set this instance to their own implementation.*/
public static Platform instance = new Platform() {};
/**
* Format the date using the default date formatter.
*/
public String format(Date date){
return "invalid";
}
/**
* Format a number by adding in commas or periods where needed.
*/
public String format(int number){
return "invalid";
}
/**
* Show a native error dialog.
*/
public void showError(String text){
}
/**
* Add a text input dialog that should show up after the field is tapped.
*/
/**Format the date using the default date formatter.*/
public String format(Date date){return "invalid";}
/**Format a number by adding in commas or periods where needed.*/
public String format(int number){return "invalid";}
/**Show a native error dialog.*/
public void showError(String text){}
/**Add a text input dialog that should show up after the field is tapped.*/
public void addDialog(TextField field){
addDialog(field, 16);
}
/**
* See addDialog().
*/
public void addDialog(TextField field, int maxLength){
}
/**
* Update discord RPC.
*/
public void updateRPC(){
}
/**
* Called when the game is exited.
*/
public void onGameExit(){
}
/**
* Open donation dialog. Currently android only.
*/
public void openDonations(){
}
/**
* Whether donating is supported.
*/
/**See addDialog().*/
public void addDialog(TextField field, int maxLength){}
/**Update discord RPC.*/
public void updateRPC(){}
/**Called when the game is exited.*/
public void onGameExit(){}
/**Open donation dialog. Currently android only.*/
public void openDonations(){}
/**Whether donating is supported.*/
public boolean canDonate(){
return false;
}
/**
* Whether discord RPC is supported.
*/
public boolean hasDiscord(){
return true;
}
/**
* Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().
*/
/**Whether the user has Discord installed. Defaults to true if unknown.*/
public boolean hasDiscord(){return true;}
/**Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().*/
public String getLocaleName(Locale locale){
return locale.toString();
}
/**
* Whether joining games is supported.
*/
/**Whether joining games is supported.*/
public boolean canJoinGame(){
return true;
}
/**
* Whether debug mode is enabled.
*/
public boolean isDebug(){
return false;
}
/**
* Must be a base64 string 8 bytes in length.
*/
/**Whether debug mode is enabled.*/
public boolean isDebug(){return false;}
/**Must be a base64 string 8 bytes in length.*/
public String getUUID(){
String uuid = Settings.getString("uuid", "");
if(uuid.isEmpty()){
@@ -119,21 +62,12 @@ public abstract class Platform{
}
return uuid;
}
/**Only used for iOS or android: open the share menu for a map or save.*/
public void shareFile(FileHandle file){}
/**Download a file. Only used on GWT backend.*/
public void downloadFile(String name, byte[] bytes){}
/**
* Only used for iOS or android: open the share menu for a map or save.
*/
public void shareFile(FileHandle file){
}
/**
* Download a file. Only used on GWT backend.
*/
public void downloadFile(String name, byte[] bytes){
}
/**
* Show a file chooser. Desktop only.
/**Show a file chooser. Desktop only.
*
* @param text File chooser title text
* @param content Description of the type of files to be loaded
@@ -141,54 +75,24 @@ public abstract class Platform{
* @param open Whether to open or save files
* @param filetype File extension to filter
*/
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){
}
/**
* Use the default thread provider from the kryonet module for this.
*/
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){}
/**Use the default thread provider from the kryonet module for this.*/
public ThreadProvider getThreadProvider(){
return new ThreadProvider(){
@Override
public boolean isOnThread(){
return true;
}
@Override
public void sleep(long ms){
}
@Override
public void start(Runnable run){
}
@Override
public void stop(){
}
@Override
public void notify(Object object){
}
@Override
public void wait(Object object){
}
return new ThreadProvider() {
@Override public boolean isOnThread() {return true;}
@Override public void sleep(long ms) {}
@Override public void start(Runnable run) {}
@Override public void stop() {}
@Override public void notify(Object object) {}
@Override public void wait(Object object) {}
};
}
//TODO iOS implementation
/**
* Forces the app into landscape mode. Currently Android only.
*/
public void beginForceLandscape(){
}
/**Forces the app into landscape mode. Currently Android only.*/
public void beginForceLandscape(){}
//TODO iOS implementation
/**
* Stops forcing the app into landscape orientation. Currently Android only.
*/
public void endForceLandscape(){
}
}
/**Stops forcing the app into landscape orientation. Currently Android only.*/
public void endForceLandscape(){}
}

View File

@@ -13,15 +13,12 @@ import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.ui.dialogs.*;
import io.anuke.mindustry.ui.fragments.*;
import io.anuke.ucore.core.*;
import io.anuke.ucore.function.Callable;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.function.Listenable;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.modules.SceneModule;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.Skin;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.builders.build;
import io.anuke.ucore.scene.ui.Dialog;
import io.anuke.ucore.scene.ui.TextField;
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
@@ -32,9 +29,7 @@ import io.anuke.ucore.util.Mathf;
import java.util.Locale;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.players;
import static io.anuke.mindustry.Vars.threads;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.ucore.scene.actions.Actions.*;
public class UI extends SceneModule{
@@ -162,10 +157,10 @@ public class UI extends SceneModule{
levels = new LevelDialog();
language = new LanguageDialog();
settings = new SettingsMenuDialog();
host = new HostDialog();
paused = new PausedDialog();
changelog = new ChangelogDialog();
about = new AboutDialog();
host = new HostDialog();
bans = new BansDialog();
admins = new AdminsDialog();
traces = new TraceDialog();
@@ -175,8 +170,6 @@ public class UI extends SceneModule{
unlocks = new UnlocksDialog();
content = new ContentInfoDialog();
build.begin(scene);
Group group = Core.scene.getRoot();
backfrag.build(group);
@@ -186,8 +179,6 @@ public class UI extends SceneModule{
listfrag.build(group);
debugfrag.build(group);
loadfrag.build(group);
build.end();
}
@Override
@@ -220,11 +211,11 @@ public class UI extends SceneModule{
}
}
public void loadAnd(Callable call){
public void loadAnd(Runnable call){
loadAnd("$text.loading", call);
}
public void loadAnd(String text, Callable call){
public void loadAnd(String text, Runnable call){
loadfrag.show(text);
Timers.runTask(7f, () -> {
call.run();
@@ -232,11 +223,11 @@ public class UI extends SceneModule{
});
}
public void loadLogic(Callable call){
public void loadLogic(Runnable call){
loadLogic("$text.loading", call);
}
public void loadLogic(String text, Callable call){
public void loadLogic(String text, Runnable call){
loadfrag.show();
Timers.runTask(7f, () -> {
threads.run(() -> {
@@ -289,14 +280,14 @@ public class UI extends SceneModule{
}}.show();
}
public void showConfirm(String title, String text, Listenable confirmed){
public void showConfirm(String title, String text, Runnable confirmed){
FloatingDialog dialog = new FloatingDialog(title);
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons().defaults().size(200f, 54f).pad(2f);
dialog.buttons().addButton("$text.cancel", dialog::hide);
dialog.buttons().addButton("$text.ok", () -> {
dialog.hide();
confirmed.listen();
confirmed.run();
});
dialog.keyDown(Keys.ESCAPE, dialog::hide);
dialog.keyDown(Keys.BACK, dialog::hide);

View File

@@ -11,8 +11,8 @@ import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.content.blocks.StorageBlocks;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.io.MapIO;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.maps.MapMeta;
import io.anuke.mindustry.maps.MapTileData;
import io.anuke.mindustry.type.Recipe;
@@ -23,13 +23,9 @@ import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.function.Listenable;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.input.Input;
import io.anuke.ucore.scene.actions.Actions;
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.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
@@ -95,8 +91,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
t.addImageTextButton("$text.editor.import", "icon-load-map", isize, () ->
createDialog("$text.editor.import",
"$text.editor.importmap", "$text.editor.importmap.description", "icon-load-map", (Listenable) loadDialog::show,
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Listenable) () -> {
"$text.editor.importmap", "$text.editor.importmap.description", "icon-load-map", (Runnable) loadDialog::show,
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Runnable) () -> {
Platform.instance.showFileChooser("$text.loadimage", "Map Files", file -> {
ui.loadAnd(() -> {
try{
@@ -135,7 +131,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
}*/));
t.addImageTextButton("$text.editor.export", "icon-save-map", isize, () -> createDialog("$text.editor.export",
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Listenable) () -> {
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Runnable) () -> {
if(!gwt){
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
@@ -224,9 +220,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
clearChildren();
margin(0);
build.begin(this);
build();
build.end();
update(() -> {
if(Core.scene.getKeyboardFocus() instanceof Dialog && Core.scene.getKeyboardFocus() != this){
@@ -302,10 +296,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
String name = (String) arguments[i];
String description = (String) arguments[i + 1];
String iconname = (String) arguments[i + 2];
Listenable listenable = (Listenable) arguments[i + 3];
Runnable listenable = (Runnable) arguments[i + 3];
TextButton button = dialog.content().addButton(name, () -> {
listenable.listen();
listenable.run();
dialog.hide();
menu.hide();
}).left().get();
@@ -386,14 +380,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
float size = mobile ? (int) (Math.min(Gdx.graphics.getHeight(), Gdx.graphics.getWidth()) / amount / Unit.dp.scl(1f)) :
Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize);
new table(){{
aleft();
table(cont -> {
cont.left();
new table("button"){{
margin(0);
Table tools = new Table();
tools.top();
atop();
cont.table("button", mid -> {
mid.top();
Table tools = new Table().top();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
@@ -411,8 +404,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.defaults().size(size, size + 4f).padBottom(-5.1f);
//tools.addImageButton("icon-back", 16*2, () -> tryExit());
tools.addImageButton("icon-menu-large", 16 * 2f, menu::show);
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16 * 2f, () -> view.setGrid(!view.isGrid())).get();
@@ -452,9 +443,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.row();
tools.table("button", t -> {
t.add("$text.editor.teams");
}).colspan(3).height(40).width(size * 3f);
tools.table("button", t -> t.add("$text.editor.teams"))
.colspan(3).height(40).width(size * 3f);
tools.row();
@@ -475,58 +465,48 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(i++ % 3 == 2) tools.row();
}
add(tools).top().padBottom(-6);
mid.add(tools).top().padBottom(-6);
row();
mid.row();
new table("button"){{
atop();
mid.table("button", t -> {
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
new label("brush");
row();
add(slider).width(size * 3f - 20).padTop(4f);
}}.padTop(5).growX().growY().top().end();
row();
t.top();
t.add("$text.editor.brush");
t.row();
t.add(slider).width(size * 3f - 20).padTop(4f);
}).padTop(5).growX().growY().top();
get().table("button", t -> {
t.add("$text.editor.elevation");
}).colspan(3).height(40).width(size * 3f);
mid.row();
row();
mid.table("button", t -> t.add("$text.editor.elevation"))
.colspan(3).height(40).width(size * 3f);
get().table("button", t -> {
mid.row();
mid.table("button", t -> {
t.margin(0);
t.addImageButton("icon-arrow-left", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
t.label(() -> editor.getDrawElevation() == -1 ? "$text.editor.slope" : (editor.getDrawElevation() + ""))
.size(size).get().setAlignment(Align.center, Align.center);
.size(size).get().setAlignment(Align.center, Align.center);
t.addImageButton("icon-arrow-right", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
.disabled(b -> editor.getDrawElevation() >= 127).size(size);
.disabled(b -> editor.getDrawElevation() >= 127).size(size);
}).colspan(3).height(size).padTop(-5).width(size * 3f);
}}.left().growY().end();
}).margin(0).left().growY();
new table("button"){{
margin(5);
marginBottom(10);
add(view).grow();
}}.grow().end();
cont.table("button", t -> t.add(view).grow())
.margin(5).marginBottom(10).grow();
new table(){{
cont.table(this::addBlockSelection).right().growY();
row();
addBlockSelection(get());
row();
}}.right().growY().end();
}}.grow().end();
}).grow();
}
private void doInput(){

View File

@@ -16,7 +16,6 @@ import io.anuke.mindustry.world.meta.BlockBar;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.Callable;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.graphics.Lines;
@@ -100,7 +99,7 @@ public class OverlayRenderer{
int[] values = {0, 0};
boolean[] doDraw = {false};
Callable drawbars = () -> {
Runnable drawbars = () -> {
for(BlockBar bar : block.bars.list()){
float offset = Mathf.sign(bar.top) * (block.size / 2f * tilesize + 2f + (bar.top ? values[0] : values[1]));

View File

@@ -1,6 +1,5 @@
package io.anuke.mindustry.input;
import io.anuke.ucore.function.Callable;
import io.anuke.ucore.scene.utils.Cursors;
/**
@@ -12,9 +11,9 @@ public enum CursorType{
drill(() -> Cursors.set("drill")),
unload(() -> Cursors.set("unload"));
private final Callable call;
private final Runnable call;
CursorType(Callable call){
CursorType(Runnable call){
this.call = call;
}

View File

@@ -31,8 +31,6 @@ import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.util.Mathf;
@@ -210,25 +208,23 @@ public class MobileInput extends InputHandler implements GestureListener{
public void buildUI(Group group){
//Create confirm/cancel table
new table(){{
abottom().aleft();
group.fill(c -> {
c.bottom().left().visible(() -> !state.is(State.menu));
new table("pane"){{
margin(5);
defaults().size(60f);
touchable(Touchable.enabled);
c.table("pane", act -> {
act.margin(5);
act.defaults().size(60f);
//Add a cancel button
new imagebutton("icon-cancel", 16 * 2f, () -> {
act.addImageButton("icon-cancel", 16*2f, () -> {
mode = none;
recipe = null;
});
row();
act.row();
//Add an accept button, which places everything.
new imagebutton("icon-check", 16 * 2f, () -> {
act.addImageButton("icon-check", 16 * 2f, () -> {
for(PlaceRequest request : selection){
Tile tile = request.tile();
@@ -248,48 +244,39 @@ public class MobileInput extends InputHandler implements GestureListener{
removals.addAll(selection);
selection.clear();
selecting = false;
}).cell.disabled(i -> selection.size == 0);
}).disabled(i -> selection.size == 0);
row();
act.row();
//Add a rotate button
new imagebutton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
.update(i -> {
i.getImage().setRotation(rotation * 90);
i.getImage().setOrigin(Align.center);
}).cell.disabled(i -> recipe == null || !recipe.result.rotate);
}}.visible(() -> mode != none).end();
act.addImageButton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
.disabled(i -> recipe == null || !recipe.result.rotate);
}).visible(() -> mode != none).touchable(Touchable.enabled);;
row();
c.row();
new table("pane"){{
margin(5);
defaults().size(60f);
touchable(Touchable.enabled);
c.table("pane", remove -> {
remove.defaults().size(60f);
//Add a break button.
new imagebutton("icon-break", "toggle", 16 * 2f, () -> {
remove.addImageButton("icon-break", "toggle", 16 * 2f, () -> {
mode = mode == breaking ? recipe == null ? none : placing : breaking;
lastRecipe = recipe;
if(mode == breaking){
showGuide("deconstruction");
}
}).update(l -> l.setChecked(mode == breaking));
}}.end();
}).margin(5).touchable(Touchable.enabled);;
new table("pane"){{
margin(5);
defaults().size(60f);
touchable(Touchable.enabled);
c.table("pane", cancel -> {
cancel.defaults().size(60f);
//Add a 'cancel building' button.
new imagebutton("icon-cancel", 16 * 2f, player::clearBuilding);
cancel.addImageButton("icon-cancel", 16 * 2f, player::clearBuilding);
visible(() -> player.getPlaceQueue().size > 0);
}}.left().colspan(2).end();
}}.visible(() -> !state.is(State.menu)).end();
}).left().colspan(2).margin(5).touchable(Touchable.enabled).visible(() -> player.getPlaceQueue().size > 0);
});
}
@Override

View File

@@ -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;

View File

@@ -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);

View File

@@ -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();
});
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));

View File

@@ -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){

View File

@@ -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);
});
}
}

View File

@@ -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{

View File

@@ -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);

View File

@@ -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(){

View File

@@ -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();
}