v0.7.5b: removed the baseline method from RenderedText, fixed one layout error with WndTitledMessage

This commit is contained in:
Evan Debenham 2019-10-11 20:30:55 -04:00
parent b439092443
commit 72d1db49ed
5 changed files with 8 additions and 12 deletions

View File

@ -73,10 +73,6 @@ public class RenderedText extends Image {
measure(); measure();
} }
public float baseLine(){
return size * scale.y;
}
private synchronized void measure(){ private synchronized void measure(){
if (Thread.currentThread().getName().equals("SHPD Actor Thread")){ if (Thread.currentThread().getName().equals("SHPD Actor Thread")){
@ -106,7 +102,7 @@ public class RenderedText extends Image {
protected void updateMatrix() { protected void updateMatrix() {
super.updateMatrix(); super.updateMatrix();
//the y value is set at the top of the character, not at the top of accents. //the y value is set at the top of the character, not at the top of accents.
Matrix.translate( matrix, 0, Math.round((baseLine()*Game.platform.getFontHeightOffset(font))/scale.y) ); Matrix.translate( matrix, 0, Math.round(size*Game.platform.getFontHeightOffset(font)));
} }
private static TextRenderBatch textRenderer = new TextRenderBatch(); private static TextRenderBatch textRenderer = new TextRenderBatch();

View File

@ -353,7 +353,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
public float getFontHeightOffset( BitmapFont font ){ public float getFontHeightOffset( BitmapFont font ){
//more weirdness with android 6 OTF fonts //more weirdness with android 6 OTF fonts
if (android6OTFPresent && !basicFonts.containsValue(font)){ if (android6OTFPresent && !basicFonts.containsValue(font)){
return -0.2f; return -0.25f;
} else { } else {
return 0.0f; return 0.0f;
} }

View File

@ -141,7 +141,7 @@ public class StyledButton extends Button {
reqHeight = Math.max(icon.height() + 4, reqHeight); reqHeight = Math.max(icon.height() + 4, reqHeight);
} }
if (text != null && !text.text().equals("")){ if (text != null && !text.text().equals("")){
reqHeight = Math.max(text.baseLine() + 4, reqHeight); reqHeight = Math.max(text.height() + 4, reqHeight);
} }
return reqHeight; return reqHeight;
} }

View File

@ -61,7 +61,7 @@ public class WndStartGame extends Window {
RenderedTextBlock title = PixelScene.renderTextBlock(Messages.get(this, "title"), 12 ); RenderedTextBlock title = PixelScene.renderTextBlock(Messages.get(this, "title"), 12 );
title.hardlight(Window.TITLE_COLOR); title.hardlight(Window.TITLE_COLOR);
title.setPos( (WIDTH - title.width())/2f, 2); title.setPos( (WIDTH - title.width())/2f, 3);
PixelScene.align(title); PixelScene.align(title);
add(title); add(title);
@ -70,7 +70,7 @@ public class WndStartGame extends Window {
float curX = heroBtnSpacing; float curX = heroBtnSpacing;
for (HeroClass cl : HeroClass.values()){ for (HeroClass cl : HeroClass.values()){
HeroBtn button = new HeroBtn(cl); HeroBtn button = new HeroBtn(cl);
button.setRect(curX, title.baseLine() + 4, HeroBtn.WIDTH, HeroBtn.HEIGHT); button.setRect(curX, title.height() + 7, HeroBtn.WIDTH, HeroBtn.HEIGHT);
curX += HeroBtn.WIDTH + heroBtnSpacing; curX += HeroBtn.WIDTH + heroBtnSpacing;
add(button); add(button);
} }
@ -294,12 +294,12 @@ public class WndStartGame extends Window {
super.layout(); super.layout();
avatar.x = x; avatar.x = x;
avatar.y = y + (height - avatar.height() - name.baseLine() - 2)/2f; avatar.y = y + (height - avatar.height() - name.height() - 4)/2f;
PixelScene.align(avatar); PixelScene.align(avatar);
name.setPos( name.setPos(
x + (avatar.width() - name.width())/2f, x + (avatar.width() - name.width())/2f,
avatar.y + avatar.height() + 2 avatar.y + avatar.height() + 3
); );
PixelScene.align(name); PixelScene.align(name);

View File

@ -54,6 +54,6 @@ public class WndTitledMessage extends Window {
text.setPos( titlebar.left(), titlebar.bottom() + GAP ); text.setPos( titlebar.left(), titlebar.bottom() + GAP );
add( text ); add( text );
resize( width, (int)text.bottom() ); resize( width, (int)text.bottom() + 2 );
} }
} }