Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Construed on Sat 18/02/2012 02:11:41

Title: Wordwrap in a label[SOLVED]
Post by: Construed on Sat 18/02/2012 02:11:41
Is it possible to use word wrap in a label?
Also
Is there any workaround for adding scrollbar to a label?
Title: Re: Wordwrap in a label
Post by: RickJ on Sat 18/02/2012 06:33:37
You are probably wanting to use a listbox.  You will have to do word wrap and justification yourself.  There are functions that return the pixel length of a string using a specified font. 
Title: Re: Wordwrap in a label
Post by: Construed on Sat 18/02/2012 08:18:15
Ah, okay, I've got a label that's kinda heavily tied in to different variables etc, but I'm assuming that's a no go with that so i suppose i need to focus on switching over to ListBox. Thanks for the reply bud :D
Title: Re: Wordwrap in a label
Post by: Khris on Sat 18/02/2012 08:20:28
It's not only possible, labels word wrap by default. But no, you can't easily scroll a label.
Title: Re: Wordwrap in a label
Post by: Construed on Sat 18/02/2012 08:36:15
Ah, ok cause i have a label that is used as an input box but the text stops at the end,
I had to extend it eastward to fit more letters but it may be because of some predefined word formatting code previously implemented.
Title: Re: Wordwrap in a label
Post by: Khris on Sat 18/02/2012 08:58:27
Input boxes don't wrap, labels wrap. InputBox != Label.
Title: Re: Wordwrap in a label
Post by: Construed on Sat 18/02/2012 09:07:56
Yea, this is a very shiesty use of a label:

#define LINE_WIDTH 99 // Max number of characters on a line
#define LINE_COUNT 5 // Max number of lines in the textbox


void PushLine(String line)
{
 if (line.Length > LINE_WIDTH)
 {
   PushLine(line.Truncate(LINE_WIDTH));
   PushLine(line.Substring(LINE_WIDTH, line.Length - LINE_WIDTH));
   return;
 }
 
 String text;

 text = String.Format("%s[%s", lblOutput.Text, line); ////////This is the label


 int i = text.Length;
 int count = 0;
 int pos = -1;
 while (i)
 {
   if (text.Chars[i] == '[')
     count++;
   
   if (count == LINE_COUNT)
   {
     pos = i;
     i = 0;
   }
   else
     i--;
 }
 
 lblOutput.Text = text.Substring(pos + 1, text.Length - pos - 1);
}
Title: Re: Wordwrap in a label
Post by: Construed on Sat 18/02/2012 17:39:55
Well, I'm guessing there is no possibility of enhancing this label beyond what it already is.
So I'm going to say [SOLVED]

Answer: use ListBox