I am messing around with choice button styles at the moment and have all my choices arranged in a nice horizontal line (hbox) now instead of the usual virtical list (vbox)
The problem I am having is that if the text for a particular choice wraps then its button grows both up and down to accomodate the text. What I would like is for it to grow up or down then I can position the choices bar correctly releative to the screen contants.
Is there any easy way to tell a choice button which direction to grow in?
Text wrapping and button growth direction
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.
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.
-
- Newbie
- Posts: 15
- Joined: Thu Apr 12, 2018 5:55 am
- Contact:
Re: Text wrapping and button growth direction
Check the code of your choice screen and instead of align set pos and anchor for your hbox.
-
- Newbie
- Posts: 15
- Joined: Thu Apr 12, 2018 5:55 am
- Contact:
Re: Text wrapping and button growth direction
OK, looked at the docs and very confused by "anchor". Currently I have my screen defined as 2560x1440 and this for my choice box
How would I alter this so it works the same except for the text growing down towards the bottom of the screen?
Sorry for being a bit thick
Code: Select all
screen choice(items):
style_prefix "choice"
hbox:
xalign 0.5
yalign 0.9
for i in items:
textbutton i.caption action i.action
Sorry for being a bit thick
Re: Text wrapping and button growth direction
When you use 'align' or 'pos', it will not in fact target the whole widget: it will align one pixel and the rest will follow. Anchor set the coordinates of that pixel.
Let's say you are showing a simple picture: using 'xanchor 0.0 yanchor 0.0' will align the first pixel on the top left to the set coordinates, and the picture will be arranged to the right and down from there. Conversely, using 'xanchor 1.0 yanchor 1.0' will align the bottom right pixel and the picture will be displayed up and left from there. Using 'xanchor 0.5 yanchor 0.5' will center the picture on the aligned coordinates.
To make matters more confusing, I believe text within a textbutton also has its own anchor properties, which are accessed by using the 'text_' prefix.
So, will set the text anchor to the top left of the text.
TL/DR: Use 'text_yanchor 0.0' to make your text grow down within a textbutton.
Let's say you are showing a simple picture: using 'xanchor 0.0 yanchor 0.0' will align the first pixel on the top left to the set coordinates, and the picture will be arranged to the right and down from there. Conversely, using 'xanchor 1.0 yanchor 1.0' will align the bottom right pixel and the picture will be displayed up and left from there. Using 'xanchor 0.5 yanchor 0.5' will center the picture on the aligned coordinates.
To make matters more confusing, I believe text within a textbutton also has its own anchor properties, which are accessed by using the 'text_' prefix.
So,
Code: Select all
textbutton text_xanchor 0.0 text_yanchor 0.0
TL/DR: Use 'text_yanchor 0.0' to make your text grow down within a textbutton.
-
- Newbie
- Posts: 15
- Joined: Thu Apr 12, 2018 5:55 am
- Contact:
[solved]Text wrapping and button growth direction
Thanks for all the help guys. This worked for me:
Code: Select all
screen choice(items):
style_prefix "choice"
hbox:
xalign 0.5
yalign 0.9
xanchor 0.5
yanchor 0.0
for i in items:
textbutton i.caption action i.action
Who is online
Users browsing this forum: Bing [Bot]