Search in sources :

Example 1 with PressGroup

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

the class PausedDialog method setup.

void setup() {
    update(() -> {
        if (state.is(State.menu) && isShown()) {
            hide();
        }
    });
    shown(() -> {
        wasPaused = state.is(State.paused);
        if (!Net.active())
            state.set(State.paused);
    });
    if (!android) {
        content().defaults().width(220).height(50);
        content().addButton("$text.back", () -> {
            hide();
            if ((!wasPaused || Net.active()) && !state.is(State.menu))
                state.set(State.playing);
        });
        content().row();
        content().addButton("$text.settings", ui.settings::show);
        content().row();
        content().addButton("$text.savegame", () -> {
            save.show();
        }).disabled(b -> world.getMap().id == -1);
        content().row();
        content().addButton("$text.loadgame", () -> {
            load.show();
        }).disabled(b -> Net.active());
        content().row();
        if (!gwt) {
            content().addButton("$text.hostserver", () -> {
                ui.host.show();
            }).disabled(b -> Net.active());
        }
        content().row();
        content().addButton("$text.quit", () -> {
            ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
                if (Net.client())
                    netClient.disconnectQuietly();
                runExitSave();
                hide();
            });
        });
    } else {
        build.begin(content());
        PressGroup group = new PressGroup();
        content().defaults().size(120f).pad(5);
        float isize = 14f * 4;
        new imagebutton("icon-play-2", isize, () -> {
            hide();
            if (!wasPaused && !state.is(State.menu))
                state.set(State.playing);
        }).text("$text.back").padTop(4f);
        new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
        imagebutton sa = new imagebutton("icon-save", isize, save::show);
        sa.text("$text.save").padTop(4f);
        sa.cell.disabled(b -> world.getMap().id == -1);
        content().row();
        imagebutton lo = new imagebutton("icon-load", isize, load::show);
        lo.text("$text.load").padTop(4f);
        lo.cell.disabled(b -> Net.active());
        imagebutton ho = new imagebutton("icon-host", isize, () -> {
            ui.host.show();
        });
        ho.text("$text.host").padTop(4f);
        ho.cell.disabled(b -> Net.active());
        new imagebutton("icon-quit", isize, () -> {
            ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
                if (Net.client())
                    netClient.disconnectQuietly();
                runExitSave();
                hide();
            });
        }).text("Quit").padTop(4f);
        for (Element e : content().getChildren()) {
            if (e instanceof ImageButton) {
                group.add((ImageButton) e);
            }
        }
        build.end();
    }
}
Also used : ImageButton(io.anuke.ucore.scene.ui.ImageButton) PressGroup(io.anuke.mindustry.ui.PressGroup) Element(io.anuke.ucore.scene.Element) io.anuke.ucore.scene.builders.imagebutton(io.anuke.ucore.scene.builders.imagebutton)

Aggregations

PressGroup (io.anuke.mindustry.ui.PressGroup)1 Element (io.anuke.ucore.scene.Element)1 io.anuke.ucore.scene.builders.imagebutton (io.anuke.ucore.scene.builders.imagebutton)1 ImageButton (io.anuke.ucore.scene.ui.ImageButton)1