[SOLVED] How to use 2 style prefixes for one element?

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
span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

[SOLVED] How to use 2 style prefixes for one element?

#1 Post by span4ev » Sat Jul 09, 2022 10:37 pm

Just tell me if this is in Renpy or should I use more obvious methods?

I have a screen, it has a frame, it has a few more frames.
Is it possible to make one style prefix for the first frame (background color, padding position) and a separate prefix for child elements?

I tried like this but it didn't work:
(This is just the simplest example so as not to load the example with unnecessary code)

Code: Select all

screen statsDetail():

    ???   style_prefix 'statsDetail_outer statsDetail_inner'  ???

    frame:

        grid 2 1:

            frame:
                vbox:
                    text '123s'
                    text '123s'

            frame:
                vbox:
                    text '345'      
                    text '63634'   


style statsDetail_outer_frame:
    margin(120, 10)
    background '#21293a'
    padding
    something else

style statsDetail_inner_frame:
    background '#21293a'
    margin(10, 10)
    ...

style statsDetail2inner_vbox:
    background '#293448'
    padding(10,10)
    ...
Why do I want to do this?
Because I want to set several changes for the first frame, but I don't want to write a prefix for each inner frame separately.

There is still a nuance: if I write the style for the first frame inside the frame itself, and for the child elements I use the style override by prefix, then I will have to override all changes for the first frame. For example, for child frames, I will specify indents 30, 30, but because of the prefix, these indents will be applied to the first frame, which means I will have to remove the indents (0,0) for it separately.
This applies to all other changes: width, height, alignment, etc.

Or maybe it's possible to specify a child element, as is done in CSS

Code: Select all

# this option does not throw an error, but the styles do not work at all
style_prefix 'statsDetail_outer statsDetail_inner'

# this option gives an error and swears that two prefixes are used
style_prefix 'statsDetail_outer'
style_prefix 'statsDetail_inner'

# style_prefix 'statsDetail_outer, statsDetail_inner'
# style_prefix 'statsDetail_outer' 'statsDetail_inner'
# style_prefix 'statsDetail_outer', 'statsDetail_inner'
Last edited by span4ev on Sat Oct 15, 2022 5:02 am, edited 1 time in total.

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

Re: How to use 2 style prefixes for one element?

#2 Post by Ocelot » Sun Jul 10, 2022 2:51 am

Instead of messing with style prefficses, just set an unique suffix to the first frame:

Code: Select all

screen test():
    style_prefix 'test_prefix'
    frame:
        style_suffix 'unique_frame'
        # style test_prefix_unique_frame
        frame:
            # style test_prefix_frame
< < insert Rick Cook quote here > >

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to use 2 style prefixes for one element?

#3 Post by span4ev » Sun Jul 10, 2022 3:56 am

Ocelot wrote:
Sun Jul 10, 2022 2:51 am
Instead of messing with style prefficses, just set an unique suffix to the first frame:

Code: Select all

screen test():
    style_prefix 'test_prefix'
    frame:
        style_suffix 'unique_frame'
        # style test_prefix_unique_frame
        frame:
            # style test_prefix_frame
Thanks for the reply and advice.
style_suffix - I didn't know about this thing

I'm sorry I don't know how to mark your comment as "answered"

Post Reply

Who is online

Users browsing this forum: Alex, nyeowmi