From f5d3a01e76520895acb00cf6519bba3282b24304 Mon Sep 17 00:00:00 2001 From: Recrown Date: Tue, 16 Jan 2018 11:20:59 -0600 Subject: [PATCH] scroll text now centers duplicate text rotations --- .../graphics/ui/components/ScrollText.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ScrollText.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ScrollText.java index 3069713..541f528 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ScrollText.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/ScrollText.java @@ -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,13 +105,25 @@ public class ScrollText extends Widget { public void act(float delta) { setSize(getWidth(), textHeight + 4); clipBounds.setSize(getWidth()-2, getHeight()*1.5f); - if (text1Width + text2Width > clipBounds.getWidth()) { - if (scrollOnHover) { - if (scroll || text1Offset < 0 || text1Offset > 2) { + 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) { + scroll(delta); + } + } else { scroll(delta); } - } else { - scroll(delta); } } super.act(delta); @@ -173,12 +186,13 @@ public class ScrollText extends Widget { gLayout = new GlyphLayout(font, text1); text1Width = gLayout.width; textHeight = gLayout.height; - + if (text2 != null) { this.text2 = text2; gLayout = new GlyphLayout(font, text2); text2Width = gLayout.width; } else { + dupFirstText = true; this.text2 = text1; this.text2Width = text1Width; }