Search in sources :

Example 21 with Table

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

the class JoinDialog method setup.

void setup() {
    hosts.clear();
    hosts.add(remote).growX();
    hosts.row();
    hosts.add(local).width(w);
    ScrollPane pane = new ScrollPane(hosts, "clear");
    pane.setFadeScrollBars(false);
    pane.setScrollingDisabled(true, false);
    setupRemote();
    refreshRemote();
    content().clear();
    content().table(t -> {
        t.add("$text.name").padRight(10);
        t.addField(Settings.getString("name"), text -> {
            if (text.isEmpty())
                return;
            Vars.player.name = text;
            Settings.put("name", text);
            Settings.save();
        }).grow().pad(8).get().setMaxLength(40);
        ImageButton button = t.addImageButton("white", 40, () -> {
            new ColorPickDialog().show(color -> {
                player.color.set(color);
                Settings.putInt("color", Color.rgba8888(color));
                Settings.save();
            });
        }).size(50f, 54f).get();
        button.update(() -> button.getStyle().imageUpColor = player.getColor());
    }).width(w).height(70f).pad(4);
    content().row();
    content().add(pane).width(w + 34).pad(0);
    content().row();
    content().addCenteredImageTextButton("$text.server.add", "icon-add", "clear", 14 * 3, () -> {
        renaming = null;
        add.show();
    }).marginLeft(6).width(w).height(80f).update(button -> {
        float pw = w;
        float pad = 0f;
        if (pane.getChildren().first().getPrefHeight() > pane.getHeight()) {
            pw = w + 30;
            pad = 6;
        }
        Cell<TextButton> cell = ((Table) pane.getParent()).getCell(button);
        if (!MathUtils.isEqual(cell.getMinWidth(), pw)) {
            cell.width(pw);
            cell.padLeft(pad);
            pane.getParent().invalidateHierarchy();
        }
    });
}
Also used : 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) TextButton(io.anuke.ucore.scene.ui.TextButton) ImageButton(io.anuke.ucore.scene.ui.ImageButton) Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane)

Example 22 with Table

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

the class LanguageDialog method setup.

private void setup() {
    Table langs = new Table();
    langs.marginRight(24f).marginLeft(24f);
    ScrollPane pane = new ScrollPane(langs, "clear");
    pane.setFadeScrollBars(false);
    ButtonGroup<TextButton> group = new ButtonGroup<>();
    for (Locale loc : locales) {
        TextButton button = new TextButton(Platform.instance.getLocaleName(loc), "toggle");
        button.setChecked(ui.getLocale().equals(loc));
        button.clicked(() -> {
            if (ui.getLocale().equals(loc))
                return;
            Settings.putString("locale", loc.toString());
            Settings.save();
            Log.info("Setting locale: {0}", loc.toString());
            ui.showInfo("$text.language.restart");
        });
        langs.add(button).group(group).update(t -> {
            t.setChecked(loc.equals(ui.getLocale()));
        }).size(400f, 60f).row();
    }
    content().add(pane);
}
Also used : TextButton(io.anuke.ucore.scene.ui.TextButton) Locale(java.util.Locale) Table(io.anuke.ucore.scene.ui.layout.Table) ButtonGroup(io.anuke.ucore.scene.ui.ButtonGroup) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane)

Example 23 with Table

use of io.anuke.ucore.scene.ui.layout.Table 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();
}
Also used : io.anuke.ucore.scene.builders.button(io.anuke.ucore.scene.builders.button) Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) FileHandle(com.badlogic.gdx.files.FileHandle) Enemy(io.anuke.mindustry.entities.enemies.Enemy) Label(io.anuke.ucore.scene.ui.Label) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table)

Example 24 with Table

use of io.anuke.ucore.scene.ui.layout.Table 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();
}
Also used : io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table) Core(io.anuke.ucore.core.Core) Bundles(io.anuke.ucore.util.Bundles) Settings(io.anuke.ucore.core.Settings) io.anuke.ucore.scene.builders.imagebutton(io.anuke.ucore.scene.builders.imagebutton) Gdx(com.badlogic.gdx.Gdx) Net(io.anuke.mindustry.net.Net) Color(com.badlogic.gdx.graphics.Color) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) Label(io.anuke.ucore.scene.ui.Label) ImageButton(io.anuke.ucore.scene.ui.ImageButton) Table(io.anuke.ucore.scene.ui.layout.Table) Actions(io.anuke.ucore.scene.actions.Actions) Interpolation(com.badlogic.gdx.math.Interpolation) Vars(io.anuke.mindustry.Vars) State(io.anuke.mindustry.core.GameState.State) Touchable(io.anuke.ucore.scene.event.Touchable) Interpolation(com.badlogic.gdx.math.Interpolation) Label(io.anuke.ucore.scene.ui.Label) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) io.anuke.ucore.scene.builders.imagebutton(io.anuke.ucore.scene.builders.imagebutton) io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table)

Example 25 with Table

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

the class MapEditorDialog method addBlockSelection.

private void addBlockSelection(Table table) {
    Table content = new Table();
    pane = new ScrollPane(content, "volume");
    pane.setScrollingDisabled(true, false);
    pane.setFadeScrollBars(false);
    pane.setOverscroll(true, false);
    ButtonGroup<ImageButton> group = new ButtonGroup<>();
    blockgroup = group;
    int i = 0;
    for (BlockPair pair : ColorMapper.getPairs()) {
        Block block = pair.wall == Blocks.air ? pair.floor : pair.wall;
        ImageButton button = new ImageButton(Draw.hasRegion(block.name) ? Draw.region(block.name) : Draw.region(block.name + "1"), "toggle");
        button.clicked(() -> editor.setDrawBlock(block));
        button.resizeImage(8 * 4f);
        group.add(button);
        content.add(button).pad(4f).size(53f, 58f);
        if (i++ % 2 == 1) {
            content.row();
        }
    }
    group.getButtons().get(2).setChecked(true);
    Table extra = new Table("button");
    extra.labelWrap(() -> editor.getDrawBlock().formalName).width(180f).center();
    table.add(extra).padBottom(-6).growX();
    table.row();
    table.add(pane).growY().fillX();
}
Also used : Table(io.anuke.ucore.scene.ui.layout.Table) BlockPair(io.anuke.mindustry.world.ColorMapper.BlockPair) Block(io.anuke.mindustry.world.Block)

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