def convert(raw_path):
    src = os.path.join(config.RAW_RESOURCE_PATH, config.TARGET, raw_path)
    print "parse xml %s"%src
    xmldoc = xml.dom.minidom.parse(src)
    srcKey = util.get_path_key(raw_path)
    root = xmldoc.documentElement
    dest = os.path.join(config.BIN_RESOURCE_PATH, config.TARGET, str(srcKey))
    sprite_name = raw_path[7:-4].replace("\\", "_")
    out = open(dest, "wb")
    
    #for test
    #out.write(struct.pack("h", -10));
    #image
    imagesNode = root.getElementsByTagName("images")[0]
    sprite.convert_images(imagesNode, out)
    
    #modules
    modulesNode = root.getElementsByTagName("modules")[0]
    sprite.convert_modules(modulesNode, out)
    
    #patch
    patchesNode = root.getElementsByTagName("magicbgs")[0]
    convert_patches(patchesNode, out)
    logging.info("convert patch_sprite %s"%dest)
    out.close()
    gen.add_item("patch_sprite", (sprite_name, srcKey))
示例#2
0
def convert(raw_path):
    """
    raw_path 相对路径,去掉taget之后的路径
    """
    src = os.path.join(config.RAW_RESOURCE_PATH, config.TARGET, raw_path)
    print "parse xml %s" % src
    xmldoc = xml.dom.minidom.parse(src)
    srcKey = util.get_path_key(raw_path)
    root = xmldoc.documentElement
    dest = os.path.join(config.BIN_RESOURCE_PATH, config.TARGET, str(srcKey))
    sprite_name = raw_path[7:-4].replace("\\", "_")
    out = open(dest, "wb")

    # for test
    # out.write(struct.pack("h", -10));
    # image
    imagesNode = root.getElementsByTagName("images")[0]
    convert_images(imagesNode, out)

    # modules
    modulesNode = root.getElementsByTagName("modules")[0]
    convert_modules(modulesNode, out)

    # frames
    framesNode = root.getElementsByTagName("frames")[0]
    convert_frames(framesNode, out)

    # actions
    actionsNodes = root.getElementsByTagName("actions")
    if actionsNodes:
        convert_actions(actionsNodes[0], out)

    out.close()
    gen.add_item("sprite", (sprite_name, srcKey))
示例#3
0
def convert(scene_path):
    src = os.path.join(config.RAW_RESOURCE_PATH, config.TARGET, scene_path)
    xmldoc = xml.dom.minidom.parse(src)
    root = xmldoc.documentElement
    key = util.get_path_key(scene_path)
    dest = os.path.join(config.BIN_RESOURCE_PATH, config.TARGET, str(key))
    out = open(dest, "wb")
    #parser_node(root, out, controlItems, 0, "")
    out.close()
    scenename = os.path.split(scene_path)[1][0:-4]
    gen.add_item("scene", (scenename, key))
示例#4
0
def convert_images(node, out):
    imageNodes = node.getElementsByTagName("image")
    image_count = len(imageNodes)
    out.write(struct.pack("B", image_count))
    for imageNode in imageNodes:
        image_file = imageNode.getAttribute("file")
        relative_image_file = image_file[3:]
        key = util.get_path_key(relative_image_file)
        raw_image_path = os.path.join(config.RAW_RESOURCE_PATH, config.TARGET, relative_image_file)

        bin_image_path = os.path.join(config.BIN_RESOURCE_PATH, config.TARGET, str(key))
        util.copy_file(raw_image_path, bin_image_path)
        out.write(struct.pack("I", key))
示例#5
0
def convert(ui_path):
	src = os.path.join(config.RAW_RESOURCE_PATH, config.TARGET, ui_path)
	xmldoc = xml.dom.minidom.parse(src)
	root = xmldoc.documentElement
	key = util.get_path_key(ui_path)
	dest = os.path.join(config.BIN_RESOURCE_PATH, config.TARGET, str(key))
	out = open(dest, "wb")
	controlItems = []
	global EVENTS
	EVENTS = []
	parser_node(root, out, controlItems, 0, "")
	out.close()
	page_name = root.getAttribute("name")
	gen.add_page(page_name, key, controlItems)
	gen.add_ui_command(page_name, EVENTS)