WTS/game/scripts/wardrobe/wardrobe.rpy
LoafyLemon 59788d5f16 Wardrobe
* Handle equip/unequip methods
* Handle dialogues inside interfaces
* Fix style assignment
* Move wardrobe checks inside wardrobe python scope
2024-10-15 17:22:38 +01:00

224 lines
7.6 KiB
Plaintext

# Defines
define wardrobe.outfit_schedule = ("day", "night", "cloudy", "rainy", "snowy")
define wardrobe.subcategories = {
"hair": 5, "shirts": 5, "skirts": 5, "pantyhose": 5, "slot1": 5, "panties": 5, "save": 5,
"earrings": 4, "sweaters": 4, "trousers": 4, "stockings": 4, "bikini panties": 4, "load": 4,
"neckwear": 3, "dresses": 3, "shorts": 3, "socks": 3, "schedule": 3,
"one-piece suits": 2, "import": 2,
"robes": 1, "export": 1,
"gloves": 0, "pubes": 0, "delete": 0,
"other": -1,
}
# Settings
default wardrobe.music = False
default wardrobe.chitchats = True
default wardrobe.autosave = False
default wardrobe.suppress_warnings = False
default wardrobe.randomize_color = False
default wardrobe.global_color = False
# Functions
init python in wardrobe:
from collections import OrderedDict
def get_subcategories(d):
return OrderedDict(
sorted(
[
(subcat, [item for item in items if item.unlocked])
for subcat, items in subcategories.get(d, {}).items()
],
key=lambda x: subcategories.get(x[0], 0),
reverse=True
)
)
def get_icon(category):
fp = f"gui/creamy_pumpkin_pie/icons/{category}.png"
if renpy.loadable(fp):
return renpy.store.Image(fp, oversample=4)
return renpy.store.Image("gui/creamy_pumpkin_pie/icons/noicon.png", oversample=4)
def equip(item):
scope = renpy.get_screen("wardrobe").scope
character = scope["character"]
if item.type == "hair" and character.is_equipped_item(item):
renpy.play("sounds/fail.ogg")
renpy.notify("Hair cannot be removed.")
else:
if character.is_equipped_item(item):
if wardrobe_check_unequip(item):
wardrobe_react("unequip", item)
character.unequip(item)
else:
wardrobe_react("unequip_fail", item)
else:
if wardrobe_check_equip(item):
wardrobe_react("equip", item)
if not wardrobe_check_blacklist(item):
wardrobe_react("blacklist", item)
item.mark_as_seen()
character.equip(item)
if wardrobe_fallback_required(item):
# Has to be called regardless of player preference.
renpy.call(get_character_response(states.active_girl, "fallback"), item)
else:
wardrobe_react("equip_fail", item)
renpy.restart_interaction()
def strip():
scope = renpy.get_screen("wardrobe").scope
state = scope.get("__character_strip", 0)
character = scope["character"]
if state == 0: # Strip to underwear
character.strip("clothes")
character.wear("bra", "panties")
scope["__character_strip"] = 1
elif state == 1: # Strip naked
character.strip("bra", "panties")
scope["__character_strip"] = 2
elif state == 2: # Wear everything
character.wear("all")
scope["__character_strip"] = 0
renpy.restart_interaction()
def exit():
scope = renpy.get_screen("wardrobe").scope
character = scope["character"]
# Handle exit animation
scope["navigation_last_frame_atl"] = renpy.store.navigation_last_frame_hide
scope["navigation_atl"] = renpy.store.navigation_hide
scope["navigation_exit"] = True
# Save the outfit
outfit = renpy.store.get_character_outfit(renpy.store.states.active_girl, typ="last")
outfit.save()
# Reset states
character.wear("all")
renpy.restart_interaction()
label wardrobe(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 wardrobe
$ enable_game_menu()
jump main_room_menu
screen wardrobe():
layer "interface"
zorder 0
style_prefix "wardrobe"
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 character = get_character_object(states.active_girl)
default selected_category = None
default selected_subcategory = None
# default menu_items = inventory.get_instances_of_type(category)
# default selected_item = None
add last_frame at navigation_last_frame_atl
add "gui_fade_both" at gui_fade
if navigation_exit:
timer 0.4 action Return()
frame:
at navigation_atl
vbox:
hbox:
spacing 0
for category in character.wardrobe:
if category == "hidden":
continue
button:
add wardrobe.get_icon(category) xysize (64, 64)
tooltip category
action [SetScreenVariable("selected_category", category), SetScreenVariable("selected_subcategory", None)]
null height 5
add "frame_spacer" xsize 500 xalign 0.5
null height 5
if selected_category:
viewport:
ysize 32
edgescroll (60, 50)
mousewheel "horizontal"
hbox:
for subcategory in character.wardrobe[selected_category]:
button:
label subcategory
action SetScreenVariable("selected_subcategory", subcategory)
null height 5
add "frame_spacer" xsize 500 xalign 0.5
null height 5
if selected_subcategory:
vpgrid:
cols 5
ysize 399
xspacing 5
yspacing 5
mousewheel True
scrollbars "vertical"
for item in character.wardrobe[selected_category][selected_subcategory]:
add item.button
add character.image align (1.0, 1.0) zoom 0.6
vbox:
align (0.5, 1.0)
textbutton "Return" action wardrobe.exit keysym "game_menu"
textbutton "Strip" action wardrobe.strip
style wardrobe_item_button is empty:
background Transform("wheelmenu_button", xysize=(96,96))
hover_background At(Transform("wheelmenu_button_opaque", xysize=(96,96)), wheelmenu_hover_anim)
selected_foreground Transform("#ffffff", alpha=0.5)
hover_sound "sounds/qubodup-hover1.ogg"
activate_sound "sounds/qubodup-click2.ogg"
# anchor (0.5, 0.5)
style wardrobe_item_button_inadequate is empty:
background Transform("wheelmenu_button", xysize=(96,96))
hover_background At(Transform("wheelmenu_button_opaque", xysize=(96,96), matrixcolor=TintMatrix("#ff0000")), wheelmenu_hover_anim)
hover_sound "sounds/qubodup-hover1.ogg"
activate_sound "sounds/qubodup-click2.ogg"
# anchor (0.5, 0.5)
style wardrobe_frame is empty:
xsize 540
yfill True
padding (10, 10)
background Frame(Image("gui/creamy_pumpkin_pie/side_frame.png", oversample=4), 0, 100, 9, 75, tile=False)
style wardrobe_button is frame_button:
xpadding 0
style wardrobe_button_text is frame_button_text:
size 18
style wardrobe_label:
xpadding 5
ypadding 5
style wardrobe_label_text is wardrobe_button_text
style wardrobe_viewport:
fit_first True
xsize 500