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))))
$ icon = entry.kwargs.get("icon", None)
$ progress = entry.kwargs.get("progress", None)
$ btn_style = entry.kwargs.get("style", None)
$ is_disabled = btn_style == "disabled"
button:
action entry.action
if is_disabled:
style "choice_button_disabled"
# Handle columns
if columns > 1:
xmaximum (config.screen_width // columns)
@ -220,7 +225,10 @@ screen choice(items):
hbox:
null width 16
at gui_perspective, gui_perspective_hover
if is_disabled:
at gui_perspective, gui_perspective_disabled_hover
else:
at gui_perspective, gui_perspective_hover
if has_icons:
if icon:
@ -228,7 +236,10 @@ screen choice(items):
else:
null width 32
text entry.caption size 32 * scale
text entry.caption:
size 32 * scale
if is_disabled:
style "choice_disabled_text"
if progress:
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)
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:
subpixel True
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)
)
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:
color "#dddddd"
hover_color "#ffffff"
@ -330,6 +361,10 @@ style choice_text:
hinting "bytecode"
size 32
style choice_disabled_text is choice_text:
color "#7e7e7e"
hover_color "#bebebe"
style choice_number is choice_text:
offset (0, 5)
size 16