def get_stock_rstb() -> rstb.ResourceSizeTable: """ Gets the unmodified RSTB """ if not hasattr(get_stock_rstb, 'table'): get_stock_rstb.table = read_rstb( str(util.get_game_file('System/Resource/ResourceSizeTable.product.srsizetable')), True ) return deepcopy(get_stock_rstb.table)
def get_stock_rstb() -> rstb.ResourceSizeTable: if not hasattr(get_stock_rstb, "table"): get_stock_rstb.table = read_rstb( str( util.get_game_file( "System/Resource/ResourceSizeTable.product.srsizetable")), util.get_settings("wiiu"), ) return deepcopy(get_stock_rstb.table)
def set_size(entry: str, size: int): rstb_path = (util.get_master_modpack_dir() / util.get_content_path() / "System" / "Resource" / "ResourceSizeTable.product.srsizetable") if rstb_path.exists(): table = read_rstb(rstb_path, be=util.get_settings("wiiu")) else: table = get_stock_rstb() rstb_path.parent.mkdir(parents=True, exist_ok=True) table.set_size(entry, size) buf = io.BytesIO() table.write(buf, be=util.get_settings("wiiu")) rstb_path.write_bytes(util.compress(buf.getvalue()))
def set_size(entry: str, size: int): """ Sets the size of a resource in the current master RSTB :param entry: The resource to set :type entry: str :param size: The resource size :type size: int """ rstb_path = util.get_master_modpack_dir() / 'content' / 'System' / 'Resource' /\ 'ResourceSizeTable.product.srsizetable' if rstb_path.exists(): table = read_rstb(rstb_path, be=True) else: table = get_stock_rstb() rstb_path.parent.mkdir(parents=True, exist_ok=True) table.set_size(entry, size) buf = io.BytesIO() table.write(buf, be=True) rstb_path.write_bytes( util.compress(buf.getvalue()) )
def rstb_to_json(): parser = argparse.ArgumentParser( description="Converts a binary RSTB file to JSON.") parser.add_argument( "-b", "--be", action="store_true", help= "Read the RSTB as big endian for Wii U, otherwise little endian for Switch", ) parser.add_argument("rstb", help="Path to a binary RSTB file", nargs="?") parser.add_argument("-o", "--output", help="Path to output JSON file", nargs="?") args = parser.parse_args() in_file = Path(args.rstb).resolve() table = util.read_rstb(str(in_file), be=args.be) output = (Path(args.output).resolve() if args.output else in_file.with_suffix(".rsizetable.json")) unbuilder.rstb_to_json(table, output, set())
def rstb_to_json(): parser = argparse.ArgumentParser( description='Converts a binary RSTB file to JSON.') parser.add_argument( '-b', '--be', action='store_true', help= 'Read the RSTB as big endian for Wii U, otherwise little endian for Switch' ) parser.add_argument('rstb', help='Path to a binary RSTB file', nargs='?') parser.add_argument('-o', '--output', help='Path to output JSON file', nargs='?') args = parser.parse_args() in_file = Path(args.rstb).resolve() table = util.read_rstb(str(in_file), be=args.be) output = Path(args.output).resolve( ) if args.output else in_file.with_suffix('.rsizetable.json') unbuilder.rstb_to_json(table, output, set())
def _unbuild_rstb(content: Path, be: bool, out: Path, mod: Path, names: set): f: Path = content / "System" / "Resource" / "ResourceSizeTable.product.srsizetable" table = read_rstb(str(f), be=be) rstb_to_json(table, out / f.relative_to(mod).with_suffix(".json"), names)