Hi.
In the current settings of my game, up to 9 choices fit on the screen. In a single situation, however, I need to extend this list. Is it possible to put a vertical bar so the player can scroll and see all the possible options?
Or would it be better to make a specific screen just for this part? If this is the best option, could someone explain how to make a screen with the various options and a vertical scrollbar? I tried to make one but the end result was poor (I like to keep the same formatting as the default choice screen, but with a vertical bar).
Add a vertical bar when there are too many choices?
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.
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: Add a vertical bar when there are too many choices?
You have to make an edit to current "screen choice" in "screens.rpy" by add Viewport in:
Code: Select all
screen choice(items):
style_prefix "choice"
if len(items) >= 10:
viewport:
draggable True
mousewheel True
scrollbars "vertical"
xsize gui.choice_button_width
ysize config.screen_height - 180
xalign 0.5
yalign 0.5
vbox:
for i in items:
textbutton i.caption action i.action
else:
vbox:
for i in items:
textbutton i.caption action i.action
Re: Add a vertical bar when there are too many choices?
Thanks!! It worked "almost" perfectly. For some reason, the xalign and yalign are not having any effect (the viewport always starts at pixels 0x0), but I believe it is easy to solve this. I'll read the documentation to try to understand the problem. Bye!
EDIT: I believe I have to adjust the position of the viewport using these commands, but when I enter them in the code, Renpy accuses an error> the object is not adjustable.
xadjustment
The ui.adjustment() used for the x-axis of the viewport. When omitted, a new adjustment is created.
yadjustment
The ui.adjustment() used for the y-axis of the viewport. When omitted, a new adjustment is created.
EDIT: I believe I have to adjust the position of the viewport using these commands, but when I enter them in the code, Renpy accuses an error> the object is not adjustable.
xadjustment
The ui.adjustment() used for the x-axis of the viewport. When omitted, a new adjustment is created.
yadjustment
The ui.adjustment() used for the y-axis of the viewport. When omitted, a new adjustment is created.
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: Add a vertical bar when there are too many choices?
"xalign" and "yalign" both set to 0.5 so viewport should appear in the middle of the screen. Does that not the case?
"xadjustment" and "yadjustment" are the position of "horizontal" and "vertical" scroll. If that's the part you want to move, first declare and assign variable to "ui.adjustment()". Than you can assign value and put them in:
"xadjustment" and "yadjustment" are the position of "horizontal" and "vertical" scroll. If that's the part you want to move, first declare and assign variable to "ui.adjustment()". Than you can assign value and put them in:
Code: Select all
default y_adjustment = ui.adjustment()
screen choice(items):
style_prefix "choice"
python:
y_adjustment.value = float("inf") # start scrollbar at the bottom.
if len(items) >= 10:
viewport:
draggable True
mousewheel True
scrollbars "vertical"
yadjustment y_adjustment
xsize gui.choice_button_width
ysize config.screen_height - 180
xalign 0.5
yalign 0.5
vbox:
for i in items:
textbutton i.caption action i.action
else:
vbox:
for i in items:
textbutton i.caption action i.action
Re: Add a vertical bar when there are too many choices?
No, viewport appears in 0x0.
Using xpos and ypos instead xaling and yalign changes the viewport position, but not the scrollbar position. By the way, I found exactly the same question resolved in this topic:
viewtopic.php?f=8&t=39275&p=420893&hili ... en#p420893
Apparently the problem was solved when the topic author sets xfill parameter for the vbox to True. I tried adding "xfill True" to your code's vbox but nothing happened. I still do not have enough knowledge to understand where I have to change the "xfill" to True.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3791
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Add a vertical bar when there are too many choices?
What happens if you remove 'vbox' and replace it with 'has vbox'?
Remember to correct indentation.
Remember to correct indentation.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Add a vertical bar when there are too many choices?
Nothing changes.
I solved the problem by changing xalign and yalign to xpos and ypos and centering according to the resolution I am using. The bar is half misaligned, as much as I try to adjust the size of the viewport, the bar is not aligned right, but I think it will be the only way to solve this, since xalign and yalign, for some reason that escapes me, has no effect in viewport.
Who is online
Users browsing this forum: Google [Bot]