How to use the bcml.util 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 / _oneclick.py View on Github external
def _win_create_handler():
    # pylint: disable=import-error,import-outside-toplevel,undefined-variable
    import winreg

    if (util.get_exec_dir().parent.parent.parent / "Scripts" / "bcml.exe").exists():
        exec_path = (
            '"'
            + str(
                (
                    util.get_exec_dir().parent.parent.parent / "Scripts" / "bcml.exe"
                ).resolve()
            )
            + '"'
        )
    elif (util.get_exec_dir().parent.parent / "bin" / "bcml.exe").exists():
        exec_path = (
            '"'
            + str((util.get_exec_dir().parent.parent / "bin" / "bcml.exe").resolve())
            + '"'
        )
    else:
github NiceneNerd / BCML / bcml / mergers / quests.py View on Github external
def perform_merge(self):
        merged_quests = util.get_master_modpack_dir() / "logs" / "quests.byml"
        print("Loading quest mods...")
        diffs = self.consolidate_diffs(self.get_all_diffs())
        if not diffs:
            print("No quest merging necessary")
            if merged_quests.exists():
                merged_quests.unlink()
                try:
                    util.inject_file_into_sarc(
                        "Quest/QuestProduct.sbquestpack",
                        util.get_nested_file_bytes(
                            (
                                f'{str(util.get_game_file("Pack/TitleBG.pack"))}'
                                "//Quest/QuestProduct.sbquestpack"
                            ),
                            unyaz=False,
                        ),
github NiceneNerd / BCML / bcml / _api.py View on Github external
def create_bnp(self, params):
        out = self.window.create_file_dialog(
            webviewb.SAVE_DIALOG,
            file_types=("BOTW Nano Patch (*.bnp)", "All files (*.*)"),
            save_filename=util.get_safe_pathname(params["name"]) + ".bnp",
        )
        if not out:
            raise Exception("canceled")
        meta = params.copy()
        del meta["folder"]
        meta["options"] = params["selects"]
        del meta["selects"]
        dev.create_bnp_mod(
            mod=Path(params["folder"]),
            output=Path(out if isinstance(out, str) else out[0]),
            meta=meta,
            options=params["options"],
        )
github NiceneNerd / BCML / bcml / _api.py View on Github external
def launch_game(self, params=None):
        cemu = next(
            iter(
                {f for f in util.get_cemu_dir().glob("*.exe") if "cemu" in f.name.lower()}
            )
        )
        uking = util.get_game_dir().parent / "code" / "U-King.rpx"
        try:
            assert uking.exists()
        except AssertionError:
            raise FileNotFoundError("Your BOTW executable could not be found")
        if SYSTEM == "Windows":
            cemu_args = [str(cemu), "-g", str(uking)]
        else:
            cemu_args = [
                "wine",
                str(cemu),
                "-g",
                "Z:\\" + str(uking).replace("/", "\\"),
            ]
        Popen(cemu_args, cwd=str(util.get_cemu_dir()))
github NiceneNerd / BCML / bcml / dev.py View on Github external
def _yml_to_byml(file: Path):
    data = oead.byml.to_binary(
        oead.byml.from_text(file.read_text("utf-8")),
        big_endian=util.get_settings("wiiu"),
    )
    out = file.with_suffix("")
    out.write_bytes(data if not out.suffix.startswith(".s") else util.compress(data))
    file.unlink()
github NiceneNerd / BCML / bcml / mergers / actors.py View on Github external
def generate_diff(self, mod_dir: Path, modded_files: List[Union[Path, str]]):
        try:
            actor_file = next(
                iter(
                    [
                        file
                        for file in modded_files
                        if Path(file).name == "ActorInfo.product.sbyml"
                    ]
                )
            )
        except StopIteration:
            return {}
        print("Detecting modified actor info entries...")
        data = util.decompress(actor_file.read_bytes())
        try:
            actorinfo = oead.byml.from_binary(data)
        except oead.InvalidDataError:
            data = bytearray(data)
            data[3] = 2
            try:
                actorinfo = oead.byml.from_binary(data)
            except oead.InvalidDataError as err:
                raise ValueError("This mod contains a corrupt actor info file.") from err
        del actor_file
        stock_actorinfo = get_stock_actorinfo()
        stock_actors = {actor["name"]: actor for actor in stock_actorinfo["Actors"]}
        del stock_actorinfo
        diff = oead.byml.Hash(
            {
                **{
github NiceneNerd / BCML / bcml / __init__.py View on Github external
if util.get_settings_bool('dark_theme'):
        app.setStyleSheet(DARK_THEME)
        if 'Roboto Lt' in QtGui.QFontDatabase().families(QtGui.QFontDatabase.Latin):
            app.setFont(QtGui.QFont('Roboto Lt', 10, weight=QtGui.QFont.DemiBold))
    application = MainWindow()
    try:
        application.show()
        application.SetupChecks()
        if len(sys.argv) > 1:
            parg = process_args()
            if parg:
                application.InstallClicked(parg)
        app.exec_()
    except Exception: # pylint: disable=broad-except
        tb = traceback.format_exc(limit=-2)
        e = util.get_work_dir() / 'error.log'
        QtWidgets.QMessageBox.warning(
            None,
            'Error',
            f'An unexpected error has occured:\n\n{tb}\n\nThe error has been logged to:\n'
            f'{e}\n\nBCML will now close.'
        )
        e.write_text(tb, encoding='utf-8')
    finally:
        util.clear_temp_dir()
github NiceneNerd / BCML / bcml / _api.py View on Github external
def remerge(self, params):
        try:
            if not util.get_installed_mods():
                if util.get_master_modpack_dir().exists():
                    rmtree(util.get_master_modpack_dir())
                    install.link_master_mod()
                return
            if params["name"] == "all":
                install.refresh_merges()
            else:
                [
                    m()
                    for m in mergers.get_mergers()
                    if m().friendly_name == params["name"]
                ][0].perform_merge()
        except Exception as err:  # pylint: disable=broad-except
            raise Exception(
                f"There was an error merging your mods. {str(err)}\n"
                "Note that this could leave your game in an unplayable state."