Beispiel #1
0
 def get_all_diffs(self):
     diffs = []
     for m in util.get_installed_mods():
         diff = self.get_mod_diff(m)
         if diff:
             diffs.append(diff)
     return diffs
Beispiel #2
0
def get_savedata_mods() -> List[BcmlMod]:
    """ Gets a list of all installed mods that modify save data """
    sdata_mods = [
        mod for mod in util.get_installed_mods()
        if (mod.path / 'logs' / 'savedata.yml').exists()
    ]
    return sorted(sdata_mods, key=lambda mod: mod.priority)
Beispiel #3
0
def merge_dungeonstatic(diffs: dict = None):
    """Merges all changes to the CDungeon Static.smubin"""
    if not diffs:
        diffs = {}
        loader = yaml.CSafeLoader
        yaml_util.add_constructors(loader)
        for mod in [mod for mod in util.get_installed_mods() \
                    if (mod.path / 'logs' / 'dstatic.yml').exists()]:
            diffs.update(
                yaml.load((mod.path / 'logs' / 'dstatic.yml').read_bytes(),
                          Loader=loader))

    if not diffs:
        return

    new_static = byml.Byml(
        util.decompress_file(
            str(util.get_game_file(
                'aoc/0010/Map/CDungeon/Static.smubin')))).parse()

    base_dungeons = [dungeon['Map'] for dungeon in new_static['StartPos']]
    for dungeon, diff in diffs.items():
        if dungeon not in base_dungeons:
            new_static['StartPos'].append(diff)
        else:
            for key, value in diff.items():
                new_static['StartPos'][base_dungeons.index(
                    dungeon)][key] = value

    output_static = util.get_master_modpack_dir() / 'aoc' / '0010' / 'Map' / \
        'CDungeon' / 'Static.smubin'
    output_static.parent.mkdir(parents=True, exist_ok=True)
    output_static.write_bytes(
        util.compress(byml.Writer(new_static, True).get_bytes()))
Beispiel #4
0
 def get_all_diffs(self):
     diffs = []
     for mod in [
             mod for mod in util.get_installed_mods()
             if self.is_mod_logged(mod)
     ]:
         diffs.append(self.get_mod_diff(mod))
     return diffs
Beispiel #5
0
def get_text_mods(lang: str = 'USen') -> List[BcmlMod]:
    """
    Gets all installed text mods for a given language

    :param lang: The game language to use, defaults to USen.
    :type lang: str, optional
    :return: Returns a list of all text mods installed for the selected language.
    :rtype: list of class:`bcml.util.BcmlMod`
    """
    tmods = [mod for mod in util.get_installed_mods() if (
        mod.path / 'logs' / f'texts_{lang}.yml').exists()]
    return sorted(tmods, key=lambda mod: mod.priority)
Beispiel #6
0
def get_added_text_mods(lang: str = 'USen') -> List[sarc.SARC]:
    """
    Gets a list containing all mod-original texts installed
    """
    textmods = []
    tm = TextsMerger()
    for mod in [mod for mod in util.get_installed_mods() if tm.is_mod_logged(mod)]:
        l = match_language(lang, mod.path / 'logs')
        try:
            with (mod.path / 'logs' / f'newtexts_{l}.sarc').open('rb') as s_file:
                textmods.append(sarc.read_file_and_make_sarc(s_file))
        except FileNotFoundError:
            pass
    return textmods
Beispiel #7
0
def get_modded_text_entries(lang: str = 'USen') -> List[dict]:
    """
    Gets a list containing all modified text entries installed
    """
    textmods = []
    tm = TextsMerger()
    for mod in [mod for mod in util.get_installed_mods() if tm.is_mod_logged(mod)]:
        l = match_language(lang, mod.path / 'logs')
        try:
            with (mod.path / 'logs' / f'texts_{l}.yml').open('r', encoding='utf-8') as mod_text:
                textmods.append(yaml.safe_load(mod_text))
        except FileNotFoundError:
            pass
    return textmods
Beispiel #8
0
def get_all_map_diffs() -> dict:
    """
    Consolidates diffs for installed map unit mods into a single set of additions, modifications,
    and deletions.

    :return: Returns a dict of modded map units with their added, modified, and deleted actors.
    :rtype: dict of str: dict
    """
    diffs = {}
    loader = yaml.CSafeLoader
    yaml_util.add_constructors(loader)
    for mod in util.get_installed_mods():
        if (mod.path / 'logs' / 'map.yml').exists():
            with (mod.path / 'logs' / 'map.yml').open(
                    'r', encoding='utf-8') as y_file:
                map_yml = yaml.load(y_file, Loader=loader)
            for file, diff in map_yml.items():
                a_map = Map(*file.split('_'))
                if a_map not in diffs:
                    diffs[a_map] = []
                diffs[a_map].append(diff)
    c_diffs = {}
    for file, mods in list(diffs.items()):
        c_diffs[file] = {
            'add': [],
            'mod': {},
            'del': list(set([hash_id for hashes in [mod['del']\
                            for mod in mods] for hash_id in hashes]))
        }
        for mod in mods:
            for hash_id, actor in mod['mod'].items():
                c_diffs[file]['mod'][hash_id] = deepcopy(actor)
        add_hashes = []
        for mod in reversed(mods):
            for actor in mod['add']:
                if actor['HashId'] not in add_hashes:
                    add_hashes.append(actor['HashId'])
                    c_diffs[file]['add'].append(actor)
    return c_diffs
Beispiel #9
0
def get_actorinfo_mods() -> List[BcmlMod]:
    """ Gets a list of all installed mods that modify ActorInfo.product.sbyml """
    actor_mods = [mod for mod in util.get_installed_mods()\
                  if (mod.path / 'logs' / 'actorinfo.yml').exists()]
    return sorted(actor_mods, key=lambda mod: mod.priority)
Beispiel #10
0
 def get_all_diffs(self):
     diffs = []
     for mod in util.get_installed_mods():
         diffs.extend(self.get_mod_diff(mod))
     return diffs