Search in sources :

Example 11 with Table

use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.

the class ToolFragment method build.

public void build() {
    InputHandler input = control.input();
    float isize = 14 * 3;
    tools = new Table();
    tools.addImageButton("icon-cancel", isize, () -> {
        if (input.placeMode == PlaceMode.areaDelete && confirming) {
            confirming = false;
        } else {
            input.recipe = null;
        }
    });
    tools.addImageButton("icon-rotate", isize, () -> {
        input.rotation++;
        input.rotation %= 4;
    });
    tools.addImageButton("icon-check", isize, () -> {
        if (input.placeMode == PlaceMode.areaDelete && confirming) {
            input.placeMode.released(px, py, px2, py2);
            confirming = false;
        } else {
            input.placeMode.tapped(control.input().getBlockX(), control.input().getBlockY());
        }
    });
    Core.scene.add(tools);
    tools.setVisible(() -> !state.is(State.menu) && android && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && input.placeMode == PlaceMode.cursor) || confirming));
    tools.update(() -> {
        if (confirming) {
            Vector2 v = Graphics.screen((px + px2) / 2f * tilesize, Math.min(py, py2) * tilesize - tilesize * 1.5f);
            tools.setPosition(v.x, v.y, Align.top);
        } else {
            tools.setPosition(control.input().getCursorX(), Gdx.graphics.getHeight() - control.input().getCursorY() - 15 * Core.cameraScale, Align.top);
        }
        if (input.placeMode != PlaceMode.areaDelete) {
            confirming = false;
        }
    });
}
Also used : InputHandler(io.anuke.mindustry.input.InputHandler) Table(io.anuke.ucore.scene.ui.layout.Table) Vector2(com.badlogic.gdx.math.Vector2)

Example 12 with Table

use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.

the class JoinDialog method setupRemote.

void setupRemote() {
    remote.clear();
    for (Server server : servers) {
        // why are java lambdas this bad
        TextButton[] buttons = { null };
        TextButton button = buttons[0] = remote.addButton("[accent]" + server.ip, "clear", () -> {
            if (!buttons[0].childrenPressed())
                connect(server.ip, Vars.port);
        }).width(w).height(150f).pad(4f).get();
        button.getLabel().setWrap(true);
        Table inner = new Table();
        button.clearChildren();
        button.add(inner).growX();
        inner.add(button.getLabel()).growX();
        inner.addImageButton("icon-loading", "empty", 16 * 2, () -> {
            refreshServer(server);
        }).margin(3f).padTop(6f).top().right();
        inner.addImageButton("icon-pencil", "empty", 16 * 2, () -> {
            renaming = server;
            add.show();
        }).margin(3f).padTop(6f).top().right();
        inner.addImageButton("icon-trash-16", "empty", 16 * 2, () -> {
            ui.showConfirm("$text.confirm", "$text.server.delete", () -> {
                servers.removeValue(server, true);
                saveServers();
                setupRemote();
                refreshRemote();
            });
        }).margin(3f).pad(6).top().right();
        button.row();
        server.content = button.table(t -> {
        }).grow().get();
        remote.row();
    }
}
Also used : TextButton(io.anuke.ucore.scene.ui.TextButton) Version(io.anuke.mindustry.io.Version) MathUtils(com.badlogic.gdx.math.MathUtils) Strings(io.anuke.ucore.util.Strings) Array(com.badlogic.gdx.utils.Array) Platform(io.anuke.mindustry.io.Platform) Cell(io.anuke.ucore.scene.ui.layout.Cell) Bundles(io.anuke.ucore.util.Bundles) Settings(io.anuke.ucore.core.Settings) Vars.ui(io.anuke.mindustry.Vars.ui) Net(io.anuke.mindustry.net.Net) Color(com.badlogic.gdx.graphics.Color) Drawable(io.anuke.ucore.scene.style.Drawable) Vars.player(io.anuke.mindustry.Vars.player) Host(io.anuke.mindustry.net.Host) TextButton(io.anuke.ucore.scene.ui.TextButton) Dialog(io.anuke.ucore.scene.ui.Dialog) ImageButton(io.anuke.ucore.scene.ui.ImageButton) Table(io.anuke.ucore.scene.ui.layout.Table) Timers(io.anuke.ucore.core.Timers) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) Log(io.anuke.ucore.util.Log) Vars(io.anuke.mindustry.Vars) Table(io.anuke.ucore.scene.ui.layout.Table)

Example 13 with Table

use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.

the class LoadDialog method setup.

