use of io.anuke.ucore.scene.ui.Label in project Mindustry by Anuken.
the class DebugFragment method build.
@Override
public void build() {
new table() {
{
visible(() -> debug);
atop().aright();
new table("pane") {
{
defaults().fillX();
new label("Debug");
row();
new button("noclip", "toggle", () -> noclip = !noclip);
row();
new button("hideplayer", "toggle", () -> showPlayer = !showPlayer);
row();
new button("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
row();
new button("paths", "toggle", () -> showPaths = !showPaths);
row();
new button("wave", () -> state.wavetime = 0f);
row();
new button("time 0", () -> Timers.resetTime(0f));
row();
new button("time max", () -> Timers.resetTime(1080000 - 60 * 10));
row();
new button("clear", () -> {
enemyGroup.clear();
state.enemies = 0;
netClient.clearRecieved();
});
row();
new button("spawn", () -> {
new Enemy(EnemyTypes.healer).set(player.x, player.y).add();
});
row();
}
}.end();
row();
}
}.end();
new table() {
{
visible(() -> console);
atop().aleft();
new table("pane") {
{
defaults().fillX();
ScrollPane pane = new ScrollPane(new Label(DebugFragment::debugInfo), "clear");
add(pane);
row();
new button("dump", () -> {
try {
FileHandle file = Gdx.files.local("packet-dump.txt");
file.writeString("--INFO--\n", false);
file.writeString(debugInfo(), true);
file.writeString("--LOG--\n\n", true);
file.writeString(log.toString(), true);
} catch (Exception e) {
ui.showError("Error dumping log.");
}
});
}
}.end();
}
}.end();
new table() {
{
visible(() -> console);
atop();
Table table = new Table("pane");
table.label(() -> log.toString());
ScrollPane pane = new ScrollPane(table, "clear");
get().add(pane);
}
}.end();
}
use of io.anuke.ucore.scene.ui.Label in project Mindustry by Anuken.
the class HudFragment method build.
public void build() {
// menu at top left
new table() {
{
atop();
aleft();
new table() {
{
new table() {
{
left();
float dsize = 58;
defaults().size(dsize).left();
float isize = 40;
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
flip = new imagebutton("icon-arrow-up", isize, () -> {
if (wavetable.getActions().size != 0)
return;
float dur = 0.3f;
Interpolation in = Interpolation.pow3Out;
flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
if (shown) {
blockfrag.toggle(false, dur, in);
wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
infolabel.actions(Actions.translateBy(0, wavetable.getHeight(), dur, in), Actions.call(() -> shown = false));
} else {
shown = true;
blockfrag.toggle(true, dur, in);
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in));
}
}).get();
new imagebutton("icon-pause", isize, () -> {
if (android)
DebugFragment.printDebugInfo();
if (Net.active() && android) {
ui.listfrag.visible = !ui.listfrag.visible;
} else {
state.set(state.is(State.paused) ? State.playing : State.paused);
}
}).update(i -> {
if (Net.active() && android) {
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();
new imagebutton("icon-settings", isize, () -> {
if (Net.active() && android) {
if (ui.chatfrag.chatOpen()) {
ui.chatfrag.hide();
} else {
ui.chatfrag.toggle();
}
} else {
ui.settings.show();
}
}).update(i -> {
if (Net.active() && android) {
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
} else {
i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
}
}).get();
}
}.end();
row();
new table() {
{
touchable(Touchable.enabled);
visible(() -> shown);
addWaveTable();
}
}.fillX().end();
row();
visible(() -> !state.is(State.menu));
infolabel = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") + (threads.isEnabled() ? " / " + threads.getFPS() + " TPS" : "") + (Net.client() && !gwt ? "\nPing: " + Net.getPing() : "") : ""));
row();
add(infolabel).size(-1);
}
}.end();
}
}.end();
// tutorial ui table
new table() {
{
control.tutorial().buildUI(this);
visible(() -> control.tutorial().active());
}
}.end();
// paused table
new table() {
{
visible(() -> state.is(State.paused) && !Net.active());
atop();
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();
// respawn table
new table() {
{
new table("pane") {
{
new label(() -> "[orange]" + Bundles.get("text.respawn") + " " + (int) (control.getRespawnTime() / 60)).scale(0.75f).pad(10);
visible(() -> control.getRespawnTime() > 0 && !state.is(State.menu));
}
}.end();
}
}.end();
new table() {
{
abottom();
visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
new label("$text.saveload");
}
}.end();
blockfrag.build();
}
use of io.anuke.ucore.scene.ui.Label in project Mindustry by Anuken.
the class PlacementFragment method build.
public void build() {
if (!android)
return;
InputHandler input = control.input();
float s = 50f;
float translation = Unit.dp.scl(58f);
new table() {
{
visible(() -> !state.is(State.menu));
abottom();
aleft();
ButtonGroup<ImageButton> placeGroup = new ButtonGroup<>();
ButtonGroup<ImageButton> breakGroup = new ButtonGroup<>();
update(t -> {
if ((input.recipe == null) == placing) {
float i = 0.1f;
Interpolation n = Interpolation.pow3Out;
if (input.recipe == null) {
placing = false;
container.clearActions();
container.actions(Actions.translateBy(0, -(container.getTranslation().y + translation), i, n));
if (!input.lastBreakMode.both)
input.placeMode = input.lastBreakMode;
} else {
placing = true;
container.clearActions();
container.actions(Actions.translateBy(0, -(container.getTranslation().y), i, n));
input.placeMode = input.lastPlaceMode;
}
}
if (!input.placeMode.delete) {
placeGroup.setMinCheckCount(1);
for (ImageButton button : placeGroup.getButtons()) {
if (button.getName().equals(input.placeMode.name())) {
button.setChecked(true);
break;
}
}
} else {
placeGroup.setMinCheckCount(0);
for (ImageButton button : placeGroup.getButtons()) button.setChecked(false);
}
if (input.placeMode.delete || input.breakMode.both) {
PlaceMode mode = input.breakMode;
breakGroup.setMinCheckCount(1);
for (ImageButton button : breakGroup.getButtons()) {
if (button.getName().equals(mode.name())) {
button.setChecked(true);
break;
}
}
} else {
breakGroup.setMinCheckCount(0);
for (ImageButton button : breakGroup.getButtons()) button.setChecked(false);
}
});
container = new table() {
{
modelabel = new label("").get();
row();
// break menu
new table() {
{
abottom();
aleft();
height(s + 5 + 4);
next = new table("pane") {
{
margin(5f);
defaults().padBottom(-5.5f);
new imagebutton("icon-arrow-right", 10 * 3, () -> {
toggle(!shown);
}).update(l -> l.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-left" : "icon-" + input.breakMode.name())).size(s, s + 4);
}
}.end().get();
breaktable = new table("pane") {
{
visible(() -> shown);
margin(5f);
marginLeft(-(Unit.dp.scl(1f) - 1f) * 2.5f);
touchable(Touchable.enabled);
aleft();
defaults().size(s, s + 4);
for (PlaceMode mode : PlaceMode.values()) {
if (!mode.shown || !mode.delete)
continue;
defaults().padBottom(-5.5f);
ImageButton button = new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
control.input().resetCursor();
input.breakMode = mode;
input.lastBreakMode = mode;
if (!mode.both) {
input.placeMode = mode;
} else {
input.placeMode = input.lastPlaceMode;
}
modeText(Bundles.format("text.mode.break", mode.toString()));
}).group(breakGroup).get();
button.setName(mode.name());
button.released(() -> {
// TODO hack
if (mode == PlaceMode.areaDelete) {
((AndroidInput) input).placing = false;
}
});
}
}
}.end().get();
breaktable.getParent().swapActor(breaktable, next);
breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0);
}
}.end().get();
row();
// place menu
new table() {
{
touchable(Touchable.enabled);
aleft();
new table("pane") {
{
margin(5f);
aleft();
defaults().size(s, s + 4).padBottom(-5.5f);
Color color = Color.GRAY;
new imagebutton("icon-cancel", 14 * 3, () -> {
input.recipe = null;
}).imageColor(color).visible(() -> input.recipe != null);
for (PlaceMode mode : PlaceMode.values()) {
if (!mode.shown || mode.delete)
continue;
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
control.input().resetCursor();
input.placeMode = mode;
input.lastPlaceMode = mode;
modeText(Bundles.format("text.mode.place", mode.toString()));
}).group(placeGroup).get().setName(mode.name());
}
new imagebutton("icon-arrow", 14 * 3, () -> {
input.rotation = Mathf.mod(input.rotation + 1, 4);
}).imageColor(color).visible(() -> input.recipe != null).update(image -> {
image.getImage().setRotation(input.rotation * 90);
image.getImage().setOrigin(Align.center);
});
}
}.left().end();
}
}.left().end();
}
}.end().get();
container.setTranslation(0, -translation);
}
}.end();
}
Aggregations