From 99fbcd4ea7f99b982568157ed6f42ec0d975eea4 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Sun, 28 Apr 2024 15:33:40 +0100 Subject: [PATCH] DollClothDynamic * Added new prefix for lookahead type. * Added tracked item rebuild for the purpose of tracking types --- game/scripts/doll/clothes_dynamic.rpy | 17 +++++++++++++-- game/scripts/doll/main.rpy | 30 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/game/scripts/doll/clothes_dynamic.rpy b/game/scripts/doll/clothes_dynamic.rpy index f97d7d73..4b9c24f6 100644 --- a/game/scripts/doll/clothes_dynamic.rpy +++ b/game/scripts/doll/clothes_dynamic.rpy @@ -1,6 +1,6 @@ init python: class DollClothDynamic(DollCloth): - prefixes = ["!=", "?=", "+=", "!", "?", "+"] + prefixes = ["!=", "?=", "+=", "!", "?", "+", "*"] def __init__(self, name, categories, type, id, color, zorder=None, unlocked=False, level=0, blacklist=[], modpath=None, tracking=None, parent=None): self._tracking = tracking @@ -21,7 +21,7 @@ init python: @property def tracking_object(self): - if self.prefix in ("!", "?", "+"): + if self.prefix in ("!", "?", "+", "*"): return self.char.states.get(self.tracking)[0] else: return eval(self.tracking) @@ -49,6 +49,18 @@ init python: return "default" return tracking_id + def _lookahead_type(path): + tracking_object = self.tracking_object + + if not tracking_object: + return "default" + + path = posixpath.join(path, tracking_object.type) + + if not any(fp.startswith(path) for fp in renpy.list_files()): + return "default" + return tracking_object.type + def _chainload(): def __wrapper(obj): @@ -89,6 +101,7 @@ init python: "!": lambda tracking, _: _negative_lookahead(), "?": lambda tracking, path: _lookahead(path), "+": lambda tracking, _: _chainload(), + "*": lambda tracking, path: _lookahead_type(path), "!=": lambda tracking, _: _negative_lookahead_item(), "?=": lambda tracking, _: _lookahead_item(), "+=": lambda tracking, _: _chainload(), diff --git a/game/scripts/doll/main.rpy b/game/scripts/doll/main.rpy index b200f6ad..e9f9416f 100644 --- a/game/scripts/doll/main.rpy +++ b/game/scripts/doll/main.rpy @@ -235,16 +235,24 @@ init python: def unequip(self, *args): """Takes argument(s) containing string cloth type(s) to unequip.""" + def _tracker_rebuild(type): + for tracking in self.get_trackers_list(type): + tracking.is_stale() + def _unequip_all(): for k, v in self.states.items(): if not k in self.blacklist_unequip: v[0], v[2] = None, True + _tracker_rebuild(k) + def _unequip_type(type): for k, v in self.states.items(): if not k in self.blacklist_unequip and istype(v[0], type): v[0], v[2] = None, True + _tracker_rebuild(k) + def _unequip_slot(slot): if slot in self.blacklist_unequip: return @@ -256,6 +264,8 @@ init python: else: self.states[slot][0], self.states[slot][2] = None, True + _tracker_rebuild(slot) + for arg in args: if isinstance(arg, str): if arg == "all": @@ -302,16 +312,24 @@ init python: def strip(self, *args): """Takes argument(s) containing string cloth type(s) to temporarily displace (hide).""" + def _tracker_rebuild(type): + for tracking in self.get_trackers_list(type): + tracking.is_stale() + def _strip_all(): for k, v in self.states.items(): if not k.startswith(self.blacklist_unequip): v[2] = False + _tracker_rebuild(k) + def _strip_type(type): for k, v in self.states.items(): if istype(v[0], type) and not k in self.blacklist_unequip and (k in self.multislots or not k.startswith(self.blacklist_strip)): v[2] = False + _tracker_rebuild(k) + def _strip_slot(slot): if slot in self.blacklist_unequip: return @@ -323,6 +341,8 @@ init python: else: self.states[slot][2] = False + _tracker_rebuild(slot) + for arg in args: if arg == "all": @@ -342,15 +362,23 @@ init python: def wear(self, *args): """Takes argument(s) containing string cloth type(s) to temporarily displace (hide).""" + def _tracker_rebuild(type): + for tracking in self.get_trackers_list(type): + tracking.is_stale() + def _wear_all(): for k, v in self.states.items(): v[2] = True + _tracker_rebuild(k) + def _wear_type(type): for k, v in self.states.items(): if istype(v[0], type): v[2] = True + _tracker_rebuild(v) + def _wear_slot(slot): if slot in self.multislots: for k, v in self.states.items(): @@ -359,6 +387,8 @@ init python: else: self.states[slot][2] = True + _tracker_rebuild(slot) + for arg in args: if arg == "all":