diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 92d8552618..2ef979c0ed 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -270,8 +270,15 @@ public class UI implements ApplicationListener, Loadable{ }); } - public void showTextInput(String titleText, String text, int textLength, String def, boolean numbers, Cons confirmed, Runnable closed){ + + public void showTextInput(String titleText, String text, int textLength, String def, boolean numbers, Cons confirmed, Runnable closed) { + showTextInput(titleText, text, textLength, def, numbers, false, confirmed, closed); + } + + public void showTextInput(String titleText, String text, int textLength, String def, boolean numbers, boolean allowEmpty, Cons confirmed, Runnable closed){ if(mobile){ + var description = text; + var empty = allowEmpty; Core.input.getTextInput(new TextInput(){{ this.title = (titleText.startsWith("@") ? Core.bundle.get(titleText.substring(1)) : titleText); this.text = def; @@ -279,7 +286,8 @@ public class UI implements ApplicationListener, Loadable{ this.maxLength = textLength; this.accepted = confirmed; this.canceled = closed; - this.allowEmpty = false; + this.allowEmpty = empty; + this.message = description; }}); }else{ new Dialog(titleText){{ @@ -296,11 +304,11 @@ public class UI implements ApplicationListener, Loadable{ buttons.button("@ok", () -> { confirmed.get(field.getText()); hide(); - }).disabled(b -> field.getText().isEmpty()); + }).disabled(b -> !allowEmpty && field.getText().isEmpty()); keyDown(KeyCode.enter, () -> { String text = field.getText(); - if(!text.isEmpty()){ + if(allowEmpty || !text.isEmpty()){ confirmed.get(text); hide(); } diff --git a/core/src/mindustry/ui/Menus.java b/core/src/mindustry/ui/Menus.java index b4dfdd247d..6533f455e1 100644 --- a/core/src/mindustry/ui/Menus.java +++ b/core/src/mindustry/ui/Menus.java @@ -31,6 +31,7 @@ public class Menus{ @Remote(variants = Variant.both) public static void menu(int menuId, String title, String message, String[][] options){ if(title == null) title = ""; + if(message == null) message = ""; if(options == null) options = new String[0][0]; ui.showMenu(title, message, options, (option) -> Call.menuChoose(player, menuId, option)); @@ -39,6 +40,7 @@ public class Menus{ @Remote(variants = Variant.both) public static void followUpMenu(int menuId, String title, String message, String[][] options){ if(title == null) title = ""; + if(message == null) message = ""; if(options == null) options = new String[0][0]; ui.showFollowUpMenu(menuId, title, message, options, (option) -> Call.menuChoose(player, menuId, option)); @@ -61,9 +63,16 @@ public class Menus{ @Remote(variants = Variant.both) public static void textInput(int textInputId, String title, String message, int textLength, String def, boolean numeric){ - if(title == null) title = ""; + textInput(textInputId, title, message, textLength, def, numeric, false); + } - ui.showTextInput(title, message, textLength, def, numeric, (text) -> { + @Remote(variants = Variant.both) + public static void textInput(int textInputId, String title, String message, int textLength, String def, boolean numeric, boolean allowEmpty){ + if(title == null) title = ""; + if(message == null) message = ""; + if(def == null) def = ""; + + ui.showTextInput(title, message, textLength, def, numeric, allowEmpty, (text) -> { Call.textInputResult(player, textInputId, text); }, () -> { Call.textInputResult(player, textInputId, null); diff --git a/gradle.properties b/gradle.properties index f5117eea6d..2f5c533ade 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=867271d6a4 +archash=70f345cc75