• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

non-list scrolling

G

gibberingmouther

Guest
so i need a branching dialogue system for my game and i decided to make a new one instead of the pre-made one i was using.

i think i can figure out most of it, but i don't know how to do a scrollbar for text on a white rectangle. i know how to do scrollbars for lists but not for generic blocks of text. any ideas or hints? i want to keep this simple btw.
 
R

rui.rosario

Guest
With lists you'd probably use the sum of the heights of all the list elements to get the total height. With an arbitrary text you can just use string_height_ext.

With that information you could probably perform all required calculations for the scrollbar.
 
G

gibberingmouther

Guest
With lists you'd probably use the sum of the heights of all the list elements to get the total height. With an arbitrary text you can just use string_height_ext.

With that information you could probably perform all required calculations for the scrollbar.
that's helpful but i still don't know what the "required calculations" would look like. if i just knew where in the manual to look, that's all i'm asking.
 
R

rui.rosario

Guest
that's helpful but i still don't know what the "required calculations" would look like. if i just knew where in the manual to look, that's all i'm asking.
I can't give you exact calculations, but it would be something along the lines of:

A variable (e.g. scrollInterval) would hold the number of pixels you can move the scrollbar. So it would be the maximum displacement of the scrollbar, 0 being 0%, scrollInterval being 100%.
Another variable (e.g. boxHeight) would represent the number of vertical pixels you show in the textbox, so it would be the total amount of viewable vertical space.
You could then get the height of the drawn string (through a function like string_height_ext). If the height was smaller than the vertical space (boxHeight) you wouldn't need a scrollbar since all the text would fit the window. Else, you could retrieve the excess height (subtract the boxHeight by the string height) and that would give you your scrollInterval. You would just need to then process the logic of dragging the scrollbar and displacing the text drawing.
 
G

gibberingmouther

Guest
i'm not sure what function to use for displacing the text drawing, as Rosario put it. i thought about string_copy - you could put the text in the increments of box height into different strings this way, but i'm not sure how you would know the number of spaces per line except through trial and error which would work i guess.

do i have the right idea here or am i missing something?
 
R

rui.rosario

Guest
You could just draw the text to a surface and then draw part of the surface, "displacing" which part of the surface to draw according to the scrollnar
 
G

gibberingmouther

Guest
so does this mean i use views to do the scrolling? i thought i read something about that awhile ago but i don't remember. ugh this is giving me a headache. i can't use either of my list scroll bar codes for my text boxes.
 
Top