How can I create a GUI button to Scroll up and down text?

Started by Meistari F, Fri 20/05/2011 19:58:24

Previous topic - Next topic

Meistari F

I am trying to make a GUI scroller buttons and textbox so I can scroll  a long text just like in that image demo from Baldurs Gate.

I need help with this . I just need the scrolling button code so it can work like this. Thanks  :)




Khris

Just use a listbox, it has built in scroll arrows.


Meistari F

Now I have another question.  I'm trying to put the long dialog in that listbox but the text goes in one straigth line. And that is not what I like. How can I make it fit perfectly in the listbox?


My listbox I am using is 115 height and  100 width and I want the whole text fit in that box.  

It worked much better when I tryed it with GUI labels because the text was exactly like I wanted it to be (with word-wrapping) but I had to split it because the dialog text was too long and I didn't had a scoll button to scroll the whole text up and down.  That's why I really need to know how to make a scroller button so I can scroll a long text up and down.

All I did then was this:

labeltext.Text. String.Format=("blablablabla");
Wait(200)
labeltext.Text. String.Format=("blablablabla");
Wait(200)
etc.

I had to do this in that way because if the text is too long.  the whole text wont appear 100%.

So that's way the idea about scrolling text came to me. The problem is I don't know how to create it.



This is the GUI I am working on.  And as you can see. The long text is the dialog text from that guy in the avatar and a new text is  supposed to appear everytime you choose something from the list. Sometimes he gives a longer conversation but like I said I had to split it to make the dialog text shorter so the whole text could fit perfectly in the label box. But I don't like that.

So If I could add a longer text I really need to know how to make a scroll up and down button.

Khris

Unfortunately, that's were things get complicated.
Labels support word-wrapping, ListBoxes don't.

I guess the fastest way is to split up the string manually into several lines and add those to the listbox.
monkey has written a module for String stuff: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20950.0

You can use this function:
String[] String.SplitByWidth(int width, FontType font, optional String delimiters, optional bool caseSensitive)

Code: ags
  String line[] = message.SplitByWidth(lbDialog.Width - 20, lbDialog.Font);
  int i;
  while (!String.IsNullOrEmpty(line[i]) {
    lbDialog.AddItem(line[i]);
  }


Completely untested, probably won't work as-is.

Meistari F

Does that work for AGS 2.72 version? But I'm still using that version.  ::)

I think I have to use the label box again. Since there is no scrolling button available for label box.

What if I use credit module for this so the whole label text scroll down automatic ? What code should I use then for it so it can work?


SMF spam blocked by CleanTalk