Page 1 of 1

screens and layers

Posted: Tue Mar 11, 2014 8:39 pm
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?

Re: screens and layers

Posted: Tue Mar 11, 2014 10:43 pm
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.

Re: screens and layers

Posted: Wed Mar 12, 2014 6:20 pm
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?

Re: screens and layers

Posted: Wed Mar 12, 2014 6:29 pm
by Asceai
Yeah, although you'll have to pass everything that screen needs across too.

Re: screens and layers

Posted: Wed Mar 12, 2014 6:43 pm
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?

Re: screens and layers

Posted: Wed Mar 12, 2014 6:49 pm
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.

Re: screens and layers

Posted: Wed Mar 12, 2014 6:53 pm
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.

Re: screens and layers

Posted: Fri Mar 14, 2014 2:40 pm
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.

Re: screens and layers

Posted: Fri Mar 14, 2014 3:57 pm
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?

Re: screens and layers

Posted: Tue Apr 29, 2014 11:11 pm
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.