def insert_textures(pak_dir, filename): pak = ModelPak(filename=filename) for gmo_name in os.listdir(pak_dir): full_path = os.path.join(pak_dir, gmo_name) if not os.path.isdir(full_path): _LOGGER.warning( "Not a directory of textures. Skipped importing %s to %s" % (full_path, filename)) continue gmo_id = pak.id_from_name(gmo_name) if gmo_id == None: _LOGGER.warning("GMO %s does not exist in %s" % (gmo_name, filename)) continue gmo = pak.get_gmo(gmo_id) if gmo == None: _LOGGER.warning("Failed to retrieve GMO %s from %s" % (gmo_name, filename)) continue for img in os.listdir(os.path.join(pak_dir, gmo_name)): name, ext = os.path.splitext(img) if ext.lower() == ".gim": is_png = False elif ext.lower() == ".png": is_png = True else: _LOGGER.warning("Did not insert %s into %s" % (img, gmo_name)) continue gim_id = int(name) if is_png: gmo.replace_png_file(gim_id, os.path.join(pak_dir, gmo_name, img)) else: gmo.replace_gim_file(gim_id, os.path.join(pak_dir, gmo_name, img)) pak.replace_gmo(gmo_id, gmo) pak.save(filename)
def insert_textures(pak_dir, filename): pak = ModelPak(filename = filename) for gmo_name in os.listdir(pak_dir): full_path = os.path.join(pak_dir, gmo_name) if not os.path.isdir(full_path): _LOGGER.warning("Not a directory of textures. Skipped importing %s to %s" % (full_path, filename)) continue gmo_id = pak.id_from_name(gmo_name) if gmo_id == None: _LOGGER.warning("GMO %s does not exist in %s" % (gmo_name, filename)) continue gmo = pak.get_gmo(gmo_id) if gmo == None: _LOGGER.warning("Failed to retrieve GMO %s from %s" % (gmo_name, filename)) continue for img in os.listdir(os.path.join(pak_dir, gmo_name)): name, ext = os.path.splitext(img) if ext.lower() == ".gim": is_png = False elif ext.lower() == ".png": is_png = True else: _LOGGER.warning("Did not insert %s into %s" % (img, gmo_name)) continue gim_id = int(name) if is_png: gmo.replace_png_file(gim_id, os.path.join(pak_dir, gmo_name, img)) else: gmo.replace_gim_file(gim_id, os.path.join(pak_dir, gmo_name, img)) pak.replace_gmo(gmo_id, gmo) pak.save(filename)
def extract_model_pak(filename, out_dir, to_png): pak = ModelPak(filename=filename) pak.extract(out_dir, to_png)
def extract_model_pak(filename, out_dir, to_png): pak = ModelPak(filename = filename) pak.extract(out_dir, to_png)