Fixed chat scaling for mobile
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user