WTS/game/scripts/minigames/mirror/menu.rpy

359 lines
13 KiB
Plaintext
Raw Normal View History

2024-11-17 14:32:23 +00:00
# init python:
# def mirror_sortfilter(item, sortby="A-z", filtering=None):
# if filtering == "Locked":
# item = [x for x in item if x.is_unlocked()]
# elif filtering == "Unlocked":
# item = [x for x in item if x.is_unlocked() is True]
# # Always sort alphabetically first.
# item = sorted(item, key=lambda x: natsort_key(x.name))
# if sortby == "z-A":
# item = sorted(item, key=lambda x: natsort_key(x.name), reverse=True)
# return item
# label mirror:
# $ gui.in_context("mirror_menu")
# call screen room_menu
# label mirror_menu(xx=150, yy=90):
# python:
# mirror_categories = mirror.get_tags()
# items_shown = 36
# current_page = 0
# current_category = mirror_categories[0]
# current_filter = "Unlocked"
# current_sorting = "A-z"
# menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
# menu_items_length = len(menu_items)
# current_item = next(iter(menu_items), None)
# show screen mirror(xx, yy)
# label .after_init:
# $ renpy.dynamic(__choice = ui.interact())
# if __choice[0] == "select":
# $ current_item = __choice[1]
# $ current_item.seen = True
# elif __choice[0] == "category":
# $ current_category = __choice[1]
# $ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
# $ menu_items_length = len(menu_items)
# $ current_page = 0
# $ current_item = next(iter(menu_items), None)
# elif __choice == "inc":
# $ current_page += 1
# elif __choice == "dec":
# $ current_page += -1
# elif __choice == "filter":
# if current_filter == "Unlocked":
# $ current_filter = None
# elif current_filter is None:
# $ current_filter = "Unlocked"
# $ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
# $ menu_items_length = len(menu_items)
# $ current_page = 0
# $ current_item = next(iter(menu_items), None)
# elif __choice == "sort":
# if current_sorting == "A-z":
# $ current_sorting = "z-A"
# else:
# $ current_sorting = "A-z"
# $ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
# $ menu_items_length = len(menu_items)
# $ current_page = 0
# $ current_item = next(iter(menu_items), None)
# elif __choice[0] == "play":
# $ __choice[1].play()
# $ renpy.jump_out_of_context("mirror")
# else:
# $ enable_game_menu()
# hide screen mirror
# return
# jump .after_init
# screen mirror(xx, yy):
# tag mirror
# zorder 30
# modal True
# add "gui_fade_both"
# if renpy.mobile:
# use close_button_background
# use close_button
# fixed:
# if settings.get("animations"):
# at gui_animation
# use mirror_menu(xx, yy)
# use mirror_menuitem(xx, yy)
# screen mirror_menu(xx, yy):
# window:
# style "empty"
# style_prefix gui.theme('achievements')
# pos (xx, yy)
# xysize (207, 454)
# use invisible_button()
# add gui.format("interface/achievements/{}/panel_left.webp")
# vbox:
# style_prefix gui.theme('achievements_categories')
# pos (6, 41)
# for category in mirror_categories:
# vbox:
# textbutton category:
# selected (current_category == category)
# action Return(["category", category])
# add gui.format("interface/achievements/{}/spacer_left.webp")
# vbox:
# style_prefix gui.theme('achievements_filters')
# pos (6, 384)
# if current_filter is None:
# textbutton "Show: All" action Return("filter")
# else:
# textbutton "Show: [current_filter]" action Return("filter")
# textbutton "Sort by: [current_sorting]" action Return("sort")
# screen mirror_menuitem(xx, yy):
# window:
# style "empty"
# pos (xx+217, yy-53)
# xysize (560, 507)
# use invisible_button()
# #add "interface/achievements/star.webp"
# add gui.format("interface/achievements/{}/panel.webp")
# text "Mirror of Erised" size 22 xalign 0.5 ypos 65
# # Add items
# viewport:
# style_prefix gui.theme()
# draggable True
# mousewheel "vertical"
# scrollbars "vertical"
# maximum (512, 290)
# pos (24, 113)
# vbox:
# style_prefix "mirror"
# for ev in menu_items:
# $ authors = ", ".join(ev.authors)
# $ is_unlocked = ev.is_unlocked()
# button:
# ysize 30
# selected_background Transform(gui.format("interface/achievements/{}/highlight.webp"), ysize=26)
# selected (current_item == ev)
# sensitive is_unlocked
# xfill True
# action Return(["select", ev])
# if is_unlocked and not ev.seen:
# text "NEW" style "wardrobe_item_caption" align (1.0, 1.0) offset (-5, -5)
# if ev.played:
# add "interface/topbar/icon_check.webp" align (1.0, 1.0) offset (-5, -5) zoom 0.7
# vbox:
# text ev.name
# text f"By {authors}" size 10
# add gui.format("interface/achievements/{}/spacer_left.webp")
# if menu_items_length <= 0:
# text "Nothing here yet" align (0.5, 0.5) size 24
# if current_item:
# frame style "empty":
# xalign 0.5
# ypos 412
# vbox:
# xalign 0.5
# add gui.format("interface/achievements/{}/highlight.webp")
# add gui.format("interface/achievements/{}/spacer.webp")
# vbox:
# yoffset 6
# xmaximum 400
# text "[current_item.desc]" size 12
# text "Tags:{}".format(", ".join(current_item.tags)) size 10
# text "[current_item.name]" xalign 0.5 ypos 3 size 16
# textbutton "Play":
# xalign 0.95
# text_size 16
# sensitive current_item.is_unlocked()
# action Return(["play", current_item])
# style mirror_button is empty
# style mirror_button_text:
# color "#402313"
# insensitive_color "#40231380"
# hover_color "#FFF"
# outlines []
# style mirror_text is mirror_button_text:
# color "#402313"
# insensitive_color "#40231380"
# hover_color "#FFF"
# outlines []
init python in mirror_of_erised:
def select(item):
scope = renpy.get_screen("mirror_interface").scope
scope["selected_item"] = item
item.seen = True
renpy.restart_interaction()
def play(item):
item.play()
renpy.jump("mirror")
label mirror(inter_pause=True):
$ disable_game_menu()
if inter_pause:
# Ensures all irrelevant screens are hidden before capturing the surface tree
with Pause(0.2)
call screen mirror_interface
$ enable_game_menu()
2022-05-16 23:48:22 +00:00
call screen room_menu
2024-11-17 14:32:23 +00:00
screen mirror_interface():
2022-05-16 23:48:22 +00:00
modal True
2024-11-17 14:32:23 +00:00
layer "interface"
zorder 0
style_prefix "mirror"
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
default navigation_atl = navigation_show
default last_frame = (screenshot.capture() or screenshot.image)
default navigation_last_frame_atl = navigation_last_frame_show
default navigation_exit = False
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
default menu_categories = mirror.get_tags()
default category = menu_categories[0]
default menu_items = mirror.get_instances_of_tag(category)
default selected_item = None
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
add last_frame at navigation_last_frame_atl
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
if navigation_exit:
timer 0.4 action Return()
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
frame:
2022-05-16 23:48:22 +00:00
style "empty"
2024-11-17 14:32:23 +00:00
align (0.5, 0.5)
at navigation_atl
2022-05-16 23:48:22 +00:00
vbox:
2024-11-17 14:32:23 +00:00
style_prefix "navigation_subtabs"
pos (286, 170)
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
at navigation_subtabs_show
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
for i in menu_categories:
textbutton "[i.capitalize()]" action [SetScreenVariable("category", i), SetScreenVariable("menu_items", mirror.get_instances_of_tag(i))] selected (category==i) at navigation_tabs
null height 35
textbutton _("Return") action [SetScreenVariable("navigation_last_frame_atl", navigation_last_frame_hide), SetScreenVariable("navigation_atl", navigation_hide), SetScreenVariable("navigation_exit", True)] keysym ["game_menu", "achievements"] at navigation_tabs
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
if selected_item:
2022-05-16 23:48:22 +00:00
vbox:
2024-11-17 14:32:23 +00:00
style_prefix "navigation_tabs"
pos (798, 170)
at navigation_tabs_show
textbutton _("Play"):
action Function(mirror_of_erised.play, selected_item)
style "navigation_tabs_button_special"
at navigation_tabs
frame:
label _("Mirror of Erised")
# text "([achievements.get_percentage()]%)" pos (108, -3)
2022-05-16 23:48:22 +00:00
2024-11-17 14:32:23 +00:00
# Add items
viewport:
ypos 32
scrollbars "vertical"
mousewheel True
draggable "touch"
2022-05-16 23:48:22 +00:00
vbox:
2024-11-17 14:32:23 +00:00
for item in menu_items:
$ authors = ", ".join(item.authors)
$ item_unlocked = item.is_unlocked()
$ item_color = "#ffffff" if item_unlocked else "#8d8d8d"
fixed:
fit_first True
button:
hbox:
fixed:
xysize (48, 48)
add Text("Placeholder") xysize (48, 48) fit "contain" align (0.5, 0.5)
# add crop_image_zoom(Text("No icon"), 48, 48, not item_unlocked) xysize (48, 48) fit "contain" align (0.5, 0.5)
null width 5
vbox:
text "[item.name]" color item_color
text _("By [authors]") size 10 color item_color style "mirror_text_small"
text "[item.desc]" color item_color style "mirror_text_small"
action Function(mirror_of_erised.select, item)
selected (selected_item == item)
sensitive (item_unlocked)
if item.played:
add "interface/topbar/icon_check.webp" xysize (24, 24) yalign 0.5
if item_unlocked and not item.seen:
text "NEW" align (1.0, 1.0) offset (-5, -5)
# if item_data.progression:
# if item_unlocked:
# bar value StaticValue(1.0)
# else:
# bar value StaticValue(eval(item_data.progression), item_data.progression_max) style "achievements_bar_disabled"
add "frame_spacer" xalign 0.5 xsize 500
style mirror_viewport is viewport:
xalign 0.5
ymaximum 397
style mirror_vbox is frame_vbox:
ypos 0
yspacing 0
xalign 0
style mirror_frame is frame
style mirror_label is frame_label
style mirror_label_text is frame_label_text
style mirror_text is frame_text:
xalign 0
style mirror_text_small is mirror_text:
xalign 0
size 12
style mirror_button is frame_button:
xfill True
yminimum 48
selected_foreground "#ffffff2d"
style mirror_button_text is frame_button_text
style mirror_bar is player_bar:
xmaximum 400
yalign 1.0
xpos 78
ysize 10
yoffset -2
style mirror_bar_disabled is mirror_bar:
left_bar Frame(Transform(Image("gui/creamy_pumpkin_pie/player/player_bar_full.png", oversample=4), matrixcolor=BrightnessMatrix(-0.5)), 24, 0, tile=False)
right_bar Frame(Transform(Image("gui/creamy_pumpkin_pie/player/player_bar_empty.png", oversample=4), matrixcolor=BrightnessMatrix(-0.5)), 24, 0, tile=False)