wrap hbox up instead of down?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

wrap hbox up instead of down?

#1 Post by Kia »

I've tried to fill an hbox from bottom up but it seems like the box_wrap always wraps down to the next row. I know I can remedy it using the `box_wrap_spacing` or transforms, but I'm wondering if there's something obvious like `box_wrap "up` that I've missed before suggesting it to be added.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: wrap hbox up instead of down?

#2 Post by Alex »

Could you... hm... draw how it looks right now and how it should look like?

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: wrap hbox up instead of down?

#3 Post by Kia »

Screenshot_11.png
Screenshot_11.png (5.61 KiB) Viewed 607 times
well, it should start at the bottom and when it reaches the wrapping size, the next row should be above the first row.
here's the code to a hacky way to do it, but as you can guess, it wouldn't work in cases that the items in the box have varied sizes:

Code: Select all

screen hboxtest:
    frame:
        xysize 300,300 
        hbox:
            align .5,1.0 box_wrap True box_wrap_spacing -100
            for i in range(12):
                frame:
                    xysize 50,50
perhaps adding something like `wrap_reverse True` to boxes can be a better solution

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: wrap hbox up instead of down?

#4 Post by Alex »

Kind of workaround...

Code: Select all

transform flip_tr:
    yzoom -1
    
screen test_scr():
    frame:
        xysize 300,300 
        hbox:
            #box_reverse True
            align .5,1.0 box_wrap True
            at flip_tr
            for i in range(12):
                frame:
                    at flip_tr
                    xysize 50,50
                    text "[i]" align 0.5, 0.5

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: wrap hbox up instead of down?

#5 Post by Kia »

well, I did think of that as well, but it would be better to have it addressed directly instead of using tricks to accomplish it.
since I usually use transforms to animate the individual items, having them flipped too adds another layer of complexity to the mix and makes the code heavier.
my intention was to make sure such a thing doesn't already exist before suggesting it.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: wrap hbox up instead of down?

#6 Post by Alex »

Kia wrote: Fri Mar 26, 2021 5:12 pm well, I did think of that as well, but it would be better to have it addressed directly instead of using tricks to accomplish it.
...
Well, you could try to open renpy_folder/renpy/display/layout.py and search for lines

Code: Select all

                if box_wrap and remwidth - sw - padding < 0 and line:
                    maxx, maxy = layout_line(line, target_width - x, 0)

                    y += line_height + box_wrap_spacing
                    x = 0
                    line_height = 0
                    remwidth = width
                    line = [ ]
then change them to

Code: Select all

                if box_wrap and remwidth - sw - padding < 0 and line:
                    maxx, maxy = layout_line(line, (target_width - x), 0)

                    if box_wrap == 'up':
                        y -= line_height + box_wrap_spacing
                    else:
                        y += line_height + box_wrap_spacing
                    x = 0
                    line_height = 0
                    remwidth = width
                    line = [ ]
So, you could use

Code: Select all

box_wrap 'up'

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: wrap hbox up instead of down?

#7 Post by Kia »

since you've already done the work, I think you should suggest it to be added to renpy's code on github for the next version. ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot