BitmapFont -> Font / Bugfixes

This commit is contained in:
Anuken
2020-07-30 16:59:53 -04:00
parent f39609d1ef
commit 06b08c80c2
13 changed files with 52 additions and 43 deletions

View File

@@ -14,6 +14,7 @@ public class LoadingFragment extends Fragment{
private Table table;
private TextButton button;
private Bar bar;
private Label nameLabel;
@Override
public void build(Group parent){
@@ -23,11 +24,13 @@ public class LoadingFragment extends Fragment{
t.add().height(133f).row();
t.add(new WarningBar()).growX().height(24f);
t.row();
t.add("$loading").name("namelabel").pad(10f).style(Styles.techLabel);
nameLabel = t.add("$loading").pad(10f).style(Styles.techLabel).get();
t.row();
t.add(new WarningBar()).growX().height(24f);
t.row();
text("$loading");
bar = t.add(new Bar()).pad(3).size(500f, 40f).visible(false).get();
t.row();
button = t.button("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
@@ -48,8 +51,8 @@ public class LoadingFragment extends Fragment{
}
public void setText(String text){
table.<Label>find("namelabel").setText(text);
table.<Label>find("namelabel").setColor(Pal.accent);
text(text);
nameLabel.setColor(Pal.accent);
}
public void show(){
@@ -57,11 +60,11 @@ public class LoadingFragment extends Fragment{
}
public void show(String text){
table.<Label>find("namelabel").setColor(Color.white);
nameLabel.setColor(Color.white);
bar.visible = false;
table.clearActions();
table.touchable = Touchable.enabled;
table.<Label>find("namelabel").setText(text);
text(text);
table.visible = true;
table.color.a = 1f;
table.toFront();
@@ -73,4 +76,19 @@ public class LoadingFragment extends Fragment{
table.touchable = Touchable.disabled;
table.actions(Actions.fadeOut(0.5f), Actions.visible(false));
}
private void text(String text){
nameLabel.setText(text);
CharSequence realText = nameLabel.getText();
//fallback to the default font if characters are missing
for(int i = 0; i < realText.length(); i++){
if(Fonts.tech.getData().getGlyph(realText.charAt(i)) == null){
nameLabel.setStyle(Styles.defaultLabel);
return;
}
}
nameLabel.setStyle(Styles.techLabel);
}
}