Handle choice menu overflow

This commit is contained in:
LoafyLemon 2024-05-29 22:16:58 +01:00
parent e9cadcdc89
commit 792467e25a

View File

@ -153,44 +153,52 @@ screen choice(items):
variant "pc" variant "pc"
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items]) default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
default columns = math.ceil(len(items) / 12)
vbox: hbox:
at gui_choice_show_hide at gui_choice_show_hide
for i, entry in enumerate(items, 1): for column in range(columns):
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
vbox: vbox:
spacing 2 $ start_index = column * 12
$ end_index = start_index + 12
for i, entry in enumerate(items[start_index:end_index], 1):
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
button: button:
action entry.action action entry.action
if i < 10 and entry.action:
keysym ("K_"+str(i), "K_KP"+str(i))
text "[i]" style "choice_number": # Handle columns
at gui_perspective if columns > 1:
xmaximum (config.screen_width // columns)
hbox: if i < 10 and entry.action:
null width 16 keysym ("K_"+str(i), "K_KP"+str(i))
at gui_perspective, gui_perspective_hover
if has_icons: text "[i+start_index]" style "choice_number":
if icon: at gui_perspective
add icon xysize (32, 32) xcenter 12 yalign 1.0 yoffset -4
else:
null width 32
text entry.caption size 32 * scale hbox:
null width 16
at gui_perspective, gui_perspective_hover
if progress: if has_icons:
bar value StaticValue(progress[0], progress[1]) offset (-16, 22) if icon:
add icon xysize (32, 32) xcenter 12 yalign 1.0 yoffset -4
if progress[0] == progress[1]: else:
text _("{wave}{size=20}Done!{/size}{/wave}") style "choice_progress" at transform: null width 32
rotate 12.5
gui_hover text entry.caption size 32 * scale
if progress:
bar value StaticValue(progress[0], progress[1]) offset (-16, 22)
if progress[0] == progress[1]:
text _("{wave}{size=20}Done!{/size}{/wave}") style "choice_progress" at transform:
rotate 12.5
gui_hover
transform gui_perspective: transform gui_perspective:
@ -257,12 +265,13 @@ style choice_button is button
style choice_button_text is button_text style choice_button_text is button_text
style choice_vbox: style choice_vbox:
xalign 0.5 align (0.5, 1.0)
yanchor 1.0
ypos 0.75
spacing 10 spacing 10
style choice_hbox: style choice_hbox:
xalign 0.5
yanchor 1.0
ypos 0.75
spacing 2 spacing 2
style choice_button: style choice_button: