GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-05-20 17:30:58

flexaplex
Member
Registered: 2008-12-11
Posts: 72

Draw_text_ext doesn't wrap long words

References:  [1]

draw_text_ext is often used to wrap strings however when using a word longer than the stated string width it will not split it up as it only splits the string up at spaces or - characters. You can use this replacement function to get the proper functionality:

Expand//draw_text_ext2(x,y,str,sep,w)
var str;
str = argument2;
if (string_width_ext(str,argument3,argument4) > argument4)
{
  var i;
  for (i = 1; i <= string_length(str); i += 1)
  {
    if (string_width_ext(string_copy(str,1,i),argument3,argument4) > argument4)
    {
      str = string_insert(chr(13),str,i);
    }
  }
}
draw_text_ext(argument0,argument1,str,argument3,argument4);

Last edited by flexaplex (2009-06-16 08:30:55)

Offline

Board footer

Powered by FluxBB