Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2023-09-16 11:19:43 -04:00
3 changed files with 24 additions and 7 deletions

View File

@@ -270,8 +270,15 @@ public class UI implements ApplicationListener, Loadable{
}); });
} }
public void showTextInput(String titleText, String text, int textLength, String def, boolean numbers, Cons<String> confirmed, Runnable closed){
public void showTextInput(String titleText, String text, int textLength, String def, boolean numbers, Cons<String> 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<String> confirmed, Runnable closed){
if(mobile){ if(mobile){
var description = text;
var empty = allowEmpty;
Core.input.getTextInput(new TextInput(){{ Core.input.getTextInput(new TextInput(){{
this.title = (titleText.startsWith("@") ? Core.bundle.get(titleText.substring(1)) : titleText); this.title = (titleText.startsWith("@") ? Core.bundle.get(titleText.substring(1)) : titleText);
this.text = def; this.text = def;
@@ -279,7 +286,8 @@ public class UI implements ApplicationListener, Loadable{
this.maxLength = textLength; this.maxLength = textLength;
this.accepted = confirmed; this.accepted = confirmed;
this.canceled = closed; this.canceled = closed;
this.allowEmpty = false; this.allowEmpty = empty;
this.message = description;
}}); }});
}else{ }else{
new Dialog(titleText){{ new Dialog(titleText){{
@@ -296,11 +304,11 @@ public class UI implements ApplicationListener, Loadable{
buttons.button("@ok", () -> { buttons.button("@ok", () -> {
confirmed.get(field.getText()); confirmed.get(field.getText());
hide(); hide();
}).disabled(b -> field.getText().isEmpty()); }).disabled(b -> !allowEmpty && field.getText().isEmpty());
keyDown(KeyCode.enter, () -> { keyDown(KeyCode.enter, () -> {
String text = field.getText(); String text = field.getText();
if(!text.isEmpty()){ if(allowEmpty || !text.isEmpty()){
confirmed.get(text); confirmed.get(text);
hide(); hide();
} }

View File

@@ -31,6 +31,7 @@ public class Menus{
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void menu(int menuId, String title, String message, String[][] options){ public static void menu(int menuId, String title, String message, String[][] options){
if(title == null) title = ""; if(title == null) title = "";
if(message == null) message = "";
if(options == null) options = new String[0][0]; if(options == null) options = new String[0][0];
ui.showMenu(title, message, options, (option) -> Call.menuChoose(player, menuId, option)); ui.showMenu(title, message, options, (option) -> Call.menuChoose(player, menuId, option));
@@ -39,6 +40,7 @@ public class Menus{
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void followUpMenu(int menuId, String title, String message, String[][] options){ public static void followUpMenu(int menuId, String title, String message, String[][] options){
if(title == null) title = ""; if(title == null) title = "";
if(message == null) message = "";
if(options == null) options = new String[0][0]; if(options == null) options = new String[0][0];
ui.showFollowUpMenu(menuId, title, message, options, (option) -> Call.menuChoose(player, menuId, option)); ui.showFollowUpMenu(menuId, title, message, options, (option) -> Call.menuChoose(player, menuId, option));
@@ -61,9 +63,16 @@ public class Menus{
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void textInput(int textInputId, String title, String message, int textLength, String def, boolean numeric){ 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, text);
}, () -> { }, () -> {
Call.textInputResult(player, textInputId, null); Call.textInputResult(player, textInputId, null);

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=867271d6a4 archash=70f345cc75