diff --git a/src/modlunky2/ui/levels/custom_levels/custom_level_editor.py b/src/modlunky2/ui/levels/custom_levels/custom_level_editor.py index a2894baa2..90924f067 100644 --- a/src/modlunky2/ui/levels/custom_levels/custom_level_editor.py +++ b/src/modlunky2/ui/levels/custom_levels/custom_level_editor.py @@ -756,7 +756,9 @@ def add_tilecode(self, tile, percent, alt_tile): ) return - ref_tile = Tile(new_tile_code, str(usable_code), "", tile_image, tile_image_picker) + ref_tile = Tile( + new_tile_code, str(usable_code), "", tile_image, tile_image_picker + ) self.tile_palette_ref_in_use.append(ref_tile) self.tile_palette_map[usable_code] = ref_tile diff --git a/src/modlunky2/ui/levels/vanilla_levels/vanilla_level_editor.py b/src/modlunky2/ui/levels/vanilla_levels/vanilla_level_editor.py index bbd54510f..aeb9a2af5 100644 --- a/src/modlunky2/ui/levels/vanilla_levels/vanilla_level_editor.py +++ b/src/modlunky2/ui/levels/vanilla_levels/vanilla_level_editor.py @@ -449,7 +449,9 @@ def register_tile_code(tile): ) # Clear tilecodes from all sister locations so they do not get reused. - sister_locations = LevelDependencies.sister_locations_for_level(lvl, self.lvls_path, self.extracts_path) + sister_locations = LevelDependencies.sister_locations_for_level( + lvl, self.lvls_path, self.extracts_path + ) for sister_location_path in sister_locations: for level in sister_location_path: for tilecode in level.level.tile_codes.all(): @@ -1000,8 +1002,11 @@ def log_codes_left(self): def use_dependency_tile(self, tile, dependency): new_tile = tile + def tile_will_conflict(): - sister_locations = LevelDependencies.sister_locations_for_level(self.lvl, self.lvls_path, self.extracts_path) + sister_locations = LevelDependencies.sister_locations_for_level( + self.lvl, self.lvls_path, self.extracts_path + ) for sister_location_path in sister_locations: for level in sister_location_path: for tilecode in level.level.tile_codes.all(): @@ -1015,7 +1020,8 @@ def tile_will_conflict(): self.usable_codes.remove(usable_code) else: tkMessageBox.showinfo( - "Uh Oh!", "This tile has a conflict, and you've reached the tilecode limit; delete some to add more" + "Uh Oh!", + "This tile has a conflict, and you've reached the tilecode limit; delete some to add more", ) return new_tile = Tile( @@ -1100,7 +1106,9 @@ def add_tilecode( ) return - ref_tile = Tile(new_tile_code, str(usable_code), "", tile_image, tile_image_picker) + ref_tile = Tile( + new_tile_code, str(usable_code), "", tile_image, tile_image_picker + ) self.tile_palette_ref_in_use.append(ref_tile) self.tile_palette_map[usable_code] = ref_tile diff --git a/src/modlunky2/ui/levels/vanilla_levels/variables/dependencies_tree.py b/src/modlunky2/ui/levels/vanilla_levels/variables/dependencies_tree.py index c49a2b3fc..9318f372c 100644 --- a/src/modlunky2/ui/levels/vanilla_levels/variables/dependencies_tree.py +++ b/src/modlunky2/ui/levels/vanilla_levels/variables/dependencies_tree.py @@ -10,15 +10,19 @@ from modlunky2.levels.level_templates import Chunk from modlunky2.levels.tile_codes import VALID_TILE_CODES, TileCode, TileCodes, ShortCode from modlunky2.utils import tb_info -from modlunky2.ui.levels.vanilla_levels.variables.level_dependencies import SisterLocation +from modlunky2.ui.levels.vanilla_levels.variables.level_dependencies import ( + SisterLocation, +) logger = logging.getLogger(__name__) + @dataclass class BrokenTile: level: SisterLocation tile: TileCode + class DependenciesTree(ttk.Treeview): def __init__(self, parent, lvls_path, extracts_path, *args, **kwargs): super().__init__(parent, *args, **kwargs) @@ -50,13 +54,18 @@ def find_broken_tiles(self): checked_levels.append(other_location.level_name) for othertilecode in other_location.level.tile_codes.all(): - if tilecode.value == othertilecode.value and tilecode.name != othertilecode.name: + if ( + tilecode.value == othertilecode.value + and tilecode.name != othertilecode.name + ): if not added_code: added_code = True broken_tiles.append( BrokenTile(self.current_location, tilecode) ) - broken_tiles.append(BrokenTile(other_location, othertilecode)) + broken_tiles.append( + BrokenTile(other_location, othertilecode) + ) logger.debug( "tilecode conflict: %s", tilecode.value, @@ -99,9 +108,7 @@ def resolve_conflicts(self): usable_codes.remove(new_code) level.tile_codes.set_obj( TileCode( - name = old_tile.name, - value = new_code, - comment = old_tile.comment + name=old_tile.name, value=new_code, comment=old_tile.comment ) ) # adds new tile to database with new code else: @@ -111,14 +118,30 @@ def resolve_conflicts(self): for template in level.level_templates.all(): new_chunks = [] for room in template.chunks: - foreground = [ [ str(new_code) if str(code) == str(old_tile_code) else str(code) for code in row] for row in room.foreground] - background = [ [ str(new_code) if str(code) == str(old_tile_code) else str(code) for code in row] for row in room.background] + foreground = [ + [ + str(new_code) + if str(code) == str(old_tile_code) + else str(code) + for code in row + ] + for row in room.foreground + ] + background = [ + [ + str(new_code) + if str(code) == str(old_tile_code) + else str(code) + for code in row + ] + for row in room.background + ] new_chunks.append( Chunk( - comment = room.comment, - settings = room.settings, - foreground = foreground, - background = background, + comment=room.comment, + settings=room.settings, + foreground=foreground, + background=background, ) ) template.chunks = new_chunks @@ -147,7 +170,10 @@ def update_dependencies(self, level_paths, current_location): values=( str(broken_tile.tile.name), str(broken_tile.tile.value), - str(broken_tile.level.level_name) + " " + str(broken_tile.level.location) + " file", + str(broken_tile.level.level_name) + + " " + + str(broken_tile.level.location) + + " file", ), ) diff --git a/src/modlunky2/ui/levels/vanilla_levels/variables/level_dependencies.py b/src/modlunky2/ui/levels/vanilla_levels/variables/level_dependencies.py index c2eb47b10..6a7c8232f 100644 --- a/src/modlunky2/ui/levels/vanilla_levels/variables/level_dependencies.py +++ b/src/modlunky2/ui/levels/vanilla_levels/variables/level_dependencies.py @@ -9,12 +9,14 @@ logger = logging.getLogger(__name__) + @dataclass class SisterLocation: level_name: str level: LevelFile location: str + class LevelDependencies: @staticmethod def dependencies_for_level(lvl): @@ -98,7 +100,10 @@ def get_loaded_level(item): levels.append([get_loaded_level(lvl_name)]) if lvl_name.startswith("generic.lvl"): - return [[get_loaded_level(dep)] for dep in LevelDependencies.generic_dependencies()] + return [ + [get_loaded_level(dep)] + for dep in LevelDependencies.generic_dependencies() + ] elif not lvl_name.startswith("basecamp"): for dependencies in levels: dependencies.append(get_loaded_level("generic.lvl")) @@ -108,48 +113,48 @@ def get_loaded_level(item): @staticmethod @lru_cache def generic_dependencies(): - return [ - "dwellingarea.lvl", - "cavebossarea.lvl", - "junglearea.lvl", - "blackmarket.lvl", - "beehive.lvl", - "challenge_moon.lvl", - "volcanoarea.lvl", - "vladscastle.lvl", - "challenge_moon.lvl", - "olmecarea.lvl", - "tidepoolarea.lvl", - "lake.lvl", - "lakeoffire.lvl", - "challenge_star.lvl", - "abzu.lvl", - "templearea.lvl", - "beehive.lvl", - "challenge_star.lvl", - "cityofgold.lvl", - "duat.lvl", - "icecavesarea.lvl", - "babylonarea.lvl", - "babylonarea_1-1.lvl", - "hallofushabti.lvl", - "palaceofpleasure.lvl", - "tiamat.lvl", - "sunkencityarea.lvl", - "challenge_sun.lvl", - "eggplantarea.lvl", - "hundun.lvl", - "ending.lvl", - "ending_hard.lvl", - "cosmicocean_babylon.lvl", - "cosmicocean_dwelling.lvl", - "cosmicocean_icecavesarea.lvl", - "cosmicocean_jungle.lvl", - "cosmicocean_sunkencity.lvl", - "cosmicocean_temple.lvl", - "cosmicocean_tidepool.lvl", - "cosmicocean_volcano.lvl", - ] + return [ + "dwellingarea.lvl", + "cavebossarea.lvl", + "junglearea.lvl", + "blackmarket.lvl", + "beehive.lvl", + "challenge_moon.lvl", + "volcanoarea.lvl", + "vladscastle.lvl", + "challenge_moon.lvl", + "olmecarea.lvl", + "tidepoolarea.lvl", + "lake.lvl", + "lakeoffire.lvl", + "challenge_star.lvl", + "abzu.lvl", + "templearea.lvl", + "beehive.lvl", + "challenge_star.lvl", + "cityofgold.lvl", + "duat.lvl", + "icecavesarea.lvl", + "babylonarea.lvl", + "babylonarea_1-1.lvl", + "hallofushabti.lvl", + "palaceofpleasure.lvl", + "tiamat.lvl", + "sunkencityarea.lvl", + "challenge_sun.lvl", + "eggplantarea.lvl", + "hundun.lvl", + "ending.lvl", + "ending_hard.lvl", + "cosmicocean_babylon.lvl", + "cosmicocean_dwelling.lvl", + "cosmicocean_icecavesarea.lvl", + "cosmicocean_jungle.lvl", + "cosmicocean_sunkencity.lvl", + "cosmicocean_temple.lvl", + "cosmicocean_tidepool.lvl", + "cosmicocean_volcano.lvl", + ] @staticmethod @lru_cache diff --git a/src/modlunky2/ui/levels/vanilla_levels/variables/variables_tab.py b/src/modlunky2/ui/levels/vanilla_levels/variables/variables_tab.py index d89f01457..afdbbc3b0 100644 --- a/src/modlunky2/ui/levels/vanilla_levels/variables/variables_tab.py +++ b/src/modlunky2/ui/levels/vanilla_levels/variables/variables_tab.py @@ -115,9 +115,12 @@ def check_dependencies(self): delimiter = ", " if len(levels) <= 4: delimiter = "\n" - self.depend_order_label["text"] = delimiter.join([" -> ".join( - [level.level_name for level in level_path] - ) for level_path in levels]) + self.depend_order_label["text"] = delimiter.join( + [ + " -> ".join([level.level_name for level in level_path]) + for level_path in levels + ] + ) self.depend_order_label.grid() def update_lvls_path(self, new_path):