Compare commits

...

3 Commits
main ... dev

Author SHA1 Message Date
LoafyLemon 8b272ca8b5 gitignore 2024-04-28 17:04:00 +01:00
LoafyLemon 99fbcd4ea7 DollClothDynamic
* Added new prefix for lookahead type.
* Added tracked item rebuild for the purpose of tracking types
2024-04-28 15:33:40 +01:00
LoafyLemon 8aa1a84efb Bug fix
* Fix detection of orphaned script and clarify the exception
2024-04-28 13:43:47 +01:00
4 changed files with 62 additions and 17 deletions

3
.gitignore vendored
View File

@ -11,6 +11,9 @@ Desktop.ini
$RECYCLE.BIN/
.DS_Store
# Hidden dirs
*/.*
# Python
*.py[cod]

View File

@ -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(),

View File

@ -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":

View File

@ -26,26 +26,25 @@ python early:
UNDERLINE = '\033[4;37;48m'
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():
excluded = ["tl/", "00db.rpyc", "00sshtransition.rpyc"]
def detect_orphaned_rpyc_files():
excluded = ["tl/"]
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)]
scripts = [x for x in files if x.endswith(".rpy")]
orphaned = []
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")]
orphaned = []
for i in compiled:
if not i[:-1] in scripts:
orphaned.append(i)
for i in compiled:
if not i[:-1] in scripts:
orphaned.append(i)
if orphaned:
raise Exception(f"Orphaned compiled scripts detected, please delete them before continuing:\n{orphaned}")
detect_orphaned_rpyc_files()
if orphaned:
raise Exception(f"Orphaned compiled scripts detected, please force recompile in Ren'py Launcher before continuing:\n{orphaned}")
detect_orphaned_rpyc_files()
# class InstanceDebugger(object):