Menu Screen with Different Looking Choice Buttons

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
timepatches
Regular
Posts: 91
Joined: Sun Aug 14, 2016 1:52 am
Completed: When Aster Falls; Were|House; DemiDato: Monster Dating Show; Grand-Nya
Projects: The Bat-Chelor
Organization: Sad Ghost Studios
Tumblr: sadghoststudios
itch: Sad Ghost Studios
Location: Australia
Contact:

Menu Screen with Different Looking Choice Buttons

#1 Post by timepatches »

Pretty sure this is a silly question but I can't seem to squeeze an answer out of my noggin! :|
In my game, I'd like my choice menus to have aesthetically different buttons, something like this:
Image
which would need a different file to be used for each button, but I have 0 idea how to go about doing it.
If it ends up being difficult to code I can just scrap the idea, but I think it'd look nicer aesthetically if I could make the choice buttons like this instead of all looking the same.
Help would be very appreciated!!
ImageImage Image

★☆ currently: DEMIDATO RELEASED MARCH 14 \ *°▽°* /
i appreciate honest critique!

User avatar
Pyr0
Newbie
Posts: 20
Joined: Mon Aug 07, 2017 4:34 pm
Contact:

Re: Menu Screen with Different Looking Choice Buttons

#2 Post by Pyr0 »

Class UniqueButtons:

Code: Select all

    class UniqueButtons:
        buttons = [Solid("#ff0000",xfill=True,yfill=True),Solid("#00ff00",xfill=True,yfill=True),Solid("#0000ff",xfill=True,yfill = True)]
        counter = 0
        
        @classmethod
        def GetBackground(cls):
            bg = cls.buttons[cls.counter]
            cls.counter = ((cls.counter + 1) % len(cls.buttons))
            return bg
        
        @classmethod
        def Reset(cls):
            cls.counter = 0
Set this up somewhere. Put your backgrounds inside the "buttons" list. I used three differently coloured boxes as placeholder.
You need to modify the screen_choice(items) screen in your screens.rpy to look like this:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption:
                action i.action
                background UniqueButtons.GetBackground()
    $UniqueButtons.Reset()    
This is fairly simple, but I don't know how much knowledge of Ren'py\Python you have, so if you want a detailed explanation feel free to ask.

User avatar
timepatches
Regular
Posts: 91
Joined: Sun Aug 14, 2016 1:52 am
Completed: When Aster Falls; Were|House; DemiDato: Monster Dating Show; Grand-Nya
Projects: The Bat-Chelor
Organization: Sad Ghost Studios
Tumblr: sadghoststudios
itch: Sad Ghost Studios
Location: Australia
Contact:

Re: Menu Screen with Different Looking Choice Buttons

#3 Post by timepatches »

Just wanted to say thankyou for the help!! I haven't had the chance to try implementing this code yet but it looks like exactly what I was after.
(I might need that extra bit of help but I'm going to give it a red hot go first ^^)
Thanks again!
ImageImage Image

★☆ currently: DEMIDATO RELEASED MARCH 14 \ *°▽°* /
i appreciate honest critique!

User avatar
Zaeriz
Newbie
Posts: 3
Joined: Mon May 09, 2022 12:26 pm
Projects: Space Project (Name TBD)
Tumblr: Zaeriz
Location: AZ
Discord: zaeriz#3907
Contact:

Re: Menu Screen with Different Looking Choice Buttons

#4 Post by Zaeriz »

Does this work with changing the image while it's being hovered over?
-- Zaeriz was here. --

User avatar
Zelan
Lemma-Class Veteran
Posts: 2436
Joined: Tue Mar 01, 2016 7:23 pm
Completed: The Dark
Projects: Cosplay Couple
Tumblr: evns
itch: Zelan
Discord: ltnkitsuragi#7082
Contact:

Re: Menu Screen with Different Looking Choice Buttons

#5 Post by Zelan »

Zaeriz wrote: Tue May 10, 2022 3:31 pm Does this work with changing the image while it's being hovered over?
You'll want to use hover for this. (: https://www.renpy.org/doc/html/style_pr ... t=slow_cps

User avatar
Zaeriz
Newbie
Posts: 3
Joined: Mon May 09, 2022 12:26 pm
Projects: Space Project (Name TBD)
Tumblr: Zaeriz
Location: AZ
Discord: zaeriz#3907
Contact:

Re: Menu Screen with Different Looking Choice Buttons

#6 Post by Zaeriz »

Zelan wrote: Tue May 10, 2022 3:45 pm
Zaeriz wrote: Tue May 10, 2022 3:31 pm Does this work with changing the image while it's being hovered over?
You'll want to use hover for this. (: https://www.renpy.org/doc/html/style_pr ... t=slow_cps
Thank you! :D
-- Zaeriz was here. --

Post Reply

Who is online

Users browsing this forum: No registered users