Ren'Py renpy.register_style_preference

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
I'm changing the textbox on button click:

renpy.register_style_preference("txtbox", "off", style.say_dialogue, "outlines", [ (absolute(2), "#000", absolute(1), absolute(1)) ])

Works well so far, but once this is triggered and I want to change the style back to normal, the outline stays, so how do I tell renpy to do the opposite, to not use outline in this case?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
Works well so far, but once this is triggered and I want to change the style back to normal, the outline stays, so how do I tell renpy to do the opposite, to not use outline in this case?
Right now I can only think about defining a blank one :
Either with renpy.register_style_preference("txtbox", "off", style.say_dialogue, "outlines", []) or with renpy.register_style_preference("txtbox", "off", style.say_dialogue, "outlines", [ (0, "#000", 0, 0) ]) if the first one don't works.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Right now I can only think about defining a blank one :
Either with renpy.register_style_preference("txtbox", "off", style.say_dialogue, "outlines", []) or with renpy.register_style_preference("txtbox", "off", style.say_dialogue, "outlines", [ (0, "#000", 0, 0) ]) if the first one don't works.
The first one works, thx.
Another, similiar question:
If I register a background first renpy.register_style_preference("txtbox", "off", style.window, "background", Image("images/bg.png", xalign=0.5, yalign=1.0))

and try to hide it afterwards, I would usually use background none, but it seem that "none" doesn't work on init. So I use a transparent image, but out of interest, is there a way without using an image?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
I would usually use background none, but it seem that "none" doesn't work on init. So I use a transparent image, but out of interest, is there a way without using an image?
It's None, with the uppercase "N". Verify that you haven't also made the typo in your code, because normally it should works. It's the only way to reset the background. Else it's what you already do, using a transparent image. The only other alternative is to use a ( "#00000000" ), but it will be expanded to the whole background, while a 1x1 image will stay like this and so need less works coming from Ren'py.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
It's None, with the uppercase "N". Verify that you haven't also made the typo in your code, because normally it should works. It's the only way to reset the background. Else it's what you already do, using a transparent image. The only other alternative is to use a ( "#00000000" ), but it will be expanded to the whole background, while a 1x1 image will stay like this and so need less works coming from Ren'py.
That's the first thing I tried, lower and uppercase, brackets, no brackets. No matter what I tried, nothing worked.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
That's the first thing I tried, lower and uppercase, brackets, no brackets. No matter what I tried, nothing worked.
It's weird :/ According to the , "If None, no background is drawn, but other properties function as if the background was present."
Well, sorry, I don't see another solution than using a transparent image.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
It's weird :/ According to the , "If None, no background is drawn, but other properties function as if the background was present."
Well, sorry, I don't see another solution than using a transparent image.
That seems to be something renpy specific. That would at least explain why it doesn't work on init.
Anyway, thanks again :)
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Me again and I'm about to freak out >_<
Still working on the same, but now I'm on the styling. This should be the most simple thing in the world, I want the active button to look like the non-active button:
Python:
screen bla:
    style_prefix "txtbox"
    textbutton _("Yes") ...
    textbutton _("No") ...
    
style txtbox_button is default
style txtbox_button_text is button_text
    
style txtbox_button_text:
    selected_insensitive_color "#000"
    color "#000"
    selected_color "#000"
    selected_hover_color "#000"
^ but of course nothing works, no matter what color, or prefix I use, nothing changes. I even tried to use the choice_button style, but even then, no change at all. No error, no nothing o_O
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
Me again and I'm about to freak out >_<
Still working on the same, but now I'm on the styling. This should be the most simple thing in the world, I want the active button to look like the non-active button:
Then do the opposite.

The propagate their value starting by the non-prefixed value. Therefore if you write :
Code:
style txtbox_button_text is button_text:
    color "#0F0"
    hover_color "#F00"
Both active and non-active buttons will have their text displayed in green. And you don't need more since non-active button can't be hovered nor selected.

If it still don't works for you, then somewhere you are redefining again the style or, for a reason or another, it's not this style that is applied to the button. To verify this, use the style inspector ; put the mouse over the button, then press Shift + i (need the developer mode enabled). If the name of the style is correct, click on it to have its definition.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Then do the opposite.

The propagate their value starting by the non-prefixed value. Therefore if you write :
Code:
style txtbox_button_text is button_text:
    color "#0F0"
    hover_color "#F00"
Both active and non-active buttons will have their text displayed in green. And you don't need more since non-active button can't be hovered nor selected.

If it still don't works for you, then somewhere you are redefining again the style or, for a reason or another, it's not this style that is applied to the button. To verify this, use the style inspector ; put the mouse over the button, then press Shift + i (need the developer mode enabled). If the name of the style is correct, click on it to have its definition.
That's the problem:
1568737900021.png
Python:
screen showtextbox:
    style_prefix "txtbox"
    ...
    
style txtbox_button_text is button_text:
    ...
Even if the style is overwritten somewhere, it should be visible in the style inspector... right?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
Even if the style is overwritten somewhere, it should be visible in the style inspector... right?
Yes.

Try by forcing the style, textbutton "something" style "txtbox_button", to see if it change something.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Doesn't work as well, the only thing that changes, is that the button text is handled as normal text (no hover or active, etc effect at all). I also tried a different random name for the style, just to make sure that it doesn't exist somewhere in the code. Then I added a vbox, to see if it changes something... no luck :/
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,268
Doesn't work as well, the only thing that changes, is that the button text is handled as normal text (no hover or active, etc effect at all).
Which is what is supposed to happen. Then for the other style properties that possibly have a insensitive variant, you do the same, redefining them by giving a value to the non-prefixed attribute.
So, if the original style is, by example :
Code:
style button:
    insensitive_background Solid( "#00F" )
    insensitive_xalign 0.1
style button_text:
    insensitive_outlines [ ( 10, "#0FF", 1, 1 ) ]
    insensitive_color "#F00"
Then your own button must start like this :
Code:
style txtbox_button is button:
    background Solid( "#0F0" )
    xalign 0.5
style txtbox_button_text is button_text:
    outlines []
    color "#FF0"
This will revert all the "insensitive_" style properties and give them the same value than for an active button. Starting this base you can add your own parts.
 
  • Like
Reactions: recreation

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
Which is what is supposed to happen. Then for the other style properties that possibly have a insensitive variant, you do the same, redefining them by giving a value to the non-prefixed attribute.
So, if the original style is, by example :
Code:
style button:
    insensitive_background Solid( "#00F" )
    insensitive_xalign 0.1
style button_text:
    insensitive_outlines [ ( 10, "#0FF", 1, 1 ) ]
    insensitive_color "#F00"
Then your own button must start like this :
Code:
style txtbox_button is button:
    background Solid( "#0F0" )
    xalign 0.5
style txtbox_button_text is button_text:
    outlines []
    color "#FF0"
This will revert all the "insensitive_" style properties and give them the same value than for an active button. Starting this base you can add your own parts.
got it, that works:
Python:
screen showtextbox:
    textbutton _("Yes") action [ StylePreference("txtbox", "on"), Return(True) ] yalign .45 style "textbox"
    textbutton _("No") action [ StylePreference("txtbox", "off"), Return(True) ] yalign .5 style "textbox"
    
    
style textbox is button:
    xalign .5
style textbox_text is button_text:
    color "#fff"
    selected_color "#fff"
    hover_color "#666"
    selected_hover_color "#666"
Thanks again!
 
  • Like
Reactions: anne O'nymous