Trying to pull out text properties from say_dialogue style

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
Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Trying to pull out text properties from say_dialogue style

#1 Post by Alem » Mon May 08, 2017 3:54 am

Hello! I want to let players decide which font to use inside the main say box from the predefined number of options. Thanks to Ren'py manual and community I managed to get this done and now it's time to put a finishing touch - a test string to show how the resulting text will look like. Otherwise, players would need to leave preferences menu to see the outcome and go back if they don't like it.

I've created another hbox below the switching option, but I don't know how to pull the text properties from the say_dialogue style. Linking it directly to the hbox causes problems - the test string disappears and the alignment goes awry.

Is there a method to pull current text properties from a specific style but nothing else? Or maybe there is a more convenient way to achieve the result I seek?

Thank you.

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#2 Post by philat » Mon May 08, 2017 6:40 am

Why would you need to pull it from the say_dialogue style? Presumably you are using a button to set the style in the first place in the same preference menu.

Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#3 Post by Alem » Mon May 08, 2017 2:42 pm

philat wrote:Why would you need to pull it from the say_dialogue style? Presumably you are using a button to set the style in the first place in the same preference menu.
Yes, the button is in the preference menu. Here's the code to clear things up:

Code: Select all

                vbox:

                    label _("Choose the narrative font")
                        
                    hbox:   
                        textbutton "Garamond" action StylePreference ("text", "Garamond")
                        textbutton "Efron" action StylePreference ("text", "Efron")
                        textbutton "Sans" action StylePreference ("text", "Sans")
                        textbutton "Serif" action StylePreference ("text", "Serif")

                    hbox:
                        text _("Ingame story text will look like this")
I add said fonts with this:

Code: Select all

    renpy.register_style_preference("text", "Efron", style.say_dialogue, "font", "Efron.ttf")
    renpy.register_style_preference("text", "Efron", style.say_dialogue, "size", 34)
    renpy.register_style_preference("text", "Efron", style.say_dialogue, "color", "#000000")

    renpy.register_style_preference("text", "Serif", style.say_dialogue, "font", "PTSerif.ttf")
    renpy.register_style_preference("text", "Serif", style.say_dialogue, "size", 34)
    renpy.register_style_preference("text", "Serif", style.say_dialogue, "color", "#000000")
So, I want to dynamicly change the test string sitting under the font buttons depending on the current font of the main text box. I tried linking say_dialogue to hbox, but it turns out ugly. If there is better way, please do enlighten me - I'm not familiar with coding yet.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#4 Post by Divona » Mon May 08, 2017 4:20 pm

Do this:

Code: Select all

                    hbox:
                        text _("Ingame story text will look like this") style style.say_dialogue
Completed:
Image

Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#5 Post by Alem » Tue May 09, 2017 4:32 am

Divona wrote:Do this:

Code: Select all

                    hbox:
                        text _("Ingame story text will look like this") style style.say_dialogue
Thanks, but linking it directly like this forces (or at least I think so?) the text to use all the settings from the say_dialogue style including placement. In the result, I can't even see the string properly - it slides off. That's why I'm trying to pull only the font/text properties from it.

I also tried to do this with style.say_dialogue.text and Ren'py gives me an exception about the missing attribute for the style.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#6 Post by Divona » Tue May 09, 2017 9:44 am

Then just give the text or hbox xpos, ypos that you want it to appears on screen.
Completed:
Image

Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Re: Trying to pull out text properties from say_dialogue sty

#7 Post by Alem » Wed May 10, 2017 2:01 pm

After some poking around I ended up with this:

Code: Select all

                    hbox:

                        text _("Ingame story text will look like this") font style.say_dialogue.font size style.say_dialogue.size color style.say_dialogue.color

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], span4ev