Page 1 of 1

Menu Screen with Different Looking Choice Buttons

Posted: Sat Aug 12, 2017 1:44 pm
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!!

Re: Menu Screen with Different Looking Choice Buttons

Posted: Sun Aug 13, 2017 4:29 am
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.

Re: Menu Screen with Different Looking Choice Buttons

Posted: Wed Aug 16, 2017 11:25 am
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!

Re: Menu Screen with Different Looking Choice Buttons

Posted: Tue May 10, 2022 3:31 pm
by Zaeriz
Does this work with changing the image while it's being hovered over?

Re: Menu Screen with Different Looking Choice Buttons

Posted: Tue May 10, 2022 3:45 pm
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

Re: Menu Screen with Different Looking Choice Buttons

Posted: Tue May 10, 2022 6:43 pm
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