[SOLVED] Applying a style (group) to textbox with id window

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
User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

[SOLVED] Applying a style (group) to textbox with id window

#1 Post by SinnyROM » Mon Jun 22, 2015 2:12 pm

For a while, I've been hardcoding my say screen because of this issue: the style or style group isn't applied to the textbox. The namebox styling works, but not the textbox. After some tinkering, I found that with id "window" the style isn't applied, but removing it will make it work as it should. Could anyone enlighten me on how and why this works? I have a game planned that will call on changing the style of the say screen and I want to use styles to make it easier to change later.

Code: Select all

init python:

    # style setting
    persistent.style = "1"

    # style 1: red
    namebox1 = Frame("#f00c",0,0)
    textbox1 = Frame("#ff0c",0,0)

    # style 2: blue
    namebox2 = Frame("#00fc",0,0)
    textbox2 = Frame("#0ffc",0,0)

init:
    # Namebox
    style namebox1_window is say_who_window:
        background namebox1
    style textbox2_window:
        background textbox2

    # Textbox
    style textbox1_window:
        background textbox1
    style namebox2_window is say_who_window:
        background namebox2

Code: Select all

screen say(who, what, side_image=None, two_window=False):

    # Style changer
    frame:
        has vbox
        textbutton "Style 1: red" action SetField(persistent, "style", "1")
        textbutton "Style 2: blue" action SetField(persistent, "style", "2")

    # The two window variant.
    vbox:
        style "say_two_window_vbox"
        if who:
            window:
                # style "say_who_window"
                if persistent.style == "1":
                    style_group "namebox1"
                else:
                    style_group "namebox2"
                
                text who:
                    id "who"

        window:
            id "window"
            if persistent.style == "1":
                style_group "textbox1"
            else:
                style_group "textbox2"
                    
            vbox:
                style "say_vbox"

                text what id "what"
Last edited by SinnyROM on Mon Jun 22, 2015 10:35 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Applying a style (group) to textbox with id "window"

#2 Post by PyTom » Mon Jun 22, 2015 8:20 pm

It's probably being overridden by the style taken from the Character. You can either get rid of id "window", or pass window_style="my_window_style" into the Character objects. (Doing the former will prevent any of the "window_" arguments to Character from working - which isn't a big loss, IMO.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: Applying a style (group) to textbox with id "window"

#3 Post by SinnyROM » Mon Jun 22, 2015 9:53 pm

So that's it, Character's window style is the default window style and it took priority over the style group. That makes some sense now.

I'm most likely going to go with the former, but are there any consequences to removing the window id? I noticed in the documentation that it's only a convention, as opposed to keeping the id on what.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Applying a style (group) to textbox with id "window"

#4 Post by PyTom » Mon Jun 22, 2015 10:11 pm

The only consequence is that window_<whatever> parameters to Character stop working. Screens generally make those redundant, so it's unlikely to be a change that will hurt you.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: Applying a style (group) to textbox with id "window"

#5 Post by SinnyROM » Mon Jun 22, 2015 10:35 pm

That's good to know. Thanks!

Post Reply

Who is online

Users browsing this forum: Ocelot