protected void setup() {
    content().clear();
    slots = new Table();
    pane = new ScrollPane(slots, "clear-black");
    pane.setFadeScrollBars(false);
    pane.setScrollingDisabled(true, false);
    slots.marginRight(24);
    Timers.runTask(2f, () -> Core.scene.setScrollFocus(pane));
    Array<SaveSlot> array = control.getSaves().getSaveSlots();
    for (SaveSlot slot : array) {
        TextButton button = new TextButton("[accent]" + slot.getName(), "clear");
        button.getLabelCell().growX().left();
        button.getLabelCell().padBottom(8f);
        button.getLabelCell().top().left().growX();
        button.defaults().left();
        button.table(t -> {
            t.right();
            t.addImageButton("icon-floppy", "emptytoggle", 14 * 3, () -> {
                slot.setAutosave(!slot.isAutosave());
            }).checked(slot.isAutosave()).right();
            t.addImageButton("icon-trash", "empty", 14 * 3, () -> {
                ui.showConfirm("$text.confirm", "$text.save.delete.confirm", () -> {
                    slot.delete();
                    setup();
                });
            }).size(14 * 3).right();
            t.addImageButton("icon-pencil-small", "empty", 14 * 3, () -> {
                ui.showTextInput("$text.save.rename", "$text.save.rename.text", slot.getName(), text -> {
                    slot.setName(text);
                    setup();
                });
            }).size(14 * 3).right();
            if (!gwt) {
                t.addImageButton("icon-save", "empty", 14 * 3, () -> {
                    new FileChooser("$text.save.export", false, file -> {
                        try {
                            slot.exportFile(file);
                            setup();
                        } catch (IOException e) {
                            ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
                        }
                    }).show();
                }).size(14 * 3).right();
            }
        }).padRight(-10).growX();
        String color = "[lightgray]";
        button.defaults().padBottom(3);
        button.row();
        button.add(Bundles.format("text.save.map", color + slot.getMap().localized()));
        button.row();
        button.add(Bundles.get("text.level.mode") + " " + color + slot.getMode());
        button.row();
        button.add(Bundles.format("text.save.wave", color + slot.getWave()));
        button.row();
        button.add(Bundles.format("text.save.difficulty", color + slot.getDifficulty()));
        button.row();
        button.label(() -> Bundles.format("text.save.autosave", color + Bundles.get(slot.isAutosave() ? "text.on" : "text.off")));
        button.row();
        button.add();
        button.add(Bundles.format("text.save.date", color + slot.getDate()));
        button.row();
        modifyButton(button, slot);
        slots.add(button).uniformX().fillX().pad(4).padRight(-4).margin(10f).marginLeft(20f).marginRight(20f);
        slots.row();
    }
    content().add(pane);
    addSetup();
}
Also used : TextButton(io.anuke.ucore.scene.ui.TextButton) Strings(io.anuke.ucore.util.Strings) SaveIO(io.anuke.mindustry.io.SaveIO) Core(io.anuke.ucore.core.Core) Array(com.badlogic.gdx.utils.Array) Bundles(io.anuke.ucore.util.Bundles) IOException(java.io.IOException) TextButton(io.anuke.ucore.scene.ui.TextButton) Table(io.anuke.ucore.scene.ui.layout.Table) Timers(io.anuke.ucore.core.Timers) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) Log(io.anuke.ucore.util.Log) SaveSlot(io.anuke.mindustry.io.Saves.SaveSlot) Vars(io.anuke.mindustry.Vars) State(io.anuke.mindustry.core.GameState.State) Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) SaveSlot(io.anuke.mindustry.io.Saves.SaveSlot) IOException(java.io.IOException)

Example 14 with Table

use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.

the class TraceDialog method show.

public void show(Player player, TraceInfo info) {
    content().clear();
    Table table = new Table("button");
    table.margin(14);
    table.defaults().pad(1);
    table.defaults().left();
    table.add(Bundles.format("text.trace.playername", player.name));
    table.row();
    table.add(Bundles.format("text.trace.ip", info.ip));
    table.row();
    table.add(Bundles.format("text.trace.id", info.uuid));
    table.row();
    table.add(Bundles.format("text.trace.modclient", info.modclient));
    table.row();
    table.add(Bundles.format("text.trace.android", info.android));
    table.row();
    table.add().pad(5);
    table.row();
    table.add(Bundles.format("text.trace.totalblocksbroken", info.totalBlocksBroken));
    table.row();
    table.add(Bundles.format("text.trace.structureblocksbroken", info.structureBlocksBroken));
    table.row();
    table.add(Bundles.format("text.trace.lastblockbroken", info.lastBlockBroken.formalName));
    table.row();
    table.add().pad(5);
    table.row();
    table.add(Bundles.format("text.trace.totalblocksplaced", info.totalBlocksPlaced));
    table.row();
    table.add(Bundles.format("text.trace.lastblockplaced", info.lastBlockPlaced.formalName));
    table.row();
    content().add(table);
    show();
}
Also used : Table(io.anuke.ucore.scene.ui.layout.Table)

Example 15 with Table

use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.

the class BlockConfigFragment method build.

@Override
public void build() {
    table = new Table();
    Core.scene.add(table);
}
Also used : Table(io.anuke.ucore.scene.ui.layout.Table)

Aggregations

Table (io.anuke.ucore.scene.ui.layout.Table)29 ScrollPane (io.anuke.ucore.scene.ui.ScrollPane)11 Vars (io.anuke.mindustry.Vars)9 Bundles (io.anuke.ucore.util.Bundles)9 ImageButton (io.anuke.ucore.scene.ui.ImageButton)8 io.anuke.ucore.scene.builders.table (io.anuke.ucore.scene.builders.table)7 Color (com.badlogic.gdx.graphics.Color)6 io.anuke.ucore.scene.builders.label (io.anuke.ucore.scene.builders.label)6 State (io.anuke.mindustry.core.GameState.State)5 Net (io.anuke.mindustry.net.Net)5 Core (io.anuke.ucore.core.Core)5 Timers (io.anuke.ucore.core.Timers)5 Touchable (io.anuke.ucore.scene.event.Touchable)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Settings (io.anuke.ucore.core.Settings)4 ButtonGroup (io.anuke.ucore.scene.ui.ButtonGroup)4 TextButton (io.anuke.ucore.scene.ui.TextButton)4 Log (io.anuke.ucore.util.Log)4 Strings (io.anuke.ucore.util.Strings)4 Array (com.badlogic.gdx.utils.Array)3