Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Prote1n on December 02, 2009, 03:00:46 PM

Title: SizeToFit problem
Post by: Prote1n on December 02, 2009, 03:00:46 PM
This function does not take into account the line break

The text "aaa|bbb|ccc|ddd" has the size of "aaabbbccddd" instead of the maximum of the splitted string... but the HeightToFit is well calculted

Title: Re: SizeToFit problem
Post by: Mnemonic on December 02, 2009, 04:22:19 PM
How exactly are you using the method? If you're setting the text from script, you should use the "~n" sequence for newlines, not the | character.

SomeControl.Text = "aaa~nbbb~nccc~nddd";
SomeControl.SizeToFit();

...should work, I think...?
Title: Re: SizeToFit problem
Post by: Prote1n on December 02, 2009, 06:33:53 PM
I try both (| and ~n) with the same result. I actually solved the problem while splitting the string and calculating the maximum length

       
Title: Re: SizeToFit problem
Post by: Prote1n on May 11, 2010, 03:31:40 PM
Here is my script:

var win=Game.LoadWindow("interface\system\info.window");
var info = win.GetControl("message");

info.Text = "abcdefghijklnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 236

info.Text = "abcdefghijkl|nmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 248

info.Text = "abcdefghijkl~nnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 248

Title: Re: SizeToFit problem
Post by: metamorphium on May 13, 2010, 09:25:58 PM
what's info.Height?
Title: Re: SizeToFit problem
Post by: Prote1n on May 18, 2010, 10:31:11 AM
var win=Game.LoadWindow("interface\system\info.window");
var info = win.GetControl("message");

info.Text = "abcdefghijklnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 19

info.Text = "abcdefghijkl|nmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 38

info.Text = "abcdefghijkl~nnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 38