import argparse import fparser import pprint parser = argparse.ArgumentParser(description='Dump x801 fparser files.') parser.add_argument('source', metavar='s', type=str, help='the input file') args = parser.parse_args() doc = fparser.parse(open(args.source)) pp = pprint.PrettyPrinter(indent=1, compact=True) pp.pprint(doc)
nargs=1, help='the model function source') parser.add_argument('output', metavar='out', type=str, nargs=1, help='the path of the model') parser.add_argument('outputTab', metavar='outt', type=str, nargs=1, help='the path of the texture name table') args = parser.parse_args() mdf = fparser.parse(open(args.sourceFunction[0])) out = open(args.output[0], "wb") pp = pprint.PrettyPrinter(indent=1, compact=True) hitboxType = hitboxTypes[mdf[0]['Hitbox'][0][0]] opacityFlags = getDirectionFlags(mdf[0]['Opaque'][0]) vertices = [] verticesByName = {} mdfVertices = mdf[1]['Vertices'][0]['Vertex'] for i in range(len(mdfVertices)): v = mdfVertices[i] name = v[0]
nargs=1, help='the path of the compiled blueprint') args = parser.parse_args() tabDir = args.tableDirectory[0] tableCache = {} def getCompID(part, comp): if not (part in tableCache): tableCache[part] = readtable.read(tabDir + "/" + part + ".tab") return tableCache[part][comp] emc = fparser.parse(open(args.sourceBP[0])) emcParts = emc[1]["Parts"][0]["Part"] parentsByName = {} parts = [] for i in range(0, len(emcParts)): part = emcParts[i] partName = part["PartName"][0][0] partID = partName if "PartID" in part: partID = part["PartID"][0][0] parentsByName[partID] = i for part in emcParts: partName = part["PartName"][0][0]
metavar='out', type=str, nargs=1, help='the path of the part') parser.add_argument( 'table', metavar='tab', type=str, nargs=1, help= 'the path where the table between component names and IDs should be output' ) args = parser.parse_args() emp = fparser.parse(open(args.sourcePart[0])) empComponents = emp[1]['Components'][0]['Component'] empFaces = emp[1]['Faces'][0] components = [] componentIndicesByName = {} controlAngles = defaultdict(list) faces = [] componentIndicesByName['ground'] = 0xFFFFFFFF # Fill in componentIndicesByName for i in range(len(empComponents)): comp = empComponents[i] name = comp['Name'][0][0]
parser = argparse.ArgumentParser(description='Compile model applications for x801.') parser.add_argument('sourceApplication', metavar='sa', type=str, nargs=1, help='the application source') parser.add_argument('tableFunction', metavar='tf', type=str, nargs=1, help='the .tab file containing function names') parser.add_argument('tableBlocks', metavar='tb', type=str, nargs=1, help='the directory of individual block model .tab files') parser.add_argument('tableTextures', metavar='tb', type=str, nargs=1, help='the .tti file with the texture names') parser.add_argument('output', metavar='out', type=str, nargs=1, help='the path of the model application file') args = parser.parse_args() mdf = fparser.parse(open(args.sourceApplication[0])) functionTable = readtable.read(args.tableFunction[0]) textureTable = readtable.read(args.tableTextures[0]) out = open(args.output[0], "wb") pp = pprint.PrettyPrinter(indent=1, compact=True) modelName = mdf[0]['Function'][0][0] locationTable = readtable.read(args.tableBlocks[0] + '/' + modelName + '.tab') parameters = mdf[1]['Textures'][0] modelNumber = functionTable[modelName] textureCount = len(locationTable)
'--level', metavar='L', type=int, nargs='?', help= 'the level of compression (-1 is default; higher numbers indicate smaller size but longer compression times)' ) args = parser.parse_args() source = open(args.source[0], "r") dest = open(args.destination[0], "wb") table = readtable.read(args.table[0]) dtable = readtable.read(args.dtable[0]) level = args.level if args.level else -1 header, sections, dsCount = fparser.parse(source) dest.write(xmap) dest.write(version) writeInt(dest, header['WorldID'][0][0], 2) writeInt(dest, header['AreaID'][0][0], 2) writeInt(dest, dsCount, 4) for name, seclist in sections.items(): for sec in seclist: bname = name.encode() if len(bname) != 4: fparser.error("Section names must be 4 bytes long. You put" + name) dest.write(bname) buf = maprules.handlers[name](sec, table=table, dtable=dtable) usize = len(buf)