def loadLevel(self,lvl): topxml = xml.dom.minidom.parse("level.xml") lvlxml = None for n in topxml.getElementsByTagName('level'): if n.hasAttribute("id") and n.getAttribute("id") == str(lvl): lvlxml = n break if lvlxml == None: print "no such level exists!" return for n in lvlxml.getElementsByTagName('entity'): if n.hasAttribute("type"): ten = pedo_lookup.enTables(n) #WE WILL SEPARATE THIS FROm XML LATER if isinstance(ten,PEG_network.Network): self.entityDict["Network"]= ten if isinstance(ten,MenuEn): self.entityDict["MenuEn"]= ten if isinstance(ten,PEG_effects.EffectMenu): self.entityDict["EffectMenu"]= ten try: if isinstance(ten,PEG_serial.SerialEntity): self.entityDict["SerialEntity"]= ten except: print "could not find serial" self.entityList.append(ten)
def addMode(self): self.setMouse() for e in PEG_mainLoop.mainLoop().eventList: if e.type == pygame.KEYDOWN: if e.key == pygame.K_PAGEUP: self.setActive(1) if e.key == pygame.K_PAGEDOWN: self.setActive(-1) if e.key == pygame.K_SPACE: self.toggleMode() if e.type == pygame.MOUSEBUTTONUP: PEG_mainLoop.mainLoop().entityList.append(self.activeObject) self.activeObject = pedo_lookup.enTables(self.entityList[self.currentItem].cloneNode(True))
def parseEnData(self, d): if d["name"] not in self.enDict: try: exml = xml.dom.minidom.parseString( '<entity type="' + d["entity"] + '" x="' + str(d["x"]) + '" y="' + str(d["y"]) + '" name="' + str(d["name"]) + '" size="3' + '" />' ).getElementsByTagName("entity")[0] self.enDict[d["name"]] = pedo_lookup.enTables(exml) print d["entity"], ": ", d["name"], " created!" # =============================================================================== # try: # if 'team' in data: # self.enDict[d['name']].team = data['team'] # except: pass # =============================================================================== # USER CONTROLLED STUFF if self.color == d["name"]: self.enDict[d["name"]].controlled = True print "self identified as: ", d["name"] except: print "data misformated: ", d exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() print "*** print_tb:" traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout) print "*** print_exception:" traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback, limit=2, file=sys.stdout) try: self.enDict[d["name"]].data = d except: print d["name"], " data set failed" try: self.enDict[d["name"]].updatePos() except: print d["name"], "update pos failed"
def setActive(self, move = 0): if not self.activeObject: self.activeObject = pedo_lookup.enTables(self.entityList[self.currentItem]) else: self.currentItem = (self.currentItem + move)%len(self.entityList) self.activeObject = pedo_lookup.enTables(self.entityList[self.currentItem])