ValueLineCount

Talk about ManiaLink development in this forum

Moderator: NADEO

Post Reply
zocka
Posts: 205
Joined: 15 Jun 2010, 17:56

ValueLineCount

Post by zocka »

I can't get a hang on the CMlLabel::ValueLineCount method:

My train of thought for my code:

Code: Select all

MyLabel.AutoNewLine = False;
MyLabel.Size[0] = MathLib::Min(MyLabel.ComputeWidth(MyLabel.Value), 80.);
// Thinking that Autonewline only works on a given size, so I calculate my needed size first
MyLabel.AutoNewLine = True;
// Turn it back on, so it can wrap lines and calculate the LineCount
declare Integer LineCount = MyLabel.ValueLineCount;
// It doesn't seem to care about newlines
declare Text[] Helper = TextLib::Split("\n", MyLabel.Value);
LineCount += Helper.count - 1;
MyLabel.Size[1] = LineCount * 4.;
After all that I display my label and get varying results, depending on the last time, I executed the code, sometimes 50+-3 characters mess it up completely, I don't understand it at all :roll:

Oh and another problem I encountered: ComputeWidth seems to calculate the last line's width, not the longest line's.

Image In the image you can't see "multi\nline\n!" :?
My complete extract of code for interested readers:

Code: Select all

_Toast_Label.Value = TextLib::Trim(_Toast_Queue[0]);
_Toast_Label.AutoNewLine = False;
_Toast_Label.Size[0] = TextLib::Min(80., _Toast_Label.ComputeWidth(_Toast_Label.Value));
_Toast_Label.AutoNewLine = True;
declare Integer LineCount = _Toast_Label.ValueLineCount;
declare Text[] Helper = TextLib::Split("\n", _Toast_Label.Value);
LineCount += Helper.count - 1;
_Toast_Label.Size[1] = LineCount * 4.;
_Toast_Label.Show();
_Toast_Background.Size = _Toast_Label.Size + <6., 4.>;
log(LineCount); // The call for the image above logs 1
_Toast_Background.Show();
manialink minigame shatter
my manialink: zockaml
my maniaflash: maniaflash?zocka
User avatar
noyranea
Nadeo
Nadeo
Posts: 187
Joined: 29 Apr 2014, 14:50
Location: Paris, France

Re: ValueLineCount

Post by noyranea »

Hi zocka,

I checked, and you're totally right : Label.ComputeWidth(Text) returns only the length of the last line (more precisely the length it should have without autonewline=True, so you can remove your two Autonewline=False; / Autonewline=True; lines). This will be fixed soon.

Label.ValueLineCount equals the number of lines effectively displayed (\n plus autonewlines). There shouldn't be any problems with this.

Moreover, I recently added a Label.ComputeHeight(Text) function, which should be added soon. I think this does exactly what you're trying to do ;)

Have a nice day,

-- noyranea
zocka
Posts: 205
Joined: 15 Jun 2010, 17:56

Re: ValueLineCount

Post by zocka »

Great! I'm looking forward to your changes :thx:
manialink minigame shatter
my manialink: zockaml
my maniaflash: maniaflash?zocka
Post Reply

Return to “ManiaLink”

Who is online

Users browsing this forum: No registered users and 0 guests