Questions about galleries and In-game menus.

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
AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

Questions about galleries and In-game menus.

#1 Post by AlexCLD »

Hi again! :) I have been using NVL mode on my game and I'm trying to do something like this:

Image

Is it possible to place two columns on NVL mode?

And the second question is about the galleries.

http://www.renpy.org/doc/html/rooms.html Here, I can learn to create an image gallery, but... What happens if I want to create an information gallery?

Thanks in advance :)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Questions about galleries and In-game menus.

#2 Post by qirien »

Yes, this is possible! First, make sure your menus are using NVL mode. In one of your init blocks, put

Code: Select all

$ menu = nvl_menu
Then you need to open up screens.rpy. Find the NVL screen (it says "screen nvl"). This is where you tell Ren'Py how to display your NVL text. Down lower in this function, where it says:

Code: Select all

# Display a menu
if items:
we are going to change the code. Right now it puts all the choices in a vbox, which means they will just be listed one on top of the other. We want to change it into a grid. Here is some code that will do that (this can replace the entire NVL screen in your screens.rpy, or just take the parts you need):

Code: Select all


#############################################################
# Nvl
#
# Screen used for nvl-mode dialogue and menus.
# http://www.renpy.org/doc/html/screen_special.html#nvl

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        has vbox:
            style "nvl_vbox"

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            window:
                id window_id

                has hbox:
                    spacing 10

                if who is not None:
                    text who id who_id

                text what id what_id

        # Display a menu, if given.
        if items:

            vbox:
                id "menu"

                # How many choices are in this menu?
                $ num_choices = len(items)
                # How many rows do we need?
                $ choice_rows = ((num_choices-1) // 2) + 1
                
                # Make a grid with two columns and however many rows we need
                grid 2 choice_rows: 
                    for caption, action, chosen in items:

                        if action:

                            # Display the choice
                            button:
                                style "nvl_menu_choice_button"
                                action action

                                text caption style "nvl_menu_choice"

                        else:
                            text caption style "nvl_dialogue"
                            
                    # If there is an odd number of choices, add an extra bit of text to fill up the grid
                    if ((2 * choice_rows) != num_choices):
                        text ""

    add SideImage() xalign 0.0 yalign 1.0

    use quick_menu
I hope this helps you figure out how to do that!
Finished games:
Image
Image
Image

AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

Re: Questions about galleries and In-game menus.

#3 Post by AlexCLD »

Thanks for your help! But when I tried to implement the code on the game, something like this happen:

Image

:oops:

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Questions about galleries and In-game menus.

#4 Post by qirien »

Yes, you'll probably need to change the style of the nvl buttons.

You can do this with some code like this:

Code: Select all

# Make each button the size of its text, and center it
style nvl_menu_choice_button:
    xfill False
    xalign 0.5
# Put the choices in the middle of the screen horizontally
style nvl_vbox:
    xalign 0.5
If this doesn't look the way you want, take a look at Style Properties for additional things you can customize.
Finished games:
Image
Image
Image

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]