diff --git a/game/scripts/doll/body.rpy b/game/scripts/doll/body.rpy index 1e17f794..f9cf729a 100644 --- a/game/scripts/doll/body.rpy +++ b/game/scripts/doll/body.rpy @@ -13,8 +13,8 @@ init python: sprites = [] # Add body parts and skin layers from clothes, face, cum - sprites.extend(("{}{}/{}.webp".format(self.imagepath, k, v[0]), v[1]) for k, v in self.body.iteritems() if v[0]) # Body parts - sprites.extend((o[0].skin, self.zorder_skin) for o in self.char.clothes.itervalues() if o[0] and o[0].skin and o[2]) # Clothes skin + sprites.extend(("{}{}/{}.webp".format(self.imagepath, k, v[0]), v[1]) for k, v in self.body.items() if v[0]) # Body parts + sprites.extend((o[0].skin, self.zorder_skin) for o in self.char.clothes.values() if o[0] and o[0].skin and o[2]) # Clothes skin sprites.extend((x, self.zorder_skin) for x in self.char.face.get_skin()) # Face skin sprites.extend((x, self.zorder_skin) for x in self.char.cum.get_skin()) # Cum skin @@ -31,7 +31,7 @@ init python: sprites = [] # Add body parts and skin layers from clothes - sprites.extend(("{}{}/{}.webp".format(self.imagepath, k, v[0]), v[1]) for k, v in self.body.iteritems() if v[0]) + sprites.extend(("{}{}/{}.webp".format(self.imagepath, k, v[0]), v[1]) for k, v in self.body.items() if v[0]) if group: sprites.extend((o.skin, self.zorder_skin) for o in group if o and o.skin) @@ -50,7 +50,7 @@ init python: """Takes keyword argument(s) with the string name of body part file(s). Returns True if image is changed.""" changed = False - for arg, value in kwargs.iteritems(): + for arg, value in kwargs.items(): if value != self.body[str(arg)][0]: self.body[str(arg)][0] = value changed = True @@ -72,7 +72,7 @@ init python: """Takes keyword argument(s) with the string name of body type(s) and int value(s). Returns True if image is changed.""" changed = False - for arg, value in kwargs.iteritems(): + for arg, value in kwargs.items(): if value != self.body[str(arg)][1]: self.body[str(arg)][1] = value changed = True diff --git a/game/scripts/doll/clothes.rpy b/game/scripts/doll/clothes.rpy index 454ba113..582f36ba 100644 --- a/game/scripts/doll/clothes.rpy +++ b/game/scripts/doll/clothes.rpy @@ -54,7 +54,7 @@ init python: for x in self.layers_additional: self.__dict__[x] = [] - for i in xrange(self.layers): + for i in range(self.layers): path = "{}{}_{}.webp".format(self.imagepath, i, x) if renpy.loadable(path): self.__dict__[x].append(path) @@ -65,7 +65,7 @@ init python: self.__dict__[x+"_outline"] = path if renpy.loadable(path) else None def build_image(self): - sprites = [(self.apply_color("{}{}.webp".format(self.imagepath, x), x), x) for x in xrange(self.layers)] + sprites = [(self.apply_color("{}{}.webp".format(self.imagepath, x), x), x) for x in range(self.layers)] # Add extra layers if exist for n, x in enumerate(self.layers_extra): diff --git a/game/scripts/doll/cum.rpy b/game/scripts/doll/cum.rpy index 1c4f0c90..7ff113d4 100644 --- a/game/scripts/doll/cum.rpy +++ b/game/scripts/doll/cum.rpy @@ -10,23 +10,23 @@ init python: self.cum = dict((k, None) for k in {"hair", "face", "breasts", "body", "crotch", "pussy", "legs"}) def build_image(self): - sprites = tuple("{}{}/{}.webp".format(self.imagepath, k, v) for k, v in self.cum.iteritems() if v != None) + sprites = tuple("{}{}/{}.webp".format(self.imagepath, k, v) for k, v in self.cum.items() if v != None) return sprites def get_skin(self): - return ["{}{}/{}_skin.webp".format(self.imagepath, k, v) for k, v in self.cum.iteritems() if renpy.loadable("{}{}/{}_skin.webp".format(self.imagepath, k, v))] + return ["{}{}/{}_skin.webp".format(self.imagepath, k, v) for k, v in self.cum.items() if renpy.loadable("{}{}/{}_skin.webp".format(self.imagepath, k, v))] def set_cum(self, *args, **kwargs): """Takes keyword argument(s) containing string name(s) of cum layers to apply or None. Returns True if image is changed.""" changed = False if args: - for k, v in self.cum.iteritems(): + for k, v in self.cum.items(): if v != args[0]: self.cum[k] = args[0] changed = True - for arg, value in kwargs.iteritems(): + for arg, value in kwargs.items(): if str(arg) != value: self.cum[str(arg)] = value changed = True diff --git a/game/scripts/doll/face.rpy b/game/scripts/doll/face.rpy index 9df454df..dabe4fc2 100644 --- a/game/scripts/doll/face.rpy +++ b/game/scripts/doll/face.rpy @@ -14,7 +14,7 @@ init python: ### TODO: This piece of code needs to be simplified. # Add facial expressions - for k, v in self.face.iteritems(): + for k, v in self.face.items(): if v[0] and k not in ("eyes", "pupils"): sprites.append(("{}{}/{}.webp".format(self.imagepath, k, v[0]), v[1])) @@ -51,18 +51,18 @@ init python: return sprites def get_skin(self): - for k, v in self.face.iteritems(): + for k, v in self.face.items(): skin_path = "{}{}/{}_skin.webp".format(self.imagepath, k, v[0]) if renpy.loadable(skin_path): yield skin_path def get_face(self): - return dict((k, v[0]) for k, v in self.face.iteritems()) + return dict((k, v[0]) for k, v in self.face.items()) def set_face(self, **kwargs): """Takes keyword argument(s) with the string name of expression file(s). Returns True if image is changed.""" changed = False - for arg, value in kwargs.iteritems(): + for arg, value in kwargs.items(): if value not in (self.face[str(arg)][0], False): self.face[str(arg)][0] = value changed = True @@ -84,7 +84,7 @@ init python: def set_zorder(self, **kwargs): """Takes keyword argument(s) with the string name of face type(s) and int value(s). Returns True if image is changed.""" changed = False - for arg, value in kwargs.iteritems(): + for arg, value in kwargs.items(): if value != self.face[str(arg)][1]: self.face[str(arg)][1] = value changed = True diff --git a/game/scripts/doll/init.rpy b/game/scripts/doll/init.rpy index dffba943..51d69808 100644 --- a/game/scripts/doll/init.rpy +++ b/game/scripts/doll/init.rpy @@ -10,4 +10,3 @@ init python: outfit_last = outfit = get_character_outfit(c, type="last") outfit_last.save() - diff --git a/game/scripts/doll/lipstick.rpy b/game/scripts/doll/lipstick.rpy index cd7ce07c..8327ef49 100644 --- a/game/scripts/doll/lipstick.rpy +++ b/game/scripts/doll/lipstick.rpy @@ -10,7 +10,7 @@ init python: for x in self.layers_additional: self.__dict__[x] = [] - for i in xrange(self.layers): + for i in range(self.layers): path = "{}{}_{}.webp".format(self.imagepath, i, x) if renpy.loadable(path): self.__dict__[x].append(path) diff --git a/game/scripts/doll/main.rpy b/game/scripts/doll/main.rpy index 7649707c..ab30e88c 100644 --- a/game/scripts/doll/main.rpy +++ b/game/scripts/doll/main.rpy @@ -70,7 +70,7 @@ init python: (self.emote, 1000), ] - for i in self.clothes.itervalues(): + for i in self.clothes.values(): clothing, _, is_worn = i if not clothing is None and is_worn: @@ -156,7 +156,7 @@ init python: def unequip(self, *args): """Takes argument(s) containing string cloth type(s) to unequip.""" if "all" in args: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if not k in self.blacklist_unequip: if self.pose and v[0]: v[0].set_pose(None) @@ -187,13 +187,13 @@ init python: def strip(self, *args): """Takes argument(s) containing string cloth type(s) to temporarily displace (hide).""" if "all" in args: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if not k.startswith(self.blacklist_toggles): v[2] = False else: for arg in args: if arg in self.multislots: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if k.startswith(arg): v[2] = False else: @@ -208,12 +208,12 @@ init python: if self.is_worn("all"): return - for v in self.clothes.itervalues(): + for v in self.clothes.values(): v[2] = True else: for arg in args: if arg in self.multislots: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if k.startswith(arg): v[2] = True else: @@ -226,7 +226,7 @@ init python: """Takes argument containing string cloth type. Returns True if slot is occupied, False otherwise.""" for arg in args: if arg in self.multislots: - return any(bool(v[0]) for k, v in self.clothes.iteritems() if k.startswith(arg)) + return any(bool(v[0]) for k, v in self.clothes.items() if k.startswith(arg)) else: if not self.clothes[arg][0]: return False @@ -235,7 +235,7 @@ init python: def is_any_equipped(self, *args): """Takes arguments containing string cloth types. Returns True if ANY of them is equipped, False otherwise.""" if "clothes" in args: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if not k.startswith(self.blacklist_toggles): if self.is_equipped(k): return True @@ -252,13 +252,13 @@ init python: def is_worn(self, *args): """Takes argument(s) containing string cloth type(s). Returns True if worn, False otherwise.""" if "all" in args: - for v in self.clothes.itervalues(): + for v in self.clothes.values(): if not v[2]: return False else: for arg in args: if arg in self.multislots: - return any( (v[0] and v[2]) for k, v in self.clothes.iteritems() if k.startswith(arg)) + return any( (v[0] and v[2]) for k, v in self.clothes.items() if k.startswith(arg)) else: if not self.clothes[arg][0] or not self.clothes[arg][2]: return False @@ -267,7 +267,7 @@ init python: def is_any_worn(self, *args): """Takes arguments containing string cloth types. Returns True if ANY of them is worn, False otherwise.""" if "clothes" in args: - for k, v in self.clothes.iteritems(): + for k, v in self.clothes.items(): if not k.startswith(self.blacklist_toggles): if self.is_worn(k): return True @@ -320,7 +320,7 @@ init python: self.face.set_pose(pose) self.body.set_pose(pose) self.cum.set_pose(pose) - for v in self.clothes.itervalues(): + for v in self.clothes.values(): if v[0]: v[0].set_pose(pose) self.rebuild_image() @@ -329,7 +329,7 @@ init python: def rebuild_blacklist(self): blacklist = [] - for v in self.clothes.itervalues(): + for v in self.clothes.values(): if v[0]: blacklist.extend(v[0].blacklist) self.blacklist = list(set(blacklist)) @@ -340,11 +340,11 @@ init python: def get_blacklister(self, type): """Takes string cloth type. Returns a list of clothing types that report incompatibility.""" - return [x[0].type for x in self.clothes.itervalues() if x[0] and type in x[0].blacklist] + return [x[0].type for x in self.clothes.values() if x[0] and type in x[0].blacklist] def create_outfit(self, temp=False): """Creates a copy of the current character clothes and stores it.""" - return DollOutfit([x[0] for x in self.clothes.itervalues() if x[0]], True, temp=temp) + return DollOutfit([x[0] for x in self.clothes.values() if x[0]], True, temp=temp) def import_outfit(self, path, fromfile=True): """Imports outfit from .png file or clipboard text.""" @@ -427,4 +427,3 @@ init python: path = "characters/{}/emote/{}.webp".format(self.name, emote) self.emote = DollDisplayable(Image(path)) - diff --git a/game/scripts/doll/outfits.rpy b/game/scripts/doll/outfits.rpy index b7e6ec1e..27196448 100644 --- a/game/scripts/doll/outfits.rpy +++ b/game/scripts/doll/outfits.rpy @@ -9,7 +9,7 @@ init python: self.price = price self.char = self.group[0].char self.unlocked = unlocked - self.schedule = dict(self.default_schedule.items() + schedule.items()) + self.schedule = dict(list(self.default_schedule.items()) + list(schedule.items())) self.hash = self.generate_hash() self.temp = temp self.hidden = hidden @@ -33,7 +33,7 @@ init python: return self.hash == obj.hash def generate_hash(self): - salt = str( sorted([ sorted([x.name, x.type, x.id, x.color]) for x in self.group ]) ) + salt = str( sorted( [sorted([x.name, x.type, x.id, str(x.color)] ) for x in self.group]) ) return hash(salt) def delete(self): @@ -127,7 +127,7 @@ init python: def save(self): """Overwrites this outfit with clothes currently equipped by the character.""" self.group = [] - for v in self.char.clothes.itervalues(): + for v in self.char.clothes.values(): if v[0]: self.group.append(v[0].clone()) self.rebuild_image() @@ -149,7 +149,7 @@ init python: return self.schedule def set_schedule(self, **kwargs): - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): self.schedule[k] = v def has_type(self, *args): @@ -168,7 +168,7 @@ init python: def has_any_type(self, *args): """Takes arguments containing string cloth types. Returns True if ANY of them is worn, False otherwise.""" if "clothes" in args: - for k in self.char.clothes.iterkeys(): + for k in self.char.clothes.keys(): if not k.startswith(self.blacklist_toggles): if self.has_type(k): return True diff --git a/game/scripts/doll/threading.rpy b/game/scripts/doll/threading.rpy index 694e50b5..c060afa9 100644 --- a/game/scripts/doll/threading.rpy +++ b/game/scripts/doll/threading.rpy @@ -2,19 +2,14 @@ init python: import threading class DollThread(threading.Thread, NoRollback): - def __init__(self, group=None, target=None, name=None, args=(), kwargs={}, Verbose=None): - super(DollThread, self).__init__(group, target, name, args, kwargs, Verbose) + def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None): + threading.Thread.__init__(self, group, target, name, args, kwargs, daemon=daemon) + self._return = None def run(self): - try: - self._return = self._Thread__target(*self._Thread__args, **self._Thread__kwargs) - except: - import traceback - traceback.print_exc() - - if config.developer: - raise Exception("Thread just pooped itself.") + if self._target is not None: + self._return = self._target(*self._args, **self._kwargs) renpy.restart_interaction() diff --git a/game/scripts/events/queue.rpy b/game/scripts/events/queue.rpy index 8244719d..44809e4f 100644 --- a/game/scripts/events/queue.rpy +++ b/game/scripts/events/queue.rpy @@ -28,7 +28,7 @@ init -1 python: def start(self): queue = self.queue - queue = filter(lambda x: (x.wait <= 0) and (x.daytime == game.daytime), queue) + queue = [x for x in queue if (x.wait <= 0) and (x.daytime == game.daytime)] queue.sort(key=lambda x: x.priority) for ev in queue: diff --git a/game/scripts/interface/achievements.rpy b/game/scripts/interface/achievements.rpy index e05ac788..1cad09bb 100644 --- a/game/scripts/interface/achievements.rpy +++ b/game/scripts/interface/achievements.rpy @@ -53,7 +53,7 @@ init python: def validate(self): """Check if icons are loadable at init""" - for i in self.achievements.itervalues(): + for i in self.achievements.values(): if not renpy.loadable(i[4]): raise IOError("\"{}\"".format(i[4])) @@ -65,9 +65,9 @@ init python: Attempted repair will try to fix the mismatched values without resetting the completion status.""" # Save unlock states - unlock_states = {k: v[3] for k, v in self.achievements.iteritems()} + unlock_states = {k: v[3] for k, v in self.achievements.items()} # Keys that should not exist in the persistent state anymore - orphans = self.achievements.viewkeys() - achievements_dict.viewkeys() + orphans = self.achievements.keys() - achievements_dict.keys() # Making some K-pop for k in orphans: @@ -76,7 +76,7 @@ init python: self.achievements.update(achievements_dict) # Reapply unlock states - for k, v in self.achievements.iteritems(): + for k, v in self.achievements.items(): v[3] = unlock_states.get(k, False) def status(self, id): @@ -97,11 +97,11 @@ init python: def achievement_sortfilter(item, sortby="A-z", filtering=None): if filtering == "Locked": - item = filter(lambda x: x[1][3] is False, item) + item = [x for x in item if x[1][3] is False] elif filtering == "Unlocked": - item = filter(lambda x: x[1][3] is True, item) + item = [x for x in item if x[1][3] is True] elif filtering == "Secret": - item = filter(lambda x: x[1][5] is True, item) + item = [x for x in item if x[1][5] is True] # Always sort alphabetically first. item = sorted(item, key=lambda x: natsort_key(x[1][1])) @@ -179,69 +179,72 @@ label achievement: label achievement_menu(xx=150, yy=90): - $ achievement_categories_sorted = ["All", "General", "Characters", "Cardgame", "Mirror"] + python: + achievement_categories_sorted = ["All", "General", "Characters", "Cardgame", "Mirror"] - $ items_shown = 36 - $ current_page = 0 - $ current_category = achievement_categories_sorted[0] - $ current_filter = None - $ current_sorting = "Unlocked" + items_shown = 36 + current_page = 0 + current_category = achievement_categories_sorted[0] + current_filter = None + current_sorting = "Unlocked" - $ category_items = list(persistent.achievements.iteritems()) - $ menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_item = next(iter(menu_items), None) + category_items = list(persistent.achievements.items()) + menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) + current_item = next(iter(menu_items), None) - show screen achievements(xx, yy) + renpy.show_screen("achievements", xx, yy) label .after_init: - $ _choice = ui.interact() - if _choice[0] == "select": - $ current_item = _choice[1] - elif _choice[0] == "category": - $ current_category = _choice[1] - if current_category == "All": - $ category_items = list(persistent.achievements.iteritems()) + python: + _choice = ui.interact() + + if _choice[0] == "select": + current_item = _choice[1] + elif _choice[0] == "category": + current_category = _choice[1] + if current_category == "All": + category_items = list(persistent.achievements.items()) + else: + category_items = [x for x in list(persistent.achievements.items()) if current_category in x[1][0]] + menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) + current_page = 0 + current_item = next(iter(menu_items), None) + elif _choice == "inc": + current_page += 1 + elif _choice == "dec": + current_page += -1 + elif _choice == "filter": + if current_filter == None: + current_filter = "Locked" + elif current_filter == "Locked": + current_filter = "Unlocked" + elif current_filter == "Unlocked": + current_filter = "Secret" + else: + current_filter = None + menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) + current_page = 0 + current_item = next(iter(menu_items), None) + elif _choice == "sort": + if current_sorting == "A-z": + current_sorting = "z-A" + elif current_sorting == "z-A": + current_sorting = "Unlocked" + elif current_sorting == "Unlocked": + current_sorting = "Locked" + else: + current_sorting = "A-z" + menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) + current_page = 0 + current_item = next(iter(menu_items), None) else: - $ category_items = filter(lambda x: current_category in x[1][0], list(persistent.achievements.iteritems())) - $ menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_page = 0 - $ current_item = next(iter(menu_items), None) - elif _choice == "inc": - $ current_page += 1 - elif _choice == "dec": - $ current_page += -1 - elif _choice == "filter": - if current_filter == None: - $ current_filter = "Locked" - elif current_filter == "Locked": - $ current_filter = "Unlocked" - elif current_filter == "Unlocked": - $ current_filter = "Secret" - else: - $ current_filter = None - $ menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_page = 0 - $ current_item = next(iter(menu_items), None) - elif _choice == "sort": - if current_sorting == "A-z": - $ current_sorting = "z-A" - elif current_sorting == "z-A": - $ current_sorting = "Unlocked" - elif current_sorting == "Unlocked": - $ current_sorting = "Locked" - else: - $ current_sorting = "A-z" - $ menu_items = achievement_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_page = 0 - $ current_item = next(iter(menu_items), None) - else: - hide screen achievements - return + renpy.hide_screen("achievements") + renpy.return_statement() jump .after_init @@ -306,7 +309,7 @@ screen achievement_menuitem(xx, yy): text "Achievements" size 22 xalign 0.5 ypos 65 - text "Unlocked: "+str(len(filter(lambda x: x[1][3] is True, menu_items)))+"/[menu_items_length]" size 12 pos (24, 70) + text "Unlocked: "+str(len([x for x in menu_items if x[1][3] is True]))+"/[menu_items_length]" size 12 pos (24, 70) # Page counter if menu_items_length > items_shown: @@ -333,7 +336,7 @@ screen achievement_menuitem(xx, yy): action Return("inc") # Add items - for i in xrange(current_page*items_shown, (current_page*items_shown)+items_shown): + for i in range(current_page*items_shown, (current_page*items_shown)+items_shown): if i < menu_items_length: $ row = (i // 9) % 4 $ col = i % 9 diff --git a/game/scripts/utility/common_functions.rpy b/game/scripts/utility/common_functions.rpy index 53fb25a7..f5a82f0b 100644 --- a/game/scripts/utility/common_functions.rpy +++ b/game/scripts/utility/common_functions.rpy @@ -30,12 +30,12 @@ init -1 python: output.append("zero") else: s = str(n) - groups = (len(s)+2)/3 + groups = (len(s)+2)//3 s = s.zfill(groups*3) - for i in xrange(0, groups*3, 3): + for i in range(0, groups*3, 3): h,t,u = int(s[i]), int(s[i+1]), int(s[i+2]) - g = groups-(i/3+1) + g = groups-(i//3+1) if h > 0: output.append(units[h]+" hundred") @@ -120,7 +120,7 @@ init -1 python: if isinstance(obj, _list): return [make_revertable(x) for x in obj] elif isinstance(obj, _dict): - return dict([(make_revertable(k), make_revertable(v)) for (k,v) in obj.iteritems()]) + return dict([(make_revertable(k), make_revertable(v)) for (k,v) in obj.items()]) else: return obj @@ -136,10 +136,10 @@ init -1 python: def timeit(func, loops=10000, args=(), kwargs={}): start = time.time() - for i in xrange(loops): + for i in range(loops): func(*args, **kwargs) end = time.time() - print("The task has taken {} seconds to finish".format(end-start)) + print(f"The task has taken {end-start} seconds to finish") def list_swap_values(l, val1, val2): """Mutates the original list.""" @@ -191,7 +191,7 @@ init -1 python: renpy.display.tts.tts(str(s)) def is_in_lead(house): - if isinstance(house, basestring): + if isinstance(house, str): house = getattr(renpy.store, house) return (house == max(gryffindor, slytherin, ravenclaw, hufflepuff)) diff --git a/game/scripts/utility/editor.rpy b/game/scripts/utility/editor.rpy index 7951a311..03303ffc 100644 --- a/game/scripts/utility/editor.rpy +++ b/game/scripts/utility/editor.rpy @@ -101,7 +101,7 @@ init python: # We need to make sure not to add quotes # to expressions or variables. - if isinstance(val, basestring): + if isinstance(val, str): val = "\"{}\"".format(val) # Insert new expression @@ -109,11 +109,11 @@ init python: d[expr] = val # Convert to list of tuples - # l = [(k, "\"{}\"".format(v)) for k, v in d.iteritems() if not v is None] # This is faster, but not robust enough. + # l = [(k, "\"{}\"".format(v)) for k, v in d.items() if not v is None] # This is faster, but not robust enough. l = _list() - for key, val in d.iteritems(): + for key, val in d.items(): if key in kw_args and val is None: continue @@ -268,7 +268,7 @@ init python: for expr in ("mouth", "eyes", "eyebrows", "pupils", "cheeks", "tears"): path = "characters/{}/face/{}/".format(name, expr) - files = filter(lambda x: path in x, all_files) + files = [x for x in all_files if path in x] d[key][expr] = [x.split(path)[1].split(".webp")[0] for x in files if x.endswith(".webp") and not any(f in x for f in filters)] @@ -290,7 +290,7 @@ init python: # Define expressions for Snape. filters = ("b01", "b01_01", "b02", "picture_Frame", "wand") path = "characters/snape/main/" - files = filter(lambda x: path in x, all_files) + files = [x for x in all_files if path in x] d["sna"] = _dict() d["sna"]["expression"] = [x.split(path)[1].split(".webp")[0] for x in files if x.endswith(".webp") and not any(f in x for f in filters)] @@ -338,7 +338,7 @@ init python: # if we don't, we'll end up messing up # the order of keywordless arguments. imap = {v: i for i, v in enumerate(keywords)} - d[who] = OrderedDict(sorted(d[who].items(), key=lambda x: imap[x[0]])) + d[who] = OrderedDict(sorted(list(d[who].items()), key=lambda x: imap[x[0]])) return d def get_expression_types(self, who): @@ -349,7 +349,7 @@ init python: def get_expressions_active_type(self, who, type): expr = self.get_expressions_active(who).get(type) - if isinstance(expr, basestring): + if isinstance(expr, str): expr = strip(expr) return expr @@ -371,7 +371,7 @@ init python: def get_expressions_last_type(self, who, type): expr = self.get_expressions_last(who).get(type, None) - if isinstance(expr, basestring): + if isinstance(expr, str): expr = strip(expr) return expr @@ -391,7 +391,7 @@ init python: if last == active: return - for type, val in persistent.iteritems(): + for type, val in persistent.items(): if val is False: continue @@ -459,7 +459,7 @@ screen editor(): if e.node: vbox: hbox: - for expr_type in e.get_expression_types(e.node.who).iterkeys(): + for expr_type in e.get_expression_types(e.node.who).keys(): textbutton "[expr_type]": action [CaptureFocus(expr_type), SetScreenVariable("focused", expr_type)] selected GetFocusRect(expr_type) @@ -510,7 +510,7 @@ screen editor(): textbutton "[e.live_code]" action SetScreenVariable("focused", 0) if e.node: - for expr_type, expr_list in e.get_expression_types(e.node.who).iteritems(): + for expr_type, expr_list in e.get_expression_types(e.node.who).items(): if GetFocusRect(expr_type): dismiss action [ClearFocus(expr_type), SetScreenVariable("focused", None)] diff --git a/game/scripts/utility/image_crop.rpy b/game/scripts/utility/image_crop.rpy index 4861b5e0..d8d1816a 100644 --- a/game/scripts/utility/image_crop.rpy +++ b/game/scripts/utility/image_crop.rpy @@ -4,7 +4,7 @@ init python: line = fp.readline() while line: path, area = line.strip("\r\n").split(':') - whitespace_dict[path] = map(int, area.split(',')) + whitespace_dict[path] = list(map(int, area.split(','))) line = fp.readline() def crop_whitespace(path): @@ -25,7 +25,7 @@ init python: return Transform(sprite, crop=(x, y, w, h), xsize=xsize, ysize=ysize, fit="contain", matrixcolor=matrix, subpixel=True) def get_zoom(image, size): - if isinstance(image, basestring): + if isinstance(image, str): image = Image(image) r = renpy.render(image, 800, 800, 0, 0) diff --git a/game/scripts/wardrobe/wardrobe.rpy b/game/scripts/wardrobe/wardrobe.rpy index 1cb1bf8e..271d2290 100644 --- a/game/scripts/wardrobe/wardrobe.rpy +++ b/game/scripts/wardrobe/wardrobe.rpy @@ -63,9 +63,9 @@ label wardrobe_menu(): # Defaults current_category = "head" - category_items = OrderedDict(sorted(wardrobe_subcategories.get(current_category, {}).iteritems(), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) - current_subcategory = category_items.keys()[0] if category_items else "" - menu_items = filter(lambda x: x.unlocked==True, category_items.get(current_subcategory, [])) + category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) + current_subcategory = list(category_items.keys())[0] if category_items else "" + menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True] current_item = char_active.get_equipped_item(menu_items) if wardrobe_music: @@ -75,114 +75,115 @@ label wardrobe_menu(): label .after_init: - $ _choice = ui.interact() + python: - if _choice[0] == "category": - if not current_category == _choice[1]: - if wardrobe_check_category(_choice[1]): - $ wardrobe_loaded = False - $ current_category = _choice[1] + _choice = ui.interact() - $ category_items = OrderedDict(sorted(wardrobe_subcategories.get(current_category, {}).iteritems(), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) - $ current_subcategory = category_items.keys()[0] if category_items else "" - $ menu_items = filter(lambda x: x.unlocked==True, category_items.get(current_subcategory, [])) + if _choice[0] == "category": + if not current_category == _choice[1]: + if wardrobe_check_category(_choice[1]): + wardrobe_loaded = False + current_category = _choice[1] + + category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) + current_subcategory = list(category_items.keys())[0] if category_items else "" + menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True] + + if current_category == "outfits": + _outfit = char_active.create_outfit(temp=True) + current_item = next( (x for x in char_active.outfits if _outfit == x), None) + else: + current_item = char_active.get_equipped_item(menu_items) + + char_active.wear("all") + if current_category in ("lower undergarment", "upper undergarment"): + char_active.strip("top", "bottom", "robe", "accessory") + elif current_category == "piercings & tattoos": + char_active.strip("top", "bottom", "robe", "accessory", "bra", "panties", "stockings", "gloves") + else: + wardrobe_react("category_fail", _choice[1]) + + elif _choice[0] == "subcategory": + if not current_subcategory == _choice[1]: + wardrobe_loaded = False + current_subcategory = _choice[1] + + if current_subcategory == "import": + menu_items = list_outfit_files() + else: + menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] if current_category == "outfits": - $ _outfit = char_active.create_outfit(temp=True) - $ current_item = next( (x for x in char_active.outfits if _outfit == x), None) + _outfit = char_active.create_outfit(temp=True) + current_item = next( (x for x in char_active.outfits if _outfit == x), None) else: - $ current_item = char_active.get_equipped_item(menu_items) + current_item = char_active.get_equipped_item(menu_items) - $ char_active.wear("all") - if current_category in ("lower undergarment", "upper undergarment"): - $ char_active.strip("top", "bottom", "robe", "accessory") - elif current_category == "piercings & tattoos": - $ char_active.strip("top", "bottom", "robe", "accessory", "bra", "panties", "stockings", "gloves") - else: - $ wardrobe_react("category_fail", _choice[1]) - - elif _choice[0] == "subcategory": - if not current_subcategory == _choice[1]: - $ wardrobe_loaded = False - $ current_subcategory = _choice[1] - - if current_subcategory == "import": - $ menu_items = list_outfit_files() - else: - $ menu_items = filter(lambda x: x.unlocked==True, category_items.get(current_subcategory)) - - if current_category == "outfits": - $ _outfit = char_active.create_outfit(temp=True) - $ current_item = next( (x for x in char_active.outfits if _outfit == x), None) - else: - $ current_item = char_active.get_equipped_item(menu_items) - - elif _choice[0] == "equip": - ### CLOTHING ### - if isinstance(_choice[1], DollCloth): - if _choice[1].type == "hair" and char_active.is_equipped_item(_choice[1]): - $ renpy.play("sounds/fail.ogg") - $ renpy.notify("Hair cannot be removed.") - else: - if char_active.is_equipped_item(_choice[1]): - # UNEQUIP - if wardrobe_check_unequip(_choice[1]): - $ wardrobe_react("unequip", _choice[1]) - $ char_active.unequip(_choice[1].type) - $ current_item = None - else: - $ wardrobe_react("unequip_fail", _choice[1]) + elif _choice[0] == "equip": + ### CLOTHING ### + if isinstance(_choice[1], DollCloth): + if _choice[1].type == "hair" and char_active.is_equipped_item(_choice[1]): + renpy.play("sounds/fail.ogg") + renpy.notify("Hair cannot be removed.") else: - # EQUIP - if wardrobe_check_equip(_choice[1]): - $ wardrobe_react("equip", _choice[1]) - - # Blacklist handling - if not wardrobe_check_blacklist(_choice[1]): - $ wardrobe_react("blacklist", _choice[1]) - - $ char_active.equip(_choice[1]) - $ current_item = _choice[1] - - if wardrobe_fallback_required(_choice[1]): - # Has to be called regardless of player preference. - $ renpy.call(get_character_response(active_girl, "fallback"), _choice[1]) - - # Lipstick Fix - Synchronize image with the current mouth after equipping. - if isinstance(_choice[1], DollLipstick): - $ _choice[1].rebuild_image() + if char_active.is_equipped_item(_choice[1]): + # UNEQUIP + if wardrobe_check_unequip(_choice[1]): + wardrobe_react("unequip", _choice[1]) + char_active.unequip(_choice[1].type) + current_item = None + else: + wardrobe_react("unequip_fail", _choice[1]) else: - $ wardrobe_react("equip_fail", _choice[1]) + # EQUIP + if wardrobe_check_equip(_choice[1]): + wardrobe_react("equip", _choice[1]) + + # Blacklist handling + if not wardrobe_check_blacklist(_choice[1]): + wardrobe_react("blacklist", _choice[1]) + + char_active.equip(_choice[1]) + current_item = _choice[1] + + if wardrobe_fallback_required(_choice[1]): + # Has to be called regardless of player preference. + renpy.call(get_character_response(active_girl, "fallback"), _choice[1]) + + # Lipstick Fix - Synchronize image with the current mouth after equipping. + if isinstance(_choice[1], DollLipstick): + _choice[1].rebuild_image() + else: + wardrobe_react("equip_fail", _choice[1]) ### OUTFIT ### elif isinstance(_choice[1], DollOutfit): - $ _outfit = char_active.create_outfit(temp=True) + _outfit = char_active.create_outfit(temp=True) if _outfit == _choice[1]: - $ renpy.notify("Load failed: Outfit already equipped.") + renpy.notify("Load failed: Outfit already equipped.") else: if wardrobe_check_equip_outfit(_choice[1]): if not _outfit.exists(): - $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Discard unsaved changes and load this outfit?") + _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Discard unsaved changes and load this outfit?") if _confirmed: - $ wardrobe_react("equip_outfit", _choice[1]) - $ char_active.equip(_choice[1]) - $ current_item = _choice[1] + wardrobe_react("equip_outfit", _choice[1]) + char_active.equip(_choice[1]) + current_item = _choice[1] else: - $ renpy.notify("Load failed: Cancelled by user.") + renpy.notify("Load failed: Cancelled by user.") else: - $ wardrobe_react("equip_outfit", _choice[1]) - $ char_active.equip(_choice[1]) - $ current_item = _choice[1] + wardrobe_react("equip_outfit", _choice[1]) + char_active.equip(_choice[1]) + current_item = _choice[1] else: - $ wardrobe_react("equip_outfit_fail", _choice[1]) + wardrobe_react("equip_outfit_fail", _choice[1]) - elif _choice[0] == "setcolor": - $ current_item.set_color(_choice[1]) + elif _choice[0] == "setcolor": + current_item.set_color(_choice[1]) - python: if wardrobe_global_color: for outfit in char_active.outfits: rebuild = False @@ -197,10 +198,9 @@ label wardrobe_menu(): if rebuild: outfit.rebuild_image() - elif _choice[0] == "resetcolor": - $ current_item.reset_color() + elif _choice[0] == "resetcolor": + current_item.reset_color() - python: if wardrobe_global_color: for outfit in char_active.outfits: rebuild = False @@ -215,87 +215,86 @@ label wardrobe_menu(): if rebuild: outfit.rebuild_image() - elif _choice[0] == "touch": - if wardrobe_check_touch(_choice[1]): - $ wardrobe_react("touch", _choice[1]) - else: - $ wardrobe_react("touch_fail", _choice[1]) - - elif _choice[0] == "addoutfit": - $ _outfit = char_active.create_outfit(temp=True) - - if _outfit.exists(): - $ renpy.notify("Save failed: Outfit already exists.") - else: - if _choice[1]: - $ _index = char_active.outfits.index(_choice[1]) - $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Overwrite this outfit?") - - if _confirmed: - $ _old_outfit = char_active.outfits[_index] - $ _old_schedule = _old_outfit.schedule.copy() - - $ _outfit = char_active.create_outfit() - $ _outfit.delete() # Removes it from list only - $ _outfit.schedule = _old_schedule - - $ char_active.outfits[_index] = _outfit - $ renpy.notify("Overwritten.") - else: - $ renpy.notify("Save failed: Cancelled by user.") - + elif _choice[0] == "touch": + if wardrobe_check_touch(_choice[1]): + wardrobe_react("touch", _choice[1]) else: - $ char_active.create_outfit() - $ renpy.notify("Outfit Saved.") + wardrobe_react("touch_fail", _choice[1]) - $ menu_items = filter(lambda x: x.unlocked==True, category_items.get(current_subcategory)) - $ current_item = next( (x for x in char_active.outfits if _outfit == x), None) + elif _choice[0] == "addoutfit": + _outfit = char_active.create_outfit(temp=True) - elif _choice[0] == "deloutfit": - $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Delete this outfit?") + if _outfit.exists(): + renpy.notify("Save failed: Outfit already exists.") + else: + if _choice[1]: + _index = char_active.outfits.index(_choice[1]) + _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Overwrite this outfit?") - if _confirmed: - $ _choice[1].delete() - $ menu_items = filter(lambda x: x.unlocked==True, category_items.get(current_subcategory)) - $ renpy.notify("Outfit Deleted.") + if _confirmed: + _old_outfit = char_active.outfits[_index] + _old_schedule = _old_outfit.schedule.copy() - elif _choice[0] == "export": - $ _choice[1].export_data(datetime.datetime.now().strftime("%d %b %Y-%H%M%S")) - $ achievements.unlock("export") + _outfit = char_active.create_outfit() + _outfit.delete() # Removes it from list only + _outfit.schedule = _old_schedule - elif _choice[0] == "import": - $ _outfit = char_active.import_outfit(_choice[1]) + char_active.outfits[_index] = _outfit + renpy.notify("Overwritten.") + else: + renpy.notify("Save failed: Cancelled by user.") - elif _choice[0] == "schedule": - $ renpy.call_screen("wardrobe_schedule_menuitem", _choice[1]) + else: + char_active.create_outfit() + renpy.notify("Outfit Saved.") - elif _choice == "music": - if wardrobe_music: - $ wardrobe_music = False - $ renpy.call("play_music", active_girl) - $ get_character_sayer(active_girl)("", face="happy") - else: - $ wardrobe_music = True - $ renpy.call("play_music", "wardrobe") - $ get_character_sayer(active_girl)("", face="happy") + menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] + current_item = next( (x for x in char_active.outfits if _outfit == x), None) - elif _choice == "randomise": - $ _confirmed = False + elif _choice[0] == "deloutfit": + _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Delete this outfit?") - $ _outfit = char_active.create_outfit(temp=True) + if _confirmed: + _choice[1].delete() + menu_items = [x for x in category_items.get(current_subcategory) if x.unlocked==True] + renpy.notify("Outfit Deleted.") - if not _outfit.exists(): - $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Randomise Outfit?\n{size=-6}Unsaved changes will be lost.{/size}") + elif _choice[0] == "export": + _choice[1].export_data(datetime.datetime.now().strftime("%d %b %Y-%H%M%S")) + achievements.unlock("export") - if not _confirmed: - $ renpy.notify("Advice: If you want to keep an outfit, save it.") - jump .after_init + elif _choice[0] == "import": + _outfit = char_active.import_outfit(_choice[1]) + + elif _choice[0] == "schedule": + renpy.call_screen("wardrobe_schedule_menuitem", _choice[1]) + + elif _choice == "music": + if wardrobe_music: + wardrobe_music = False + renpy.call("play_music", active_girl) + get_character_sayer(active_girl)("", face="happy") + else: + wardrobe_music = True + renpy.call("play_music", "wardrobe") + get_character_sayer(active_girl)("", face="happy") + + elif _choice == "randomise": + _confirmed = False + + _outfit = char_active.create_outfit(temp=True) + + if not _outfit.exists(): + _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Randomise Outfit?\n{size=-6}Unsaved changes will be lost.{/size}") + + if not _confirmed: + renpy.notify("Advice: If you want to keep an outfit, save it.") + renpy.jump("wardrobe_menu.after_init") - python: progress = get_character_progression(active_girl) - for k in char_active.clothes.iterkeys(): - valid_choices = filter(lambda x: (x.type == k and x.unlocked and progress >= x.level), char_active.wardrobe_list) + for k in char_active.clothes.keys(): + valid_choices = [x for x in char_active.wardrobe_list if (x.type == k and x.unlocked and progress >= x.level)] if k == "panties": if not progress >= get_character_requirement(active_girl, "category lower undergarment"): @@ -333,7 +332,7 @@ label wardrobe_menu(): if wardrobe_randomise_color: col = [] - for i in xrange(cloth.layers): + for i in range(cloth.layers): col.append([random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255]) cloth.set_color(col) @@ -360,24 +359,23 @@ label wardrobe_menu(): char_active.unequip(k) - else: #_choice == "Close": - $ _confirmed = False + else: #_choice == "Close": + _confirmed = False - if wardrobe_autosave: - $ _outfit = char_active.create_outfit() - else: - $ _outfit = char_active.create_outfit(temp=True) + if wardrobe_autosave: + _outfit = char_active.create_outfit() + else: + _outfit = char_active.create_outfit(temp=True) - if not _outfit.exists(): - $ renpy.notify("Advice: If you want to keep an outfit, save it.") - $ _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Exit without saving?\n{size=-6}Unsaved changes will be lost.{/size}") + if not _outfit.exists(): + renpy.notify("Advice: If you want to keep an outfit, save it.") + _confirmed = wardrobe_suppress_warnings or renpy.call_screen("confirm", "Exit without saving?\n{size=-6}Unsaved changes will be lost.{/size}") - if not _confirmed: - jump .after_init + if not _confirmed: + renpy.jump("wardrobe_menu.after_init") - $ char_active.equip(char_outfit) + char_active.equip(char_outfit) - python: if wardrobe_global_color: for cloth in char_outfit.group: for outfit in char_active.outfits: @@ -393,14 +391,14 @@ label wardrobe_menu(): if rebuild: outfit.rebuild_image() - hide screen wardrobe - $ char_active.wear("all") - $ renpy.play('sounds/door2.ogg') - if wardrobe_music: - $ renpy.call("play_music", active_girl) - $ enable_game_menu() - $ wardrobe_loaded = False - return + renpy.hide_screen("wardrobe") + char_active.wear("all") + renpy.play('sounds/door2.ogg') + if wardrobe_music: + renpy.call("play_music", active_girl) + enable_game_menu() + wardrobe_loaded = False + renpy.return_statement() jump .after_init