Scrollbar In-Game Menu Coding?

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
Silence in Space
Regular
Posts: 31
Joined: Tue Nov 22, 2016 4:48 pm
Projects: Silence in Space
Contact:

Scrollbar In-Game Menu Coding?

#1 Post by Silence in Space »

Code: Select all

label terminal_entries:
    
    menu:
        "Entry_001"
        "Entry_002"
        "Entry_003"
        "Entry_004"
        "Entry_005"
        "Entry_006"
        "Entry_007"
        "Entry_008"
        "Entry_009"
        "Entry_010"
        "Entry_011"
        "Entry_012"
        "Entry_013"
How could would you make an scroll-bar feature for an in-game menu such as a long one like this?

User avatar
Silence in Space
Regular
Posts: 31
Joined: Tue Nov 22, 2016 4:48 pm
Projects: Silence in Space
Contact:

Re: Scrollbar In-Game Menu Coding?

#2 Post by Silence in Space »

I'm not having any success with replicating any of the viewport and scrollbar examples.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Scrollbar In-Game Menu Coding?

#3 Post by nyaatrap »

Add viewport on the choice screen in screens.rpy.

Code: Select all

screen choice(items):
    style_prefix "choice"

    viewport:
        scrollbars "vertical"
        mousewheel True
        draggable True

        side_yfill True

        vbox:
            for i in items:
                textbutton i.caption action i.action

User avatar
Silence in Space
Regular
Posts: 31
Joined: Tue Nov 22, 2016 4:48 pm
Projects: Silence in Space
Contact:

Re: Scrollbar In-Game Menu Coding?

#4 Post by Silence in Space »

nyaatrap wrote:Add viewport on the choice screen in screens.rpy.

Code: Select all

screen choice(items):
    style_prefix "choice"

    viewport:
        scrollbars "vertical"
        mousewheel True
        draggable True

        side_yfill True

        vbox:
            for i in items:
                textbutton i.caption action i.action
The scrollbar appears now in game; however, this is what happens.
Attachments
Progress.png

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Scrollbar In-Game Menu Coding?

#5 Post by papiersam »

Might wanna change the child size, something like:

Code: Select all

screen choice(items):
    style_prefix "choice"
    side "c b r":
         area (100, 100, 600, 400)
             viewport:
                 scrollbars "vertical"
                 mousewheel True
                 draggable True

                 side_yfill True

                 vbox:
                     for i in items:
                         textbutton i.caption action i.action
(Note: not tested).

User avatar
Silence in Space
Regular
Posts: 31
Joined: Tue Nov 22, 2016 4:48 pm
Projects: Silence in Space
Contact:

Re: Scrollbar In-Game Menu Coding?

#6 Post by Silence in Space »

The entire code for script.ryp

Code: Select all

## The script of the game goes in this file.

## Declare characters used by this game. The color argument colorizes the name
## of the character.

image bg blackness = "Nothingness.png"

init:
    $ c = Character(_(None),
        kind=nvl,
        what_font="whitrabt.ttf",
        what_slow_cps=27)


## The game starts here.

label start:
    
    "You access the terminal."
    
    c "Booting up System Archieve"
    
    nvl clear
    
    c "Which entry do you wish to access?"
    
    nvl clear
    
    label terminal_monitor:
        
        menu:
        
            "Access Archieve":
                jump terminal_entries
                
            "Leave Terminal":
                return
The entire code for terminal_entries.rpy

Code: Select all

define entry001 = "alpha"
define entry002 = "beta"
define entry003 = "delta"
define entry004 = "gamma"
define entry005 = "sigma"
define entry006 = "lambda"
define entry007 = "tau"
define entry008 = "phi"
define entry009 = "pi"
define entry010 = "omega"
define entry011 = "15876"
define entry012 = "22179"
define entry013 = "54897"

label terminal_entries:
    
    menu:
        "Entry_001":
            jump terminal_entry_001
        "Entry_002":
            jump terminal_entry_002
        "Entry_003":
            jump terminal_entry_003
        "Entry_004":
            jump terminal_entry_004
        "Entry_005":
            jump terminal_entry_005
        "Entry_006":
            jump terminal_entry_006
        "Entry_007":
            jump terminal_entry_007
        "Entry_008":
            jump terminal_entry_008
        "Entry_009":
            jump terminal_entry_009
        "Entry_010":
            jump terminal_entry_010
        "Entry_011":
            jump terminal_entry_011
        "Entry_012":
            jump terminal_entry_012
        "Entry_013":
            jump terminal_entry_013

label terminal_entry_001:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_001")
    if password == entry001:
        jump entry_001_terminal
    else:
        jump invalid
        
label terminal_entry_002:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_002")
    if password == entry002:
        jump entry_002_terminal
    else:
        jump invalid
        
label terminal_entry_003:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_003")
    if password == entry003:
        jump entry_003_terminal
    else:
        jump invalid
        
