How to make the background inherit styles correctly?

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
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

How to make the background inherit styles correctly?

#1 Post by Chekhov »

Okay, so it's the first time I'm working with styles in ren'py and I'm running into a wall.

In this case I'm working on the "History" game screen. I'm trying to darken the area behind the lines of text.

I've got an image with less than 100% opacity. However, when I style it this way

Code: Select all

style history_window:
	"gui/history_bg.png"
It doesn't come out quite right, because sometimes it is a pixel more and sometimes a pixel less, which works poorly for an image with some transparency. (It's very noticable when it overlaps).

so instead I added a vbox and try to style that instead:

Code: Select all

style history_window:
style history_vbox:
    background "gui/history_bg.png"
Through testing and inspection I can see that other styles that I apply get applied, but not the background image. I would have expected this to add the background to the items in it, but that doesn't seem to appear how it works. How can I make a background, overlayed on the general background of the menu, and underlayed to the text of history_window?
inheritance.JPG

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

Re: How to make the background inherit styles correctly?

#2 Post by Ocelot »

vbox does not have background property, so it is natural that it does not apply something that cannot be applied.

I have a gard time grasping what you exactly trying to od, what does "sometimes it is a pixel more and sometimes a pixel less" means? How are you trying to do this.

When I need to darken background, I usually place a semitransparent grey rectangle between background and text.
< < insert Rick Cook quote here > >

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: How to make the background inherit styles correctly?

#3 Post by zmook »

Chekhov wrote: Sat Dec 04, 2021 5:40 am

Code: Select all

style history_window:
	"gui/history_bg.png"
If this is your actual code, the problem is that you're missing the property name, `background`.

Code: Select all

style history_window:
	background "gui/history_bg.png"
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

Re: How to make the background inherit styles correctly?

#4 Post by Chekhov »

Ocelot wrote: Sat Dec 04, 2021 7:22 am vbox does not have background property, so it is natural that it does not apply something that cannot be applied.

I have a gard time grasping what you exactly trying to od, what does "sometimes it is a pixel more and sometimes a pixel less" means? How are you trying to do this.

When I need to darken background, I usually place a semitransparent grey rectangle between background and text.
Hmm, okay, I wanted to show it with a new project, but I discovered that it worked there perfectly without the 1 pixel more or less overlap, so something somewhere else has gone wonky, so it's just regular old bug searching I guess. Thanks though!

zmook wrote: Sat Dec 04, 2021 10:56 am
Chekhov wrote: Sat Dec 04, 2021 5:40 am

Code: Select all

style history_window:
	"gui/history_bg.png"
If this is your actual code, the problem is that you're missing the property name, `background`.

Code: Select all

style history_window:
	background "gui/history_bg.png"
Thanks! Good catch, but it was a copy paste error. The code did have "background".

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: How to make the background inherit styles correctly?

#5 Post by zmook »

If you paste your whole screen code, including the style statements, one of us might spot the bug.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

Post Reply

Who is online

Users browsing this forum: Kocker