Fixed chat scaling for mobile

This commit is contained in:
Anuken
2018-01-07 19:46:10 -05:00
parent 37f9e1394f
commit f1fa194aa0
6 changed files with 30 additions and 30 deletions

View File

@@ -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

View File

@@ -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(){}

View File

@@ -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<ChatMessage> 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;

View File

@@ -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();

View File

@@ -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;