WTS/game/scripts/interface/brewing.rpy

242 lines
8.5 KiB
Plaintext
Raw Permalink Normal View History

2022-05-16 23:48:22 +00:00
init python:
def brewing_sortfilter(item, sortby="A-z", filtering=None):
# if filtering == "Locked":
# item = filter(lambda x: x.is_unlocked(), item)
# elif filtering == "Unlocked":
# item = filter(lambda x: x.is_unlocked() is True, item)
# Always sort alphabetically first.
item = sorted(item, key=lambda x: natsort_key(x.name))
if sortby == "z-A":
2023-11-17 03:05:49 +00:00
item.sort(key=lambda x: natsort_key(x.name), reverse=True)
2022-05-16 23:48:22 +00:00
return item
def __actuate():
global menu_items
global current_item
menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
if current_item not in menu_items:
current_item = next(iter(menu_items), None)
2022-05-16 23:48:22 +00:00
label brewing:
$ gui.in_context("brewing_menu")
return
label .make(item):
if item.has_ingredients():
play sound "sounds/bubble.ogg"
$ item.make()
else:
gen "It appears I'm missing some key ingredients..." ("base", xpos="far_left", ypos="head")
return
2022-05-16 23:48:22 +00:00
label brewing_menu(xx=150, yy=90):
$ renpy.dynamic(
"menu_items",
items_shown = 36,
current_filter = "Unlocked",
current_sorting = "A-z",
current_item = None,
)
$ __actuate()
2022-09-29 21:19:55 +00:00
call screen brewing(xx, yy)
2022-05-16 23:48:22 +00:00
return
2022-05-16 23:48:22 +00:00
screen brewing(xx, yy):
tag brewing
zorder 15
modal True
add "gui_fade"
if renpy.mobile:
use close_button_background
use close_button
fixed:
2023-11-17 03:07:53 +00:00
pos (xx, yy)
2022-05-16 23:48:22 +00:00
if settings.get("animations"):
at gui_animation
2023-11-17 03:07:53 +00:00
use brewing_menu
use brewing_menuitem
2022-05-16 23:48:22 +00:00
2023-11-17 03:07:53 +00:00
screen brewing_menu():
2022-05-16 23:48:22 +00:00
window:
style "empty"
style_prefix gui.theme('achievements')
xysize (207, 454)
use invisible_button()
add gui.format("interface/achievements/{}/panel_left.webp")
vpgrid:
rows 1
yfill True
vbox:
style_prefix gui.theme('achievements_categories')
pos (6, 6)
2023-11-17 03:35:53 +00:00
for i_item in menu_items:
2022-05-16 23:48:22 +00:00
frame:
style "empty"
xysize (195, 50)
vbox:
2023-11-17 03:35:53 +00:00
textbutton i_item.name:
2022-05-16 23:48:22 +00:00
xysize (195, 46)
text_align (0.6, 0.5)
text_xanchor 0.5
text_size 12
2023-11-17 03:35:53 +00:00
if current_item == i_item:
2022-05-16 23:48:22 +00:00
background gui.format("interface/achievements/{}/highlight_left_b.webp")
else:
hover_background gui.format("interface/achievements/{}/highlight_left_b.webp")
2023-11-17 03:35:53 +00:00
selected (current_item == i_item)
action SetVariable("current_item", i_item)
2022-05-16 23:48:22 +00:00
add gui.format("interface/achievements/{}/spacer_left.webp")
button:
style gui.theme("overlay_button")
background gui.format("interface/achievements/{}/iconbox.webp")
foreground "interface/achievements/glass_iconbox.webp"
xysize (48, 48)
2023-11-17 03:35:53 +00:00
add crop_image_zoom(i_item.get_image(), 42, 42) align (0.5, 0.5)
2022-05-16 23:48:22 +00:00
2023-11-17 03:35:53 +00:00
if i_item.owned > 0:
text "[i_item.owned]" size 10 align (0.02, 0.1) color "#ffffff" outlines [ (1, "#000", 0, 0) ]
2022-05-16 23:48:22 +00:00
vbox:
style_prefix gui.theme('achievements_filters')
pos (6, 384)
2023-11-16 16:53:29 +00:00
if current_filter is None:
textbutton "Show: All" action [SetVariable("current_filter", "Unlocked"), Function(__actuate)]
2022-05-16 23:48:22 +00:00
else:
textbutton "Show: [current_filter]" action [SetVariable("current_filter", None), Function(__actuate)]
textbutton "Sort by: [current_sorting]" action [SetVariable("current_sorting", current_sorting[::-1]), Function(__actuate),]
2022-05-16 23:48:22 +00:00
2023-11-17 03:07:53 +00:00
screen brewing_menuitem():
2022-05-16 23:48:22 +00:00
default turned_on = False
default drop_ingredients = False
window:
style "empty"
2023-11-17 03:07:53 +00:00
pos (217, -53)
2022-05-16 23:48:22 +00:00
xysize (560, 507)
use invisible_button()
#add "interface/achievements/star.webp"
add gui.format("interface/achievements/{}/panel.webp")
if turned_on:
add "interface/brewing/bg_on.webp" align (0.5, 1.0) xsize 548 fit "contain" yoffset -6
else:
add "interface/brewing/bg_off.webp" align (0.5, 1.0) xsize 548 fit "contain" yoffset -6
text "Brewing Station" size 22 xalign 0.5 ypos 65
if current_item:
vbox:
xsize 560
pos (24, 113)
spacing 5
text "[current_item.desc]" size 12
text "Usable on:" size 12
hbox:
for c in current_item.usable_on:
add "interface/icons/head/{}.webp".format(c) size (24, 24)
hbox:
spacing 10
pos (24, 270)
for ingredient in current_item.recipe:
frame:
style "empty"
xysize (48, 48)
add gui.format("interface/achievements/{}/iconbox.webp")
2023-11-16 16:40:48 +00:00
add crop_image_zoom(ingredient.get_image(), 42, 42, ingredient.owned <= 0) align (0.5, 0.5)
2022-05-16 23:48:22 +00:00
button:
style gui.theme("overlay_button")
background "interface/achievements/glass_iconbox.webp"
xsize 46 ysize 46
action NullAction()
tooltip ingredient.name
if ingredient.owned > 0:
if ingredient.infinite:
text "{unicode}∞{/unicode}" size 20 align (0.1, 0.1) offset(-1, -9) color "#FFFFFF" outlines [ (1, "#000", 0, 0) ]
else:
2023-11-16 16:42:55 +00:00
text "[ingredient.owned]" size 10 align (0.1, 0.1) color "#ffffff" outlines [ (1, "#000", 0, 0) ]
2022-05-16 23:48:22 +00:00
else:
2023-11-16 16:42:55 +00:00
text "[ingredient.owned]" size 10 align (0.1, 0.1) color "#ff0000" outlines [ (1, "#000", 0, 0) ]
2022-05-16 23:48:22 +00:00
frame:
style "empty"
xysize (64, 64)
pos (464, 254)
add gui.format("interface/achievements/{}/iconbox.webp") size (64, 64)
2023-11-16 16:40:48 +00:00
add crop_image_zoom(current_item.get_image(), 52, 52, current_item.owned <= 0) align (0.5, 0.5)
2022-05-16 23:48:22 +00:00
button:
style gui.theme("overlay_button")
background Transform("interface/achievements/glass_iconbox.webp", size=(64, 64))
xysize (64, 64)
action NullAction()
tooltip current_item.name
if current_item.owned > 0:
2023-11-16 16:42:55 +00:00
text "[current_item.owned]" size 14 align (0.1, 0.1) color "#ffffff" outlines [ (1, "#000", 0, 0) ]
2022-05-16 23:48:22 +00:00
imagebutton:
if current_item.has_ingredients():
at transform:
subpixel True
on hover:
easeout_bounce 0.77 rotate 2 xoffset 3
easeout_bounce 0.77 rotate -2 xoffset -3
repeat
on idle:
linear 0.33 rotate 0 xoffset 0
idle "cauldron_off"
focus_mask None
pos (381, 311)
anchor (0.5, 0.5)
action Call("brewing.make", current_item, from_current=True)
2022-05-16 23:48:22 +00:00
if current_item.has_ingredients():
hover image_hover("cauldron_on")
hovered [Play("background", "sounds/brewing_idle.ogg"), SetLocalVariable("turned_on", True)]
unhovered [Stop("background"), SetLocalVariable("turned_on", False)]
2022-05-16 23:48:22 +00:00
else:
hover image_hover("cauldron_off")
if turned_on:
add "interface/brewing/glow.webp":
at transform:
align (0.5, 1.0)
xsize 548
fit "contain"
yoffset -6
alpha 0.1
linear 2.0 alpha 1.0
linear 1.5 alpha 0.1
repeat