mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Text field dialog cleanup
This commit is contained in:
parent
7f6026bd52
commit
fd89911dd4
@ -1369,8 +1369,8 @@ public class Blocks implements ContentList{
|
||||
Items.pyratite, Bullets.pyraFlame
|
||||
);
|
||||
recoilAmount = 0f;
|
||||
reloadTime = 5f;
|
||||
coolantMultiplier = 2f;
|
||||
reloadTime = 6f;
|
||||
coolantMultiplier = 1.5f;
|
||||
range = 60f;
|
||||
shootCone = 50f;
|
||||
targetAir = false;
|
||||
|
@ -452,7 +452,7 @@ public class Bullets implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
basicFlame = new BulletType(3f, 30f){
|
||||
basicFlame = new BulletType(3f, 15f){
|
||||
{
|
||||
ammoMultiplier = 3f;
|
||||
hitSize = 7f;
|
||||
@ -472,31 +472,21 @@ public class Bullets implements ContentList{
|
||||
public float range(){
|
||||
return 50f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
}
|
||||
};
|
||||
|
||||
pyraFlame = new BulletType(3.3f, 45f){
|
||||
{
|
||||
ammoMultiplier = 4f;
|
||||
hitSize = 7f;
|
||||
lifetime = 42f;
|
||||
pierce = true;
|
||||
drag = 0.05f;
|
||||
statusDuration = 60f * 6;
|
||||
shootEffect = Fx.shootPyraFlame;
|
||||
hitEffect = Fx.hitFlameSmall;
|
||||
despawnEffect = Fx.none;
|
||||
status = StatusEffects.burning;
|
||||
hittable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Bullet b){
|
||||
}
|
||||
};
|
||||
pyraFlame = new BulletType(3.3f, 22f){{
|
||||
ammoMultiplier = 4f;
|
||||
hitSize = 7f;
|
||||
lifetime = 42f;
|
||||
pierce = true;
|
||||
drag = 0.05f;
|
||||
statusDuration = 60f * 6;
|
||||
shootEffect = Fx.shootPyraFlame;
|
||||
hitEffect = Fx.hitFlameSmall;
|
||||
despawnEffect = Fx.none;
|
||||
status = StatusEffects.burning;
|
||||
hittable = false;
|
||||
}};
|
||||
|
||||
waterShot = new LiquidBulletType(Liquids.water){{
|
||||
knockback = 0.7f;
|
||||
|
@ -84,7 +84,20 @@ public class UnitTypes implements ContentList{
|
||||
reload = 14f;
|
||||
recoil = 1f;
|
||||
ejectEffect = Fx.none;
|
||||
bullet = Bullets.basicFlame;
|
||||
bullet = new BulletType(3f, 30f){{
|
||||
ammoMultiplier = 3f;
|
||||
hitSize = 7f;
|
||||
lifetime = 42f;
|
||||
pierce = true;
|
||||
drag = 0.05f;
|
||||
statusDuration = 60f * 4;
|
||||
shootEffect = Fx.shootSmallFlame;
|
||||
hitEffect = Fx.hitFlameSmall;
|
||||
despawnEffect = Fx.none;
|
||||
status = StatusEffects.burning;
|
||||
keepVelocity = false;
|
||||
hittable = false;
|
||||
}};
|
||||
}});
|
||||
}};
|
||||
|
||||
@ -640,16 +653,25 @@ public class UnitTypes implements ContentList{
|
||||
risse = new UnitType("risse"){{
|
||||
speed = 1.3f;
|
||||
drag = 0.1f;
|
||||
hitsize = 8f;
|
||||
hitsize = 10f;
|
||||
health = 130;
|
||||
immunities = ObjectSet.with(StatusEffects.wet);
|
||||
weapons.add(new Weapon("mount-weapon"){{
|
||||
reload = 10f;
|
||||
x = 1.25f;
|
||||
x = 4f;
|
||||
rotate = true;
|
||||
ejectEffect = Fx.shellEjectSmall;
|
||||
bullet = Bullets.standardCopper;
|
||||
}});
|
||||
|
||||
weapons.add(new Weapon("missiles-mount"){{
|
||||
mirror = false;
|
||||
reload = 20f;
|
||||
x = 0f;
|
||||
rotate = true;
|
||||
ejectEffect = Fx.shellEjectSmall;
|
||||
bullet = Bullets.flakScrap;
|
||||
}});
|
||||
}};
|
||||
|
||||
minke = new UnitType("minke"){{
|
||||
|
@ -1,11 +1,9 @@
|
||||
package mindustry.core;
|
||||
|
||||
import arc.*;
|
||||
import arc.Input.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.serialization.*;
|
||||
@ -59,29 +57,6 @@ public interface Platform{
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Add a text input dialog that should show up after the field is tapped. */
|
||||
default void addDialog(TextField field){
|
||||
addDialog(field, 16);
|
||||
}
|
||||
|
||||
/** See addDialog(). */
|
||||
default void addDialog(TextField field, int maxLength){
|
||||
if(!mobile) return; //this is mobile only, desktop doesn't need dialogs
|
||||
|
||||
field.tapped(() -> {
|
||||
TextInput input = new TextInput();
|
||||
input.text = field.getText();
|
||||
input.maxLength = maxLength;
|
||||
input.accepted = text -> {
|
||||
field.clearText();
|
||||
field.appendText(text);
|
||||
field.change();
|
||||
Core.input.setOnscreenKeyboardVisible(false);
|
||||
};
|
||||
Core.input.getTextInput(input);
|
||||
});
|
||||
}
|
||||
|
||||
/** Update discord RPC. */
|
||||
default void updateRPC(){
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -23,8 +23,7 @@ public class BasicBulletType extends BulletType{
|
||||
super(speed, damage);
|
||||
this.sprite = bulletSprite;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BasicBulletType(float speed, float damage){
|
||||
this(speed, damage, "bullet");
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
@ -189,10 +188,10 @@ public class CustomRulesDialog extends BaseDialog{
|
||||
t.left();
|
||||
t.add(text).left().padRight(5)
|
||||
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
|
||||
Vars.platform.addDialog(t.field((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
|
||||
t.field((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
|
||||
.valid(Strings::canParsePositiveFloat).width(120f).left().addInputDialog();
|
||||
}).padTop(0);
|
||||
main.row();
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.gen.*;
|
||||
@ -15,8 +15,6 @@ import mindustry.ui.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static mindustry.Vars.platform;
|
||||
|
||||
public class FileChooser extends BaseDialog{
|
||||
private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
|
||||
private static Fi lastDirectory = homeDirectory;
|
||||
@ -56,7 +54,7 @@ public class FileChooser extends BaseDialog{
|
||||
|
||||
filefield = new TextField();
|
||||
filefield.setOnlyFontChars(false);
|
||||
if(!open) platform.addDialog(filefield);
|
||||
if(!open) filefield.addInputDialog();
|
||||
filefield.setDisabled(open);
|
||||
|
||||
ok = new TextButton(open ? "$load" : "$save");
|
||||
|
@ -49,9 +49,7 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
TextField field = add.cont.field(Core.settings.getString("ip"), text -> {
|
||||
Core.settings.put("ip", text);
|
||||
}).size(320f, 54f).get();
|
||||
|
||||
platform.addDialog(field, 100);
|
||||
}).size(320f, 54f).maxTextLength(100).addInputDialog().get();
|
||||
|
||||
add.cont.row();
|
||||
add.buttons.defaults().size(140f, 60f).pad(4f);
|
||||
@ -261,7 +259,7 @@ public class JoinDialog extends BaseDialog{
|
||||
t.field(Core.settings.getString("name"), text -> {
|
||||
player.name(text);
|
||||
Core.settings.put("name", text);
|
||||
}).grow().pad(8).get().setMaxLength(maxNameLength);
|
||||
}).grow().pad(8).addInputDialog(maxNameLength);
|
||||
}else{
|
||||
t.add(player.name).update(l -> l.setColor(player.color())).grow().pad(8);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user