Performance
* Improve wardrobe performance by caching last 100 generated icon references
This commit is contained in:
parent
6e93d8628f
commit
a2794e3e47
@ -33,6 +33,10 @@ init python:
|
|||||||
|
|
||||||
_lock = False
|
_lock = False
|
||||||
|
|
||||||
|
@functools.lru_cache(maxsize=100)
|
||||||
|
def create_wardrobe_icon(d, size=(96, 96), fit="contain", anchor=(0.5, 0.5), align=(0.5, 0.5), yoffset=0, crop=None):
|
||||||
|
return Transform(d, size=size, fit=fit, anchor=anchor, align=align, yoffset=yoffset, crop=crop)
|
||||||
|
|
||||||
style loading_text:
|
style loading_text:
|
||||||
color "#ffffff"
|
color "#ffffff"
|
||||||
size 64
|
size 64
|
||||||
@ -162,7 +166,7 @@ label wardrobe_menu():
|
|||||||
category_items = OrderedDict(sorted(iter(list(wardrobe_subcategories.get(current_category, {}).items())), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True))
|
category_items = OrderedDict(sorted(iter(list(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 ""
|
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]
|
menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True]
|
||||||
icon_items = [Transform(x.icon, size=(96, 96), fit="contain", anchor=(0.5, 0.5), align=(0.5, 0.5)) for x in menu_items]
|
icon_items = [create_wardrobe_icon(x.icon) for x in menu_items]
|
||||||
current_item = char_active.get_equipped_item(menu_items)
|
current_item = char_active.get_equipped_item(menu_items)
|
||||||
last_track = renpy.music.get_playing()
|
last_track = renpy.music.get_playing()
|
||||||
|
|
||||||
@ -198,11 +202,11 @@ label wardrobe_menu():
|
|||||||
if current_category == "outfits":
|
if current_category == "outfits":
|
||||||
$ _outfit = char_active.create_outfit(temp=True)
|
$ _outfit = char_active.create_outfit(temp=True)
|
||||||
$ menu_items = [x for x in reversed(category_items.get(current_subcategory, [])) if x.unlocked==True]
|
$ menu_items = [x for x in reversed(category_items.get(current_subcategory, [])) if x.unlocked==True]
|
||||||
$ icon_items = [Transform(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
$ icon_items = [create_wardrobe_icon(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
||||||
$ current_item = next( (x for x in char_active.outfits if _outfit == x), None)
|
$ current_item = next( (x for x in char_active.outfits if _outfit == x), None)
|
||||||
else:
|
else:
|
||||||
$ menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True]
|
$ menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True]
|
||||||
$ icon_items = [Transform(x.icon, size=(96, 96), fit="contain", anchor=(0.5, 0.5), align=(0.5, 0.5)) for x in menu_items]
|
$ icon_items = [create_wardrobe_icon(x.icon) for x in menu_items]
|
||||||
$ current_item = char_active.get_equipped_item(menu_items)
|
$ current_item = char_active.get_equipped_item(menu_items)
|
||||||
|
|
||||||
$ char_active.wear("all")
|
$ char_active.wear("all")
|
||||||
@ -223,13 +227,13 @@ label wardrobe_menu():
|
|||||||
|
|
||||||
if current_subcategory == "import":
|
if current_subcategory == "import":
|
||||||
$ menu_items = list_outfit_files()
|
$ menu_items = list_outfit_files()
|
||||||
$ icon_items = [Transform(f"outfits/{x}", size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
$ icon_items = [create_wardrobe_icon(f"outfits/{x}", size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
||||||
else:
|
else:
|
||||||
$ menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
$ menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
||||||
$ icon_items = [Transform(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
$ icon_items = [create_wardrobe_icon(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
||||||
else:
|
else:
|
||||||
$ menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True]
|
$ menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True]
|
||||||
$ icon_items = [Transform(x.icon, size=(96, 96), fit="contain", anchor=(0.5, 0.5), align=(0.5, 0.5)) for x in menu_items]
|
$ icon_items = [create_wardrobe_icon(x.icon) for x in menu_items]
|
||||||
$ current_item = char_active.get_equipped_item(menu_items)
|
$ current_item = char_active.get_equipped_item(menu_items)
|
||||||
|
|
||||||
elif _choice[0] == "equip":
|
elif _choice[0] == "equip":
|
||||||
@ -310,7 +314,7 @@ label wardrobe_menu():
|
|||||||
outfit.is_stale()
|
outfit.is_stale()
|
||||||
|
|
||||||
menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True]
|
menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True]
|
||||||
icon_items = [Transform(x.icon, size=(96, 96), fit="contain", anchor=(0.5, 0.5), align=(0.5, 0.5)) for x in menu_items]
|
icon_items = [create_wardrobe_icon(x.icon) for x in menu_items]
|
||||||
|
|
||||||
elif _choice[0] == "touch":
|
elif _choice[0] == "touch":
|
||||||
if wardrobe_check_touch(_choice[1]):
|
if wardrobe_check_touch(_choice[1]):
|
||||||
@ -346,9 +350,9 @@ label wardrobe_menu():
|
|||||||
char_active.create_outfit()
|
char_active.create_outfit()
|
||||||
renpy.notify("Outfit Saved.")
|
renpy.notify("Outfit Saved.")
|
||||||
|
|
||||||
menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
||||||
icon_items = [Transform(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
icon_items = [create_wardrobe_icon(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
||||||
current_item = next( (x for x in char_active.outfits if _outfit == x), None)
|
current_item = next( (x for x in char_active.outfits if _outfit == x), None)
|
||||||
|
|
||||||
elif _choice[0] == "deloutfit":
|
elif _choice[0] == "deloutfit":
|
||||||
python:
|
python:
|
||||||
@ -357,7 +361,7 @@ label wardrobe_menu():
|
|||||||
if _confirmed:
|
if _confirmed:
|
||||||
_choice[1].delete()
|
_choice[1].delete()
|
||||||
menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
menu_items = [x for x in reversed(category_items.get(current_subcategory)) if x.unlocked==True]
|
||||||
icon_items = [Transform(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
icon_items = [create_wardrobe_icon(x.image, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", anchor=(0.5, 1.0), align=(0.5, 1.0), yoffset=-6) for x in menu_items]
|
||||||
renpy.notify("Outfit Deleted.")
|
renpy.notify("Outfit Deleted.")
|
||||||
|
|
||||||
elif _choice[0] == "export":
|
elif _choice[0] == "export":
|
||||||
|
Loading…
Reference in New Issue
Block a user