def bnp_to_gfx(self, params=None): try: bnp = Path(self.file_pick({"multiple": False})[0]) except IndexError: return with util.TempModContext(): install.install_mod( bnp, merge_now=True, options={ "options": { "texts": { "all_langs": True } }, "disable": [] }, ) 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=f"{bnp.stem}.zip", ) if out: output = Path(out if isinstance(out, str) else out[0]) install.export(output)
def gen_rstb(self, params=None): try: mod = Path(self.get_folder()) assert mod.exists() except (FileNotFoundError, IndexError, AssertionError): return with util.TempModContext(): if not ((mod / "info.json").exists() or (mod / "rules.txt").exists()): (mod / "info.json").write_text( json.dumps( { "name": "Temp", "desc": "Temp pack", "url": "", "id": "VGVtcD0wLjA=", "image": "", "version": "1.0.0", "depends": [], "options": {}, "platform": "wiiu" if util.get_settings("wiiu") else "switch", } ) ) install.install_mod( mod, merge_now=True, options={ "options": {}, "disable": [ m.NAME for m in mergers.get_mergers() if m.NAME != "rstb" ], }, ) (mod / util.get_content_path() / "System" / "Resource").mkdir( parents=True, exist_ok=True ) copyfile( util.get_master_modpack_dir() / util.get_content_path() / "System" / "Resource" / "ResourceSizeTable.product.srsizetable", mod / util.get_content_path() / "System" / "Resource" / "ResourceSizeTable.product.srsizetable", )
def update_mod(self, params): try: update_file = self.file_pick({"multiple": False})[0] except IndexError: return mod = BcmlMod.from_json(params["mod"]) if (mod.path / "options.json").exists(): options = json.loads((mod.path / "options.json").read_text(), encoding="utf-8") else: options = {} remergers = mergers.get_mergers_for_mod(mod) rmtree(mod.path) with Pool(maxtasksperchild=1000) as pool: new_mod = install.install_mod( Path(update_file), insert_priority=mod.priority, options=options, pool=pool, ) remergers |= { m for m in mergers.get_mergers_for_mod(new_mod) if m.NAME not in {m.NAME for m in remergers} } try: install.refresh_merges() except Exception: # pylint: disable=broad-except pool.terminate() raise
def update_mod(self, params): try: update_file = self.file_pick({"multiple": False})[0] except IndexError: return mod = BcmlMod.from_json(params["mod"]) if (mod.path / "options.json").exists(): options = json.loads((mod.path / "options.json").read_text()) else: options = {} rmtree(mod.path) with Pool(maxtasksperchild=500) as pool: new_mod = install.install_mod( Path(update_file), insert_priority=mod.priority, options=options, pool=pool, )
def install_mod(self, params: dict): util.vprint(params) with Pool(maxtasksperchild=1000) as pool: selects = (params["selects"] if "selects" in params and params["selects"] else {}) mods = [ install.install_mod( Path(m), options=params["options"], selects=selects.get(m, None), pool=pool, ) for m in params["mods"] ] util.vprint(f"Installed {len(mods)} mods") print(f"Installed {len(mods)} mods") try: install.refresh_merges() print("Install complete") except Exception: # pylint: disable=broad-except pool.terminate() raise
def apply_queue(self, params): mods = [] for move_mod in params["moves"]: mod = BcmlMod.from_json(move_mod["mod"]) mods.append(mod) mod.change_priority(move_mod["priority"]) with Pool(maxtasksperchild=500) as pool: for i in params["installs"]: print(i) mods.append( install.install_mod( Path(i["path"].replace("QUEUE", "")), options=i["options"], insert_priority=i["priority"], pool=pool, )) try: install.refresh_merges() except Exception: # pylint: disable=broad-except pool.terminate() raise install.refresh_master_export()