label terminal_entry_004:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_004")
    if password == entry004:
        jump entry_004_terminal
    else:
        jump invalid
        
label terminal_entry_005:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_005")
    if password == entry005:
        jump entry_005_terminal
    else:
        jump invalid
        
label terminal_entry_006:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_006")
    if password == entry006:
        jump entry_006_terminal
    else:
        jump invalid
        
label terminal_entry_007:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_007")
    if password == entry007:
        jump entry_007_terminal
    else:
        jump invalid
        
label terminal_entry_008:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_008")
    if password == entry008:
        jump entry_008_terminal
    else:
        jump invalid
        
label terminal_entry_009:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_009")
    if password == entry009:
        jump entry_009_terminal
    else:
        jump invalid
        
label terminal_entry_010:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_010")
    if password == entry010:
        jump entry_010_terminal
    else:
        jump invalid
        
label terminal_entry_011:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_011")
    if password == entry011:
        jump entry_011_terminal
    else:
        jump invalid
        
label terminal_entry_012:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_012")
    if password == entry012:
        jump entry_012_terminal
    else:
        jump invalid
        
label terminal_entry_013:
    
    c "Please enter password."
    $ password = renpy.input("Enter Password for Entry_013")
    if password == entry013:
        jump entry_013_terminal
    else:
        jump invalid
        
label entry_001_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "..........................."
    
    jump terminal_monitor
    
label entry_002_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "..........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_003_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c ".........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_004_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c ".........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_005_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c ".........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_006_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c ".........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_007_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "..........................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_008_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "............................"
    
    nvl clear
    
    jump terminal_monitor
    
label entry_009_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "............................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_010_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "............................."
    
    nvl clear
    
    jump terminal_monitor
    
label entry_011_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "............................"
    
    nvl clear
    
    jump terminal_monitor
    
label entry_012_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c "............................"
    
    nvl clear
    
    jump terminal_monitor
    
label entry_013_terminal:
    
    nvl clear
    
    c "Authorization Granted"
    
    nvl clear
    
    c ".............................."
    
    nvl clear
    
    jump terminal_monitor
    
label invalid:
    
    nvl clear
    
    c "INVALID PASSWORD"
    
    nvl clear
    
    jump terminal_monitor

User avatar
Silence in Space
Regular
Posts: 31
Joined: Tue Nov 22, 2016 4:48 pm
Projects: Silence in Space
Contact:

Re: Scrollbar In-Game Menu Coding?

#7 Post by Silence in Space »

r_sami wrote:Might wanna change the child size, something like:

Code: Select all

screen choice(items):
    style_prefix "choice"
    side "c b r":
         area (100, 100, 600, 400)
             viewport:
                 scrollbars "vertical"
                 mousewheel True
                 draggable True

                 side_yfill True

                 vbox:
                     for i in items:
                         textbutton i.caption action i.action
(Note: not tested).
Regardless of where it is put in the coding, it will always show a blank screen for the first menu (i.e. in script.rpy) making impossible to test any of the other menus.

It does not result in an error, unless placed after menu. script.rpy and terminal_entries.rpy function correctly without this.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Scrollbar In-Game Menu Coding?

#8 Post by nyaatrap »

Wrap viewport by fixed or frame, giving its xysize. You only need to modify screens.rpy.

Code: Select all

screen choice(items):
    style_prefix "choice"

    fixed pos (x,y) xysize (x,y): #or frame, window
        viewport:
            scrollbars "vertical"
            mousewheel True
            draggable True

            side_yfill True

            vbox:
                for i in items:
                    textbutton i.caption action i.action

User avatar
scorlight
Regular
Posts: 67
Joined: Fri Sep 13, 2013 7:02 am
Contact:

Re: Scrollbar In-Game Menu Coding?

#9 Post by scorlight »

I know it's late but in case someone still need it, this is the code I use

Code: Select all

screen choice(items): 
    window:
        style_prefix "choice"
        area (240, 112, 843, 400)
        viewport:
            if len(items) >= 6:
                scrollbars "vertical"
                mousewheel True
                draggable True
                
            vbox:
                spacing 20
                for i in items:
                    textbutton i.caption action i.action
I got it from this post: viewtopic.php?f=8&t=41504
Artist for rent, see my art here: http://scorlight.deviantart.com/gallery/

User avatar
Triority
Regular
Posts: 185
Joined: Fri Jul 20, 2018 1:28 pm
Completed: Welcome To... Chichester 0, 1,2 OVN 1, OVN 2, OVN 3, No Regrets For The Future
Projects: Welcome To... Chichester series
Organization: Triority
Tumblr: Sku-te
itch: triority
Location: England
Discord: sku_te
Contact:

Re: Scrollbar In-Game Menu Coding?

#10 Post by Triority »

The problem with that is the options wont appear inside the defined area. Have to get rid of the window command for it to work correctly

Post Reply

Who is online

Users browsing this forum: No registered users