Esempio n. 1
0
def main():
    args = parse_args()

    print "Loading %s..." % args.source_wad
    inwad = wad.WAD()
    inwad.from_file(args.source_wad)

    if args.list:
        print "Found %d maps:" % len(inwad.maps)
        for mapName in inwad.maps.keys():
            print "  %s" % mapName
        sys.exit(0)

    # lets make sure all output files are written here
    os.chdir(args.output)

    # export the textures first, so we know all their sizes
    textureNames, textureSizes = writemtl(inwad)

    maps = util.find(inwad.maps, args.maps)
    if len(maps) == 0:
        print "No maps matching pattern '%s' were found." % (args.maps)
    else:
        print "Found %d maps matching pattern '%s'" % (len(maps), args.maps)
        for name in maps:
            objfile = name+".obj"
            print "Writing %s" % objfile
            objmap(inwad, name, objfile, textureNames, textureSizes, args.center)
Esempio n. 2
0
    def execute_wad(self, wad_file: str):
        input_wad = wad.WAD()
        input_wad.from_file(wad_file)

        # export textures

        for level_map in input_wad.maps.keys():
            self.execute_level(input_wad, level_map)
Esempio n. 3
0
def main(args):
    if (len(args) < 2):
        print "    Omgifol script: mirror maps\n"
        print "    Usage:"
        print "    mirror.py input.wad output.wad [pattern]\n"
        print "    Mirror all maps or those whose name match the given pattern"
        print "    (eg E?M4 or MAP*)."
        print "    Note: nodes will have to be rebuilt externally.\n"
    else:
        print "Loading %s..." % args[0]
        inwad = wad.WAD()
        outwad = wad.WAD()
        inwad.from_file(args[0])
        pattern = "*"
        if (len(args) == 3):
            pattern = args[2]
        for name in util.find(inwad.maps,pattern):
            print "Mirroring %s" % name
            outwad.maps[name] = mirror(inwad.maps[name])
        print "Saving %s..." % args[1]
        outwad.to_file(args[1])
Esempio n. 4
0
def execute(source_wad,
            list_maps,
            output_dir,
            center_map_origin,
            textureNames,
            textureSizes,
            maps=None):
    print("Loading %s..." % source_wad)
    inwad = wad.WAD()
    inwad.from_file(source_wad)
    map_regex = None
    try:
        map_regex = re.compile(maps)
    except Exception:
        print("Couldn't compile map search expression - getting all maps")

    if list_maps:
        print("Found %d maps:" % len(inwad.maps))
        for mapName in inwad.maps.keys():
            print("  %s" % mapName)
        sys.exit(0)

    # lets make sure all output files are written here
    cwd = os.getcwd()
    os.chdir(output_dir)

    # export the textures first, so we know all their sizes
    textureNames, textureSizes = writemtl(inwad, textureNames, textureSizes)

    for mapName in inwad.maps.keys():
        if map_regex is not None:
            if len(map_regex.findall(mapName)) == 0:
                continue

        objfile = mapName.lower() + ".obj"
        print("Writing %s" % objfile)
        objmap(inwad, mapName.lower(), objfile, textureNames, textureSizes,
               center_map_origin)

    os.chdir(cwd)

    return textureNames, textureSizes
Esempio n. 5
0
import sys

from omg import wad

if (len(sys.argv) < 3):
    print "\n    Omgifol script: merge WADs\n"
    print "    Usage:"
    print "    merge.py input1.wad input2.wad ... [-o output.wad]\n"
    print "    Default output is merged.wad"
else:
    w = wad.WAD()
    for a in sys.argv[1:]:
        if a == "-o":
            break
        print "Adding %s..." % a
        w += wad.WAD(a)
    outpath = "merged.wad"
    if "-o" in sys.argv: outpath = sys.argv[-1]
    w.to_file(outpath)
Esempio n. 6
0
        draw.line((p1x - 1, p1y, p2x - 1, p2y), fill=color)
        draw.line((p1x, p1y + 1, p2x, p2y + 1), fill=color)
        draw.line((p1x, p1y - 1, p2x, p2y - 1), fill=color)

    del draw

    im.save(filename, format)


#import psyco
#psyco.full()

if (len(sys.argv) < 5):
    print "\n    Omgifol script: draw maps to image files\n"
    print "    Usage:"
    print "    drawmaps.py source.wad pattern width format\n"
    print "    Draw all maps whose names match the given pattern (eg E?M4 or MAP*)"
    print "    to image files of a given format (PNG, BMP, etc). width specifies the"
    print "    desired width of the output images."
else:

    print "Loading %s..." % sys.argv[1]
    inwad = wad.WAD()
    inwad.from_file(sys.argv[1])
    width = int(sys.argv[3])
    format = sys.argv[4].upper()
    for name in util.find(inwad.maps, sys.argv[2]):
        print "Drawing %s" % name
        drawmap(inwad, name, name + "_map" + "." + format.lower(), width,
                format)