Wardrobe 2.0 - Performance boost, hook cache into export func

This commit is contained in:
LoafyLemon 2024-11-07 08:44:09 +00:00
parent 481270faaf
commit 8cfff1febe
3 changed files with 40 additions and 56 deletions

View File

@ -177,7 +177,7 @@ init python:
@functools.cache
def build_icon(self, hash):
if (d := self.get_disk_cache(hash)):
return d
return AlphaMask(Transform(d, xysize=(96, 96)), Transform("wheelmenu_button_opaque", xysize=(96, 96)))
matrix = SaturationMatrix(0.0)
sprites = [i for i in self.build_image(hash, matrix=matrix) if not i[0] == "mask"]
@ -209,7 +209,7 @@ init python:
y = hmax-h
d = Transform(Fixed(*[i[1] for i in sprites], fit_first=True), crop=(x, y, w, h), size=(256, 256), fit="contain", align=(0.5, 0.5))
return self.create_disk_cache(d, hash)
return AlphaMask(Transform(self.create_disk_cache(d, hash), xysize=(96, 96)), Transform("wheelmenu_button_opaque", xysize=(96, 96)))
@property
def icon(self):
@ -230,7 +230,7 @@ init python:
blacklister = self.char.get_blacklister(self.type) # Victim (List clothing types blacklisting this item )
warnings.append("Incompatible with:{size=-4}\n" + "\n".join(set(blacklisted + blacklister)) + "{/size}")
child = AlphaMask(Transform(self.icon, xysize=(96, 96)), Transform("wheelmenu_button_opaque", xysize=(96, 96)))
child = self.icon
hbox = []
overlay = []
@ -276,7 +276,6 @@ init python:
else:
alternate = [Function(wardrobe.equip, self), Function(wardrobe.jump_to_item, self, "color_picker")]
return Button(child=child, focus_mask=None, xysize=(96, 96), action=action, tooltip=("\n".join(warnings)), unhovered=unhovered, style=style, selected=is_equipped, alternate=alternate)
@functools.cache

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,6 @@ default wardrobe.allow_opacity = False
# Functions
init python in wardrobe:
import functools
import datetime
import os
from collections import OrderedDict
@ -65,10 +64,11 @@ init python in wardrobe:
def change_category(category):
scope = renpy.get_screen("wardrobe").scope
character = scope["character"]
if scope["selected_category"] == category:
return
scope["selected_category"] = category
scope["selected_subcategory"] = None
scope["selected_subcategory"] = next((subcat for subcat in character.wardrobe[category]), None)
def change_subcategory(subcategory):
scope = renpy.get_screen("wardrobe").scope
@ -273,7 +273,7 @@ init python in wardrobe:
d = {}
if section == "outfits":
delete_action = item.delete
export_action = renpy.store.Function(item.export_data, datetime.datetime.now().strftime("%d %b %Y-%H%M%S") + ".png")
export_action = renpy.store.Function(item.export_data, f"{item._hash}.png")
overwrite_action = renpy.store.Function(_overwrite_outfit, character, item)
d[_("Equip")] = (renpy.store.Text("👗", align=(0.5, 0.5)), [exit_action, equip_action])
@ -670,6 +670,11 @@ style wardrobe_item_small_button is wardrobe_item_button:
hover_background At(Transform("wheelmenu_button_opaque", xysize=(48,48)), wheelmenu_hover_anim)
selected_foreground Transform("interface/topbar/icon_check.webp", align=(1.0, 1.0), size=(24, 24))
style wardrobe_item_rectangular_button is wardrobe_item_button:
background Transform("wheelmenu_button", xysize=(96,168))
hover_background At(Transform("wheelmenu_button_opaque", xysize=(96,168)), wheelmenu_hover_anim)
selected_foreground Transform("interface/topbar/icon_check.webp", align=(1.0, 1.0), size=(24, 24))
style wardrobe_outline:
padding (2, 2)
foreground Frame(Image("gui/creamy_pumpkin_pie/colorpicker/colorpicker_outline.png"), 2, 0, 2, 0, tile=False)