Page 1 of 1

Make something appear above dialogue window (SOLVED)

Posted: Thu Oct 23, 2014 4:57 pm
by bimb2212
I use a slightly-complicated Digital Calendar, but when the calendar show, it appear behind the dialogue window. Anyone know how to make it move to the top first?

Re: Make something appear above dialogue window.

Posted: Fri Oct 24, 2014 2:56 pm
by Alex
It would be better if you'd show your code to let people check what should be changed.

Re: Make something appear above dialogue window.

Posted: Sat Oct 25, 2014 4:48 am
by nintendotoad
I think OP may be using the Cookbook recipe.

http://www.renpy.org/wiki/renpy/doc/coo ... l_Calendar

def Calendar(): and def Clocks(): require a yalign change in their ui.frame statements.

ui.frame(xfill=False, xminimum = 110, yminimum=None, xalign=1.0, yalign = 0.76)

0.76 is worth changing.

Re: Make something appear above dialogue window.

Posted: Sat Oct 25, 2014 10:13 am
by Milkymalk
That will change the position, but not the z-order.

The calender has to either get moved to a layer at least as high as the text box, or if it's on the same layer, be given a higher z-order.

Re: Make something appear above dialogue window.

Posted: Sat Oct 25, 2014 10:30 am
by bimb2212
Yeah, I don't know how to change the z-order when use def statement in init python. But I use a quick fix: remove the def Calendar(), def Clock(), ui, copy and change these codes that fit screen statement, and it appear in-front. For now, I only know that the dialogue box appears behind screen statement, but before define statement.

Re: Make something appear above dialogue window.

Posted: Sat Oct 25, 2014 11:44 am
by Alex
The zorder is used when you show separate screens or displayables, but in this recipe calendar and clock are added into the say screen. The elements of a screen appears onscreen in the order you added them in your code. So if you added

Code: Select all

if(clock):
        $ Calendar()
        $ Clocks()
part right at the beginning of the say screen, then your calendar appeared first and then the whole textbox over it.

Just move this lines of code to the end of say screen code (right after "use quick_menu" line) to make calendar and clock appear on top of your textbox.

Re: Make something appear above dialogue window.

Posted: Sun Oct 26, 2014 7:45 am
by bimb2212
Alex wrote:The zorder is used when you show separate screens or displayables, but in this recipe calendar and clock are added into the say screen. The elements of a screen appears onscreen in the order you added them in your code. So if you added

Code: Select all

if(clock):
        $ Calendar()
        $ Clocks()
part right at the beginning of the say screen, then your calendar appeared first and then the whole textbox over it.

