Search in sources :

Example 1 with FloatingDialog

use of io.anuke.mindustry.ui.dialogs.FloatingDialog in project Mindustry by Anuken.

the class BlocksFragment method showBlockInfo.

public void showBlockInfo(Block block) {
    statlist.clear();
    block.getStats(statlist);
    Label desclabel = new Label(block.fullDescription);
    desclabel.setWrap(true);
    boolean wasPaused = state.is(State.paused);
    state.set(State.paused);
    FloatingDialog d = new FloatingDialog("$text.blocks.blockinfo");
    Table table = new Table();
    table.defaults().pad(1f);
    ScrollPane pane = new ScrollPane(table, "clear");
    pane.setFadeScrollBars(false);
    Table top = new Table();
    top.left();
    top.add(new Image(Draw.region(block.name))).size(8 * 5 * block.width);
    top.add("[accent]" + block.formalName).padLeft(6f);
    table.add(top).fill().left();
    table.row();
    table.add(desclabel).width(600);
    table.row();
    d.content().add(pane).grow();
    if (statlist.size > 0) {
        table.add("$text.blocks.extrainfo").padTop(6).padBottom(5).left();
        table.row();
    }
    for (String s : statlist) {
        if (s.contains(":")) {
            String color = s.substring(0, s.indexOf("]") + 1);
            String first = s.substring(color.length(), s.indexOf(":")).replace("/", "").replace(" ", "").toLowerCase();
            String last = s.substring(s.indexOf(":"), s.length());
            s = color + Bundles.get("text.blocks." + first) + last;
        }
        table.add(s).left();
        table.row();
    }
    d.buttons().addButton("$text.ok", () -> {
        if (!wasPaused)
            state.set(State.playing);
        d.hide();
    }).size(110, 50).pad(10f);
    d.show();
}
Also used : Table(io.anuke.ucore.scene.ui.layout.Table) FloatingDialog(io.anuke.mindustry.ui.dialogs.FloatingDialog)

Example 2 with FloatingDialog

use of io.anuke.mindustry.ui.dialogs.FloatingDialog in project Mindustry by Anuken.

the class MenuFragment method showPlaySelect.

private void showPlaySelect() {
    float w = 200f;
    float bw = w * 2f + 10f;
    FloatingDialog dialog = new FloatingDialog("$text.play");
    dialog.addCloseButton();
    dialog.content().defaults().height(70f).width(w).padRight(5f);
    dialog.content().add(new MenuButton("icon-play-2", "$text.newgame", () -> {
        dialog.hide();
        ui.levels.show();
    })).width(bw).colspan(2);
    dialog.content().row();
    dialog.content().add(new MenuButton("icon-add", "$text.joingame", () -> {
        if (Platform.instance.canJoinGame()) {
            ui.join.show();
            dialog.hide();
        } else {
            ui.showInfo("$text.multiplayer.web");
        }
    }));
    dialog.content().add(new MenuButton("icon-tutorial", "$text.tutorial", () -> {
        control.playMap(world.maps().getMap("tutorial"));
        dialog.hide();
    }));
    dialog.content().row();
    dialog.content().add(new MenuButton("icon-load", "$text.loadgame", () -> {
        ui.load.show();
        dialog.hide();
    })).width(bw).colspan(2);
    dialog.show();
}
Also used : MenuButton(io.anuke.mindustry.ui.MenuButton) FloatingDialog(io.anuke.mindustry.ui.dialogs.FloatingDialog)

Aggregations

FloatingDialog (io.anuke.mindustry.ui.dialogs.FloatingDialog)2 MenuButton (io.anuke.mindustry.ui.MenuButton)1 Table (io.anuke.ucore.scene.ui.layout.Table)1