Having some problems with styles

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
arlj11
Regular
Posts: 30
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Having some problems with styles

#1 Post by arlj11 »

I have several problems that I am trying to solve.

First one is getting my game to use a style.

I have a bright spot in a background under some white text. I would like to give the text box a dark background to make it readable. I've tried setting up a style with the dark background. But the game isn't showing it.
What am I doing wrong?

The styles are in one file while the screen is in another file if that helps.

Code: Select all

init offset = -1

style CharProfile_hbox:
    spacing 50

style CharProfile_vbox:
    background Solid("#0008")

style CPBack:
    background Solid("#0008")

Code: Select all

screen CharacterProfile(pic, name, gender, orientation, description):
    tag CharSelection
    style_prefix "CharProfile"
    default Pronoun = "Her"
    if gender == "Male":
        $ Pronoun = "Him"

    hbox:
        yalign 0.5
        xalign 0.5
        spacing 40

        add pic
        vbox:
            yalign 0.25
            xmaximum 0.25
            grid 2 3:
                text "Name:"
                text name
                text "Gender:"
                text gender
                text "Orientation:"
                text orientation
            text "Description: [description]"
            text "Do you want to choose [Pronoun]?"
            hbox:
                textbutton "Yes" action Return()
                textbutton "No" action Jump("Selection")
Also, how do I style individual buttons in a menu. For example make one red using TintMatrix. It throws an error when I add a style to a menu line.

Example Style:

Code: Select all

style EventButton:
    background TintMatrix("#f00")

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Having some problems with styles

#2 Post by jeffster »

arlj11 wrote: Thu Apr 04, 2024 8:22 am

Code: Select all

style CharProfile_vbox:
    background Solid("#0008")
Instead of background Solid("#0008"), we can use
background "#0008"

Boxes (and grids) don't have "background" property.
https://renpy.org/doc/html/style_proper ... properties

To use background with vbox, we can wrap them in "frame".
https://renpy.org/doc/html/style_proper ... properties

I.e. instead of

Code: Select all

        vbox:
            #...
use

Code: Select all

        frame:
            background "#0008"
            vbox:
                #...
or (just a little difference in syntax)

Code: Select all

        frame:
            background "#0008"
            has vbox
            #...
Check with shift-i pointing at an element, which styles affect it. (Sometimes it's not quite obvious).
https://renpy.org/doc/html/developer_to ... inspecting

Another way to show bright text on bright background is using outlines:

Code: Select all

style CharProfile_text:
    outlines [(4, "#0006", 1, 1), (2, "#000C")]
Why this doesn't work:

Code: Select all

style EventButton:
    background TintMatrix("#f00")
My guess is that TintMatrix is a property for Transform, not a displayable.
https://renpy.org/doc/html/matrixcolor.html#matrixcolor
Anyways it doesn't make sense to set background color with TintMatrix. We set the button's background as

Code: Select all

    background "#f00"
Or if we want to recolor all the content of the button then we use "at":
https://renpy.org/doc/html/screens.html ... statements

Code: Select all

    button:
        at transform:
            matrixcolor TintMatrix("#F88")

arlj11
Regular
Posts: 30
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Re: Having some problems with styles

#3 Post by arlj11 »

Your frame trick worked.

Adding Transform to the menu button throws the "expected statement" error at the transform line.

I would like it to be a style if possible so that if I wanted to update it, I can do it once and not have to change every button.

Post Reply

Who is online

Users browsing this forum: decocloud, Google [Bot]