WTS/game/scripts/interface/inventory.rpy
LoafyLemon 1c813f5efb Bug fixes
* Fixed teleport animation issues
* Reimplemented and fixed 'centered' speaker
* Removed menu yalign params (obsolete)
* Reimplemented side image support for speakers
* Fixed selected item usable state for non-owned items in inventory
2024-09-24 16:32:33 +01:00

126 lines
7.1 KiB
Plaintext

default inventory_mode = 0 # 0 - Inventory, 1 - gifts
label inventory:
$ disable_game_menu()
call screen inventory
$ enable_game_menu()
jump main_room_menu
screen inventory():
modal True
layer "interface"
zorder 0
style_prefix "frame"
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
default category = "gift"
default menu_items = inventory.get_instances_of_type(category)
default selected_item = None
add last_frame at navigation_last_frame_atl
if navigation_exit:
timer 0.4 action Return()
frame:
style "empty"
align (0.5, 0.5)
at navigation_atl
vbox:
style_prefix "navigation_subtabs"
pos (286, 170)
at navigation_subtabs_show
textbutton _("Gifts") action [SetScreenVariable("category", "gift"), SetScreenVariable("menu_items", inventory.get_instances_of_type("gift")), SetScreenVariable("selected_item", None)] selected (category=="gift") sensitive (inventory_mode==0 or inventory.is_givable_type("gift")) at navigation_tabs
textbutton _("Books") action [SetScreenVariable("category", "book"), SetScreenVariable("menu_items", inventory.get_instances_of_type("book")), SetScreenVariable("selected_item", None)] selected (category=="book") sensitive (inventory_mode==0 or inventory.is_givable_type("book")) at navigation_tabs
textbutton _("Scrolls") action [SetScreenVariable("category", "scroll"), SetScreenVariable("menu_items", inventory.get_instances_of_type("scroll")), SetScreenVariable("selected_item", None)] selected (category=="scroll") sensitive (inventory_mode==0 or inventory.is_givable_type("scroll")) at navigation_tabs
textbutton _("Ingredients") action [SetScreenVariable("category", "ingredient"), SetScreenVariable("menu_items", inventory.get_instances_of_type("ingredient")), SetScreenVariable("selected_item", None)] selected (category=="ingredient") sensitive (inventory_mode==0 or inventory.is_givable_type("ingredient")) at navigation_tabs
textbutton _("Potions") action [SetScreenVariable("category", "potion"), SetScreenVariable("menu_items", inventory.get_instances_of_type("potion")), SetScreenVariable("selected_item", None)] selected (category=="potion") sensitive (inventory_mode==0 or inventory.is_givable_type("potion")) at navigation_tabs
textbutton _("Decorations") action [SetScreenVariable("category", "decoration"), SetScreenVariable("menu_items", inventory.get_instances_of_type("decoration")), SetScreenVariable("selected_item", None)] selected (category=="decoration") sensitive (inventory_mode==0 or inventory.is_givable_type("decoration")) at navigation_tabs
textbutton _("Consumables") action [SetScreenVariable("category", "quest"), SetScreenVariable("menu_items", inventory.get_instances_of_type("quest")), SetScreenVariable("selected_item", None)] selected (category=="quest") sensitive (inventory_mode==0 or inventory.is_givable_type("quest")) 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 ["inventory", "game_menu"] at navigation_tabs
if selected_item and ((inventory_mode==0 and selected_item.usable) or inventory_mode==1 and selected_item.givable):
vbox:
style_prefix "navigation_tabs"
pos (798, 170)
at navigation_tabs_show
textbutton selected_item.caption:
if inventory_mode==0:
sensitive selected_item.owned
action [selected_item.use, renpy.restart_interaction]
elif inventory_mode==1:
action Return(selected_item)
style "navigation_tabs_button_special"
at navigation_tabs
frame:
label _("Inventory")
# Add items
grid 10 8:
ypos 32
xalign 0.5
for item in menu_items:
if item.owned > 0 or config.developer:
$ givable = (item.givable and states.active_girl in item.usable_on)
button:
xysize (48, 48)
if selected_item == item:
add "interface/achievements/glow.webp" align (0.5, 0.5) xysize (48, 48) alpha 0.7 at rotate_circular
add crop_image_zoom(item.get_image(), 48, 48, item.owned <= 0 or (inventory_mode==1 and not givable)) align (0.5, 0.5)
if item.used or (item.type=="decoration" and item.in_use):
add "interface/topbar/icon_check.webp" xysize (16, 16) offset (8, -8)
if item.owned > 1:
text "x[item.owned]" offset (-8, 34) size 12
if not (inventory_mode==1 and not givable):
action [SetScreenVariable("selected_item", item)]
if selected_item:
vbox:
align (0.0, 1.0)
add "frame_spacer" xalign 0.5 xsize 500
null height 10
hbox:
spacing 5
add selected_item.get_image() xysize(96, 96) align (0.05, 0.95)
vbox:
spacing 5
yalign 1.0
xsize 400
yminimum 80
hbox:
label selected_item.name
if selected_item.used or (selected_item.type=="decoration" and selected_item.in_use):
add "interface/topbar/icon_check.webp" xysize (24, 24) yoffset -12
text selected_item.desc xalign 0
if inventory_mode==0 and selected_item.use_progression:
vbox:
align (0, 0)
for k, v in selected_item.use_progression.items():
$ progress = "{unicode}✔{/unicode}" if eval(v) else "{unicode}✘{/unicode}"
text "{size=-3}[k] [progress]{/size}" xalign 0 text_align 0 color ("#ffffff" if eval(v) else "#8d8d8d")
if selected_item.givable:
hbox:
yoffset -5
text _("Giftable:") yalign 0.5
for i in item.usable_on:
add "wheelmenu_[i]" xysize (24, 24) yalign 0.5
if selected_item.owned > 1:
text "x[selected_item.owned]" align (0.0, 1.0)