diff --git a/batch_vmt.py b/batch_vmt.py index f4b2d96..540f756 100644 --- a/batch_vmt.py +++ b/batch_vmt.py @@ -20,18 +20,11 @@ __version__ = "1.0.0" -def from_template(vtf_filename: str, template: str, **substitutions: Dict[str, str]): +def from_template(vtf_filename: str, template: str, substitutions: Dict[str, str] = dict()): """Generate .vmts from `template` for every .vtf in `folder`""" - # example usage: - # from_template("LightmappedGeneric{$basetexture }", "materials/folder") - # from_template(open("template.vmt").read(), "materials/folder", surfaceprop="metal") for keyword, replacement in substitutions.items(): template = template.replace(f"<{keyword}>", replacement) - # e.g. replacements = {"texture2": "a"} - # '$basetexture2 ' --> '"$basetexture2" "_a"' - # then at the file level: '_a' -> 'texture_a' for "texture.vmt" - # NOTE: never put filename in replacements unless you want to replace all textures with one texture! - filename = os.path.splitext(vtf_filename)[0] # remove .vtf extension + filename = os.path.splitext(vtf_filename)[0] with open(f"{filename}.vmt", "w") as vmt_file: vmt_file.write(template.replace("", filename)) @@ -42,13 +35,8 @@ def from_metadata(vtf_filename: str, shader: str = "LightmappedGeneric", defaults={"colour": ("%keywords", "white")}): """generate an appropriate .vmt from .vmt flags""" raise NotImplementedError() - # * EXPECTED FLAGS * - # has_alpha: bool // vtf is transparent e.g. {"has_alpha": "$translucent": 1} - # colour: Color // fuzzy colour detection - # hue_range: float // [0-1]; how close the texture's hue should be to colour filename = os.path.splitext(vtf_filename)[0] - vtf = ... # TODO: load f"{filename}.vtf" with VTFLibWrapper # check flags check: Dict[str, bool] diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..d4223a9 --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +pyinstaller --onefile --windowed batch_vmt.py +cp README.md LICENSE.txt base.vmt displacement_base.vmt dist/ +cd dist/ +rm -f batch_vmt_64bit_windows_exe.zip +zip batch_vmt_64bit_windows_exe *