Search in sources :

Example 6 with ScrollPane

use of io.anuke.ucore.scene.ui.ScrollPane 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 7 with ScrollPane

use of io.anuke.ucore.scene.ui.ScrollPane 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 8 with ScrollPane

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

Example 9 with ScrollPane

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

the class AdminsDialog method setup.

private void setup() {
    content().clear();
    if (gwt)
        return;
    float w = 400f, h = 80f;
    Table table = new Table();
    ScrollPane pane = new ScrollPane(table, "clear");
    pane.setFadeScrollBars(false);
    if (netServer.admins.getAdmins().size == 0) {
        table.add("$text.server.admins.none");
    }
    for (PlayerInfo info : netServer.admins.getAdmins()) {
        Table res = new Table("button");
        res.margin(14f);
        res.labelWrap("[LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
        res.add().growX();
        res.addImageButton("icon-cancel", 14 * 3, () -> {
            ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> {
                netServer.admins.unAdminPlayer(info.id);
                for (Player player : playerGroup.all()) {
                    NetConnection c = Net.getConnection(player.clientid);
                    if (c != null) {
                        NetEvents.handleAdminSet(player, false);
                        break;
                    }
                }
                setup();
            });
        }).size(h).pad(-14f);
        table.add(res).width(w).height(h);
        table.row();
    }
    content().add(pane);
}
Also used : Player(io.anuke.mindustry.entities.Player) NetConnection(io.anuke.mindustry.net.NetConnection) Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) PlayerInfo(io.anuke.mindustry.net.Administration.PlayerInfo)

Aggregations

ScrollPane (io.anuke.ucore.scene.ui.ScrollPane)9 Table (io.anuke.ucore.scene.ui.layout.Table)9 TextButton (io.anuke.ucore.scene.ui.TextButton)4 Vars (io.anuke.mindustry.Vars)3 Bundles (io.anuke.ucore.util.Bundles)3 Array (com.badlogic.gdx.utils.Array)2 State (io.anuke.mindustry.core.GameState.State)2 Player (io.anuke.mindustry.entities.Player)2 PlayerInfo (io.anuke.mindustry.net.Administration.PlayerInfo)2 Net (io.anuke.mindustry.net.Net)2 NetConnection (io.anuke.mindustry.net.NetConnection)2 BorderImage (io.anuke.mindustry.ui.BorderImage)2 Timers (io.anuke.ucore.core.Timers)2 io.anuke.ucore.scene.builders.button (io.anuke.ucore.scene.builders.button)2 io.anuke.ucore.scene.builders.label (io.anuke.ucore.scene.builders.label)2 io.anuke.ucore.scene.builders.table (io.anuke.ucore.scene.builders.table)2 ButtonGroup (io.anuke.ucore.scene.ui.ButtonGroup)2 Log (io.anuke.ucore.util.Log)2 Strings (io.anuke.ucore.util.Strings)2 FileHandle (com.badlogic.gdx.files.FileHandle)1