scroll text now centers duplicate text rotations

This commit is contained in:
Harrison Deng 2018-01-16 11:20:59 -06:00
parent 46541d9747
commit f5d3a01e76

View File

@ -26,6 +26,7 @@ public class ScrollText extends Widget {
private float text1Width;
private float text2Width;
private boolean dupFirstText;
private boolean scrollOnHover;
private boolean scroll;
@ -104,6 +105,17 @@ public class ScrollText extends Widget {
public void act(float delta) {
setSize(getWidth(), textHeight + 4);
clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
if (dupFirstText) {
if (text1Width > clipBounds.getWidth()) {
if (scrollOnHover) {
if (scroll || text1Offset < 0 || text1Offset > 2) {
scroll(delta);
}
} else {
scroll(delta);
}
}
} else {
if (text1Width + text2Width > clipBounds.getWidth()) {
if (scrollOnHover) {
if (scroll || text1Offset < 0 || text1Offset > 2) {
@ -113,6 +125,7 @@ public class ScrollText extends Widget {
scroll(delta);
}
}
}
super.act(delta);
}
@ -179,6 +192,7 @@ public class ScrollText extends Widget {
gLayout = new GlyphLayout(font, text2);
text2Width = gLayout.width;
} else {
dupFirstText = true;
this.text2 = text1;
this.text2Width = text1Width;
}