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.
-
RicharDann
- Veteran
- Posts: 284
- Joined: Thu Aug 31, 2017 11:47 am
-
Contact:
#1
Post
by RicharDann » Wed Nov 11, 2020 1:39 pm
I'm trying to implement styles to be able to test properties easily and reuse them in multiple screens, but I can't get the
style_prefix property to work. Here's a simplified example of my current code:
Code: Select all
screen talk_menu():
style_prefix 'talk'
frame:
align (.1,.5)
has vbox
textbutton _("Chat") action NullAction()
textbutton _("Nevermind") action Return()
style talk_textbutton:
xalign .5
I want every textbutton in the screen to take position and other properties from style talk_textbutton. If I manually add
xalign .5 to every button, it works, but that would defeat the purpose specially if I decide to change fonts or other properties later, I would have to do so for every screen element, which would be very time consuming and error-prone. This might be a bug, but I have the feeling that either I misunderstand how style_prefix works or am I missing something.
Last edited by
RicharDann on Wed Nov 11, 2020 4:23 pm, edited 1 time in total.
The most important step is always the next one.
-
Vladya
- Regular
- Posts: 34
- Joined: Sun Sep 20, 2020 3:16 am
- Github: NyashniyVladya
-
Contact:
#2
Post
by Vladya » Wed Nov 11, 2020 3:19 pm
Hi. Your logic is correct, but the keywords are not. If you want to specify button properties for textbutton, use the postfix "button", if the text properties, use "button_text".
Example:
Code: Select all
screen talk_menu():
style_prefix 'talk'
frame:
align (.1,.5)
has vbox
textbutton _("Chat") action NullAction()
textbutton _("Nevermind") action Return()
style talk_button:
xalign .5
style talk_button_text:
size 100
-
RicharDann
- Veteran
- Posts: 284
- Joined: Thu Aug 31, 2017 11:47 am
-
Contact:
#3
Post
by RicharDann » Wed Nov 11, 2020 4:23 pm
Ah, I see what I did wrong. I incorrectly assumed textbutton was a separate element from button, when it is actually just a button with a text label.
Thank you so much for your help!
The most important step is always the next one.
Users browsing this forum: Bing [Bot]