From 18b1b271bb28fefbcf48f095c064f0f823afc236 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Tue, 21 May 2024 00:08:41 +0100 Subject: [PATCH] Implement new choice menu --- game/gui/creamy_pumpkin_pie/choice.png | 3 + game/gui/creamy_pumpkin_pie/choice_arrow.png | 3 + .../creamy_pumpkin_pie/choice_bar_empty.png | 3 + .../creamy_pumpkin_pie/choice_bar_full.png | 3 + game/gui/creamy_pumpkin_pie/fade_bottom.png | 3 + game/gui/creamy_pumpkin_pie/fade_top.png | 3 + game/scripts/events/queue.rpy | 19 +- game/scripts/gui/_styles_.rpy | 21 +- game/scripts/gui/say.rpy | 329 ++++++++++-------- 9 files changed, 210 insertions(+), 177 deletions(-) create mode 100644 game/gui/creamy_pumpkin_pie/choice.png create mode 100644 game/gui/creamy_pumpkin_pie/choice_arrow.png create mode 100644 game/gui/creamy_pumpkin_pie/choice_bar_empty.png create mode 100644 game/gui/creamy_pumpkin_pie/choice_bar_full.png create mode 100644 game/gui/creamy_pumpkin_pie/fade_bottom.png create mode 100644 game/gui/creamy_pumpkin_pie/fade_top.png diff --git a/game/gui/creamy_pumpkin_pie/choice.png b/game/gui/creamy_pumpkin_pie/choice.png new file mode 100644 index 00000000..e01021a8 --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/choice.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18b70fb041f2fba88226319b78abd28dc482e32b79652b7d3d1b31b75a7c7325 +size 7962 diff --git a/game/gui/creamy_pumpkin_pie/choice_arrow.png b/game/gui/creamy_pumpkin_pie/choice_arrow.png new file mode 100644 index 00000000..8c43b748 --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/choice_arrow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca95ef0703dc4226596d565589ed3ac06fa1c4e2a0293e7760a5ea010b60efca +size 15065 diff --git a/game/gui/creamy_pumpkin_pie/choice_bar_empty.png b/game/gui/creamy_pumpkin_pie/choice_bar_empty.png new file mode 100644 index 00000000..eca29c6a --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/choice_bar_empty.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0ca76e113e1204f8e30200808c0537f1836df99f82c87a77ba1210e7bb37215 +size 2226 diff --git a/game/gui/creamy_pumpkin_pie/choice_bar_full.png b/game/gui/creamy_pumpkin_pie/choice_bar_full.png new file mode 100644 index 00000000..23c7e8dd --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/choice_bar_full.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96834c9240f5e6f1f7af3830b4b223ba3bfbaf6f0c66e3da236101db1eaaf4d4 +size 2981 diff --git a/game/gui/creamy_pumpkin_pie/fade_bottom.png b/game/gui/creamy_pumpkin_pie/fade_bottom.png new file mode 100644 index 00000000..2ff46074 --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/fade_bottom.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa17128877c13bb60aef383930a212420cc9f424aa8f375c2f7766ea4186b87a +size 2830878 diff --git a/game/gui/creamy_pumpkin_pie/fade_top.png b/game/gui/creamy_pumpkin_pie/fade_top.png new file mode 100644 index 00000000..1965808d --- /dev/null +++ b/game/gui/creamy_pumpkin_pie/fade_top.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:742fc75081ba348051c750ea170153ebab03777b6b8c2a31d467081b533eb1db +size 2741216 diff --git a/game/scripts/events/queue.rpy b/game/scripts/events/queue.rpy index 684aa37d..30dbc93e 100644 --- a/game/scripts/events/queue.rpy +++ b/game/scripts/events/queue.rpy @@ -349,23 +349,16 @@ init -1 python: def menu_hints(queue, filter): filtered_queue = queue.list_filtered() if filter is False else queue.list_filtered(filter) total_applicable = len(filtered_queue) - total_events = len(queue.queue) + # total_events = len(queue.queue) completed = 0 - icons = [] for ev in filtered_queue: if ev.completed: - icons.append(f"interface/icons/small/heart_red.webp") completed += 1 elif ev.completed_failed: - icons.append(f"interface/icons/small/heart_black.webp") completed += 1 - else: - icons.append(f"interface/icons/small/heart_empty.webp") - hints = f" {completed}/{total_applicable}/{total_events}" - - return (hints, icons) + return (completed, total_applicable) l = [] @@ -373,11 +366,7 @@ init -1 python: if isinstance(queue, str): queue = getattr(store, queue) - hints, icons = menu_hints(queue, filter) - title = f"-{title}-" - - if config.developer: - title += hints + progress = menu_hints(queue, filter) if ( ev := queue.next()) and ev.requirements_met(): action = queue @@ -391,7 +380,7 @@ init -1 python: if action in ("disabled", "noncompliant"): _kwargs["style"] = "disabled" elif report_progress: - _kwargs = {"progress": icons} + _kwargs = {"progress": progress} location = renpy.game.context().current choice = ui.ChoiceReturn(title, action, location, kwargs=_kwargs) diff --git a/game/scripts/gui/_styles_.rpy b/game/scripts/gui/_styles_.rpy index a2dbb97a..014b27f3 100644 --- a/game/scripts/gui/_styles_.rpy +++ b/game/scripts/gui/_styles_.rpy @@ -52,11 +52,11 @@ # style prompt_text is gui_text -# style bar: -# unscrollable gui.unscrollable -# ysize gui.scrollbar_size -# base_bar Frame("scrollbar_horizontal_[prefix_]bar", gui.slider_borders, tile=gui.slider_tile) -# thumb Frame("scrollbar_horizontal_[prefix_]thumb", gui.slider_borders, tile=gui.slider_tile) +style bar: + unscrollable gui.unscrollable + ysize gui.scrollbar_size + base_bar Frame("scrollbar_horizontal_[prefix_]bar", gui.slider_borders, tile=gui.slider_tile) + thumb Frame("scrollbar_horizontal_[prefix_]thumb", gui.slider_borders, tile=gui.slider_tile) # style vbar: # unscrollable gui.unscrollable @@ -119,12 +119,9 @@ # style imagemap: # activate_sound "sounds/qubodup-click2.ogg" -# style button: -# activate_sound "sounds/qubodup-click2.ogg" -# hover_sound "sounds/qubodup-hover1.ogg" -# insensitive_background "#463b3be6" -# selected_background "#766a6ae6" -# padding (5, 5, 5, 5) +style button: + activate_sound "sounds/qubodup-click2.ogg" + hover_sound "sounds/qubodup-hover1.ogg" # style dark_button: # background "#5d5151e6" @@ -284,4 +281,4 @@ # style light_text: # color settings.get('text_color_day') -# outlines [(1, settings.get('text_outline'), 1, 0)] \ No newline at end of file +# outlines [(1, settings.get('text_outline'), 1, 0)] diff --git a/game/scripts/gui/say.rpy b/game/scripts/gui/say.rpy index affa330b..cd18d4f2 100644 --- a/game/scripts/gui/say.rpy +++ b/game/scripts/gui/say.rpy @@ -131,179 +131,208 @@ style hider is namebox: style hider_button is quickbox_button style hider_button_text is quickbox_button_text -# screen say(who, what, side_image=None, icon=None): -# zorder 31 - -# if _windows_hidden: -# use invisible_button(action=SetVariable("_windows_hidden", False)) -# else: -# if not renpy.get_screen("choice"): -# use invisible_button(action=Function(ui.saybehavior), keysym="dismiss") - -# if side_image: -# add side_image yalign 1.0 zoom 0.5 -# else: -# add SideImage() - -# window id "window": -# style "say_window" - -# if who: -# window: -# id "namebox" -# style "namebox" -# text who: -# style "say_label" - -# text what: -# id "what" -# style "say_dialogue" - -# if _windows_hidden: -# ypos 1000 - -# if _game_menu_screen: -# use quick_menu - -# Quick menu screen -# -# The quick menu is displayed in-game to provide easy access to the out-of-game menus. - -# screen quick_menu(): -# hbox: -# style_prefix "quick" -# xalign 1.0 -# yoffset -30 - -# textbutton _("Q.Save") action QuickSave() -# textbutton _("Q.Load") action QuickLoad() -# textbutton _("Skip") action Skip() -# textbutton _("Auto") action Preference("auto-forward", "toggle") -# textbutton _("Preferences") action ShowMenu("preferences") - -# style quick_button is default: -# activate_sound "sounds/qubodup-click2.ogg" -# hover_sound "sounds/qubodup-hover2.ogg" -# background None -# xpadding 8 -# ypadding 8 - -# style quick_button_text: -# size 10 -# idle_color "#8888" -# hover_color "#fff" -# insensitive_color "#4448" -# idle_outlines [(1, "#0008", 1, 1)] -# hover_outlines [(1, "#000", 1, 1)] - -# Choice screen -# -# This screen is used to display the in-game choices presented by the menu -# statement. The one parameter, items, is a list of objects, each with caption -# and action fields. -# -# https://www.renpy.org/doc/html/screen_special.html#choice - -define blacklist_screens = {"say", "letter", "bld1"} -define choice_width = int(config.screen_width/2) - -screen choice(items, menu_yalign=.6): - tag menu - zorder 0 +screen choice(items): + style_prefix "choice" layer "interface" + zorder 1 + variant "pc" - style_prefix gui.theme("menu") + # default max_progress = max(len(e.kwargs.get("progress", [])) for e in items) + default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items]) + # add Image("gui/creamy_pumpkin_pie/fade_top.png", oversample=2) alpha 0.5 - default blacklist_tags = set(get_character_tag(x) for x in states.dolls) + vbox: + for i, entry in enumerate(items, 1): + $ scale = (1.0 * (32 / max(32, len(entry.caption)))) + $ icon = entry.kwargs.get("icon", None) + $ progress = entry.kwargs.get("progress", None) - # Dont add the fade if character or saybox is present (They have their own triggers for fading) - if not any(renpy.get_screen(x) for x in blacklist_screens) and not any(renpy.showing(x, layer="screens") for x in blacklist_tags): - add "interface/bld.webp" at fade_hide(0.15) + vbox: + spacing 2 - window at fade_show_hide(0.15): - style "empty" - xalign .5 - yalign menu_yalign - - vbox: - spacing 0 - - default max_progress = max(len(e.kwargs.get("progress", [])) for e in items) - - for i, entry in enumerate(items, 1): - $ style_part = entry.kwargs.get("style", None) button: - xsize choice_width - ypadding 5 action entry.action - sensitive bool(entry.action) if i < 10 and entry.action: keysym ("K_"+str(i), "K_KP"+str(i)) - fixed: - style "empty" + text "[i]" style "choice_number": + at gui_perspective - if style_part: - style_prefix gui.theme(f"{style_part}_menu") + hbox: + null width 16 + at gui_perspective, gui_perspective_hover - fit_first "height" + # if progress: + # for j in range(max_progress): + # if j < len(progress): + # add progress[j] xysize (32, 32) + # else: + # null width 32 - text entry.caption: - xsize choice_width-120 # Leave enough margin for number and icon - align (0.5, 0.5) + if has_icons: + if icon: + add icon xysize (32, 32) xcenter 12 yalign 1.0 yoffset -4 + else: + null width 32 - if i < 10 and entry.action: - text "{size=-2}[i].{/size}" xpos 5 yalign 0.5 + text entry.caption size 32 * scale - $ icon = entry.kwargs.get("icon", None) - if icon: - add icon xcenter 40 yalign 0.5 + if progress: + bar value StaticValue(progress[0], progress[1]) offset (-16, 22) - $ progress = entry.kwargs.get("progress", None) - if progress: - hbox: - spacing 2 - xpos choice_width - 5 - xanchor 1. - yalign .5 - for i in range(max_progress): - if i < len(progress): - add progress[i] - else: - null width 21 # Assume icon width -style menu_text is default: - hover_color "#fff" - text_align 0.5 - outlines [(1, "#00000080", 1, 0)] +transform gui_perspective: + perspective True + matrixanchor (0.5, 0.0) + matrixtransform RotateMatrix(45.0, -12.5, 0.0) -style dark_menu_text: - color "#9b8d84" - insensitive_color "#6c625c" +transform gui_perspective_hover: + perspective True + on hover: + easein 0.1 matrixtransform ScaleMatrix(1.05, 1.05, 1.05) + easeout 0.1 matrixtransform ScaleMatrix(1.0, 1.0, 1.0) -style light_menu_text: - color "#f9d592" - insensitive_color "#ae9566" +style choice_vbox is vbox +style choice_button is button +style choice_button_text is button_text -style dark_disabled_menu_text: - color "#6c625c" +style choice_vbox: + xalign 0.5 + yanchor 1.0 + ypos 0.75 + spacing 10 -style light_disabled_menu_text: - color "#ae9566" +style choice_hbox: + spacing 2 -style menu_button is default: - activate_sound "sounds/qubodup-click1.ogg" - hover_sound "sounds/qubodup-hover1.ogg" +style choice_button: + ysize 24 + xmaximum 0.6 + xalign 0.5 + padding (48, 0, 24, 0) + background 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)) + hover_background Fixed( + Frame(Image("gui/creamy_pumpkin_pie/choice_arrow.png", oversample=4), 48, 0, 96, 0, tile=True, xoffset=8), + Frame(Image("gui/creamy_pumpkin_pie/choice.png", oversample=4), 24, 0, 24, 0, tile=True, xmaximum=0.9, xalign=0.5) + ) -style dark_menu_button: - background "#5d5151e6" - hover_background "#897e75" - insensitive_background "#9e8449" +style choice_text: + color "#dddddd" + hover_color "#ffffff" + outlines [(1, "#000000", 1, 2), (1, "#000000", 0, 1), (1, "#000000", 0, 0)] + hinting "bytecode" + size 32 -style light_menu_button: - background "#ac8d5ae6" - hover_background "#97681f" - insensitive_background "#d1a02eb3" +style choice_number is choice_text: + offset (0, 5) + size 16 + +style choice_bar is empty: + ysize 10 + left_bar Transform(Frame(Image("gui/creamy_pumpkin_pie/choice_bar_full.png", oversample=4), 24, 0, 24, 0, tile=True), matrixcolor=SaturationMatrix(0.5)) + hover_left_bar Frame(Image("gui/creamy_pumpkin_pie/choice_bar_full.png", oversample=4), 24, 0, 24, 0, tile=True) + right_bar Frame(Image("gui/creamy_pumpkin_pie/choice_bar_empty.png", oversample=4), 24, 0, 24, 0, tile=True) + +# define blacklist_screens = {"say", "letter", "bld1"} +# define choice_width = int(config.screen_width/2) + +# screen choice(items, menu_yalign=.6): +# tag menu +# zorder 0 +# layer "interface" + +# style_prefix gui.theme("menu") + +# default blacklist_tags = set(get_character_tag(x) for x in states.dolls) + +# # Dont add the fade if character or saybox is present (They have their own triggers for fading) +# if not any(renpy.get_screen(x) for x in blacklist_screens) and not any(renpy.showing(x, layer="screens") for x in blacklist_tags): +# add "interface/bld.webp" at fade_hide(0.15) + +# window at fade_show_hide(0.15): +# style "empty" +# xalign .5 +# yalign menu_yalign + +# vbox: +# spacing 0 + +# default max_progress = max(len(e.kwargs.get("progress", [])) for e in items) + +# for i, entry in enumerate(items, 1): +# $ style_part = entry.kwargs.get("style", None) +# button: +# xsize choice_width +# ypadding 5 +# action entry.action +# sensitive bool(entry.action) +# if i < 10 and entry.action: +# keysym ("K_"+str(i), "K_KP"+str(i)) + +# fixed: +# style "empty" + +# if style_part: +# style_prefix gui.theme(f"{style_part}_menu") + +# fit_first "height" + +# text entry.caption: +# xsize choice_width-120 # Leave enough margin for number and icon +# align (0.5, 0.5) + +# if i < 10 and entry.action: +# text "{size=-2}[i].{/size}" xpos 5 yalign 0.5 + +# $ icon = entry.kwargs.get("icon", None) +# if icon: +# add icon xcenter 40 yalign 0.5 + +# $ progress = entry.kwargs.get("progress", None) +# if progress: +# hbox: +# spacing 2 +# xpos choice_width - 5 +# xanchor 1. +# yalign .5 +# for i in range(max_progress): +# if i < len(progress): +# add progress[i] +# else: +# null width 21 # Assume icon width + +# style menu_text is default: +# hover_color "#fff" +# text_align 0.5 +# outlines [(1, "#00000080", 1, 0)] + +# style dark_menu_text: +# color "#9b8d84" +# insensitive_color "#6c625c" + +# style light_menu_text: +# color "#f9d592" +# insensitive_color "#ae9566" + +# style dark_disabled_menu_text: +# color "#6c625c" + +# style light_disabled_menu_text: +# color "#ae9566" + +# style menu_button is default: +# activate_sound "sounds/qubodup-click1.ogg" +# hover_sound "sounds/qubodup-hover1.ogg" + +# style dark_menu_button: +# background "#5d5151e6" +# hover_background "#897e75" +# insensitive_background "#9e8449" + +# style light_menu_button: +# background "#ac8d5ae6" +# hover_background "#97681f" +# insensitive_background "#d1a02eb3" # Input screen # @@ -330,4 +359,4 @@ screen input(prompt): style gui.theme("say_label") input id "input": - style gui.theme("say_dialogue") \ No newline at end of file + style gui.theme("say_dialogue")