How to use the bcml.util.get_settings function in bcml

To help you get started, we’ve selected a few bcml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NiceneNerd / BCML / bcml / dev.py View on Github external
options.get("options", dict()).get("general", dict()).get("agnostic", False)
    )
    meta["platform"] = (
        "any" if any_platform else "wiiu" if util.get_settings("wiiu") else "switch"
    )
    (tmp_dir / "info.json").write_text(
        dumps(meta, ensure_ascii=False, indent=2), encoding="utf-8"
    )

    with Pool() as pool:
        yml_files = set(tmp_dir.glob("**/*.yml"))
        if yml_files:
            print("Compiling YAML documents...")
            pool.map(_do_yml, yml_files)

        hashes = util.get_hash_table(util.get_settings("wiiu"))
        print("Packing SARCs...")
        _pack_sarcs(tmp_dir, hashes, pool)
        for folder in {d for d in tmp_dir.glob("options/*") if d.is_dir()}:
            _pack_sarcs(folder, hashes, pool)

        for option_dir in tmp_dir.glob("options/*"):
            for file in {
                f
                for f in option_dir.rglob("**/*")
                if (f.is_file() and (tmp_dir / f.relative_to(option_dir)).exists())
            }:
                xh1 = xxhash.xxh64_intdigest(
                    (tmp_dir / file.relative_to(option_dir)).read_bytes()
                )
                xh2 = xxhash.xxh64_intdigest(file.read_bytes())
                if xh1 == xh2:
github NiceneNerd / BCML / bcml / _api.py View on Github external
def get_setup(self):
        return {
            "hasCemu": not util.get_settings("no_cemu"),
            "mergers": [m().friendly_name for m in mergers.get_mergers()],
        }
github NiceneNerd / BCML / bcml / texts.py View on Github external
def generate_diff(self, mod_dir: Path, modded_files: List[Union[str, Path]]):
        diffs = {}
        bootups = {util.get_file_language(file): file for file in modded_files
                   if 'Bootup_' in str(file) and 'Graphics' not in str(file) 
                   and isinstance(file, Path)}
        if not bootups:
            return {}
        mod_langs = list(bootups.keys())
        lang_map = {}
        save_langs = LANGUAGES if not self._options['user_only'] else [util.get_settings()['lang']]
        for lang in save_langs:
            if lang in mod_langs:
                lang_map[lang] = lang
            elif lang[2:4] in [l[2:4] for l in mod_langs]:
                lang_map[lang] = [l for l in mod_langs if l[2:4] == lang[2:4]][0]
            else:
                lang_map[lang] = [l for l in LANGUAGES if l in mod_langs][0]
        lang_diffs = {}
        from io import StringIO
        for lang in set(lang_map.values()):
            dict_diffs, added = get_text_mods_from_bootup(bootups[lang], lang=lang)[:2]
            str_buf = StringIO()
            yaml.dump(dict_diffs, str_buf, allow_unicode=True, encoding='utf-8')
            lang_diffs[lang] = (str_buf.getvalue(), added)
            del str_buf
        for u_lang, t_lang in lang_map.items():
github NiceneNerd / BCML / bcml / upgrade.py View on Github external
dlc_dir = util.guess_aoc_dir(Path(cemu_dir), Path(game_dir))
    settings = {
        "cemu_dir": cemu_dir,
        "game_dir": game_dir,
        "game_dir_nx": "",
        "load_reverse": old_settings["Settings"]["load_reverse"] == "True",
        "update_dir": str(update_dir or ""),
        "dlc_dir": str(dlc_dir or ""),
        "dlc_dir_nx": "",
        "site_meta": old_settings["Settings"]["site_meta"],
        "no_guess": old_settings["Settings"]["guess_merge"] == "False",
        "lang": old_settings["Settings"]["lang"],
        "no_cemu": False,
        "wiiu": True,
    }
    setattr(util.get_settings, "settings", settings)
    (util.get_data_dir() / "settings.ini").unlink()
    util.save_settings()
