[Solved] How to center (Y-align) of NVL choice menu within a frame

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
lis_cider
Newbie
Posts: 1
Joined: Tue Sep 05, 2023 4:21 am
Contact:

[Solved] How to center (Y-align) of NVL choice menu within a frame

#1 Post by lis_cider »

I have this custom NVL window for my game, and I wish to place all menu choices in the bottom everytime.
image_2023-10-28_09-10-28.png
image_2023-10-28_09-10-28.png (7.15 KiB) Viewed 5835 times
What I want to ask is how to dynamically center the choices inside this choice frame. Currently, the position is fixed no matter how many lines of choices. If there is only one or two text buttons, there will be much larger empty space left in the bottom and that looks ugly.

Changed screen.rpy:

Code: Select all

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:

            vbox spacing gui.nvl_spacing:
                use nvl_dialogue(dialogue). #### Moved 'has vbox' to here so it won't affect choice frame below.

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True.
        if len(items) > 0:

            frame:
                background "gui/custom_ui/choice_frame.png"
                xpos 420 ypos 640. #### Fixed position for the choice frame.

                vbox:
                    spacing gui.nvl_spacing
                    yalign 0.5 #### Center-align for the choices, but it won't work.
                
                    for i in items:
                        textbutton i.caption:                                    
                            action i.action
                            style "nvl_button"
                            
    add SideImage() xalign 0.0 yalign 1.0
Maybe there is a solution or maybe there is a better approach. Appreciate any help. Thanks in advance.

------------------------

Applying xsize and ysize to the choice frame solved this.

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]