Improved stat label font layout

Improved stat label font layout
Stat label style updates properly
Added more accurate metrics to font8
Fixed position and size of armorclass stat label
This commit is contained in:
Collin Smith 2019-04-24 15:49:09 -07:00
parent 7c144a329c
commit 6e3ba33a9d
3 changed files with 22 additions and 7 deletions

View File

@ -41,6 +41,11 @@ public class Fonts {
ReallyTheLastSucker = load(assets, "ReallyTheLastSucker", BlendMode.ID);
BitmapFont.BitmapFontData data;
data = font8.getData();
data.lineHeight = data.xHeight = data.capHeight = 12;
data.ascent = 16;
data.down = -12;
data = font16.getData();
data.lineHeight = data.xHeight = data.capHeight = 14;
data.ascent = 17;

View File

@ -126,8 +126,8 @@ public class CharacterPanel extends WidgetGroup implements Disposable {
//Label armorclass = createStatLabel(Stat.armorclass);
Label armorclass = new StatLabel(Riiablo.charData.getStats(), Stat.armorclass);
armorclass.setPosition(275, getHeight() - 210);
armorclass.setSize(36, 16);
armorclass.setPosition(272, getHeight() - 210);
armorclass.setSize(40, 16);
addActor(armorclass);
Label vitLabel = new Label(4066, Riiablo.fonts.ReallyTheLastSucker);

View File

@ -1,6 +1,7 @@
package com.riiablo.widget;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.utils.Align;
import com.riiablo.Riiablo;
import com.riiablo.item.Attributes;
@ -38,13 +39,22 @@ public class StatLabel extends Label {
@Override
public void setText(CharSequence newText) {
BitmapFont font = getFont(newText.length());
if (font != getStyle().font) {
getStyle().font = font;
setStyle(getStyle()); // hacky, but only way to correct update style with changes
}
super.setText(newText);
if (newText.length() > 6) {
getStyle().font = Riiablo.fonts.ReallyTheLastSucker;
} else if (newText.length() > 3) {
getStyle().font = Riiablo.fonts.font8;
}
private static BitmapFont getFont(int len) {
if (len > 6) {
return Riiablo.fonts.ReallyTheLastSucker;
} else if (len > 3) {
return Riiablo.fonts.font8;
} else {
getStyle().font = Riiablo.fonts.font16;
return Riiablo.fonts.font16;
}
}