I’m having an issue. I create a bitmapText item and and inside my “Control” item I need to update this field.
This fields is define to be “CENTER”.
Problem is when the text I update is longer then the original it never changes the Box dimensions “WITDH” it starts wrapping all the text beyond the original length.
I’ve also, tried, after setting the new text to get the new HudText Width and redefine the Box the width stays the the as the original. “needRefresh” is set and it goes through this process.
The textbox.width and letters.getTotalWidth() remains unchanged.
/**
* @return width of line
*/
public float getLineWidth() {
if (needRefresh) {
assemble();
}
Rectangle textBox = block.getTextBox();
if (textBox != null) {
return Math.max(letters.getTotalWidth(), textBox.width);
}
// Please note that BitMaptext.getLineWidth() might differ from Font.getLineWidth() --> scale it with Font.getPreferredSize()/BitMaptext.getSize()
return letters.getTotalWidth();
}
That is the expected behavior. If you want it auto-expand then you should not specify a box (set it to null).
To do so, after updating the text you should first set the box to null, then you can use getLineWidth to find the new text width and then redefine the box to the new width.
If you do not want to mess around with BitmapText, you should better use Lemur GUI that takes care of it for you.
Yes, I know about Lemur, but Lemur doesn’t support SpriteSheets (I guess the entire JME doesn’t support sprite sheets). This broke my Gui system, and forced me to handle my own.
public void setAlignment(BitmapFont.Align align) {
if (block.getTextBox() == null && align != Align.Left) {
throw new RuntimeException("Bound is not set");
}
block.setAlignment(align);
letters.invalidate();
needRefresh = true;
}
I was just saying when using images inside Lemur, it doesn’t handle Sprite sheets, each texture needs to be a single image. That breaks my game, I use sprite sheets for icons.
Yes, but you implied that you cannot use Label instead of BitmapText because of something unrelated. So I was just making sure.
And it wouldn’t take much to fork IconComponent to set the texture coordinates on the quad and support sprite sheets. Probably easier than rolling a whole new GUI.
It wasn’t easier than doing a new Gui. I did a gui years ago. This project is about moving my long term project over from “MY ENGINE” which I did the guis myself. So when converting it, I saw the limitation of Lemur, so I just converted that over also. It didn’t take much to convert it to JME, longest part was separating controls into their own “Control” class to works how JME wants it.
Sorry, it is not ready yet to put on GitHub. I need to clean it up before releasing it along with a bunch of other tools to the public and start maintaining them.
I hope you put it out. I could use such a great tool. Special one that works, so many JME tools on Github don’t work anymore. outdated and not kept up.