Use style (padding) from the namefox to other 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
sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Use style (padding) from the namefox to other screen

#1 Post by sculpteur »

Code: Select all

screen notification_floating(message):
    zorder 100

    add "gui/notification_background.png" xalign 0.15 yalign 0.43 at _notify_transform_float 
    text message:
        at _notify_transform_float
        size 25
        font "GoodDog.otf"
        color "#66cc00"
    timer 3.25 action Hide('notification_floating')

Hi, this is my customized notificaiton screen.
My displayed text lenght is variable and i would like my background image to adjust.
I know this is possible because I've already done it (but not on purpose ^^) on my namebox
(The namebox background image adjust itself in fonction of my charachters names)

I've isolated and identified the code that make the namebox working but iam not able to reproduce it neither to understand it.
The original Renpy code look something like this :

Code: Select all

style window is default
style say_label is default
style say_dialogue is default
style say_thought is say_dialogue

style namebox is default
style namebox_label is say_label

style namebox:
    xpos gui.name_xpos
    xanchor gui.name_xalign
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height

    background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
    padding gui.namebox_borders.padding

style say_label:
    properties gui.text_properties("name", accent=True)
    xalign gui.name_xalign
    yalign 0.5
I dont know what "default" refers to, or how I could possibly use it on my own notification screen.

Thank you !
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Use style (padding) from the namefox to other screen

#2 Post by Remix »

Might get you heading in the right direction...

Code: Select all

## mimic the namebox style
style notifybox is namebox:
    background Frame( "gui/notification_background.png", 15, 5)
    text_size 25
    text_font  "GoodDog.otf"
    text_color "#66cc00"

screen notification_floating(message):
    zorder 100

    window:
        style "notifybox" ## set this window widget to our style (which includes a Frame background)
        text message ## this should use the notifybox_text_ styles from our declaration

    timer 3.25 action Hide('notification_floating')

# ... likely with the transform in the show ... show screen notification_floating('some message') at _notify_transform_float  
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#3 Post by sculpteur »

that's seem interesting. I'am currently adapting it but in your code this part :

Code: Select all

    text_size 25
    text_font  "GoodDog.otf"
    text_color "#66cc00"
give me an error
(style property is not know)

I've tried :
text.size 25
style.text.size 25
text size 25
style.text size 25
text.size=25
style.text.size=25
text_size=25
style_text_size=25

Nothing work :(
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#4 Post by sculpteur »

I don't get an error when i write :

Code: Select all

style notifybox is namebox:
    background Frame( "gui/notification_background.png", 25, 25)
    size 25
    font  "GoodDog.otf"
But my text is not on the right font and the right size.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#5 Post by sculpteur »

Anyway this is making me crazy because I don't get the way style and screen are suppose to work. I mean the concept behind it. The way it's coded. I know is suppose to make it easier to use for noob like me but I have the exact opposite feeling. The mecanics behind it is hidden and it's difficult to access the code it refers to.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Empish
Veteran
Posts: 221
Joined: Thu Jan 14, 2016 9:52 pm
Projects: Efemural Hearts, It Ends With Graduation
itch: empish
Contact:

Re: Use style (padding) from the namefox to other screen

#6 Post by Empish »

Try making the size 25 and font be a part of the text's properties rather than the notifybox one

Code: Select all

text message:
    size 25
    font "GoodDog.otf"

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#7 Post by sculpteur »

All right, thanks again for you help. I finilly get it working...
And honestly, I don't really know how... coz I still don't understand it ^^

I've spend the entire afternoon doing this :

- read inapprehensible text looking useful from the screen.rpy and gui.rpy
- copy past piece of code
- lunch renpy to see the result
- getting error or see the result
- start again

So just for the record, this my final working notifications screens :

Code: Select all

define gui.message_xalign = 0.5
define gui.notifybox_borders = Borders(26, 4, 26, 8)
define gui.notifybox_tile = False
style notifybox:
    xanchor gui.name_xalign
    xsize gui.namebox_width
    ysize gui.namebox_height
    background Frame("gui/notification_background.png", gui.notifybox_borders, tile=gui.notifybox_tile, xalign=gui.message_xalign)
    padding gui.notifybox_borders.padding
    

screen notification_floating_1(message):
    zorder 100
    window at _notify_transform_float1:
        style "notifybox"
        text message:     
            size 25
            font "GoodDog.otf"
            color "#66cc00"
    timer 2.25 action Hide('notification_floating_1')

screen notification_floating_2(message):
    zorder 100
    window at _notify_transform_float2:
        style "notifybox"
        text message:
            size 25
            font "GoodDog.otf"
            color "#66cc00"
    timer 2.25 action Hide('notification_floating_2')

transform _notify_transform_float1:
    xpos 0.85
    ypos 0.19
    alpha 1.0
    linear 2 ypos 0.16 alpha 0.0
transform _notify_transform_float2:
    xpos 0.85
    ypos 0.22
    alpha 1.0
    linear 2 ypos 0.19 alpha 0.0
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#8 Post by sculpteur »

Lol, i said the entire afternoon. I didn't realized it was night time already ^^
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Use style (padding) from the namefox to other screen

#9 Post by Remix »

Oops, belatedly... something like

Code: Select all

screen notification_floating(message):
    style_prefix = "notifybox" # <- prefix should take the notifybox style and apply it to the window, another style notifybox_text could set styles for the text... I think
    zorder 100

    window:
        text message ## this should use the notifybox_text_ styles from our declaration
... would likely have got further.
Not that I advise going back to square one and starting again.... Been fighting against extending choice button styles here for a few hours... ouch the pain... still fighting
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Use style (padding) from the namefox to other screen

#10 Post by sculpteur »

Yeah I was already suspecting that something shorter and more simple like that would do a better and cleaner job.
But now that my chaotic little code is working, I'am too afraid to modify it again ^^
Anyway, thanks for your answers and good luck against extending choice button styles :)
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Use style (padding) from the namefox to other screen

#11 Post by Remix »

Anyway, thanks for your answers and good luck against extending choice button styles
It's still being a tad pesky, though not had much time to tinker with it today.

A rather useful feature (might need "define config.developer = True" set) is the style inspector...
hover over an item, press Shift+i, find the item in the hierarchy then press Style next to it to show the styles it is picking up
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Adabelitoo