I think I'll keep it short since my English isn't the best.
I want the choice screen to be scrollable if there are too many choices for the screen. First it was easy, but then I thought "Wouldn't it be nice if the scrollable screen looked different than the normal one?" And then the trouble began. After many attempts without the slightest progress I'lljust post my first version here because shows my problem just as well as the others without being confusing.
Code: Select all
init offset = -1
define gui.choice_button_height = None
$ choiceboxrender = renpy.render(ui.vbox(id="choicebox"), 1280, 720, 0, 0)
$ sizes = choiceboxrender.get_size()
$ sizey = sizes[1]
$ If(sizey>570,thumbx=570*457/sizes[1])
screen choice(items):
modal False
fixed:
yalign 0.5
xalign 0.5
xmaximum 900
ymaximum 720
if sizey>570:
add "gui/log_decor_top.png" at gui_buttonfade_enter(0.5):
xalign 0.5 ypos 69
add "gui/log_decor_top.png" at gui_buttonfade_enter(0.5):
xalign 0.5 ypos 651
viewport id "vp":
mousewheel True
draggable False
xfill True
ypos 75
ysize 570
yinitial 0.0
vbox id "choicebox":
xsize 900
xalign 0.5
first_spacing 35
spacing 20
for i in items:
button:
text i.caption style "choice_button_text"
hovered Play("system",guisfx_button_hover)
action [Play("system",guisfx_button_click),i.action]
xalign 0.5
ysize None
at gui_buttonfade_enter(0.5)
vbar:
value YScrollValue("vp")
xsize 10
ysize 457
xpos 1028
yalign 0.5
thumb_shadow None
thumb Frame("gui/log_idle_thumb.png",10,thumbx)
hover_thumb Frame("gui/log_idle_thumb.png",10,thumbx)
base_bar "gui/log_idle_bar.png"
hover_base_bar "gui/log_idle_bar.png"
hovered Play("system",guisfx_button_hover)
unscrollable "hide"
at gui_buttonfade_enter(0.5)
else:
vbox id "choicebox":
xsize 900
xalign 0.5
yalign 0.5
yoffset -76
spacing 20
for i in items:
button:
text i.caption style "choice_button_text"
hovered Play("system",guisfx_button_hover)
action [Play("system",guisfx_button_click),i.action]
xalign 0.5
ysize None
at gui_buttonfade_enter(0.5)
style choice_button_text is default:
font gui.adv_font_face
size 22
color gui.adv_font_color
kerning gui.advname_font_kerning * 0.5
outlines [ (absolute(2), "#000", absolute(3), absolute(2)) ]
text_align 0.5
bold True
line_spacing 5
It always shows me this error message.
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/Special Events.rpy", line 55, in script
menu:
File "game/gui_scripts/screenChoices.rpy", line 10, in execute
##
File "game/gui_scripts/screenChoices.rpy", line 10, in execute
##
File "game/gui_scripts/screenChoices.rpy", line 13, in execute
style choice_button is default:
File "game/gui_scripts/screenChoices.rpy", line 19, in execute
NameError: name 'sizey' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/Special Events.rpy", line 55, in script
menu:
File "[folder]\Ren'Py\renpy\ast.py", line 1564, in execute
choice = renpy.exports.menu(choices, self.set)
File "[folder]\Ren'Py\renpy\exports.py", line 917, in menu
rv = renpy.store.menu(items)
File "[folder]\Ren'Py\renpy\exports.py", line 1110, in display_menu
rv = renpy.ui.interact(mouse='menu', type=type, roll_forward=roll_forward)
File "[folder]\Ren'Py\renpy\ui.py", line 289, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "[folder]\Ren'Py\renpy\display\core.py", line 2672, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "[folder]\Ren'Py\renpy\display\core.py", line 3059, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "[folder]\Ren'Py\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "[folder]\Ren'Py\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "[folder]\Ren'Py\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "[folder]\Ren'Py\renpy\display\screen.py", line 424, in visit_all
callback(self)
File "[folder]\Ren'Py\renpy\display\core.py", line 3059, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "[folder]\Ren'Py\renpy\display\screen.py", line 434, in per_interact
self.update()
File "[folder]\Ren'Py\renpy\display\screen.py", line 619, in update
self.screen.function(**self.scope)
File "game/gui_scripts/screenChoices.rpy", line 10, in execute
##
File "game/gui_scripts/screenChoices.rpy", line 10, in execute
##
File "game/gui_scripts/screenChoices.rpy", line 13, in execute
style choice_button is default:
File "game/gui_scripts/screenChoices.rpy", line 19, in execute
File "<screen language>", line 19, in <module>
NameError: name 'sizey' is not defined
Windows-8-6.2.9200
Ren'Py 7.1.3.1092
JPDE 2.13
Sat May 18 08:51:53 2019
I appreciate every help, even if it's just "Impossible!"
Thank you!