[Solved]Issues with Styling Say 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
DFlimbingo
Regular
Posts: 25
Joined: Wed Mar 24, 2021 2:37 am
Contact:

[Solved]Issues with Styling Say screen

#1 Post by DFlimbingo »

Hey! I'm trying to style my say screen to allow for two different textboxes and dialogue styles, which switches based on a variable. Here's what I have so far, in its own .rpy file called cinematicscreen:

Code: Select all

screen say(who, what):
    if textstyle == 1:
        style_prefix "say"
        window:
            id "window"

            if who is not None:

                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"

            text what id "what"
    elif textstyle == 2:
        style_prefix "say2"
        window:
            style "window2"

            if who is not None:

                window:
                    id "namebox2"
                    style "namebox2"
                    text who id "who"

            text what id "what"
This is the entire Say screen, and the 'textstyle' variable is what changes to allow for two different textbox styles. My issue is that while style window2 and namebox2 both work, say2 appears to not be working at all.

This is what I did for say2, which was essentially copied from say_dialogue:

Code: Select all

style say2_dialogue2:
    properties gui.text_properties("dialogue2")

    xpos 280
    xsize 744
    ypos 10
I've also attempted to try to copy and change the many define gui.dialogue items, to no affect.

Code: Select all

define gui.dialogue2_xpos = 100
define gui.dialogue2_ypos = 10
define gui.dialogue2_width = 780
define gui.dialogue2_text_xalign = 0.0
Essentially, how do I change the style of the dialogue fonts so I can allow for two different types depending on the textstyle variable? The window and namebox all work fine, its only the dialogue itself that isn't working right. I really don't know what I'm doing, so I knew the 'add a 2 at the end of the name' would stop working eventually ^-^;
Last edited by DFlimbingo on Sun Oct 24, 2021 2:07 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Issues with Styling Say screen

#2 Post by Ocelot »

The style of text is controlled by what_style provided by character object. The default what_style is say_dialogue
Instead of doubling your screen size, have you considered simply changing styles for say screen? Style Preferences would work well for that.
< < insert Rick Cook quote here > >

DFlimbingo
Regular
Posts: 25
Joined: Wed Mar 24, 2021 2:37 am
Contact:

Re: Issues with Styling Say screen

#3 Post by DFlimbingo »

Ocelot wrote: Sat Oct 23, 2021 7:19 am The style of text is controlled by what_style provided by character object. The default what_style is say_dialogue
Instead of doubling your screen size, have you considered simply changing styles for say screen? Style Preferences would work well for that.
That definitely sounds like what I'm looking for! Although I'm just not sure how to implement style preferences into the current system. If I use the provided example with renpy.register_style_preference, it works, but text_cps appears to stop working and the entire text appears instantly on the screen (text bleeps also continue infinitely, but I assume that will be fixed once the cps is fixed). Here's what I added:

Code: Select all

init python:
    renpy.register_style_preference("text", "say2", style.say_dialogue, "color", "#0d0e3d")
    renpy.register_style_preference("text", "say2", style.say_dialogue, "xpos", 280)

# because i didnt know how to return these values to their defaults, these are the defaults again to return to
    renpy.register_style_preference("text", "say1", style.say_dialogue, "color", "#ffffff")
    renpy.register_style_preference("text", "say1", style.say_dialogue, "xpos", 40)
and this is what i changed from the original code from my first post.

Code: Select all

screen say(who, what):
    if textstyle == 1:
        on "show" action StylePreference("text", "say1")
        style_prefix "say"
        window:
            id "window"

            if who is not None:

                window:
                    id "namebox"
                    style "namebox"
                    text who id "who"

            text what id "what"
    elif textstyle == 2:
        on "show" action StylePreference("text", "say2")
        style_prefix "say"
        window:
            style "window2"

            if who is not None:

                window:
                    id "namebox2"
                    style "namebox2"
                    text who id "who"

            text what id "what"

DFlimbingo
Regular
Posts: 25
Joined: Wed Mar 24, 2021 2:37 am
Contact:

Re: Issues with Styling Say screen

#4 Post by DFlimbingo »

Well, I've managed to fix the text speed issue. However, now the ctc icon doesn't appear and the infinite text bleeps sound is still an issue. I simply did this to add the cps back in:

Code: Select all

renpy.register_style_preference("text", "say2", style.say_dialogue, "slow_cps", True)
However, I feel like there must be something else I'm doing wrong here that's leading to me needing to constantly fix the new issues. I'm not sure why the text bleep and ctc functions are getting upset by Style Preferences. If you have any tips about that, it'd be really appreciated! ^-^

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Issues with Styling Say screen

#5 Post by Ocelot »

Remove two kinds of say screen completely, the whole point of using preferences was to avoid that.

Code: Select all

screen say(who, what):
    style_prefix "say"
    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"
Instead, every time where you change textstyle variable just switch style preferences in Python code: renpy.set_style_preference("text", "say1")
Having action which restarts interaction on show might screw code which depends on events.
< < insert Rick Cook quote here > >

DFlimbingo
Regular
Posts: 25
Joined: Wed Mar 24, 2021 2:37 am
Contact:

Re: Issues with Styling Say screen

#6 Post by DFlimbingo »

Alright, that worked! All I did was use

Code: Select all

$ renpy.set_style_preference("text", "say1")
and everything fixed itself. Thank you!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], henne