Reverting the changes made in r9389
http://code.google.com/p/jmonkeyengine/source/detail?spec=svn9389&r=9389 That caused the StringBlock to be recreated every time the text was set to "". Doing this blew away 90% of BitmapText's internal state causing subsequent text to be the wrong size, misaligned, etc. The original reason for the change needs to be revisited. Big comment left in code with the original change commented out. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9765 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e0df200dfd
commit
a7717d9ea2
@ -112,7 +112,29 @@ public class BitmapText extends Node {
|
|||||||
*/
|
*/
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
text = text == null ? "" : text;
|
text = text == null ? "" : text;
|
||||||
if (!block.getText().equals(text)) {
|
|
||||||
|
if (text == block.getText() || block.getText().equals(text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The problem with the below block is that StringBlock carries
|
||||||
|
pretty much all of the text-related state of the BitmapText such
|
||||||
|
as size, text box, alignment, etc.
|
||||||
|
|
||||||
|
I'm not sure why this change was needed and the commit message was
|
||||||
|
not entirely helpful because it purports to fix a problem that I've
|
||||||
|
never encountered.
|
||||||
|
|
||||||
|
If block.setText("") doesn't do the right thing then that's where
|
||||||
|
the fix should go because StringBlock carries too much information to
|
||||||
|
be blown away every time. -pspeed
|
||||||
|
|
||||||
|
Change was made:
|
||||||
|
http://code.google.com/p/jmonkeyengine/source/detail?spec=svn9389&r=9389
|
||||||
|
Diff:
|
||||||
|
http://code.google.com/p/jmonkeyengine/source/diff?path=/trunk/engine/src/core/com/jme3/font/BitmapText.java&format=side&r=9389&old_path=/trunk/engine/src/core/com/jme3/font/BitmapText.java&old=8843
|
||||||
|
|
||||||
// If the text is empty, reset
|
// If the text is empty, reset
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
detachAllChildren();
|
detachAllChildren();
|
||||||
@ -125,18 +147,16 @@ public class BitmapText extends Node {
|
|||||||
block = new StringBlock();
|
block = new StringBlock();
|
||||||
letters = new Letters(font, block, letters.getQuad().isRightToLeft());
|
letters = new Letters(font, block, letters.getQuad().isRightToLeft());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Update the text content
|
// Update the text content
|
||||||
block.setText(text);
|
block.setText(text);
|
||||||
letters.setText(text);
|
letters.setText(text);
|
||||||
|
|
||||||
// Flat for refresh
|
// Flag for refresh
|
||||||
needRefresh = true;
|
needRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return returns text
|
* @return returns text
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user