screens and layers

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
pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

screens and layers

#1 Post by pucedragonlord »

I know you can show a screen on a predefined layer with renpy.show_screen, but is there a kosher, screen-language friendly way of setting a specific screen's default layer? I'd like to have some screen-based UI stuff appear behind the master layer. I know I can move the master layer forward, but then things like the normal menu screens show up behind all the show statements, too, and it's rather messy.

short version: how do I tell a screen to always show up on a specific (possibly custom) layer?
The more you know

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: screens and layers

#2 Post by Asceai »

The only way you can really do this is by creating a proxy screen to show the real screen on a different layer.

something like

Code: Select all

screen myscreen:
  on "show" action Show("myscreen_real", _layer="special")
  on "hide" action Hide("myscreen_real", _layer="special")
You can't change the default layer target of show.

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: screens and layers

#3 Post by pucedragonlord »

Hm, that is tricky. The screen I'm wanting to re-assign is the nvl screen. I suppose the only way to make that work would be to move all of the logic in the nvl screen into a custom one and change the actual nvl screen to that

Code: Select all

 on "show" action Show("nvl_proxy", _layer="special") 
bit, huh?
The more you know

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: screens and layers

#4 Post by Asceai »

Yeah, although you'll have to pass everything that screen needs across too.

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: screens and layers

#5 Post by pucedragonlord »

Okay. I've never quite done anything like that in RenPy before, so before I break everything for everyone else in the project to figure it out, I'll just ask. To do that I would have to do something like this, then:

Code: Select all

screen nvl: ##this is what the nvl_screen RenPy function will call
    on "show" action Show("nvl_proxy", dialog, items, _layer="special")
    on "hide" action Hide("nvl_proxy", _layer="special")

screen nvl_proxy:

    window:
        style "nvl_window"
        
        #text part
        has vbox:
            style "nvl_vbox"

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            window:
                id window_id

                has hbox:
                    spacing 10

                if who is not None:
                    text who id who_id

                text what id what_id

        # Display a menu, if given.
        if items:

            vbox:
                id "menu"
                    
                yalign 1.0

                for caption, action, chosen in items:

                    if action:

                        button:
                            style "nvl_menu_choice_button"
                            action action

                            text caption style "nvl_menu_choice"

                    else:

                        text caption style "nvl_dialogue"
                    
    #image window                
    window:
        style "nvl_image_window"
        
        xalign 1.0

    add SideImage() xalign 0.0 yalign 1.0

    use quick_menu
    use tab_menu_main

Or, being one of the primary screens of RenPy, will it be more complicated than just that?
The more you know

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: screens and layers

#6 Post by Asceai »

dialogue=dialogue, items=items
Also renpy expects the screen it calls to produce the window, who and what elements, so I don't know if this trick will even be allowed. It's beyond me how you'd do this otherwise, though.

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: screens and layers

#7 Post by pucedragonlord »

It's more than I knew 5 minutes ago, so thank you. I'll give it a try and we'll see what happens.
The more you know

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: screens and layers

#8 Post by pucedragonlord »

Result:
"Error: Say (or Show) statement must return text object," or something to that effect.

Though I figured out a partial solution using ui.layer('special'). I can't wrap the entire nvl screen in it, or the menu doesn't display, but if I wrap only the half I expect to use images in ui.layer()/ui.close(), it seems to work. If anyone knows how I can make the menu show up with the whole thing between ui.layer()/ui.close(), that would be awesome.
The more you know

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: screens and layers

#9 Post by neowired »

You probably already know this but you could try playing with zorder of all the screens
I think you can have a negative zorder value as well, but I'm not sure.
screens with higher zorder appear on top of screens with lower zorder, it may be easier and faster than playing with renpy layers.

But I assume that's not what you are looking for?

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: screens and layers

#10 Post by pucedragonlord »

It's certainly not a bad suggestion, but it's not quite what I was looking for. In particular I needed to keep certain elements on the master layer so as not to mess with the semantics of show statements too much. Everything outside of this particular issue, however, I can just use zorders, though.
The more you know

Post Reply

Who is online

Users browsing this forum: Google [Bot]