[SOLVED] Use a frame as a background on the choice screen

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
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

[SOLVED] Use a frame as a background on the choice screen

#1 Post by Kinmoku »

Hi all,

I'm having some difficulty with my choice screen right now (see thread: viewtopic.php?f=8&t=56835#top ), but something else I'd like to do is change the size of the box around the buttons, depending on how many choices there are.

It's my first time using frames so I don't really know what I'm doing, but here's my setup:

Code: Select all

screen choice(items):
    style_prefix "choice"
    
    vbox:
        add Frame("gui/menu_frame.png", 44, 44) xalign 0.5 yalign 0.4
        
        for i in items:
            if " (grey)" in i.caption:
                button:
                    action i.action
                    style "menu_choice_grey_button"
                    text i.caption.replace(" (grey)", "") style "menu_choice_grey_text"

            else:
                button:
                    xysize (575, 80)
                    action i.action
                    text i.caption xalign 0.5 yalign 0.5#style "menu_choice_text"
         
I tried "add Frame" in various locations but it just fills the screen and pushes everything else down. I originally had "add "menubox" which was a fixed size backdrop, and whilst it worked, it looked silly with only 2 choices and overspilled with 5+.

Any ideas?
Last edited by Kinmoku on Thu Sep 12, 2019 8:44 am, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Use a frame as a background on the choice screen

#2 Post by hell_oh_world »

Kinmoku wrote: Thu Sep 12, 2019 6:01 am Hi all,

I'm having some difficulty with my choice screen right now (see thread: viewtopic.php?f=8&t=56835#top ), but something else I'd like to do is change the size of the box around the buttons, depending on how many choices there are.

It's my first time using frames so I don't really know what I'm doing, but here's my setup:

Code: Select all

screen choice(items):
    style_prefix "choice"
    
    vbox:
        add Frame("gui/menu_frame.png", 44, 44) xalign 0.5 yalign 0.4
        
        for i in items:
            if " (grey)" in i.caption:
                button:
                    action i.action
                    style "menu_choice_grey_button"
                    text i.caption.replace(" (grey)", "") style "menu_choice_grey_text"

            else:
                button:
                    xysize (575, 80)
                    action i.action
                    text i.caption xalign 0.5 yalign 0.5#style "menu_choice_text"
         
I tried "add Frame" in various locations but it just fills the screen and pushes everything else down. I originally had "add "menubox" which was a fixed size backdrop, and whilst it worked, it looked silly with only 2 choices and overspilled with 5+.

Any ideas?
Move the frame as a sibling of the container vbox and not as a child of that container...

Code: Select all

screen choice(items):
    style_prefix "choice"
    
    add Frame("gui/menu_frame.png", 44, 44) xalign 0.5 yalign 0.4 ## This should not be a child of the vbox, doing so will fill the screen and stack below the choices
    vbox:
        
        for i in items:
            if " (grey)" in i.caption:
                button:
                    action i.action
                    style "menu_choice_grey_button"
                    text i.caption.replace(" (grey)", "") style "menu_choice_grey_text"

            else:
                button:
                    xysize (575, 80)
                    action i.action
                    text i.caption xalign 0.5 yalign 0.5#style "menu_choice_text"
         

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Use a frame as a background on the choice screen

#3 Post by Kinmoku »


Move the frame as a sibling of the container vbox and not as a child of that container...
Hey. This is what I had originally but it filled the entire screen.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Use a frame as a background on the choice screen

#4 Post by hell_oh_world »

Kinmoku wrote: Thu Sep 12, 2019 8:19 am

Move the frame as a sibling of the container vbox and not as a child of that container...
Hey. This is what I had originally but it filled the entire screen.
Ahh... my bad, in that case, if you want the frame to automatically resize just create a frame container and set its xysize to None.

Code: Select all

frame:
	xsize None
	ysize None
        background Frame("gui/menu_frame.png", 44, 44)
        
	vbox:
        
        	for i in items:
            		if " (grey)" in i.caption:
                		button:
                    			action i.action
                    			style "menu_choice_grey_button"
                    			text i.caption.replace(" (grey)", "") style "menu_choice_grey_text"

            		else:
               			button:
                    			xysize (575, 80)
                    			action i.action
                    			text i.caption xalign 0.5 yalign 0.5#style "menu_choice_text"

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Use a frame as a background on the choice screen

#5 Post by Kinmoku »

Ah, great :D I didn't know how to do this. It looks really cool now, thanks!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], MisterPinetree