From 3c15c92839d262fcfb0402ec7b29453b134de00f Mon Sep 17 00:00:00 2001 From: snake-biscuits <36507175+snake-biscuits@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:27:10 +0100 Subject: [PATCH] caught the last of the bugs and added a build script for PyInstaller --- batch_vmt.py | 16 ++-------------- build.sh | 5 +++++ 2 files changed, 7 insertions(+), 14 deletions(-) create mode 100644 build.sh 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 *