Bugfixes / Fixed #639
This commit is contained in:
@@ -3,6 +3,7 @@ package io.anuke.mindustry.core;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Graphics.*;
|
||||
import io.anuke.arc.Graphics.Cursor.*;
|
||||
import io.anuke.arc.Input.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.assets.loaders.resolvers.*;
|
||||
@@ -262,28 +263,37 @@ public class UI implements ApplicationListener, Loadable{
|
||||
});
|
||||
}
|
||||
|
||||
public void showTextInput(String titleText, String text, int textLength, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||
new Dialog(titleText){{
|
||||
cont.margin(30).add(text).padRight(6f);
|
||||
TextField field = cont.addField(def, t -> {
|
||||
}).size(170f, 50f).get();
|
||||
field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c));
|
||||
platform.addDialog(field);
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.addButton("$ok", () -> {
|
||||
confirmed.accept(field.getText());
|
||||
hide();
|
||||
}).disabled(b -> field.getText().isEmpty());
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
}}.show();
|
||||
public void showTextInput(String titleText, String dtext, int textLength, String def, boolean inumeric, Consumer<String> confirmed){
|
||||
if(mobile){
|
||||
Core.input.getTextInput(new TextInput(){{
|
||||
this.title = (titleText.startsWith("$") ? Core.bundle.get(titleText.substring(1)) : titleText);
|
||||
this.text = def;
|
||||
this.numeric = inumeric;
|
||||
this.maxLength = textLength;
|
||||
this.accepted = confirmed;
|
||||
}});
|
||||
}else{
|
||||
new Dialog(titleText){{
|
||||
cont.margin(30).add(dtext).padRight(6f);
|
||||
TextFieldFilter filter = inumeric ? TextFieldFilter.digitsOnly : (f, c) -> true;
|
||||
TextField field = cont.addField(def, t -> {}).size(170f, 50f).get();
|
||||
field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c));
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.addButton("$ok", () -> {
|
||||
confirmed.accept(field.getText());
|
||||
hide();
|
||||
}).disabled(b -> field.getText().isEmpty());
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
}}.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void showTextInput(String title, String text, String def, Consumer<String> confirmed){
|
||||
showTextInput(title, text, 12, def, (field, c) -> true, confirmed);
|
||||
showTextInput(title, text, 24, def, 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 showTextInput(String titleText, String text, int textLength, String def, Consumer<String> confirmed){
|
||||
showTextInput(titleText, text, textLength, def, false, confirmed);
|
||||
}
|
||||
|
||||
public void showInfoFade(String info){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Files.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
@@ -26,7 +27,7 @@ public class Version{
|
||||
if(!enabled) return;
|
||||
|
||||
try{
|
||||
FileHandle file = new FileHandle("version.properties", FileType.Internal);
|
||||
FileHandle file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new FileHandle("version.properties", FileType.Internal);
|
||||
|
||||
ObjectMap<String, String> map = new ObjectMap<>();
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
||||
@@ -176,6 +176,11 @@ public class Styles{
|
||||
up = none;
|
||||
over = flatOver;
|
||||
}},
|
||||
clearPartial2i = new ImageButtonStyle(){{
|
||||
down = whiteui;
|
||||
up = pane;
|
||||
over = flatDown;
|
||||
}},
|
||||
clearTogglei = new ImageButtonStyle(){{
|
||||
down = flatDown;
|
||||
checked = flatDown;
|
||||
@@ -266,6 +271,7 @@ public class Styles{
|
||||
messageFont = Fonts.def;
|
||||
messageFontColor = Color.gray;
|
||||
}};
|
||||
|
||||
public static CheckBoxStyle
|
||||
defaultCheck = new CheckBoxStyle(){{
|
||||
checkboxOn = checkOn;
|
||||
@@ -278,6 +284,7 @@ public class Styles{
|
||||
fontColor = Color.white;
|
||||
disabledFontColor = Color.gray;
|
||||
}};
|
||||
|
||||
public static DialogStyle
|
||||
defaultDialog = new DialogStyle(){{
|
||||
stageBackground = black9;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.fromGray(0.2f)).grow()));
|
||||
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
|
||||
|
||||
Button button = new Button(Tex.buttonSquare);
|
||||
Button button = new Button(Styles.squaret);
|
||||
buildButton(node.zone, button);
|
||||
stack.add(button);
|
||||
addChild(stack);
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
@@ -99,11 +100,24 @@ public class LoadoutDialog extends FloatingDialog{
|
||||
stack.amount = Math.max(stack.amount - step, 0);
|
||||
updater.run();
|
||||
}).size(bsize);
|
||||
|
||||
items.addButton("+", Styles.clearPartialt, () -> {
|
||||
stack.amount = Math.min(stack.amount + step, capacity);
|
||||
updater.run();
|
||||
}).size(bsize);
|
||||
|
||||
items.addImageButton(Icon.pencilSmaller, Styles.clearPartial2i, () -> ui.showTextInput("$configure", stack.item.localizedName, 10, stack.amount + "", true, str -> {
|
||||
if(Strings.canParsePostiveInt(str)){
|
||||
int amount = Strings.parseInt(str);
|
||||
if(amount >= 0 && amount <= capacity){
|
||||
stack.amount = amount;
|
||||
updater.run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ui.showInfo(Core.bundle.format("configure.invalid", capacity));
|
||||
})).size(bsize);
|
||||
|
||||
items.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(4).padLeft(4);
|
||||
items.label(() -> stack.amount + "").left();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user