Little used features choice menu

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Andredron
Miko-Class Veteran
Posts: 722
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Little used features choice menu

#1 Post by Andredron »

1) Blur scene behind choice menu, fade choices in and out.
https://patreon.renpy.org/dev-2020-09.h ... u-blurring

And

https://gist.github.com/dossy/cbb7b7ed1 ... 8d63a15c69

Code: Select all

screen choice(items):
    style_prefix "choice"

    $ renpy.show_layer_at(choice_bg_transform_show, layer='master')
    on "hide" action Function(renpy.show_layer_at, choice_bg_transform_hide, layer='master')

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

transform choice_bg_transform_show:
    blur 20.0

transform choice_bg_transform_hide:
    blur 0.0

transform choice_transform:
    alpha 0.0
    easein 1.0 alpha 1.0

    on hide:
        easein 1.0 alpha 0.0
2) button menu choice add zoom

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action at anim_choice_button
transform anim_choice_button: 
    on hover: 
        linear 0.25 zoom 1.25 
    on idle: 
        linear 0.25 zoom 1.0
3) How to show players when they’ve made a choice before
https://web.archive.org/web/20230308024 ... ce-before/

😁😁😁
https://akakyouryuu.com/renpy/renpy%e6% ... %83%a21-2/

viewtopic.php?p=560219

4) Shuffling Choice Menus
https://patreon.renpy.org/shuffle-menu.html

5) Mr. Python (recommend) menu choice
https://patreon.renpy.org/menu-arguments.html

6) choice menu with a scrollbar

Code: Select all

screen choice(items):
    window:
        style_prefix "choice"
        area (0.53, 0.7, 400, 2000)      
        viewport id "choicemenu":
            child_size (200, 2000)
            if len(items) >=5:
                scrollbars "vertical"
                mousewheel True
                draggable True
                yinitial 1.0
            vbar value YScrollValue ("choicemenu") pos (630, 860) ysize 100

            vbox:
                for i in items:
                    textbutton i.caption action i.action
7) side scroller for multiple choice options
viewtopic.php?p=548020#p548020

Code: Select all

screen choice(items):
    style_prefix "choice"
    default i = 0
    hbox:
        textbutton "<" sensitive i > 0 action SetScreenVariable("i", i - 1)
        textbutton items[i].caption action items[i].action
        textbutton ">" sensitive i < (len(items) - 1) action SetScreenVariable("i", i + 1)

8 ) spinning choice menu for renpy

https://github.com/yqmtat/renpy-spinning-menu

9) Mass Effect choice menu
viewtopic.php?f=8&t=40636

10) Very old features
https://patreon.renpy.org/very-old-features.html

11) Timed Choice Menus
https://patreon.renpy.org/timed-choice-menus.html

12) Drop Down Menus
https://patreon.renpy.org/dev-2022-05.h ... down-menus

13) Add sound choice menu
viewtopic.php?t=44659

14) integrating choice menus within screens
viewtopic.php?p=566083

15) autosave functionality so that it saves at the beginning of each label instead of saving right before each choice.
viewtopic.php?p=565725

16) add a text prompt as a header to an in-game menu
viewtopic.php?p=565374

17) Normal NVL Menu in NVL Text Box Frame

Code: Select all

screen nvl:
    frame:
        xpos 1390 ypos 0
        top_padding 10 bottom_padding 10 left_padding 10 right_padding 10

        has side "c r":
            area (0, 0, 510, 1080)

            viewport id "vp":
                draggable True
                yadjustment ui.adjustment (value=99999, range=99999) # <- idk, just copying your code
                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

                    # and then Display a menu, if given. in the same vbox
                    if items:
                        window:
                            vbox:
                                id "menu"
                                for caption, action, chosen in items:
                                    if action:
                                        button:
                                            style "nvl_menu_choice_button"
                                            action action
                                            text caption style "nvl_menu_choice"
                                    else:
                                        text caption style "nvl_dialogue"

            vbar value YScrollValue("vp") bar_invert True


init -2 python:
     #How far from the left menu choices should be indented.
    style.nvl_menu_choice_button.left_margin = 10
18) show multiple lines of dialogue during choices
viewtopic.php?p=563567

Code: Select all

