Search in sources :

Example 1 with Cell

use of io.anuke.ucore.scene.ui.layout.Cell 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)

Aggregations

Color (com.badlogic.gdx.graphics.Color)1 MathUtils (com.badlogic.gdx.math.MathUtils)1 Array (com.badlogic.gdx.utils.Array)1 Vars (io.anuke.mindustry.Vars)1 Vars.player (io.anuke.mindustry.Vars.player)1 Vars.ui (io.anuke.mindustry.Vars.ui)1 Platform (io.anuke.mindustry.io.Platform)1 Version (io.anuke.mindustry.io.Version)1 Host (io.anuke.mindustry.net.Host)1 Net (io.anuke.mindustry.net.Net)1 Settings (io.anuke.ucore.core.Settings)1 Timers (io.anuke.ucore.core.Timers)1 Drawable (io.anuke.ucore.scene.style.Drawable)1 Dialog (io.anuke.ucore.scene.ui.Dialog)1 ImageButton (io.anuke.ucore.scene.ui.ImageButton)1 ScrollPane (io.anuke.ucore.scene.ui.ScrollPane)1 TextButton (io.anuke.ucore.scene.ui.TextButton)1 Cell (io.anuke.ucore.scene.ui.layout.Cell)1 Table (io.anuke.ucore.scene.ui.layout.Table)1 Bundles (io.anuke.ucore.util.Bundles)1