Search in sources :

Example 6 with TextButton

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

the class MapLoadDialog method rebuild.

public void rebuild() {
    content().clear();
    selected = world.maps().getMap(0);
    ButtonGroup<TextButton> group = new ButtonGroup<>();
    int maxcol = 3;
    int i = 0;
    Table table = new Table();
    table.defaults().size(200f, 90f).pad(4f);
    table.margin(10f);
    ScrollPane pane = new ScrollPane(table, "horizontal");
    pane.setFadeScrollBars(false);
    for (Map map : world.maps().list()) {
        if (!map.visible)
            continue;
        TextButton button = new TextButton(map.localized(), "toggle");
        button.add(new BorderImage(map.texture, 2f)).size(16 * 4f);
        button.getCells().reverse();
        button.clicked(() -> selected = map);
        button.getLabelCell().grow().left().padLeft(5f);
        group.add(button);
        table.add(button);
        if (++i % maxcol == 0)
            table.row();
    }
    content().add("$text.editor.loadmap");
    content().row();
    content().add(pane);
}
Also used : TextButton(io.anuke.ucore.scene.ui.TextButton) Table(io.anuke.ucore.scene.ui.layout.Table) ButtonGroup(io.anuke.ucore.scene.ui.ButtonGroup) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) Map(io.anuke.mindustry.world.Map) BorderImage(io.anuke.mindustry.ui.BorderImage)

Aggregations

TextButton (io.anuke.ucore.scene.ui.TextButton)6 ScrollPane (io.anuke.ucore.scene.ui.ScrollPane)5 Table (io.anuke.ucore.scene.ui.layout.Table)5 Array (com.badlogic.gdx.utils.Array)3 Vars (io.anuke.mindustry.Vars)3 Host (io.anuke.mindustry.net.Host)3 Timers (io.anuke.ucore.core.Timers)3 Bundles (io.anuke.ucore.util.Bundles)3 Log (io.anuke.ucore.util.Log)3 Strings (io.anuke.ucore.util.Strings)3 Color (com.badlogic.gdx.graphics.Color)2 MathUtils (com.badlogic.gdx.math.MathUtils)2 Vars.player (io.anuke.mindustry.Vars.player)2 Vars.ui (io.anuke.mindustry.Vars.ui)2 Platform (io.anuke.mindustry.io.Platform)2 Version (io.anuke.mindustry.io.Version)2 Net (io.anuke.mindustry.net.Net)2 Settings (io.anuke.ucore.core.Settings)2 Drawable (io.anuke.ucore.scene.style.Drawable)2 ButtonGroup (io.anuke.ucore.scene.ui.ButtonGroup)2