screen note():
    frame:
        background "#CCC"
        align (1.0, 0.0)
        xsize 400
        text "{color=#F00}WARNING! The wrong choice here might damage your brain!":
            size 56
            textalign 0.5

show screen note
menu:
    "A cup of tea?"

    "Yes, thank you.":
        hide screen note
        $ theChoice = "bold"

    "From you? Never!":
        hide screen note
        $ theChoice = "paranoia"
19) Add a condition to the menu items so that the menu option appears under certain conditions.
https://www.renpy.org/doc/html/menus.html#in-game-menus

Code: Select all

menu:
    "Go left.":
        ...
    "Go right.":
        ...
    "Fly above." if drank_tea:
        ...
    "Buy cookies" if money >= 10:
        "..."
    "Don't buy anything":
        "..." 
20) QTE in choice menu
viewtopic.php?p=561777

21) Skip choice menu
viewtopic.php?p=561352

22) How to display text in menu choice and replace it with timer for another text
viewtopic.php?p=561087

23) After a time, the definition to add the choice menu new.
viewtopic.php?p=561068

24) How to set choice menu width
viewtopic.php?p=560643

25) Having some menu choices hidden, others greyed out
viewtopic.php?p=559923

26) two style choice menu

viewtopic.php?p=558928

27) Changing the width of a menu textbutton
viewtopic.php?p=558836

28) How to create multiple types of choice button images
viewtopic.php?p=558626

29) choice menu version2
viewtopic.php?p=554769

30) Description in dialog box for menu entries
viewtopic.php?p=552732#p552732

31) Make the menu items in the form of a ladder, each subsequent option shorter than the previous one.
viewtopic.php?p=544243

32) Playing music in the choice/menu screen

viewtopic.php?p=541749

Code: Select all

screen choice(items):
    style_prefix "choice"
    vbox:
        for i in items:
            textbutton i.caption action i.action
    on "show"     action [Play(channel="choice_music", file="audio/choice.mp3", fadein=1.0), Function(renpy.music.set_volume, 0.2, delay=1.0, channel="music")]
    on "replace"  action [Play(channel="choice_music", file="audio/choice.mp3", fadein=1.0), Function(renpy.music.set_volume, 0.2, delay=1.0, channel="music")]
    on "hide"     action [Stop(channel="choice_music", fadeout=1.0),                         Function(renpy.music.set_volume, 1.0, delay=1.0, channel="music")]
    on "replaced" action [Stop(channel="choice_music", fadeout=1.0),
33) How to send back to previous menu
You can give menu a name and then you'll be able to jump to this menu.

Code: Select all

label start:
    menu menu_1:
        "Choice 1":
            pass
        "Choice 2":
            pass
    "blah-blah-blah"
    jump menu_1
    
https://www.renpy.org/doc/html/menus.html

34) A one-time question on how to create.

Code: Select all

label splashscreen:
    $ if not persistent.one: ### Condition for 1 question to appear
        scene black
            menu:
                "One-off question?"
                    " yes":
                        $ persistent.one = True #####Constant variable for 1 time, so as not to get out with questions
                        show screen main_menu
                    "No":
                        $ renpy.quit()
    return

label start:
    hide screen main_menu
35) image in choice menu
http://renpyfordummies.blogspot.com/2018/05/gui.html

36) Choice menu options in dialogue box
viewtopic.php?p=535533

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        yalign 0.9 # added line
        for i in items:
            textbutton i.caption action i.action
37) сchoice menu and background
https://www.reddit.com/r/RenPy/comments ... are_button

38) Menu selections disappear every 2 seconds

Code: Select all

init python:
    def dynamicMenuManager(origin, target):
        global menuLimit
        menuLimit -= 1
        if menuLimit == 0:
            menuLimit = None
            renpy.jump(target)
        renpy.jump(origin)
        
label start:
    $ shkaf = None
    $ ulicha = None
    $ cherdak = None
    $ menuLimit = 0
    
    "A phone call and a voice comes out of it."
    
    "Maniac" "I found you..."
    "Maniac." "I'm already at your house."
    "Maniac" "Save your life HAHAHAHAHAHAHAHAHAHAHAHAHAHA!!!"
    
    $ menuLimit = 4 #Menu Items
    
    $ menuManager = renpy.curry(dynamicMenuManager)
    