Just move this lines of code to the end of say screen code (right after "use quick_menu" line) to make calendar and clock appear on top of your textbox.
I moved them to end of say screen, and even move to quick menu screen, still the same problem. I think, for default, every def statement that called in screen, will appear behind the say box. :(

Re: Make something appear above dialogue window.

Posted: Sun Oct 26, 2014 8:01 am
by Alex
Hm, it worked for me...
Show your code for say screen then (or upload the project to let people test it).

Re: Make something appear above dialogue window.

Posted: Tue Oct 28, 2014 2:57 am
by bimb2212
Alex wrote:Hm, it worked for me...
Show your code for say screen then (or upload the project to let people test it).
Sorry for slow reply, this is my say screen:

Code: Select all

screen say:
    default side_image = None
    window:
        id "window"
        has vbox:
            style "say_vbox"
        if who:
            text who id "who"
        text what id "what"     
    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign 0.0 yalign 1.0
    
    key "K_F1" action ShowMenu('help')
    key "K_F5" action QuickSave()
    key "K_F9" action QuickLoad()
    key "K_a" action [Preference("auto-forward", "toggle"), Play("sound", "sound/sfx/click.wav")]

    if show_game_hud0:
        use game_hud0
    if show_game_hud1:
        use game_hud1
    if show_game_hud2:
        use game_hud2
    if show_game_hud3:
        use game_hud3
    if show_game_hud4:
        use game_hud4

init -2 python:
    show_game_hud0=False
    show_game_hud1=True
    show_game_hud2=False
    show_game_hud3=False
    show_game_hud4=False

Re: Make something appear above dialogue window.

Posted: Wed Oct 29, 2014 1:42 pm
by Alex
So, how do you show the calendar and clock then?
I was expecting to see something like:

Code: Select all

screen say:
    default side_image = None
    window:
        id "window"
        has vbox:
            style "say_vbox"
        if who:
            text who id "who"
        text what id "what"     
    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign 0.0 yalign 1.0
    
    key "K_F1" action ShowMenu('help')
    key "K_F5" action QuickSave()
    key "K_F9" action QuickLoad()
    key "K_a" action [Preference("auto-forward", "toggle"), Play("sound", "sound/sfx/click.wav")]

    if show_game_hud0:
        use game_hud0
    if show_game_hud1:
        use game_hud1
    if show_game_hud2:
        use game_hud2
    if show_game_hud3:
        use game_hud3
    if show_game_hud4:
        use game_hud4

    if(clock):
        $ Calendar()
        $ Clocks()

Re: Make something appear above dialogue window.

Posted: Wed Oct 29, 2014 11:26 pm
by bimb2212
Alex wrote:So, how do you show the calendar and clock then?
I was expecting to see something like:
Ya, I place it at there, still appears behind the say box. Even I created fresh new renpy game, copy and paste code, the same result :(

Re: Make something appear above dialogue window.

Posted: Thu Oct 30, 2014 11:39 am
by Alex
Well, interesting...
Could you attach the rpy-files of that fresh project to let me see this behaviour?

Re: Make something appear above dialogue window.

Posted: Thu Oct 30, 2014 1:46 pm
by bimb2212
I mean that I press "create new project" in Ren'py, without touch anything about Eileen's welcome, then I paste the digital calendar code... I use lastest version of ren'py.
Testing.rar
(143.47 KiB) Downloaded 55 times

Re: Make something appear above dialogue window.

Posted: Thu Oct 30, 2014 5:23 pm
by Alex
Well, ok - this code worked in Ren'Py 6.16, but in 6.18 something has changed about using the layers. So for now you ought to specify the 'screens' layer as the layer to show your calendar and clock:

Code: Select all

    def Calendar():
        ui.layer('screens')     # <======= add this
        ui.frame(xfill=False, xminimum = 400, yminimum=None, xalign=1.0, yalign = 0.805)
        ui.vbox()
        ui.text("(%s) - %s %d %d" % (stringweekday, stringmonth, theday, theyear), xalign=1.0, size=20)
        ui.close()
        ui.close()     # <======= and this
        
    def Clocks():
        ui.layer('screens')     # <======= add this
        ui.frame(xfill=False, xminimum = 110, yminimum=None, xalign=1.0, yalign = 0.76)
        ui.vbox()
        if (minutes > 719):
            if ((minutes - (int(minutes/60))*60) < 10):
                if((int(minutes/60)) == 12):
                    ui.text("12:0%d PM" % ((minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
                else:
                    ui.text("%d:0%d PM" % ((int(minutes/60)-12), (minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
            else:
                if((int(minutes/60)) == 12):
                    ui.text("12:%d PM" % ((minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
                else:
                    ui.text("%d:%d PM" % ((int(minutes/60)-12), (minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
        else:
            if ((minutes - (int(minutes/60))*60) < 10):
                if((int(minutes/60)) == 0):
                    ui.text("12:0%d AM" % ((minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
                else:
                    ui.text("%d:0%d AM" % ((int(minutes/60)), (minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
            else:
                if((int(minutes/60)) == 0):
                    ui.text("12:%d AM" % ((minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
                else:
                    ui.text("%d:%d AM" % ((int(minutes/60)), (minutes - (int(minutes/60))*60)), xalign=1.0, size=20)
        ui.close()
        ui.close()     # <======= and this
This will make it work again.

Re: Make something appear above dialogue window.

Posted: Thu Oct 30, 2014 11:16 pm
by bimb2212
Woa, so if every def statement that I call with a frame in it, I need to specify the 'screens' layer to make it appear in front of the say screen. Thanks for your help!