Search in sources :

Example 1 with ScrollPane

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

the class PlayerListFragment method build.

@Override
public void build() {
    new table() {

        {
            new table("pane") {

                {
                    margin(14f);
                    new label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" : "text.players", playerGroup.size()));
                    row();
                    content.marginRight(13f).marginLeft(13f);
                    ScrollPane pane = new ScrollPane(content, "clear");
                    pane.setScrollingDisabled(true, false);
                    pane.setFadeScrollBars(false);
                    add(pane).grow();
                    row();
                    new table("pane") {

                        {
                            margin(12f);
                            get().addCheck("$text.server.friendlyfire", b -> {
                                state.friendlyFire = b;
                                NetEvents.handleFriendlyFireChange(b);
                            }).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
                            new button("$text.server.bans", () -> {
                                ui.bans.show();
                            }).padTop(-12).padBottom(-12).fillY().cell.disabled(b -> Net.client());
                            new button("$text.server.admins", () -> {
                                ui.admins.show();
                            }).padTop(-12).padBottom(-12).padRight(-12).fillY().cell.disabled(b -> Net.client());
                        }
                    }.pad(10f).growX().end();
                }
            }.end();
            update(t -> {
                if (!android) {
                    visible = Inputs.keyDown("player_list");
                }
                if (!(Net.active() && !state.is(State.menu))) {
                    visible = false;
                }
                if (playerGroup.size() != last) {
                    rebuild();
                    last = playerGroup.size();
                }
            });
            visible(() -> visible);
        }
    }.end();
    rebuild();
}
Also used : Player(io.anuke.mindustry.entities.Player) KickReason(io.anuke.mindustry.net.Packets.KickReason) io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table) io.anuke.ucore.scene.builders.button(io.anuke.ucore.scene.builders.button) Bundles(io.anuke.ucore.util.Bundles) Stack(io.anuke.ucore.scene.ui.layout.Stack) Net(io.anuke.mindustry.net.Net) AdminAction(io.anuke.mindustry.net.Packets.AdminAction) NetEvents(io.anuke.mindustry.net.NetEvents) BorderImage(io.anuke.mindustry.ui.BorderImage) Draw(io.anuke.ucore.graphics.Draw) Element(io.anuke.ucore.scene.Element) NetConnection(io.anuke.mindustry.net.NetConnection) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) Table(io.anuke.ucore.scene.ui.layout.Table) Mathf(io.anuke.ucore.util.Mathf) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) Vars(io.anuke.mindustry.Vars) State(io.anuke.mindustry.core.GameState.State) Inputs(io.anuke.ucore.core.Inputs) Touchable(io.anuke.ucore.scene.event.Touchable) io.anuke.ucore.scene.builders.button(io.anuke.ucore.scene.builders.button) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) 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 2 with ScrollPane

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

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

the class BansDialog 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.getBanned().size == 0) {
        table.add("$text.server.bans.none");
    }
    for (PlayerInfo info : netServer.admins.getBanned()) {
        Table res = new Table("button");
        res.margin(14f);
        res.labelWrap("IP: [LIGHT_GRAY]" + info.lastIP + "\n[]Name: [LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
        res.add().growX();
        res.addImageButton("icon-cancel", 14 * 3, () -> {
            ui.showConfirm("$text.confirm", "$text.confirmunban", () -> {
                netServer.admins.unbanPlayerID(info.id);
                setup();
            });
        }).size(h).pad(-14f);
        table.add(res).width(w).height(h);
        table.row();
    }
    content().add(pane);
}
Also used : Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane) PlayerInfo(io.anuke.mindustry.net.Administration.PlayerInfo)

Example 4 with ScrollPane

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

the class ChangelogDialog method setup.

void setup() {
    Table table = new Table();
    ScrollPane pane = new ScrollPane(table, "clear");
    content().clear();
    content().add(pane).grow();
    if (versions == null) {
        table.add("$text.changelog.error");
        if (Vars.android) {
            table.row();
            table.add("$text.changelog.error.android").padTop(8);
        }
    } else {
        for (VersionInfo info : versions) {
            Table in = new Table("clear");
            in.top().left().margin(10);
            in.add("[accent]" + info.name);
            if (info.build == Version.build) {
                in.row();
                in.add("$text.changelog.current");
            } else if (info == versions.first()) {
                in.row();
                in.add("$text.changelog.latest");
            }
            in.row();
            in.labelWrap("[lightgray]" + info.description).width(vw - 20).padTop(12);
            table.add(in).width(vw).pad(8).row();
        }
        int lastid = Settings.getInt("lastBuild");
        if (lastid != 0 && versions.peek().build > lastid) {
            Settings.putInt("lastBuild", versions.peek().build);
            Settings.save();
            show();
        }
    }
}
Also used : VersionInfo(io.anuke.mindustry.io.Changelogs.VersionInfo) Table(io.anuke.ucore.scene.ui.layout.Table) ScrollPane(io.anuke.ucore.scene.ui.ScrollPane)

Example 5 with ScrollPane

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

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