Wardrobe 2.0 - Unify icons, add automatic import and handle file deletion

This commit is contained in:
LoafyLemon 2024-11-08 16:59:11 +00:00
parent 790a12deec
commit 8def879969
4 changed files with 35 additions and 27 deletions

View File

@ -614,7 +614,9 @@ init python:
if group:
# renpy.notify("Import successful!")
return DollOutfit(group, True)
outfit = DollOutfit(group, True)
outfit.imported = path
return outfit
renpy.notify("Import failed: Unknown error.")
return None

View File

@ -19,6 +19,8 @@ init python:
self.addons = addons
self._hash = self.generate_hash()
self._button = DefaultQueue()
self.imported = False
if not self.temp:
@ -43,6 +45,11 @@ init python:
def delete(self):
if self in self.char.outfits:
self.char.outfits.remove(self)
if self.imported:
try:
os.remove(os.path.join(config.gamedir, self.imported))
except:
print(f"Warning! Failed to delete imported outfit file - {self.imported}")
@functools.cache
def build_image(self, hash):
@ -92,8 +99,8 @@ init python:
@functools.cache
def build_icon(self, hash):
sprite = self.build_image(self._hash)
sprite = Transform(sprite, crop=(220, 0, 680, 1200), size=(96, 168), fit="contain", align=(0.5, 1.0), yoffset=-6)
return AlphaMask(Transform(sprite, xysize=(96, 168)), Transform("wheelmenu_frame_opaque_vertical", xysize=(96, 168)))
return Transform(AlphaMask(Transform(sprite, crop=(250, 0, 680, 1200), fit="scale-down", ysize=168), Transform("wheelmenu_frame_opaque_vertical", xysize=(96, 168)), yalign=1.0, fit_first=True))
# 730x1020
@property
def icon(self):
@ -106,7 +113,7 @@ init python:
# is_inadequate = wardrobe.wardrobe_check_equip_outfit(self)
has_schedule = any(self.schedule.values())
child = self.icon
children = [self.icon]
warnings = []
hbox = []
vbox = []
@ -114,7 +121,11 @@ init python:
if is_modded:
warnings.append("Outfit contains items from these mods:\n{size=-4}{color=#35aae2}"+ "\n".join(self.get_modname()) + "{/color}{/size}")
hbox.append(Text("M", color="#00b200", style="wardrobe_button_text"))
hbox.append(Text("🛠️", align=(0.5, 0.5), style="wardrobe_icon_text"))
if self.imported:
warnings.append("This outfit has an associated outfit file in /outfits/ directory.")
hbox.append(Text("📦", align=(0.5, 0.5), style="wardrobe_icon_text"))
if renpy.android:
action = [Function(wardrobe.wheelmenu, self, "outfits"), self.build_button]
@ -126,20 +137,17 @@ init python:
alternate = [Function(wardrobe.wheelmenu, self, "outfits"), self.build_button]
if has_schedule:
for i in wardrobe.outfit_schedule: # NONLOCAL
for i, emoji in wardrobe.outfit_schedule.items(): # NONLOCAL
if self.schedule[i]:
vbox.append(Transform(f"interface/wardrobe/icons/outfits/{i}.webp", size=(16, 16), offset=(3, 6)))
# if is_equipped:
# hbox.append(Transform("interface/topbar/icon_check.webp", align=(1.0, 1.0), offset=(-6, -6), size=(24, 24)))
vbox.append(Text(emoji, align=(0.5, 0.5), offset=(3, 6), style="wardrobe_icon_text"))
if vbox:
hbox.append(VBox(*vbox, ypos=34))
children.append(VBox(*vbox, ypos=34))
if hbox:
child = Fixed(child, HBox(*hbox), fit_first=True)
if hbox:
children.append(HBox(*hbox))
return Button(child=child, focus_mask=None, xysize=(96, 168), action=action, tooltip=("\n".join(warnings)), unhovered=unhovered, style=style, selected=is_equipped, alternate=alternate)
return Button(child=Fixed(*children, xysize=(96, 168)), focus_mask=None, xysize=(96, 168), action=action, tooltip=("\n".join(warnings)), unhovered=unhovered, style=style, selected=is_equipped, alternate=alternate)
@functools.cache
def build_button(self):

View File

@ -1,9 +1,4 @@
init python in wardrobe:
def wardrobe_check_category(category):
req = renpy.store.get_character_requirement(renpy.store.states.active_girl, f"category {category}")
flag = renpy.store.get_character_progression(renpy.store.states.active_girl)
return (flag >= req)
def wardrobe_check_equip(item):
req = item.level

View File

@ -1,5 +1,12 @@
# Defines
define wardrobe.outfit_schedule = ("day", "night", "cloudy", "rainy", "snowy")
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,
@ -256,13 +263,7 @@ init python in wardrobe:
# character.outfits[selected_outfit_index] = current_outfit
def schedule_action():
btns = renpy.store.create_wheelmenu({
_("Day"): (renpy.store.Text("🌞", align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, "day"), "True", str(not item.schedule["day"])),
_("Night"): (renpy.store.Text("🌙", align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, "night"), "True", str(not item.schedule["night"])),
_("Rainy"): (renpy.store.Text("🌧️", align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, "rainy"), "True", str(not item.schedule["rainy"])),
_("Snowy"): (renpy.store.Text("🌨️", align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, "snowy"), "True", str(not item.schedule["snowy"])),
_("Cloudy"): (renpy.store.Text("☁️", align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, "cloudy"), "True", str(not item.schedule["cloudy"])),
})
btns = renpy.store.create_wheelmenu({k: (renpy.store.Text(v, align=(0.5, 0.5)), renpy.store.Function(toggle_schedule_action, k), "True", str(not item.schedule[k])) for k, v in outfit_schedule.items()})
renpy.show_screen("wheelmenu", btns, pos=submenu_pos, close_action=exit_action)
@ -729,6 +730,8 @@ style wardrobe_button is frame_button:
xpadding 0
style wardrobe_button_text is frame_button_text:
size 18
style wardrobe_icon_text:
size 16
style wardrobe_label:
xpadding 5
ypadding 2