Added option to set TextField length for showTextInput() (#534)
* Add files via upload * Added option to set TextField length for showTextInput() the character length default was 12, and unchangeable afaik, so I added an option to change the character length, as well as suggesting a new character length for save file's name. (I actually have no idea if this PR can be delivered correctly, wish me luck.) * Rename UI.java to core\src\io\anuke\mindustry\ui/UI.java * Rename SaveDialog.java to core\src\io\anuke\mindustry\ui\dialogs\SaveDialog.java * Delete UI.java * Added option to set TextField length for showTextInput() the character length default was 12, and unchangeable afaik, so I added an option to change the character length, as well as suggesting a new character length for save file's name. (I actually have no idea if this PR can be delivered correctly, wish me luck.) * Delete UI.java * Delete SaveDialog.java * Add files via upload * Add files via upload * Delete UI.java * Delete SaveDialog.java * Delete core\src\io\anuke\mindustry\ui\dialogs\SaveDialog.java * Delete Mindustry-64.zip
This commit is contained in:
@@ -207,12 +207,12 @@ public class UI implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTextInput(String titleText, String text, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
public void showTextInput(String titleText, String text, int textLength, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||||
new Dialog(titleText, "dialog"){{
|
new Dialog(titleText, "dialog"){{
|
||||||
cont.margin(30).add(text).padRight(6f);
|
cont.margin(30).add(text).padRight(6f);
|
||||||
TextField field = cont.addField(def, t -> {
|
TextField field = cont.addField(def, t -> {
|
||||||
}).size(170f, 50f).get();
|
}).size(170f, 50f).get();
|
||||||
field.setFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
|
field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c));
|
||||||
Platform.instance.addDialog(field);
|
Platform.instance.addDialog(field);
|
||||||
buttons.defaults().size(120, 54).pad(4);
|
buttons.defaults().size(120, 54).pad(4);
|
||||||
buttons.addButton("$ok", () -> {
|
buttons.addButton("$ok", () -> {
|
||||||
@@ -224,7 +224,11 @@ public class UI implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showTextInput(String title, String text, String def, Consumer<String> confirmed){
|
public void showTextInput(String title, String text, String def, Consumer<String> confirmed){
|
||||||
showTextInput(title, text, def, (field, c) -> true, confirmed);
|
showTextInput(title, text, 12, def, (field, c) -> true, confirmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showTextInput(String title, String text, int textLength, String def, Consumer<String> confirmed){
|
||||||
|
showTextInput(title, text, textLength < 0 ? 12 : textLength, def, (field, c) -> true, confirmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInfoFade(String info){
|
public void showInfoFade(String info){
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class SaveDialog extends LoadDialog{
|
|||||||
|
|
||||||
public void addSetup(){
|
public void addSetup(){
|
||||||
slots.row();
|
slots.row();
|
||||||
slots.addImageTextButton("$save.new", "icon-add", iconsize, () ->
|
slots.addImageTextButton("$save.new", "icon-add", 14 * 3, () ->
|
||||||
ui.showTextInput("$save", "$save.newslot", "", text -> {
|
ui.showTextInput("$save", "$save.newslot", 30, "", text -> {
|
||||||
ui.loadAnd("$saving", () -> {
|
ui.loadAnd("$saving", () -> {
|
||||||
control.saves.addSave(text);
|
control.saves.addSave(text);
|
||||||
Core.app.post(() -> Core.app.post(this::setup));
|
Core.app.post(() -> Core.app.post(this::setup));
|
||||||
|
|||||||
Reference in New Issue
Block a user