Search in sources :

Example 1 with Settings

use of io.anuke.ucore.core.Settings in project Mindustry by Anuken.

the class HudFragment method build.

public void build() {
    // menu at top left
    new table() {

        {
            atop();
            aleft();
            new table() {

                {
                    new table() {

                        {
                            left();
                            float dsize = 58;
                            defaults().size(dsize).left();
                            float isize = 40;
                            menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
                            flip = new imagebutton("icon-arrow-up", isize, () -> {
                                if (wavetable.getActions().size != 0)
                                    return;
                                float dur = 0.3f;
                                Interpolation in = Interpolation.pow3Out;
                                flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
                                if (shown) {
                                    blockfrag.toggle(false, dur, in);
                                    wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
                                    infolabel.actions(Actions.translateBy(0, wavetable.getHeight(), dur, in), Actions.call(() -> shown = false));
                                } else {
                                    shown = true;
                                    blockfrag.toggle(true, dur, in);
                                    wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
                                    infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in));
                                }
                            }).get();
                            new imagebutton("icon-pause", isize, () -> {
                                if (android)
                                    DebugFragment.printDebugInfo();
                                if (Net.active() && android) {
                                    ui.listfrag.visible = !ui.listfrag.visible;
                                } else {
                                    state.set(state.is(State.paused) ? State.playing : State.paused);
                                }
                            }).update(i -> {
                                if (Net.active() && android) {
                                    i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
                                } else {
                                    i.setDisabled(Net.active());
                                    i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
                                }
                            }).get();
                            new imagebutton("icon-settings", isize, () -> {
                                if (Net.active() && android) {
                                    if (ui.chatfrag.chatOpen()) {
                                        ui.chatfrag.hide();
                                    } else {
                                        ui.chatfrag.toggle();
                                    }
                                } else {
                                    ui.settings.show();
                                }
                            }).update(i -> {
                                if (Net.active() && android) {
                                    i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
                                } else {
                                    i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
                                }
                            }).get();
                        }
                    }.end();
                    row();
                    new table() {

                        {
                            touchable(Touchable.enabled);
                            visible(() -> shown);
                            addWaveTable();
                        }
                    }.fillX().end();
                    row();
                    visible(() -> !state.is(State.menu));
                    infolabel = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") + (threads.isEnabled() ? " / " + threads.getFPS() + " TPS" : "") + (Net.client() && !gwt ? "\nPing: " + Net.getPing() : "") : ""));
                    row();
                    add(infolabel).size(-1);
                }
            }.end();
        }
    }.end();
    // tutorial ui table
    new table() {

        {
            control.tutorial().buildUI(this);
            visible(() -> control.tutorial().active());
        }
    }.end();
    // paused table
    new table() {

        {
            visible(() -> state.is(State.paused) && !Net.active());
            atop();
            new table("pane") {

                {
                    new label("[orange]< " + Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
                }
            }.end();
        }
    }.end();
    // respawn background table
    new table("white") {

        {
            respawntable = get();
            respawntable.setColor(Color.CLEAR);
            update(t -> {
                if (state.is(State.menu)) {
                    respawntable.setColor(Color.CLEAR);
                }
            });
        }
    }.end();
    // respawn table
    new table() {

        {
            new table("pane") {

                {
                    new label(() -> "[orange]" + Bundles.get("text.respawn") + " " + (int) (control.getRespawnTime() / 60)).scale(0.75f).pad(10);
                    visible(() -> control.getRespawnTime() > 0 && !state.is(State.menu));
                }
            }.end();
        }
    }.end();
    new table() {

        {
            abottom();
            visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
            new label("$text.saveload");
        }
    }.end();
    blockfrag.build();
}
Also used : io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table) Core(io.anuke.ucore.core.Core) Bundles(io.anuke.ucore.util.Bundles) Settings(io.anuke.ucore.core.Settings) io.anuke.ucore.scene.builders.imagebutton(io.anuke.ucore.scene.builders.imagebutton) Gdx(com.badlogic.gdx.Gdx) Net(io.anuke.mindustry.net.Net) Color(com.badlogic.gdx.graphics.Color) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) Label(io.anuke.ucore.scene.ui.Label) ImageButton(io.anuke.ucore.scene.ui.ImageButton) Table(io.anuke.ucore.scene.ui.layout.Table) Actions(io.anuke.ucore.scene.actions.Actions) Interpolation(com.badlogic.gdx.math.Interpolation) Vars(io.anuke.mindustry.Vars) State(io.anuke.mindustry.core.GameState.State) Touchable(io.anuke.ucore.scene.event.Touchable) Interpolation(com.badlogic.gdx.math.Interpolation) Label(io.anuke.ucore.scene.ui.Label) io.anuke.ucore.scene.builders.label(io.anuke.ucore.scene.builders.label) io.anuke.ucore.scene.builders.imagebutton(io.anuke.ucore.scene.builders.imagebutton) io.anuke.ucore.scene.builders.table(io.anuke.ucore.scene.builders.table)

Aggregations

Gdx (com.badlogic.gdx.Gdx)1 Color (com.badlogic.gdx.graphics.Color)1 Interpolation (com.badlogic.gdx.math.Interpolation)1 Vars (io.anuke.mindustry.Vars)1 State (io.anuke.mindustry.core.GameState.State)1 Net (io.anuke.mindustry.net.Net)1 Core (io.anuke.ucore.core.Core)1 Settings (io.anuke.ucore.core.Settings)1 Actions (io.anuke.ucore.scene.actions.Actions)1 io.anuke.ucore.scene.builders.imagebutton (io.anuke.ucore.scene.builders.imagebutton)1 io.anuke.ucore.scene.builders.label (io.anuke.ucore.scene.builders.label)1 io.anuke.ucore.scene.builders.table (io.anuke.ucore.scene.builders.table)1 Touchable (io.anuke.ucore.scene.event.Touchable)1 ImageButton (io.anuke.ucore.scene.ui.ImageButton)1 Label (io.anuke.ucore.scene.ui.Label)1 Table (io.anuke.ucore.scene.ui.layout.Table)1 Bundles (io.anuke.ucore.util.Bundles)1