def __init__(self, name=""): Struct.__init__(self, "CAnimation") self.name = String(name) self.body = AnimSequence() self.back_foot = AnimSequence() self.front_foot = AnimSequence() self.attach = AnimSequence()
def __init__(self, cont=None, name=""): Struct.__init__(self, "CDataWeaponspec") self.name = String(name) self.sprite_body = Pointer(Sprite, Sprite()) self.sprite_cursor = Pointer(Sprite, Sprite()) self.sprite_proj = Pointer(Sprite, Sprite()) self.sprite_muzzles = Array(Pointer(Sprite, Sprite())) self.visual_size = Int(96) self.firedelay = Int(500) self.maxammo = Int(10) self.ammoregentime = Int(0) self.damage = Int(1) self.offsetx = Float(0) self.offsety = Float(0) self.muzzleoffsetx = Float(0) self.muzzleoffsety = Float(0) self.muzzleduration = Float(5) # dig out sprites if we have a container if cont: for sprite in cont.sprites.items: if sprite.name.value == "weapon_" + name + "_body": self.sprite_body.Set(sprite) elif sprite.name.value == "weapon_" + name + "_cursor": self.sprite_cursor.Set(sprite) elif sprite.name.value == "weapon_" + name + "_proj": self.sprite_proj.Set(sprite) elif "weapon_" + name + "_muzzle" in sprite.name.value: self.sprite_muzzles.Add(Pointer(Sprite, sprite))
def __init__(self, name="", files=()): Struct.__init__(self, "CDataSoundset") self.name = String(name) self.sounds = Array(Sound()) self.last = Int(-1) for filename in files: self.sounds.Add(Sound(filename))
def __init__(self, name="", Set=None, x=0, y=0, w=0, h=0): Struct.__init__(self, "CDataSprite") self.name = String(name) self.set = Pointer(SpriteSet, Set) # TODO self.x = Int(x) self.y = Int(y) self.w = Int(w) self.h = Int(h)
def default(self, obj): if isinstance(obj, types.GeneratorType): return [x for x in obj] elif isinstance(obj, Exception): return { "errmsg": String(obj) } elif isinstance(obj, bytes): # this seems like a py3 bug, for some reason bytes can get in here # https://bugs.python.org/issue30343 # https://stackoverflow.com/questions/43913256/understanding-subclassing-of-jsonencoder return String(obj) else: return json.JSONEncoder.default(self, obj)
def parseXML(self, xmlelement): for idname in ['NodeId', 'NodeID', 'nodeid']: if xmlelement.hasAttribute(idname): self.id = RefOrAlias(xmlelement.getAttribute(idname)) for (at, av) in xmlelement.attributes.items(): if at == "BrowseName": self.browseName = QualifiedName(av) elif at == "DisplayName": self.displayName = LocalizedText(av) elif at == "Description": self.description = LocalizedText(av) elif at == "WriteMask": self.writeMask = int(av) elif at == "UserWriteMask": self.userWriteMask = int(av) elif at == "EventNotifier": self.eventNotifier = int(av) elif at == "SymbolicName": self.symbolicName = String(av) for x in xmlelement.childNodes: if x.nodeType != x.ELEMENT_NODE: continue if x.firstChild: if x.localName == "BrowseName": self.browseName = QualifiedName(x.firstChild.data) elif x.localName == "DisplayName": self.displayName = LocalizedText(x.firstChild.data) elif x.localName == "Description": self.description = LocalizedText(x.firstChild.data) elif x.localName == "WriteMask": self.writeMask = int(unicode(x.firstChild.data)) elif x.localName == "UserWriteMask": self.userWriteMask = int(unicode(x.firstChild.data)) if x.localName == "References": self.parseXMLReferences(x)
def visit_string(self, node, visited_children): # Drop the wrapping quotes contents = node.text[1:-1] # Unescape escaped quotes literal = String(re.sub(r'\\["bfnrtv\\]', self._unescape_string, contents)) return Queue([literal])
def __init__(self, name="", respawntime=15, spawndelay=0): Struct.__init__(self, "CDataPickupspec") self.name = String(name) self.respawntime = Int(respawntime) self.spawndelay = Int(spawndelay)
def __init__(self, filename=""): Struct.__init__(self, "CDataSound") self.id = Int(0) self.filename = String(filename)
def __init__(self, name="", filename=""): Struct.__init__(self, "CDataImage") self.name = String(name) self.filename = String(filename) self.id = TextureHandle()
def string(self): return String(self.get_token().string)