label dynamicMenu1:

    "A maniac has broken into the house, hurry up and run away from the house!!!"
    
    $ ui.timer(2.0, menuManager("dynamicMenu1", "set2"))
    
    menu:
    
        "Hurry up!!! Choose where to run!!!!"
        "Hide in the closet" if menuLimit >= 1:
               "Run to the closet"
               $ shkaf = True
                jump set1
                
        " Ignore the call " if menuLimit >= 2:
               "You hung up on me, not many assholes can call."
                jump set2
                
        "Climb into the attic" if menuLimit >= 3:
               "You ran to the attic..."
               $ cherdak = True
                jump set1
        " Go to the balcony " if menuLimit >= 4:
        
         "I need a smoke."
               $ ulicha = True
                jump set1
                
label set2:  ##### Wrong choice and out of time.
    "Girl." "I heard something behind me."
    "smack."
    "And a woman's body fell to the floor."
    return
    
label set1:
    "Just as you walked in, you heard footsteps in the house..."
39) Timed Choice Menus with timeout random choice
viewtopic.php?p=533452#p533452

40) randomized styles choice
viewtopic.php?p=524333

41) Adding a pause to the choice screen
viewtopic.php?t=68168

42)Election buttons in the textbox
https://boosty.to/7dots/posts/8502272e- ... a26c6b5a62

Code: Select all

define config.default_fullscreen = True

# THE EXAMPLE IS DESIGNED FOR ONE LINE OF QUESTIONS
# AND FOR THE NUMBER OF ANSWERS FROM 1 TO 3, INCLUSIVE

# make the box taller to fit at least three buttons
define gui.textbox_height = 333

init:
    # stretch the textbox background to fit the new height (and let it be without gradients too)
    style window:
        background Frame(“#010c”, 0, 0)

# our version of the election screen within the textbox
screen textbox(items):
    style_prefix “say”

    window style “window”:
        # no need to duplicate the background if the textbox with the question is already shown
        if renpy.get_screen(“say”):
            background None

        vbox:
            xalign .5
            ypos gui.dialogue_ypos

            # smaller spacing between buttons
            spacing 4

            text “ ”
            for i in items:
                textbutton i.caption action i.action:
                    style “choice_button”
                    xalign .5
                    # rectangular buttons without gradient (can be removed)
                    idle_background gui.muted_color
                    hover_background gui.hover_color
                    insensitive_background gui.insensitive_color

label start:
    scene expression “#021” as bg
    show girl
    with dissolve

    # we need to specify our version of the election screen
    menu(screen=“textbox”):
        # one line question
        “Make a choice:”

        “Button 1”:
            pass

        “Button 2”:
            pass

        “Button 3”:
            pass

    menu(screen=“textbox”):
        “Make a selection:”

        “Button 1”:
            pass

        “Button 2”:
            pass

    menu(screen=“textbox”):
        # if not showing the question, you need a blank line so the textbox doesn't blink
        “ ”

        “Finish test”:
            pass

    return

## UNNECESSARY THINGS
init:
    # silhouette color color1 transitions to color2
    transform paint2(color1=“#354”, color2=“132”, t=3):
        matrixcolor TintMatrix(color1) * InvertMatrix(1.) * TintMatrix(“#000”)
        ease_quad t*.5 matrixcolor TintMatrix(color2) * InvertMatrix(1.) * TintMatrix(“#000”)
        ease_quad t*.5 matrixcolor TintMatrix(color1) * InvertMatrix(1.) * TintMatrix(“#000”)
        repeat

    # make the sprite flicker
    image girl = At(Placeholder(“girl”, text=“”), paint2)

Translated with DeepL.com (free version)
Last edited by Andredron on Wed Apr 24, 2024 2:15 am, edited 45 times in total.

User avatar
Tess
Regular
Posts: 59
Joined: Thu Aug 04, 2022 3:43 pm
Projects: The Songbird Guild
Organization: Yurisoft
Github: wainwt2
Discord: Tess#7782
Contact:

Re: Little used features choice menu

#2 Post by Tess »

That option to show players if they've made a choice before is really smart!
Thanks for sharing these.

Post Reply

Who is online

Users browsing this forum: No registered users