Text field dialog cleanup
This commit is contained in:
@@ -37,7 +37,7 @@ public class MapInfoDialog extends BaseDialog{
|
||||
|
||||
TextField name = t.field(tags.get("name", ""), text -> {
|
||||
tags.put("name", text);
|
||||
}).size(400, 55f).get();
|
||||
}).size(400, 55f).addInputDialog(50).get();
|
||||
name.setMessageText("$unknown");
|
||||
|
||||
t.row();
|
||||
@@ -45,7 +45,7 @@ public class MapInfoDialog extends BaseDialog{
|
||||
|
||||
TextArea description = t.area(tags.get("description", ""), Styles.areaField, text -> {
|
||||
tags.put("description", text);
|
||||
}).size(400f, 140f).get();
|
||||
}).size(400f, 140f).addInputDialog(1000).get();
|
||||
|
||||
t.row();
|
||||
t.add("$editor.author").padRight(8).left();
|
||||
@@ -53,7 +53,7 @@ public class MapInfoDialog extends BaseDialog{
|
||||
TextField author = t.field(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
|
||||
tags.put("author", text);
|
||||
Core.settings.put("mapAuthor", text);
|
||||
}).size(400, 55f).get();
|
||||
}).size(400, 55f).addInputDialog(50).get();
|
||||
author.setMessageText("$unknown");
|
||||
|
||||
t.row();
|
||||
@@ -82,9 +82,6 @@ public class MapInfoDialog extends BaseDialog{
|
||||
description.change();
|
||||
author.change();
|
||||
|
||||
Vars.platform.addDialog(name, 50);
|
||||
Vars.platform.addDialog(author, 50);
|
||||
Vars.platform.addDialog(description, 1000);
|
||||
t.margin(16f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import arc.math.*;
|
||||
import arc.scene.ui.TextField.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
public class MapResizeDialog extends BaseDialog{
|
||||
@@ -25,10 +24,10 @@ public class MapResizeDialog extends BaseDialog{
|
||||
table.add(w ? "$width" : "$height").padRight(8f);
|
||||
table.defaults().height(60f).padTop(8);
|
||||
|
||||
Vars.platform.addDialog(table.field((w ? width : height) + "", TextFieldFilter.digitsOnly, value -> {
|
||||
table.field((w ? width : height) + "", TextFieldFilter.digitsOnly, value -> {
|
||||
int val = Integer.parseInt(value);
|
||||
if(w) width = val; else height = val;
|
||||
}).valid(value -> Strings.canParsePostiveInt(value) && Integer.parseInt(value) <= maxSize && Integer.parseInt(value) >= minSize).get());
|
||||
}).valid(value -> Strings.canParsePostiveInt(value) && Integer.parseInt(value) <= maxSize && Integer.parseInt(value) >= minSize).addInputDialog(3);
|
||||
|
||||
table.row();
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.*;
|
||||
import mindustry.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class MapSaveDialog extends BaseDialog{
|
||||
private TextField field;
|
||||
private Cons<String> listener;
|
||||
|
||||
public MapSaveDialog(Cons<String> cons){
|
||||
super("$editor.savemap");
|
||||
field = new TextField();
|
||||
listener = cons;
|
||||
|
||||
Vars.platform.addDialog(field);
|
||||
|
||||
shown(() -> {
|
||||
cont.clear();
|
||||
cont.label(() -> {
|
||||
Map map = Vars.maps.byName(field.getText());
|
||||
if(map != null){
|
||||
if(map.custom){
|
||||
return "$editor.overwrite";
|
||||
}else{
|
||||
return "$editor.failoverwrite";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}).colspan(2);
|
||||
cont.row();
|
||||
cont.add("$editor.mapname").padRight(14f);
|
||||
cont.add(field).size(220f, 48f);
|
||||
});
|
||||
|
||||
buttons.defaults().size(200f, 50f).pad(2f);
|
||||
buttons.button("$cancel", this::hide);
|
||||
|
||||
TextButton button = new TextButton("$save");
|
||||
button.clicked(() -> {
|
||||
if(!invalid()){
|
||||
cons.get(field.getText());
|
||||
hide();
|
||||
}
|
||||
});
|
||||
button.setDisabled(this::invalid);
|
||||
buttons.add(button);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
if(!invalid()){
|
||||
listener.get(field.getText());
|
||||
}else{
|
||||
ui.showErrorMessage("$editor.failoverwrite");
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldText(String text){
|
||||
field.setText(text);
|
||||
}
|
||||
|
||||
private boolean invalid(){
|
||||
if(field.getText().isEmpty()){
|
||||
return true;
|
||||
}
|
||||
Map map = Vars.maps.byName(field.getText());
|
||||
return map != null && !map.custom;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user