def __init__(self, parent,idChar): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) self.character=Character(idChar) self.img = wx.BitmapButton(self, -1, wx.Bitmap("faces/" + self.character.getFace() + ".png")) self.lblname = wx.StaticText(self, label="Name :", pos=(150,15)) self.editname = wx.TextCtrl(self,value=self.character.getName(), pos=(250, 10), size=(140,-1) ) self.lblzone = wx.StaticText(self, label="Zone :", pos=(150,40)) zone=Zone(self.character.getIdZone()) self.editzone = wx.TextCtrl(self,value=str(zone.getId()) + ' | ' + zone.getName(), pos=(250, 40), size=(140,-1) ) self.lbllaststation = wx.StaticText(self, label="Last Station :", pos=(150,65)) st=station(self.character.getLastStation()) self.editlaststation = wx.TextCtrl(self,value=str(self.character.getLastStation()) + " | " + st.getName(), pos=(250, 65), size=(140,-1) ) self.lblfaction = wx.StaticText(self, label="Faction :", pos=(150,90)) fa=Faction(self.character.getIdFaction()) self.edifaction = wx.TextCtrl(self,value=str(fa.getId()) + " | " + fa.getName(), pos=(250, 90), size=(140,-1) )
def onGenerateXml(self, e): ########## Dialogue################### docXml = xml.dom.minidom.Document() dialogsXml = docXml.createElement("dialogs") listOfDialogs = Dialog.getListOfDialog() for d in listOfDialogs: di = Dialog(d) dXml = di.getXml(docXml) dialogsXml.appendChild(dXml) docXml.appendChild(dialogsXml) fileHandle = open("./datas/dialogs.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() ########## Mission################### docXml = xml.dom.minidom.Document() missionsXml = docXml.createElement("missions") listOfMissions = mission.getListOfMissions() for m in listOfMissions: mi = mission(m) mXml = mi.getXml(docXml) missionsXml.appendChild(mXml) docXml.appendChild(missionsXml) fileHandle = open("./datas/missions.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() ########## Station ################### docXml = xml.dom.minidom.Document() stationXml = docXml.createElement("stations") listOfStation = station.getListOfStation() for s in listOfStation: st = station(s) sXml = st.getXml(docXml) stationXml.appendChild(sXml) docXml.appendChild(stationXml) fileHandle = open("./datas/stations.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() ########## PNJ ################### docXml = xml.dom.minidom.Document() pnjsXml = docXml.createElement("pnjs") listOfPnj = PNJ.getListOfPNJ() for p in listOfPnj: pn = PNJ(p) pXml = pn.getXml(docXml) pnjsXml.appendChild(pXml) docXml.appendChild(pnjsXml) fileHandle = open("./datas/pnjs.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() ########## Zone ################### docXml = xml.dom.minidom.Document() zoneXml = docXml.createElement("zones") listOfZone = Zone.getListOfZone() for z in listOfZone: zo = Zone(z) zXml = zo.getXml(docXml) zoneXml.appendChild(zXml) docXml.appendChild(zoneXml) fileHandle = open("./datas/zones.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() ##########Item Template############### docXml = xml.dom.minidom.Document() itemsXml = docXml.createElement("items") listOfItemTemplates = ShimstarItem.getListOfItemTemplates() for i in listOfItemTemplates: it = ShimstarItem(0, i) if it.getTypeItem() == C_ITEM_ENGINE: eng = engine(0, i) itXml = eng.getXml() elif it.getTypeItem() == C_ITEM_WEAPON: wea = Weapon(i, it.getSpecific()) itXml = wea.getXml() elif it.getTypeItem() == C_ITEM_MINING: min = miningItem(i, it.getSpecific()) itXml = min.getXml() elif it.getTypeItem() == C_ITEM_ENERGY: min = Reactor(0, i) itXml = min.getXml() elif it.getTypeItem() == C_ITEM_SHIELD: min = Shield(0,i) itXml = min.getXml() elif it.getTypeItem() == C_ITEM_SHIP: print "main::ship " + str(i) + "/" + str(it.getSpecific()) sh = Ship(0, i) itXml = sh.getXml() else: itXml = it.getXml(docXml) itemsXml.appendChild(itXml) docXml.appendChild(itemsXml) fileHandle = open("./datas/itemtemplates.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() #############Asteroid################## docXml = xml.dom.minidom.Document() astXml = docXml.createElement("asteroids") listOfAst = Asteroid.getListOfAsteroidTemplate() # ~ print listOfAst for ida in listOfAst: a = Asteroid(0, ida) aXml = a.getXmlTemplate(docXml) astXml.appendChild(aXml) docXml.appendChild(astXml) fileHandle = open("./datas/asteroids.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() #############WormHole################## docXml = xml.dom.minidom.Document() wormXml = docXml.createElement("wormholes") listOfWorm = wormhole.getListOfWormHoleTemplate() #~ print listOfAst for idW in listOfWorm: w = wormhole(0, idW) wXml = w.getXmlTemplate(docXml) wormXml.appendChild(wXml) docXml.appendChild(wormXml) fileHandle = open("./datas/wormholes.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() #############PnjTemplate################## docXml = xml.dom.minidom.Document() pnjXml = docXml.createElement("pnjtemplates") listOfP = PNJtemplate.getListOfPNJTemplate() #~ print listOfAst for idp in listOfP: p = PNJtemplate(idp) pXml = p.getXml(docXml) pnjXml.appendChild(pXml) docXml.appendChild(pnjXml) fileHandle = open("./datas/pnjtemplate.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() #############Skill################## docXml = xml.dom.minidom.Document() skillXml = docXml.createElement("skills") listOfSkill = Skill.getListOfSkills() #~ print listOfAst for ids in listOfSkill: s = Skill(ids) sXml = s.getXml(docXml) skillXml.appendChild(sXml) docXml.appendChild(skillXml) fileHandle = open("./datas/skills.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close() #############Minerals################## docXml = xml.dom.minidom.Document() mineralXml = docXml.createElement("minerals") listOfMinerals = mineral.getListMineral() #~ print listOfAst for idm in listOfMinerals: s = mineral(0, idm) sXml = s.getXml(docXml) print sXml mineralXml.appendChild(sXml) docXml.appendChild(mineralXml) fileHandle = open("./datas/mineral.xml", 'w') fileHandle.write(docXml.toxml()) fileHandle.close()
def getXml(self, docXml=None): if docXml == None: docXml = xml.dom.minidom.Document() zoneXml = docXml.createElement("zone") nameXml = docXml.createElement("name") nameXml.appendChild(docXml.createTextNode(str(self.name))) idXml = docXml.createElement("id") idXml.appendChild(docXml.createTextNode(str(self.id))) typeZoneXml = docXml.createElement("typezone") typeZoneXml.appendChild(docXml.createTextNode(str(self.typeZone))) scaleXml = docXml.createElement("scale") scaleXml.appendChild(docXml.createTextNode(str(self.scale))) musicXml = docXml.createElement("music") musicXml.appendChild(docXml.createTextNode(str(self.music))) if int(self.typeZone) == C_TYPEZONE_SPACE: eggXml = docXml.createElement("egg") eggXml.appendChild(docXml.createTextNode(str(self.egg))) else: print "zone::getXml " + str(self.id) + "/" + str(self.typeZone) currentStation = station(self.id) eggXml = docXml.createElement("egg") eggXml.appendChild(docXml.createTextNode(str(currentStation.getBackground()))) exitZoneXml = docXml.createElement("exitzone") exitZoneXml.appendChild(docXml.createTextNode(str(currentStation.getExitZone()))) zoneXml.appendChild(exitZoneXml) zoneXml.appendChild(idXml) zoneXml.appendChild(nameXml) zoneXml.appendChild(typeZoneXml) zoneXml.appendChild(eggXml) zoneXml.appendChild(scaleXml) zoneXml.appendChild(musicXml) if int(self.typeZone) == C_TYPEZONE_SPACE: if len(self.listOfAsteroid) > 0: asteroidsXml = docXml.createElement("asteroids") for a in self.listOfAsteroid: ast = Asteroid(a) astXml = ast.getXml() asteroidsXml.appendChild(astXml) zoneXml.appendChild(asteroidsXml) if len(self.listOfStation) > 0: stationXml = docXml.createElement("stations") for s in self.listOfStation: st = station(s) stXml = st.getXml() stationXml.appendChild(stXml) zoneXml.appendChild(stationXml) if len(self.listOfStation) > 0: wormXml = docXml.createElement("wormholes") for w in self.listOfWormHole: wo = wormhole(w) wXml = wo.getXml() wormXml.appendChild(wXml) zoneXml.appendChild(wormXml) return zoneXml