Skip to content

Commit

Permalink
- Fixed LabelRenderNode not updating text if updated from its own def…
Browse files Browse the repository at this point in the history
…er call
  • Loading branch information
tomcashman committed Jul 14, 2018
1 parent e4cfd1c commit 2cad060
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[1.7.4-SNAPSHOT]
[1.7.4]
- Fixed LabelRenderNode not updating text if updated from its own defer call

[1.7.3]
- Added additional assert in DisperedIntervalEntitySystemTest
Expand Down
17 changes: 15 additions & 2 deletions ui/src/main/java/org/mini2Dx/ui/render/LabelRenderNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ public class LabelRenderNode extends RenderNode<Label, LabelStyleRule> {
protected final NullTextAnimation nullAnimation = new NullTextAnimation();
protected BitmapFontCache bitmapFontCache = DEFAULT_FONT.newFontCache();

protected boolean bitmapCacheReset = false;

public LabelRenderNode(ParentRenderNode<?, ?> parent, Label element) {
super(parent, element);
}

@Override
public void update(UiContainerRenderTree uiContainer, float delta) {
super.update(uiContainer, delta);

if(bitmapCacheReset) {
bitmapFontCache.clear();
nullAnimation.reset();

if(element.getTextAnimation() != null) {
element.getTextAnimation().reset();;
}
bitmapCacheReset = false;
}

if (element.getTextAnimation() == null) {
nullAnimation.update(bitmapFontCache, element.getText(), preferredContentWidth,
element.getHorizontalAlignment().getAlignValue(), delta);
Expand Down Expand Up @@ -122,6 +135,7 @@ protected LabelStyleRule determineStyleRule(LayoutState layoutState) {
element.getTextAnimation().reset();
}
}
bitmapCacheReset = true;

LabelStyleRule result = layoutState.getTheme().getStyleRule(element, layoutState.getScreenSize());
if (result.getBitmapFont() == null) {
Expand All @@ -145,8 +159,7 @@ public void updateBitmapFontCache() {
if (style == null) {
return;
}
bitmapFontCache.clear();
nullAnimation.reset();
bitmapCacheReset = true;

GLYPH_LAYOUT.setText(bitmapFontCache.getFont(), element.getText(), Color.WHITE, preferredContentWidth,
element.getHorizontalAlignment().getAlignValue(), true);
Expand Down

0 comments on commit 2cad060

Please sign in to comment.