Merge branch 'refs/heads/dev' into interface

This commit is contained in:
LoafyLemon 2024-04-28 16:46:23 +01:00
commit c38763c065
3 changed files with 59 additions and 17 deletions

View File

@ -1,6 +1,6 @@
init python: init python:
class DollClothDynamic(DollCloth): 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): def __init__(self, name, categories, type, id, color, zorder=None, unlocked=False, level=0, blacklist=[], modpath=None, tracking=None, parent=None):
self._tracking = tracking self._tracking = tracking
@ -21,7 +21,7 @@ init python:
@property @property
def tracking_object(self): def tracking_object(self):
if self.prefix in ("!", "?", "+"): if self.prefix in ("!", "?", "+", "*"):
return self.char.states.get(self.tracking)[0] return self.char.states.get(self.tracking)[0]
else: else:
return eval(self.tracking) return eval(self.tracking)
@ -49,6 +49,18 @@ init python:
return "default" return "default"
return tracking_id 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 _chainload():
def __wrapper(obj): def __wrapper(obj):
@ -89,6 +101,7 @@ init python:
"!": lambda tracking, _: _negative_lookahead(), "!": lambda tracking, _: _negative_lookahead(),
"?": lambda tracking, path: _lookahead(path), "?": lambda tracking, path: _lookahead(path),
"+": lambda tracking, _: _chainload(), "+": lambda tracking, _: _chainload(),
"*": lambda tracking, path: _lookahead_type(path),
"!=": lambda tracking, _: _negative_lookahead_item(), "!=": lambda tracking, _: _negative_lookahead_item(),
"?=": lambda tracking, _: _lookahead_item(), "?=": lambda tracking, _: _lookahead_item(),
"+=": lambda tracking, _: _chainload(), "+=": lambda tracking, _: _chainload(),

View File

@ -235,16 +235,24 @@ init python:
def unequip(self, *args): def unequip(self, *args):
"""Takes argument(s) containing string cloth type(s) to unequip.""" """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(): def _unequip_all():
for k, v in self.states.items(): for k, v in self.states.items():
if not k in self.blacklist_unequip: if not k in self.blacklist_unequip:
v[0], v[2] = None, True v[0], v[2] = None, True
_tracker_rebuild(k)
def _unequip_type(type): def _unequip_type(type):
for k, v in self.states.items(): for k, v in self.states.items():
if not k in self.blacklist_unequip and istype(v[0], type): if not k in self.blacklist_unequip and istype(v[0], type):
v[0], v[2] = None, True v[0], v[2] = None, True
_tracker_rebuild(k)
def _unequip_slot(slot): def _unequip_slot(slot):
if slot in self.blacklist_unequip: if slot in self.blacklist_unequip:
return return
@ -256,6 +264,8 @@ init python:
else: else:
self.states[slot][0], self.states[slot][2] = None, True self.states[slot][0], self.states[slot][2] = None, True
_tracker_rebuild(slot)
for arg in args: for arg in args:
if isinstance(arg, str): if isinstance(arg, str):
if arg == "all": if arg == "all":
@ -302,16 +312,24 @@ init python:
def strip(self, *args): def strip(self, *args):
"""Takes argument(s) containing string cloth type(s) to temporarily displace (hide).""" """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(): def _strip_all():
for k, v in self.states.items(): for k, v in self.states.items():
if not k.startswith(self.blacklist_unequip): if not k.startswith(self.blacklist_unequip):
v[2] = False v[2] = False
_tracker_rebuild(k)
def _strip_type(type): def _strip_type(type):
for k, v in self.states.items(): 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)): 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 v[2] = False
_tracker_rebuild(k)
def _strip_slot(slot): def _strip_slot(slot):
if slot in self.blacklist_unequip: if slot in self.blacklist_unequip:
return return
@ -323,6 +341,8 @@ init python:
else: else:
self.states[slot][2] = False self.states[slot][2] = False
_tracker_rebuild(slot)
for arg in args: for arg in args:
if arg == "all": if arg == "all":
@ -342,15 +362,23 @@ init python:
def wear(self, *args): def wear(self, *args):
"""Takes argument(s) containing string cloth type(s) to temporarily displace (hide).""" """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(): def _wear_all():
for k, v in self.states.items(): for k, v in self.states.items():
v[2] = True v[2] = True
_tracker_rebuild(k)
def _wear_type(type): def _wear_type(type):
for k, v in self.states.items(): for k, v in self.states.items():
if istype(v[0], type): if istype(v[0], type):
v[2] = True v[2] = True
_tracker_rebuild(v)
def _wear_slot(slot): def _wear_slot(slot):
if slot in self.multislots: if slot in self.multislots:
for k, v in self.states.items(): for k, v in self.states.items():
@ -359,6 +387,8 @@ init python:
else: else:
self.states[slot][2] = True self.states[slot][2] = True
_tracker_rebuild(slot)
for arg in args: for arg in args:
if arg == "all": if arg == "all":

View File

@ -26,13 +26,13 @@ python early:
UNDERLINE = '\033[4;37;48m' UNDERLINE = '\033[4;37;48m'
END = '\033[1;37;0m' END = '\033[1;37;0m'
if config.developer:
# Debug # Debug
# Note: config.developer flag is set to False during early initialisation
def detect_orphaned_rpyc_files(): def detect_orphaned_rpyc_files():
excluded = ["tl/"] excluded = ["tl/", "00db.rpyc", "00sshtransition.rpyc"]
files = renpy.list_files(common=True) files = renpy.list_files(common=True)
compiled = [x for x in files if x.endswith(".rpyc") if not any(x.startswith(i) for i in excluded)] compiled = [x for x in files if x.endswith(".rpyc") if not any(x.startswith(i) for i in excluded)]
scripts = [x for x in files if x.endswith(".rpy")] scripts = [x for x in files if x.endswith(".rpy")]
orphaned = [] orphaned = []
@ -42,11 +42,10 @@ python early:
orphaned.append(i) orphaned.append(i)
if orphaned: if orphaned:
raise Exception(f"Orphaned compiled scripts detected, please delete them before continuing:\n{orphaned}") raise Exception(f"Orphaned compiled scripts detected, please force recompile in Ren'py Launcher before continuing:\n{orphaned}")
detect_orphaned_rpyc_files() detect_orphaned_rpyc_files()
# class InstanceDebugger(object): # class InstanceDebugger(object):
# def __init__(self, obj): # def __init__(self, obj):