Search in sources :

Example 1 with Dialog

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

the class UI method showTextInput.

public void showTextInput(String title, String text, String def, TextFieldFilter filter, Consumer<String> confirmed) {
    new Dialog(title, "dialog") {

        {
            content().margin(30).add(text).padRight(6f);
            TextField field = content().addField(def, t -> {
            }).size(170f, 50f).get();
            field.setTextFieldFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
            Platform.instance.addDialog(field);
            buttons().defaults().size(120, 54).pad(4);
            buttons().addButton("$text.ok", () -> {
                confirmed.accept(field.getText());
                hide();
            }).disabled(b -> field.getText().isEmpty());
            buttons().addButton("$text.cancel", this::hide);
        }
    }.show();
}
Also used : TextField(io.anuke.ucore.scene.ui.TextField) Settings(io.anuke.ucore.core.Settings) TooltipManager(io.anuke.ucore.scene.ui.TooltipManager) Skin(io.anuke.ucore.scene.Skin) Gdx(com.badlogic.gdx.Gdx) TextFieldFilter(io.anuke.ucore.scene.ui.TextField.TextFieldFilter) Graphics(io.anuke.ucore.core.Graphics) Locale(java.util.Locale) Colors(com.badlogic.gdx.graphics.Colors) Dialog(io.anuke.ucore.scene.ui.Dialog) Vars.control(io.anuke.mindustry.Vars.control) Interpolation(com.badlogic.gdx.math.Interpolation) Unit(io.anuke.ucore.scene.ui.layout.Unit) Mathf(io.anuke.ucore.util.Mathf) Vars(io.anuke.mindustry.Vars) io.anuke.mindustry.ui.fragments(io.anuke.mindustry.ui.fragments) Core(io.anuke.ucore.core.Core) Platform(io.anuke.mindustry.io.Platform) Align(com.badlogic.gdx.utils.Align) Color(com.badlogic.gdx.graphics.Color) Draw(io.anuke.ucore.graphics.Draw) Consumer(io.anuke.ucore.function.Consumer) Listenable(io.anuke.ucore.function.Listenable) MapEditorDialog(io.anuke.mindustry.mapeditor.MapEditorDialog) SceneModule(io.anuke.ucore.modules.SceneModule) Keys(com.badlogic.gdx.Input.Keys) Actions(io.anuke.ucore.scene.actions.Actions) io.anuke.ucore.scene.builders.build(io.anuke.ucore.scene.builders.build) Timers(io.anuke.ucore.core.Timers) io.anuke.mindustry.ui.dialogs(io.anuke.mindustry.ui.dialogs) Dialog(io.anuke.ucore.scene.ui.Dialog) MapEditorDialog(io.anuke.mindustry.mapeditor.MapEditorDialog) TextField(io.anuke.ucore.scene.ui.TextField)

Aggregations

Gdx (com.badlogic.gdx.Gdx)1 Keys (com.badlogic.gdx.Input.Keys)1 Color (com.badlogic.gdx.graphics.Color)1 Colors (com.badlogic.gdx.graphics.Colors)1 Interpolation (com.badlogic.gdx.math.Interpolation)1 Align (com.badlogic.gdx.utils.Align)1 Vars (io.anuke.mindustry.Vars)1 Vars.control (io.anuke.mindustry.Vars.control)1 Platform (io.anuke.mindustry.io.Platform)1 MapEditorDialog (io.anuke.mindustry.mapeditor.MapEditorDialog)1 io.anuke.mindustry.ui.dialogs (io.anuke.mindustry.ui.dialogs)1 io.anuke.mindustry.ui.fragments (io.anuke.mindustry.ui.fragments)1 Core (io.anuke.ucore.core.Core)1 Graphics (io.anuke.ucore.core.Graphics)1 Settings (io.anuke.ucore.core.Settings)1 Timers (io.anuke.ucore.core.Timers)1 Consumer (io.anuke.ucore.function.Consumer)1 Listenable (io.anuke.ucore.function.Listenable)1 Draw (io.anuke.ucore.graphics.Draw)1 SceneModule (io.anuke.ucore.modules.SceneModule)1