diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index 06b3ec011a..b439264212 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -56,8 +56,8 @@ public class AndroidLauncher extends AndroidApplication{ } @Override - public void addDialog(TextField field){ - TextFieldDialogListener.add(field); + public void addDialog(TextField field, int length){ + TextFieldDialogListener.add(field, 0, length); } @Override diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 0098017300..f0a5808a34 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -70,13 +70,6 @@ public class UI extends SceneModule{ fadeOut(0.1f, Interpolation.fade) ) )); - - Mathf.each(font -> { - font.setUseIntegerPositions(false); - font.getData().setScale(Vars.fontscale); - font.getData().down += Unit.dp.scl(4f); - font.getData().lineHeight -= Unit.dp.scl(2f); - }, skin.font(), skin.getFont("default-font-chat")); TooltipManager.getInstance().animations = false; @@ -109,6 +102,12 @@ public class UI extends SceneModule{ @Override protected void loadSkin(){ skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas); + Mathf.each(font -> { + font.setUseIntegerPositions(false); + font.getData().setScale(Vars.fontscale); + font.getData().down += Unit.dp.scl(4f); + font.getData().lineHeight -= Unit.dp.scl(2f); + }, skin.font(), skin.getFont("default-font-chat")); } @Override diff --git a/core/src/io/anuke/mindustry/io/PlatformFunction.java b/core/src/io/anuke/mindustry/io/PlatformFunction.java index 4062ac1517..e7e08555f1 100644 --- a/core/src/io/anuke/mindustry/io/PlatformFunction.java +++ b/core/src/io/anuke/mindustry/io/PlatformFunction.java @@ -8,7 +8,10 @@ public abstract class PlatformFunction{ public String format(Date date){return "invalid";} public String format(int number){return "invalid";} public void openLink(String link){} - public void addDialog(TextField field){} + public void addDialog(TextField field){ + addDialog(field, 16); + } + public void addDialog(TextField field, int maxLength){} public void updateRPC(){} public void onGameExit(){} public void openDonations(){} diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index 9c570dd1d0..1912818f56 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -20,6 +20,7 @@ import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.Label.LabelStyle; import io.anuke.ucore.scene.ui.TextField; import io.anuke.ucore.scene.ui.layout.Table; +import io.anuke.ucore.scene.ui.layout.Unit; import static io.anuke.ucore.core.Core.scene; import static io.anuke.ucore.core.Core.skin; @@ -30,16 +31,15 @@ public class ChatFragment extends Table implements Fragment{ private final static int maxLength = 150; private Array messages = new Array<>(); private float fadetime; - private float lastfadetime; private boolean chatOpen = false; private TextField chatfield; private Label fieldlabel = new Label(">"); private BitmapFont font; private GlyphLayout layout = new GlyphLayout(); - private float offsetx = 4, offsety = 4, fontoffsetx = 2, chatspace = 50; - private float textWidth = 600; + private float offsetx = Unit.dp.scl(4), offsety = Unit.dp.scl(4), fontoffsetx = Unit.dp.scl(2), chatspace = Unit.dp.scl(50); + private float textWidth = Unit.dp.scl(600); private Color shadowColor = new Color(0, 0, 0, 0.4f); - private float textspacing = 10; + private float textspacing = Unit.dp.scl(10); public ChatFragment(){ super(); @@ -74,8 +74,8 @@ public class ChatFragment extends Table implements Fragment{ chatfield.getStyle().background = skin.getDrawable("chatfield"); chatfield.getStyle().fontColor = Color.WHITE; chatfield.getStyle().font = skin.getFont("default-font-chat"); - - Mindustry.platforms.addDialog(chatfield); + chatfield.setStyle(chatfield.getStyle()); + Mindustry.platforms.addDialog(chatfield, maxLength); bottom().left().marginBottom(offsety).marginLeft(offsetx*2).add(fieldlabel).padBottom(4f); @@ -90,8 +90,8 @@ public class ChatFragment extends Table implements Fragment{ if(chatOpen) batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), Gdx.graphics.getWidth()-offsetx*2, chatfield.getHeight()-1); - //font.getData().down = -21.5f; - // font.getData().lineHeight = 22f; + //font.getData().down = Unit.dp.scl(-21.5f); + //font.getData().lineHeight = 22f; //chatfield.getStyle().font.getData().setScale(Vars.fontscale); super.draw(batch, alpha); @@ -118,7 +118,7 @@ public class ChatFragment extends Table implements Fragment{ batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i)); } - batch.draw(skin.getRegion("white"), offsetx, theight-layout.height+1-4, textWidth, layout.height+textspacing); + batch.draw(skin.getRegion("white"), offsetx, theight-layout.height+1-4, textWidth + Unit.dp.scl(4f), layout.height+textspacing); batch.setColor(shadowColor); font.getCache().draw(batch); @@ -145,7 +145,6 @@ public class ChatFragment extends Table implements Fragment{ if(!chatOpen && (scene.getKeyboardFocus() == null || !scene.getKeyboardFocus().getParent().isVisible())){ scene.setKeyboardFocus(chatfield); chatOpen = !chatOpen; - lastfadetime = fadetime; fadetime = messagesShown + 1; }else if(chatOpen){ scene.setKeyboardFocus(null); @@ -174,7 +173,7 @@ public class ChatFragment extends Table implements Fragment{ public ChatMessage(String message, String sender){ this.message = message; this.sender = sender; - if(sender == null){ //no sender, this is a server message + if(sender == null){ //no sender, this is a server message? formattedMessage = message; }else{ formattedMessage = "[ROYAL]["+sender+"]: [YELLOW]"+message; diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 3ad0d051e5..08a9d7693c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -135,8 +135,7 @@ public class HudFragment implements Fragment{ //profiling table if(debug){ new table(){{ - abottom(); - aleft(); + atop(); new label("[green]density: " + Gdx.graphics.getDensity()).left(); row(); new label(() -> "[blue]requests: " + renderer.getBlocks().getRequests()).left(); diff --git a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java index 2ef10a2430..36b4328908 100644 --- a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java @@ -9,19 +9,19 @@ public class DefenseBlocks{ static final int wallHealthMultiplier = 4; public static final Block - + stonewall = new Wall("stonewall"){{ health = 50*wallHealthMultiplier; }}, - + ironwall = new Wall("ironwall"){{ health = 80*wallHealthMultiplier; }}, - + steelwall = new Wall("steelwall"){{ health = 110*wallHealthMultiplier; }}, - + titaniumwall = new Wall("titaniumwall"){{ health = 150*wallHealthMultiplier; }}, @@ -46,7 +46,7 @@ public class DefenseBlocks{ titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall"){{ health = 150*wallHealthMultiplier; }}, - + repairturret = new RepairTurret("repairturret"){ { range = 30; @@ -55,7 +55,7 @@ public class DefenseBlocks{ powerUsed = 0.08f; } }, - + megarepairturret = new RepairTurret("megarepairturret"){ { range = 44; @@ -64,7 +64,7 @@ public class DefenseBlocks{ powerUsed = 0.13f; } }, - + shieldgenerator = new ShieldBlock("shieldgenerator"){ { health = 100*wallHealthMultiplier;