Mark chosen choices

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
Moshibit
Regular
Posts: 50
Joined: Wed Oct 16, 2019 1:58 pm
Location: Mexico
Contact:

Mark chosen choices

#1 Post by Moshibit »

An important part of the visual novels are the choices, I consider that the player has the right to know which choices he has already chosen. Here is a simple script to change the text color of the chosen choices in a viusal novel. Modify the screens.rpy script

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action: # edit this line
                if i.chosen == True: # add this line
                    style "choice_chosen_button" # add this line


define config.narrator_menu = True


style choice_vbox is vbox
style choice_button is button
style choice_button_text is button_text

style choice_chosen_button is choice_button # add this line
style choice_chosen_button_text is choice_button_text # add this line

style choice_vbox:
    xalign 0.5
    ypos 270
    yanchor 0.5

    spacing gui.choice_spacing

style choice_button is default:
    properties gui.button_properties("choice_button")

style choice_button_text is default:
    properties gui.button_text_properties("choice_button")

style choice_chosen_button_text: # add this line
    idle_color "#f00" # add this line
The following script will add an image to the chosen choices. It is very simple but gives an idea of how to do it. It can be improved if you know about screen language.

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            hbox: # add this line
                textbutton i.caption action i.action # edit this line
                if i.chosen == True: # add this line
                    add "gui/choise_mark.png" # add this line. Recommended size 30*30 pixels


define config.narrator_menu = True


style choice_vbox is vbox
style choice_button is button
style choice_button_text is button_text

style choice_vbox:
    xalign 0.5
    ypos 270
    yanchor 0.5

    spacing gui.choice_spacing

style choice_button is default:
    properties gui.button_properties("choice_button")

style choice_button_text is default:
    properties gui.button_text_properties("choice_button")
I hope these examples are helpful.

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Mark chosen choices

#2 Post by RicharDann »

Pretty good, I was thinking on a really roundabout way to do this but it is actually so simple! Thank you for sharing this, you've saved me a lot of work.
The most important step is always the next one.

User avatar
Tiger Lyz
Newbie
Posts: 11
Joined: Fri Jan 17, 2020 4:09 am
Projects: Curvy heroine&Virtual Boyfriend, Homunculus, Voice of Paradaise, The Ugly Princess...
Contact:

Re: Mark chosen choices

#3 Post by Tiger Lyz »

Thanks! It's really usefull.

Post Reply

Who is online

Users browsing this forum: No registered users