From dd4b2898e0baa0dcc23152467a5969fe47a7fc06 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Fri, 4 Nov 2022 21:17:41 +0000 Subject: [PATCH] Bug fixes * Fixed Luna sprite persisting throughout Wardrobe context * Fixed regression related to wardrobe chit-chats due to the mixing of renpy and python scopes --- game/scripts/characters/luna/summon.rpy | 2 +- game/scripts/wardrobe/wardrobe.rpy | 203 +++++++++++++----------- 2 files changed, 108 insertions(+), 97 deletions(-) diff --git a/game/scripts/characters/luna/summon.rpy b/game/scripts/characters/luna/summon.rpy index 029bb610..c675f231 100644 --- a/game/scripts/characters/luna/summon.rpy +++ b/game/scripts/characters/luna/summon.rpy @@ -48,7 +48,7 @@ label summon_luna: # Wardrobe "-Wardrobe-" (icon="interface/icons/small/wardrobe.webp") if luna_wardrobe_unlocked: - hide astoria_main with d1 + hide luna_main with d1 call wardrobe jump luna_requests diff --git a/game/scripts/wardrobe/wardrobe.rpy b/game/scripts/wardrobe/wardrobe.rpy index 0f6de1f7..fb638556 100644 --- a/game/scripts/wardrobe/wardrobe.rpy +++ b/game/scripts/wardrobe/wardrobe.rpy @@ -75,113 +75,117 @@ label wardrobe_menu(): label .after_init: - python: + # Not to self: Do not use a python: block, because + # renpy cannot return to the middle of a python block + # while mixing python and renpy scope + # https://github.com/renpy/renpy/issues/959 - _choice = ui.interact() + $ _choice = ui.interact() - if _choice[0] == "category": - if not current_category == _choice[1]: - if wardrobe_check_category(_choice[1]): - wardrobe_loaded = False - current_category = _choice[1] + if _choice[0] == "category": + if not current_category == _choice[1]: + if wardrobe_check_category(_choice[1]): + $ wardrobe_loaded = False + $ current_category = _choice[1] - category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) - current_subcategory = list(category_items.keys())[0] if category_items else "" - menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True] - - if current_category == "outfits": - _outfit = char_active.create_outfit(temp=True) - current_item = next( (x for x in char_active.outfits if _outfit == x), None) - else: - current_item = char_active.get_equipped_item(menu_items) - - char_active.wear("all") - if current_category in ("lower undergarment", "upper undergarment"): - char_active.strip("top", "bottom", "robe", "accessory") - elif current_category == "piercings & tattoos": - char_active.strip("top", "bottom", "robe", "accessory", "bra", "panties", "stockings", "gloves") - else: - wardrobe_react("category_fail", _choice[1]) - - elif _choice[0] == "subcategory": - if not current_subcategory == _choice[1]: - wardrobe_loaded = False - current_subcategory = _choice[1] - - if current_subcategory == "import": - menu_items = list_outfit_files() - else: - menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] + $ category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) + $ current_subcategory = list(category_items.keys())[0] if category_items else "" + $ menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True] if current_category == "outfits": - _outfit = char_active.create_outfit(temp=True) - current_item = next( (x for x in char_active.outfits if _outfit == x), None) + $ _outfit = char_active.create_outfit(temp=True) + $ current_item = next( (x for x in char_active.outfits if _outfit == x), None) else: - current_item = char_active.get_equipped_item(menu_items) + $ current_item = char_active.get_equipped_item(menu_items) - elif _choice[0] == "equip": - ### CLOTHING ### - if isinstance(_choice[1], DollCloth): - if _choice[1].type == "hair" and char_active.is_equipped_item(_choice[1]): - renpy.play("sounds/fail.ogg") - renpy.notify("Hair cannot be removed.") - else: - if char_active.is_equipped_item(_choice[1]): - # UNEQUIP - if wardrobe_check_unequip(_choice[1]): - wardrobe_react("unequip", _choice[1]) - char_active.unequip(_choice[1].type) - current_item = None - else: - wardrobe_react("unequip_fail", _choice[1]) + $ char_active.wear("all") + if current_category in ("lower undergarment", "upper undergarment"): + $ char_active.strip("top", "bottom", "robe", "accessory") + elif current_category == "piercings & tattoos": + $ char_active.strip("top", "bottom", "robe", "accessory", "bra", "panties", "stockings", "gloves") + else: + $ wardrobe_react("category_fail", _choice[1]) + + elif _choice[0] == "subcategory": + if not current_subcategory == _choice[1]: + $ wardrobe_loaded = False + $ current_subcategory = _choice[1] + + if current_subcategory == "import": + $ menu_items = list_outfit_files() + else: + $ menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] + + if current_category == "outfits": + $ _outfit = char_active.create_outfit(temp=True) + $ current_item = next( (x for x in char_active.outfits if _outfit == x), None) + else: + $ current_item = char_active.get_equipped_item(menu_items) + + elif _choice[0] == "equip": + ### CLOTHING ### + if isinstance(_choice[1], DollCloth): + if _choice[1].type == "hair" and char_active.is_equipped_item(_choice[1]): + $ renpy.play("sounds/fail.ogg") + $ renpy.notify("Hair cannot be removed.") + else: + if char_active.is_equipped_item(_choice[1]): + # UNEQUIP + if wardrobe_check_unequip(_choice[1]): + $ wardrobe_react("unequip", _choice[1]) + $ char_active.unequip(_choice[1].type) + $ current_item = None else: - # EQUIP - if wardrobe_check_equip(_choice[1]): - wardrobe_react("equip", _choice[1]) + $ wardrobe_react("unequip_fail", _choice[1]) + else: + # EQUIP + if wardrobe_check_equip(_choice[1]): + $ wardrobe_react("equip", _choice[1]) - # Blacklist handling - if not wardrobe_check_blacklist(_choice[1]): - wardrobe_react("blacklist", _choice[1]) + # Blacklist handling + if not wardrobe_check_blacklist(_choice[1]): + $ wardrobe_react("blacklist", _choice[1]) - char_active.equip(_choice[1]) - current_item = _choice[1] + $ char_active.equip(_choice[1]) + $ current_item = _choice[1] - if wardrobe_fallback_required(_choice[1]): - # Has to be called regardless of player preference. - renpy.call(get_character_response(active_girl, "fallback"), _choice[1]) + if wardrobe_fallback_required(_choice[1]): + # Has to be called regardless of player preference. + $ renpy.call(get_character_response(active_girl, "fallback"), _choice[1]) - # Lipstick Fix - Synchronize image with the current mouth after equipping. - if isinstance(_choice[1], DollLipstick): - _choice[1].rebuild_image() - else: - wardrobe_react("equip_fail", _choice[1]) + # Lipstick Fix - Synchronize image with the current mouth after equipping. + if isinstance(_choice[1], DollLipstick): + $ _choice[1].rebuild_image() + else: + $ wardrobe_react("equip_fail", _choice[1]) ### OUTFIT ### elif isinstance(_choice[1], DollOutfit): - _outfit = char_active.create_outfit(temp=True) + $ _outfit = char_active.create_outfit(temp=True) if _outfit == _choice[1]: - renpy.notify("Load failed: Outfit already equipped.") + $ renpy.notify("Load failed: Outfit already equipped.") else: if wardrobe_check_equip_outfit(_choice[1]): if not _outfit.exists(): - _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Discard unsaved changes and load this outfit?") + $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Discard unsaved changes and load this outfit?") if _confirmed: - wardrobe_react("equip_outfit", _choice[1]) - char_active.equip(_choice[1]) - current_item = _choice[1] + $ wardrobe_react("equip_outfit", _choice[1]) + $ char_active.equip(_choice[1]) + $ current_item = _choice[1] else: - renpy.notify("Load failed: Cancelled by user.") + $ renpy.notify("Load failed: Cancelled by user.") else: - wardrobe_react("equip_outfit", _choice[1]) - char_active.equip(_choice[1]) - current_item = _choice[1] + $ wardrobe_react("equip_outfit", _choice[1]) + $ char_active.equip(_choice[1]) + $ current_item = _choice[1] else: - wardrobe_react("equip_outfit_fail", _choice[1]) + $ wardrobe_react("equip_outfit_fail", _choice[1]) - elif _choice[0] == "setcolor": + elif _choice[0] == "setcolor": + python: current_item.set_color(_choice[1]) if wardrobe_global_color: @@ -198,7 +202,8 @@ label wardrobe_menu(): if rebuild: outfit.rebuild_image() - elif _choice[0] == "resetcolor": + elif _choice[0] == "resetcolor": + python: current_item.reset_color() if wardrobe_global_color: @@ -215,13 +220,14 @@ label wardrobe_menu(): if rebuild: outfit.rebuild_image() - elif _choice[0] == "touch": - if wardrobe_check_touch(_choice[1]): - wardrobe_react("touch", _choice[1]) - else: - wardrobe_react("touch_fail", _choice[1]) + elif _choice[0] == "touch": + if wardrobe_check_touch(_choice[1]): + $ wardrobe_react("touch", _choice[1]) + else: + $ wardrobe_react("touch_fail", _choice[1]) - elif _choice[0] == "addoutfit": + elif _choice[0] == "addoutfit": + python: _outfit = char_active.create_outfit(temp=True) if _outfit.exists(): @@ -251,7 +257,8 @@ label wardrobe_menu(): menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] current_item = next( (x for x in char_active.outfits if _outfit == x), None) - elif _choice[0] == "deloutfit": + elif _choice[0] == "deloutfit": + python: _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Delete this outfit?") if _confirmed: @@ -259,17 +266,19 @@ label wardrobe_menu(): menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] renpy.notify("Outfit Deleted.") - elif _choice[0] == "export": + elif _choice[0] == "export": + python: _choice[1].export_data(datetime.datetime.now().strftime("%d %b %Y-%H%M%S")) achievements.unlock("export") - elif _choice[0] == "import": - _outfit = char_active.import_outfit(_choice[1]) + elif _choice[0] == "import": + $ _outfit = char_active.import_outfit(_choice[1]) - elif _choice[0] == "schedule": - renpy.call_screen("wardrobe_schedule_menuitem", _choice[1]) + elif _choice[0] == "schedule": + $ renpy.call_screen("wardrobe_schedule_menuitem", _choice[1]) - elif _choice == "music": + elif _choice == "music": + python: if wardrobe_music: wardrobe_music = False renpy.call("play_music", active_girl) @@ -279,7 +288,8 @@ label wardrobe_menu(): renpy.call("play_music", "wardrobe") get_character_sayer(active_girl)("", face="happy") - elif _choice == "randomise": + elif _choice == "randomise": + python: _confirmed = False _outfit = char_active.create_outfit(temp=True) @@ -359,7 +369,8 @@ label wardrobe_menu(): char_active.unequip(k) - else: #_choice == "Close": + else: #_choice == "Close": + python: _confirmed = False if wardrobe_autosave: