def onSave(self,event): if self.item==None: itemToSave=engine(0,0,True) else: itemToSave=engine(self.item.getTemplate(),self.item.getSpecific()) itemToSave.setName(self.editname.GetValue()) tab=self.cboxChoixType.GetValue().split(" | ") if len(tab)>0: itemToSave.setTypeItem(int(tab[0])) itemToSave.setImg(self.imgName.split('.')[0]) itemToSave.setSpeedMax(self.speed.GetValue()) itemToSave.setAcceleration(self.acceleration.GetValue()) itemToSave.saveToBDD() self.prt.showAllTemplate() self.Destroy()
def showEngine(self): self.lblAcceleration=self.lblname = wx.StaticText(self.panel1, label="Acceleration :", pos=(10,100)) self.acceleration= wx.TextCtrl(self.panel1,value="", pos=(120, 100), size=(60,-1) ) self.lblSpeed= wx.StaticText(self.panel1, label="Vitesse :", pos=(10,120)) self.speed= wx.TextCtrl(self.panel1,value="", pos=(120, 120), size=(60,-1) ) if self.item!=None: eng=engine(self.item.getTemplate(),self.item.getSpecific()) self.speed.SetValue(str(eng.getSpeedMax())) self.acceleration.SetValue(str(eng.getAcceleration()))
def onDelete(self,args): if self.item!=None: listOfItemInstanciated=ShimstarItem.getListOfInstanciedObject(self.item.getTemplate()) if len(listOfItemInstanciated)==0: eng=engine(self.item.getTemplate(),self.item.getSpecific()) eng.delete() self.prt.showAllTemplate() self.Destroy() else: dlg = wx.MessageDialog(self.parent, "Il existe des objets lies a ce template, vous ne pouvez pas supprimer le template", "No", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
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()