github NiceneNerd / BCML / bcml / dev.py View on Github external
aamp_log: Path = mod / "logs" / "deepmerge.aamp"
    if aamp_log.exists() and util.get_settings("wiiu") != wiiu:
        pio = oead.aamp.ParameterIO.from_binary(aamp_log.read_bytes())
        from_content = (
            "content"
            if wiiu and not util.get_settings("wiiu")
            else "01007EF00011E000/romfs"
        )
        to_content = (
            "01007EF00011E000/romfs"
            if wiiu and not util.get_settings("wiiu")
            else "content"
        )
        from_dlc = (
            "aoc/0010"
            if wiiu and not util.get_settings("wiiu")
            else "01007EF00011F001/romfs"
        )
        to_dlc = (
            "01007EF00011F001/romfs"
            if wiiu and not util.get_settings("wiiu")
            else "aoc/0010"
        )
        for file_num, file in pio.objects["FileTable"].params.items():
            old_path = file.v
            new_path = old_path.replace(from_content, to_content).replace(
                from_dlc, to_dlc
            )
            pio.objects["FileTable"].params[file_num] = oead.aamp.Parameter(new_path)
            pio.lists[new_path] = deepcopy(pio.lists[old_path])
            del pio.lists[old_path]
        aamp_log.write_bytes(pio.to_binary())
github NiceneNerd / BCML / bcml / _api.py View on Github external
def export(self):
        if not util.get_installed_mods():
            raise Exception("No mods installed to export.")
        out = self.window.create_file_dialog(
            webviewb.SAVE_DIALOG,
            file_types=(
                f"{('Graphic Pack' if util.get_settings('wiiu') else 'Atmosphere')} (*.zip)",
                "BOTW Nano Patch (*.bnp)",
            ),
            save_filename="exported-mods.zip",
        )
        if out:
            output = Path(out if isinstance(out, str) else out[0])
            install.export(output)
github NiceneNerd / BCML / bcml / __init__.py View on Github external
self.setupUi(self)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(
            str(util.get_exec_dir() / 'data' / 'bcml.ico')))
        self.setWindowIcon(icon)

        self.txtCemu.setText(str(util.get_cemu_dir()))
        self.txtGameDump.setText(str(util.get_game_dir()))
        try:
            self.txtMlc.setText(str(util.get_mlc_dir()))
        except FileNotFoundError:
            self.txtMlc.setText('')
        self.chkDark.setChecked(util.get_settings_bool('dark_theme'))
        self.chkGuessMerge.setChecked(not util.get_settings_bool('guess_merge'))
        self.drpLang.addItems(texts.LANGUAGES)
        self.drpLang.setCurrentText(util.get_settings()['lang'])

        self.btnBrowseCemu.clicked.connect(self.BrowseCemuClicked)
        self.btnBrowseGame.clicked.connect(self.BrowseGameClicked)
        self.btnBrowseMlc.clicked.connect(self.BrowseMlcClicked)
github NiceneNerd / BCML / bcml / mergers / effects.py View on Github external
"Pack/Bootup.pack",
                    )
                    del stock_effects
                except FileNotFoundError:
                    pass
            return
        util.vprint("All status effect diffs:")
        util.vprint(diffs)

        effects = get_stock_effects()
        util.dict_merge(effects, diffs, overwrite_lists=True)
        del diffs

        print("Writing new effects list...")
        effect_bytes = oead.byml.to_binary(
            oead.byml.Array([effects]), big_endian=util.get_settings("wiiu")
        )
        del effects
        util.inject_file_into_sarc(
            "Ecosystem/StatusEffectList.sbyml",
            util.compress(effect_bytes),
            "Pack/Bootup.pack",
            create_sarc=True,
        )
        print("Saving status effect merge log...")
        merged_effects.parent.mkdir(parents=True, exist_ok=True)
        merged_effects.write_bytes(effect_bytes)

        print("Updating RSTB...")
        rstb_size = rstb.SizeCalculator().calculate_file_size_with_ext(
            effect_bytes, True, ".byml"
        )
github NiceneNerd / BCML / bcml / __init__.py View on Github external
self, 'Dump Location', 'BCML could not locate your game\'s update data. Usually,  '
                'this means that either the game dump folder or the MLC folder is not correctly set'
                '. Please go to your BCML settings and confirm the correct location of both '
                'folders. You will not be able to install any mods until this is corrected')
        if 'lang' not in util.get_settings() or not util.get_settings()['lang']:
            lang, okay = QtWidgets.QInputDialog.getItem(
                self,
                'Select Language',
                'Select the regional language you\nuse to play Breath of the Wild',
                texts.LANGUAGES,
                0,
                False,
                flags=QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint
            )
            if okay and lang:
                util.get_settings()['lang'] = lang
                util.save_settings()
        self.LoadMods()