Implement disabled state style for choice menu

This commit is contained in:
LoafyLemon 2024-09-26 20:03:33 +01:00
parent a5d78748d7
commit 4846d6a789
2 changed files with 40 additions and 2 deletions

BIN
game/gui/creamy_pumpkin_pie/choice_disabled.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -204,10 +204,15 @@ screen choice(items):
$ scale = (1.0 * (28 / max(28, len(entry.caption)))) $ scale = (1.0 * (28 / max(28, len(entry.caption))))
$ icon = entry.kwargs.get("icon", None) $ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None) $ progress = entry.kwargs.get("progress", None)
$ btn_style = entry.kwargs.get("style", None)
$ is_disabled = btn_style == "disabled"
button: button:
action entry.action action entry.action
if is_disabled:
style "choice_button_disabled"
# Handle columns # Handle columns
if columns > 1: if columns > 1:
xmaximum (config.screen_width // columns) xmaximum (config.screen_width // columns)
@ -220,6 +225,9 @@ screen choice(items):
hbox: hbox:
null width 16 null width 16
if is_disabled:
at gui_perspective, gui_perspective_disabled_hover
else:
at gui_perspective, gui_perspective_hover at gui_perspective, gui_perspective_hover
if has_icons: if has_icons:
@ -228,7 +236,10 @@ screen choice(items):
else: else:
null width 32 null width 32
text entry.caption size 32 * scale text entry.caption:
size 32 * scale
if is_disabled:
style "choice_disabled_text"
if progress: if progress:
bar value StaticValue(progress[0], progress[1]) offset (-16, 22) bar value StaticValue(progress[0], progress[1]) offset (-16, 22)
@ -250,6 +261,13 @@ transform gui_perspective_hover:
easein 0.1 matrixtransform ScaleMatrix(1.05, 1.05, 1.05) easein 0.1 matrixtransform ScaleMatrix(1.05, 1.05, 1.05)
easeout 0.1 matrixtransform ScaleMatrix(1.0, 1.0, 1.0) easeout 0.1 matrixtransform ScaleMatrix(1.0, 1.0, 1.0)
transform gui_perspective_disabled_hover:
perspective True
on hover:
easein 0.1 matrixtransform OffsetMatrix(5, 0, 0)
easein 0.1 matrixtransform OffsetMatrix(-5, 0, 0)
easeout 0.1 matrixtransform OffsetMatrix(0, 0, 0)
transform gui_hover: transform gui_hover:
subpixel True subpixel True
zoom 1.0 zoom 1.0
@ -323,6 +341,19 @@ style choice_button:
Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5) Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5)
) )
style choice_button_disabled is choice_button:
background Fixed(
Transform(Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5), matrixcolor=SaturationMatrix(0.0)),
Frame(Image("gui/creamy_pumpkin_pie/choice_disabled.png", oversample=4), 0, 0, 0, 0, tile=True),
)
hover_background Fixed(
Frame(Image("gui/creamy_pumpkin_pie/choice_arrow.png", oversample=4), 48, 0, 96, 0, tile=True, xoffset=8),
Fixed(
Transform(Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5), matrixcolor=SaturationMatrix(0.0)),
Frame(Image("gui/creamy_pumpkin_pie/choice_disabled.png", oversample=4), 0, 0, 0, 0, tile=True),
)
)
style choice_text: style choice_text:
color "#dddddd" color "#dddddd"
hover_color "#ffffff" hover_color "#ffffff"
@ -330,6 +361,10 @@ style choice_text:
hinting "bytecode" hinting "bytecode"
size 32 size 32
style choice_disabled_text is choice_text:
color "#7e7e7e"
hover_color "#bebebe"
style choice_number is choice_text: style choice_number is choice_text:
offset (0, 5) offset (0, 5)
size 16 size 16