def showItems(self): items = [] selected = None player = client.getPlayer() for techID in player.techs: tech = client.getTechInfo(techID) if getattr(tech, self.techType) == 0: continue if self.techSubtype and tech.subtype not in self.techSubtype: continue # skip equipment not suitable for this hull if tech.minHull > self.hullType: continue if tech.maxHull < self.hullType: continue techType = self.getTechType(tech) if self.typeFilter & techType == 0: continue item = ui.Item(tech.name, tData=sequip.getLongDescr(techID), techID=techID, tType=typeText[techType]) if techID == self.selected: selected = item items.append(item) self.win.vList.items = items self.win.vList.itemsChanged() self.win.vList.selectItem(selected)
def showItems(self): items = [] selected = None player = client.getPlayer() for techID in player.techs: tech = client.getTechInfo(techID) if getattr(tech, self.techType) == 0: continue if self.techSubtype and tech.subtype not in self.techSubtype: continue # skip equipment not suitable for this hull if tech.minHull > self.hullType: continue if tech.maxHull < self.hullType: continue techType = self.getTechType(tech) if self.typeFilter & techType == 0: continue item = ui.Item(tech.name, tData = sequip.getLongDescr(techID), techID = techID, tType = typeText[techType]) if techID == self.selected: selected = item items.append(item) self.win.vList.items = items self.win.vList.itemsChanged() self.win.vList.selectItem(selected)
def showShip(self, techID, exp): tech = client.getPlayer().shipDesigns[techID] level = Rules.shipExpToLevel.get(int(exp / tech.baseExp), Rules.shipDefLevel) self.win.vShipModel.text = tech.name self.win.vShipClass.text = _(gdata.shipClasses[tech.combatClass]) self.win.vShipAtt.text = int(tech.combatAtt * Rules.shipLevelEff[level]) self.win.vShipDef.text = _("%d / %d") % ( int(tech.combatDef * Rules.shipLevelEff[level]), int(tech.missileDef * Rules.shipLevelEff[level]), ) self.win.vShipMaxSpeed.text = _("%.2f") % tech.speed self.win.vShipScannerPwr.text = tech.scannerPwr self.win.vShipSupport.text = _("%d + %d") % ( tech.operEn, int(tech.buildProd * Rules.operProdRatio)) info = _("Support: %d energy and %d contruction points per turn.") % ( tech.operEn, int(tech.buildProd * Rules.operProdRatio)) self.win.vShipSupport.statustip = info self.win.vShipSupport.tooltip = info self.win.vShipStorages.text = _("%d") % tech.storEn self.win.vShipSignature.text = tech.signature if tech.shieldHP > 0: self.win.vShipMaxHP.text = _("%d + %d") % ( tech.maxHP, tech.shieldHP, ) else: self.win.vShipMaxHP.text = _("%d") % (tech.maxHP, ) # show equipment items = [] for techID in tech.eqIDs: eq = client.getTechInfo(techID) short = sequip.getShortDescr(techID) long = sequip.getLongDescr(techID) item = ui.Item(_("%d x %s") % (tech.eqIDs[techID], eq.name), tData=short, tooltip=long, statustip=long) items.append(item) self.win.vShipEquipment.items = items self.win.vShipEquipment.itemsChanged()
def showShip(self, techID, exp): tech = client.getPlayer().shipDesigns[techID] level = Rules.shipExpToLevel.get(int(exp / tech.baseExp), Rules.shipDefLevel) self.win.vShipModel.text = tech.name self.win.vShipClass.text = _(gdata.shipClasses[tech.combatClass]) self.win.vShipAtt.text = int(tech.combatAtt * Rules.shipLevelEff[level]) self.win.vShipDef.text = _("%d / %d") % ( int(tech.combatDef * Rules.shipLevelEff[level]), int(tech.missileDef * Rules.shipLevelEff[level]), ) self.win.vShipMaxSpeed.text = _("%.2f") % tech.speed self.win.vShipScannerPwr.text = tech.scannerPwr self.win.vShipSupport.text = _("%d + %d") % (tech.operEn, int(tech.buildProd * Rules.operProdRatio)) info = _("Support: %d energy and %d contruction points per turn.") % (tech.operEn, int(tech.buildProd * Rules.operProdRatio)) self.win.vShipSupport.statustip = info self.win.vShipSupport.tooltip = info self.win.vShipStorages.text = _("%d") % tech.storEn self.win.vShipSignature.text = tech.signature if tech.shieldHP > 0: self.win.vShipMaxHP.text = _("%d + %d") % ( tech.maxHP, tech.shieldHP, ) else: self.win.vShipMaxHP.text = _("%d") % ( tech.maxHP, ) # show equipment items = [] for techID in tech.eqIDs: eq = client.getTechInfo(techID) short = sequip.getShortDescr(techID) long = sequip.getLongDescr(techID) item = ui.Item(_("%d x %s") % (tech.eqIDs[techID], eq.name), tData = short, tooltip = long, statustip = long) items.append(item) self.win.vShipEquipment.items = items self.win.vShipEquipment.itemsChanged()
tech = client.getTechInfo(self.hullID) self.win.vHull.text = tech.name # TODO _(tech.name) else: self.win.vHull.text = _("[Click to select]") if self.ctrlID: tech = client.getTechInfo(self.ctrlID) self.win.vCtrl.text = tech.name # TODO _(tech.name) else: self.win.vCtrl.text = _("[Click to select]") # equipments items = [] selected = None for eqID in self.eqIDs: tech = client.getTechInfo(eqID) short = sequip.getShortDescr(eqID) long = sequip.getLongDescr(eqID) item = ui.Item(tech.name, techID = eqID, tNumber = self.eqIDs[eqID], tData = short, tooltip = long, statustip = long) if eqID == self.selectedEqID: selected = item items.append(item) self.win.vEquipment.items = items self.win.vEquipment.itemsChanged() self.win.vEquipment.selectItem(selected) # display computed attrs if result: hull = client.getTechInfo(result.hullID) self.win.vAClass.text = _(gdata.shipClasses[result.combatClass]) self.win.vASignature.text = _("%d") % result.signature self.win.vASpeed.text = _("%.2f") % result.speed if result.shieldHP > 0:
def _detailEquipmentLists(self): # design info if self.hullID: tech = client.getTechInfo(self.hullID) self.win.vHull.text = tech.name # TODO _(tech.name) elif self.editMode: self.win.vHull.text = _("[Click to select]") else: self.win.vHull.text = "" if self.ctrlID: tech = client.getTechInfo(self.ctrlID) self.win.vCtrl.text = tech.name # TODO _(tech.name) elif self.editMode: self.win.vCtrl.text = _("[Click to select]") else: self.win.vCtrl.text = "" # equipments engines = [] weapons = [] equipment = [] selected = None selected_type = None for eqID in self.eqIDs: tech = client.getTechInfo(eqID) short = sequip.getShortDescr(eqID) _long = sequip.getLongDescr(eqID) # cache has been introduced to let items preserve highlight information if eqID in self.itemCache: item = self.itemCache[eqID] item.tNumber = self.eqIDs[eqID] else: item = ui.Item(tech.name, techID=eqID, tNumber=self.eqIDs[eqID], tData=short, tooltipTitle=_("Details"), tooltip=_long, statustip=_long) self.itemCache[eqID] = item if eqID == self.selectedEqID: selected = item selected_type = tech.subtype if tech.subtype == "seq_eng": engines.append(item) elif tech.subtype == "seq_wpn": weapons.append(item) elif tech.subtype in ["seq_mod", "seq_struct"]: equipment.append(item) self.win.vEngines.items = engines self.win.vEngines.itemsChanged() if selected_type == "seq_eng": self.win.vEngines.selectItem(selected) else: self.win.vEngines.selectItem(None) self.win.vWeapons.items = weapons self.win.vWeapons.itemsChanged() if selected_type == "seq_wpn": self.win.vWeapons.selectItem(selected) else: self.win.vWeapons.selectItem(None) self.win.vEquipment.items = equipment self.win.vEquipment.itemsChanged() if selected_type == "seq_mod": self.win.vEquipment.selectItem(selected) else: self.win.vEquipment.selectItem(None)
def _detailEquipmentLists(self): # design info if self.hullID: tech = client.getTechInfo(self.hullID) self.win.vHull.text = tech.name # TODO _(tech.name) elif self.editMode: self.win.vHull.text = _("[Click to select]") else: self.win.vHull.text = "" if self.ctrlID: tech = client.getTechInfo(self.ctrlID) self.win.vCtrl.text = tech.name # TODO _(tech.name) elif self.editMode: self.win.vCtrl.text = _("[Click to select]") else: self.win.vCtrl.text = "" # equipments engines = [] weapons = [] equipment = [] selected = None selected_type = None for eqID in self.eqIDs: tech = client.getTechInfo(eqID) short = sequip.getShortDescr(eqID) long = sequip.getLongDescr(eqID) # cache has been introduced to let items preserve highlight information if eqID in self.itemCache: item = self.itemCache[eqID] item.tNumber = self.eqIDs[eqID] else: item = ui.Item(tech.name, techID = eqID, tNumber = self.eqIDs[eqID], tData = short, tooltipTitle = _("Details"), tooltip = long, statustip = long) self.itemCache[eqID] = item if eqID == self.selectedEqID: selected = item selected_type = tech.subtype if tech.subtype == "seq_eng": engines.append(item) elif tech.subtype == "seq_wpn": weapons.append(item) elif tech.subtype in ["seq_mod", "seq_struct"]: equipment.append(item) self.win.vEngines.items = engines self.win.vEngines.itemsChanged() if selected_type == "seq_eng": self.win.vEngines.selectItem(selected) else: self.win.vEngines.selectItem(None) self.win.vWeapons.items = weapons self.win.vWeapons.itemsChanged() if selected_type == "seq_wpn": self.win.vWeapons.selectItem(selected) else: self.win.vWeapons.selectItem(None) self.win.vEquipment.items = equipment self.win.vEquipment.itemsChanged() if selected_type == "seq_mod": self.win.vEquipment.selectItem(selected) else: self.win.vEquipment.selectItem(None)