Files
NukageTools/edit.py
2024-09-22 05:08:11 -05:00

36 lines
924 B
Python

#!/usr/bin/env python
import sys
import os
import subprocess
BUILDER = "Builder"
GAME_CFG = "GZDoom_DoomUDMF.cfg"
IPK3 = "nukage.ipk3"
RESOURCES = [".", "graphics"]
def edit(map, resources=[]):
command = [BUILDER, os.path.join(f"maps", f"{map}.wad"), "-map", map, "-cfg", GAME_CFG]
for resource in resources:
command.append("-resource")
extension = os.path.splitext(resource)[1]
if os.path.isdir(resource):
command.append("dir")
elif extension == ".pk3" or extension == ".ipk3":
command.append("pk3")
command.append(resource)
print(command)
subprocess.call(command)
if __name__ == "__main__":
MAP = sys.argv[1]
resources = list(RESOURCES)
if os.path.isfile(IPK3):
resources.insert(0, os.path.abspath(IPK3))
if os.path.isfile(MAP):
MAP = os.path.splitext(os.path.basename(MAP))[0]
edit(MAP, resources)