How to change choice menu gui dynamically

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
apexchimps
Regular
Posts: 29
Joined: Mon Jan 25, 2016 6:12 pm
Completed: Detective Max, Nick's Night Out!, Arthur & Susan: Almost Detectives
Projects: Arthur & Susan: Almost Detectives
Contact:

How to change choice menu gui dynamically

#1 Post by apexchimps »

Hi,

We are trying unsuccessfully to change the choice menu gui dynamically. Basically we want the color of the choice buttons to change depending on the character, so the user can play with more than one character, and the gui changes depending on which character you have selected.

We know how to change the background color (black in the screenshot), by replacing the choice_idle_background.png file, but we can only do it once before compiling the game, and not once the game has started.

Image

Any advice?

Thank you in advance!

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to change choice menu gui dynamically

#2 Post by PyTom »

7.1.4 has a new feature, menu arguments, that will be perfect for this. First off, you're going to want to change the say screen in your game to read:

Code: Select all

screen choice(items, button="choice"):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption:
                action i.action
                background "gui/button/{}_idle_background.png".format(button)
                hover_background "gui/button/{}_hover_background.png".format(button)
Once that's done, you can then pass the button argument to the menu.

Code: Select all

menu (button="sylvie"):
     "To ask her right away.":
         pass
     "To ask her later.":
         pass
Remember, this needs the prerelease to work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
apexchimps
Regular
Posts: 29
Joined: Mon Jan 25, 2016 6:12 pm
Completed: Detective Max, Nick's Night Out!, Arthur & Susan: Almost Detectives
Projects: Arthur & Susan: Almost Detectives
Contact:

Re: How to change choice menu gui dynamically

#3 Post by apexchimps »

That would be... perfect! I didn't see the prerelease. You are one week ahead! :) Thank you!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How to change choice menu gui dynamically

#4 Post by Imperf3kt »

apexchimps wrote: Sun Feb 17, 2019 6:36 am didn't see the prerelease
It only came out a few hours earlier, it's unlikely you would have.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Ocelot