def setRenown(self, renown): self.renown = renown if self.displayType == SHIP_RENOWN_DISPLAY: self.rank = TitleGlobals.getRank(self.titleId, self.renown) elif self.displayType == LAND_RENOWN_DISPLAY: self.rank = TitleGlobals.getRank(self.titleId, self.renown) else: self.rank = 0 self.renownTarget = self.breakPoints[min(self.rank + 1, self.maxRank)] self.renownBase = self.breakPoints[self.rank] if self.rankBox: self.rankBox['text'] = self.titleMap[self.rank] self.rankBox['text_scale'] = 0.059999999999999998 if self.renownMeter: value = 0 if self.rank < self.maxRank and self.renownTarget - self.renownBase > 0: value = int((self.renown - self.renownBase) * 100 / (self.renownTarget - self.renownBase)) self.renownMeter['value'] = value if self.renownMeterText: if self.rank >= self.maxRank: self.renownBase = 0 self.renownTarget = 0 text = '0 / 0' if self.rank < self.maxRank and self.renownTarget - self.renownBase > 0: text = '%s / %s' % (self.renown - self.renownBase, self.renownTarget - self.renownBase) self.renownMeterText['text'] = text self.loadRankIcon()
def __init__(self, parent, titleId, position, panelIndex, titlesPage, defaultOnLand = 0, defaultOnSea = 0): DirectFrame.__init__(self, parent, pos = position) self.iconModel = loader.loadModel(TitleGlobals.getModelPath(titleId)) tempModel = loader.loadModel('models/textureCards/skillIcons') self.titleId = titleId self.rank = 1 self.maxRank = 1 self.expPoints = 241 self.expBase = 150 self.expTarget = 400 self.landActive = defaultOnLand self.seaActive = defaultOnSea self.panelIndex = panelIndex self.titlesPage = titlesPage self.booleanTitle = TitleGlobals.isBooleanTitle(self.titleId) topgui = loader.loadModel('models/gui/toplevel_gui') self.titleNameFrame = BorderFrame.BorderFrame(parent = self, relief = None, pos = (0.12, 0, 0.01), frameSize = (-0.14999999999999999, 0.5, -0.14999999999999999, 0.029999999999999999), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75), text = TitleGlobals.getTitleRankName(self.titleId, self.expPoints), text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_pos = (0, -0.02), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont()) self.titleDescFrame = DirectFrame(parent = self, relief = None, pos = (0.125, 0, -0.095000000000000001), text = TitleGlobals.getTitleDesc(self.titleId), text_align = TextNode.ALeft, text_scale = 0.029999999999999999, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont()) shipcard = loader.loadModel('models/gui/ship_battle') tex = shipcard.find('**/ship_battle_speed_bar*') self.expFrame = DirectFrame(parent = self, pos = (0.35999999999999999, 0, -0.050000000000000003), relief = None, image = tex, image_scale = (0.23000000000000001, 1, 0.5), scale = (1.48, 1, 1.2)) self.expMeter = DirectWaitBar(parent = self.expFrame, relief = DGG.RAISED, borderWidth = (0.0040000000000000001, 0.0040000000000000001), range = 100, value = 50, frameColor = (0, 0, 0, 0), barColor = (223 / 255.0, 137 / 255.0, 28 / 255.0, 1), frameSize = (-0.222, 0.084000000000000005, -0.012, 0.012), pos = (0.069000000000000006, 0, 0.0)) self.expMeterText = DirectFrame(parent = self, relief = None, pos = (0.59999999999999998, 0, 0.0), text = '%s / %s' % (self.expBase, self.expTarget), text_align = TextNode.ARight, text_scale = 0.029999999999999999, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont()) if self.booleanTitle: self.expFrame.hide() self.expMeterText.hide() imgScale = TitleGlobals.getScale(self.titleId) self.iconFrame = GuiButton.GuiButton(parent = self, pos = (0.040000000000000001, 0, -0.050000000000000003), helpText = TitleGlobals.getTitleName(self.titleId), helpPos = (-0.26000000000000001, 0, 0.080000000000000002), relief = None, image = self.iconModel.find('**/' + TitleGlobals.getIconName(self.titleId, 1)), image_scale = (0.14999999999999999 * imgScale, 1, 0.14999999999999999 * imgScale)) self.landButton = DirectButton.DirectButton(parent = self, pos = (0.70999999999999996, 0, -0.050000000000000003), relief = None, scale = 0.22, image_color = VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image = (topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command = self.selectLandBadge, extraArgs = [ self.panelIndex]) self.titlesPage.landButtons.append(self.landButton) self.seaButton = DirectButton.DirectButton(parent = self, pos = (0.87, 0, -0.050000000000000003), relief = None, scale = 0.22, image_color = VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image = (topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command = self.selectSeaBadge, extraArgs = [ self.panelIndex]) self.titlesPage.seaButtons.append(self.seaButton)
def checkInfamyReq(self, itemId): landInfamyLevel = ItemGlobals.getLandInfamyRequirement(itemId) seaInfamyLevel = ItemGlobals.getSeaInfamyRequirement(itemId) if landInfamyLevel and TitleGlobals.getRank(TitleGlobals.LandPVPTitle, localAvatar.getInfamyLand()) < landInfamyLevel: self.highlightRed(PLocalizer.LandInfamyRequirement % landInfamyLevel) if seaInfamyLevel and TitleGlobals.getRank(TitleGlobals.ShipPVPTitle, localAvatar.getInfamySea()) < seaInfamyLevel: self.highlightRed(PLocalizer.SeaInfamyRequirement % seaInfamyLevel)
def __init__(self, parent, displayType, **kw): DirectFrame.__init__(self, parent) self.renown = 0 self.spendableRenown = 0 self.renownTarget = 0 self.renownBase = 0 self.rank = 0 self.rankIcon = None self.xShift = 0 self.yShift = 0 self.titleId = 0 self.rankBox = None self.renownBox = None self.renownFrame = None self.renownMeter = None self.renownMeterText = None self.dummyFrame = None self.rankIcons = None self.iconsModel = None self.titleFrame = None self.renownSpendable = None self.displayType = displayType if self.displayType == SHIP_RENOWN_DISPLAY: self.titleMap = PLocalizer.PVPTitleSeaRanks self.renownName = PLocalizer.PVPInfamySea self.breakPoints = TitleGlobals.getBreakpoints(TitleGlobals.ShipPVPTitle) self.maxRank = TitleGlobals.getMaxRank(TitleGlobals.ShipPVPTitle) self.rankIcons = TitleGlobals.getIconList(TitleGlobals.ShipPVPTitle) self.iconsModel = loader.loadModel(TitleGlobals.getModelPath(TitleGlobals.ShipPVPTitle)) self.iconImageScale = (0.12, 1, 0.12) self.titleId = TitleGlobals.ShipPVPTitle elif self.displayType == LAND_RENOWN_DISPLAY: self.titleMap = PLocalizer.PVPTitleLandRanks self.renownName = PLocalizer.PVPInfamyLand self.breakPoints = TitleGlobals.getBreakpoints(TitleGlobals.LandPVPTitle) self.maxRank = TitleGlobals.getMaxRank(TitleGlobals.LandPVPTitle) self.rankIcons = TitleGlobals.getIconList(TitleGlobals.LandPVPTitle) self.iconsModel = loader.loadModel(TitleGlobals.getModelPath(TitleGlobals.LandPVPTitle)) self.iconImageScale = (0.12, 1, 0.12) self.titleId = TitleGlobals.LandPVPTitle else: self.titleMap = { 0: 'Unknown' } self.renownName = '?' self.breakPoints = [ 0] self.maxRank = 0 self.rankIcons = { 0: 'sail_come_about' } if not self.iconsModel: self.iconsModel = loader.loadModel('models/textureCards/skillIcons') self.iconImageScale = (0.12, 1, 0.12) self.loadRank() self.loadRankIcon() self.loadGUI() self.setRenown(self.renown) self.accept('LocalAvatarInfamyUpdated', self.updateRank)
def refresh(self): inv = localAvatar.getInventory() origRank = self.rank if inv: invType = TitleGlobals.getInventoryType(self.titleId) if self.titleId == TitleGlobals.ShipPVPTitle: self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamySea) elif self.titleId == TitleGlobals.LandPVPTitle: self.expPoints = localAvatar.getInventory().getStackQuantity(InventoryType.PVPTotalInfamyLand) elif invType: self.expPoints = inv.getStackQuantity(invType) else: self.expPoints = 0 if self.titleId == TitleGlobals.FounderTitle and localAvatar.getFounder(): self.expPoints = 1 self.rank = TitleGlobals.getRank(self.titleId, self.expPoints) self.maxRank = TitleGlobals.getMaxRank(self.titleId) self.expTarget = TitleGlobals.getBreakpoints(self.titleId)[min(self.rank + 1, self.maxRank)] self.expBase = TitleGlobals.getBreakpoints(self.titleId)[self.rank] if self.titleNameFrame: self.titleNameFrame['text'] = TitleGlobals.getTitleRankName(self.titleId, self.expPoints) if self.expMeter: value = 0 if self.rank < self.maxRank and self.expTarget - self.expBase > 0: value = int((self.expPoints - self.expBase) * 100 / (self.expTarget - self.expBase)) self.expMeter['value'] = value if self.expMeterText: if self.rank >= self.maxRank: self.expBase = 0 self.expTarget = 0 text = '0 / 0' if self.rank < self.maxRank and self.expTarget - self.expBase > 0: text = '%s / %s' % (self.expPoints - self.expBase, self.expTarget - self.expBase) self.expMeterText['text'] = text if self.iconFrame: icName = TitleGlobals.getIconName(self.titleId, self.rank) if icName: img = self.iconModel.find('**/' + icName) else: img = None self.iconFrame['image'] = img imgScale = TitleGlobals.getScale(self.titleId) self.iconFrame['image_scale'] = (0.065000000000000002 * imgScale, 1, 0.065000000000000002 * imgScale) titleOnOff = [ PLocalizer.TitleOff, PLocalizer.TitleOn] if self.rank != origRank: if self.landActive: self.titlesPage.setLandActive(self.panelIndex, self.landActive) if self.seaActive: self.titlesPage.setSeaActive(self.panelIndex, self.seaActive) if self.rank == 0 or not Freebooter.getPaidStatus(localAvatar.doId): self.landButton.hide() self.seaButton.hide() else: self.landButton.show() self.seaButton.show()
def __init__(self, parent, titleId, position, panelIndex, titlesPage, defaultOnLand=0, defaultOnSea=0): DirectFrame.__init__(self, parent, pos=position) self.iconModel = loader.loadModel(TitleGlobals.getModelPath(titleId)) tempModel = loader.loadModel('models/textureCards/skillIcons') self.titleId = titleId self.rank = 1 self.maxRank = 1 self.expPoints = 241 self.expBase = 150 self.expTarget = 400 self.landActive = defaultOnLand self.seaActive = defaultOnSea self.panelIndex = panelIndex self.titlesPage = titlesPage self.booleanTitle = TitleGlobals.isBooleanTitle(self.titleId) topgui = loader.loadModel('models/gui/toplevel_gui') self.titleNameFrame = BorderFrame.BorderFrame( parent=self, relief=None, pos=(0.12, 0, 0.01), frameSize=(-0.14999999999999999, 0.5, -0.14999999999999999, 0.029999999999999999), modelName='pir_m_gui_frm_subframe', imageColorScale=VBase4(0.75, 0.75, 0.90000000000000002, 0.75), text=TitleGlobals.getTitleRankName(self.titleId, self.expPoints), text_align=TextNode.ALeft, text_scale=0.035000000000000003, text_pos=(0, -0.02), text_fg=PiratesGuiGlobals.TextFG1, text_wordwrap=15, text_shadow=(0, 0, 0, 1), textMayChange=1, text_font=PiratesGlobals.getInterfaceFont()) self.titleDescFrame = DirectFrame( parent=self, relief=None, pos=(0.125, 0, -0.095000000000000001), text=TitleGlobals.getTitleDesc(self.titleId), text_align=TextNode.ALeft, text_scale=0.029999999999999999, text_pos=(0, -0.01), text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), textMayChange=0, text_font=PiratesGlobals.getInterfaceFont()) shipcard = loader.loadModel('models/gui/ship_battle') tex = shipcard.find('**/ship_battle_speed_bar*') self.expFrame = DirectFrame(parent=self, pos=(0.35999999999999999, 0, -0.050000000000000003), relief=None, image=tex, image_scale=(0.23000000000000001, 1, 0.5), scale=(1.48, 1, 1.2)) self.expMeter = DirectWaitBar( parent=self.expFrame, relief=DGG.RAISED, borderWidth=(0.0040000000000000001, 0.0040000000000000001), range=100, value=50, frameColor=(0, 0, 0, 0), barColor=(223 / 255.0, 137 / 255.0, 28 / 255.0, 1), frameSize=(-0.222, 0.084000000000000005, -0.012, 0.012), pos=(0.069000000000000006, 0, 0.0)) self.expMeterText = DirectFrame( parent=self, relief=None, pos=(0.59999999999999998, 0, 0.0), text='%s / %s' % (self.expBase, self.expTarget), text_align=TextNode.ARight, text_scale=0.029999999999999999, text_pos=(0, -0.01), text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), textMayChange=1, text_font=PiratesGlobals.getInterfaceFont()) if self.booleanTitle: self.expFrame.hide() self.expMeterText.hide() imgScale = TitleGlobals.getScale(self.titleId) self.iconFrame = GuiButton.GuiButton( parent=self, pos=(0.040000000000000001, 0, -0.050000000000000003), helpText=TitleGlobals.getTitleName(self.titleId), helpPos=(-0.26000000000000001, 0, 0.080000000000000002), relief=None, image=self.iconModel.find( '**/' + TitleGlobals.getIconName(self.titleId, 1)), image_scale=(0.14999999999999999 * imgScale, 1, 0.14999999999999999 * imgScale)) self.landButton = DirectButton.DirectButton( parent=self, pos=(0.70999999999999996, 0, -0.050000000000000003), relief=None, scale=0.22, image_color=VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image=(topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command=self.selectLandBadge, extraArgs=[self.panelIndex]) self.titlesPage.landButtons.append(self.landButton) self.seaButton = DirectButton.DirectButton( parent=self, pos=(0.87, 0, -0.050000000000000003), relief=None, scale=0.22, image_color=VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image=(topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command=self.selectSeaBadge, extraArgs=[self.panelIndex]) self.titlesPage.seaButtons.append(self.seaButton)
def refresh(self): inv = localAvatar.getInventory() origRank = self.rank if inv: invType = TitleGlobals.getInventoryType(self.titleId) if self.titleId == TitleGlobals.ShipPVPTitle: self.expPoints = localAvatar.getInventory().getStackQuantity( InventoryType.PVPTotalInfamySea) elif self.titleId == TitleGlobals.LandPVPTitle: self.expPoints = localAvatar.getInventory().getStackQuantity( InventoryType.PVPTotalInfamyLand) elif invType: self.expPoints = inv.getStackQuantity(invType) else: self.expPoints = 0 if self.titleId == TitleGlobals.FounderTitle and localAvatar.getFounder( ): self.expPoints = 1 self.rank = TitleGlobals.getRank(self.titleId, self.expPoints) self.maxRank = TitleGlobals.getMaxRank(self.titleId) self.expTarget = TitleGlobals.getBreakpoints(self.titleId)[min( self.rank + 1, self.maxRank)] self.expBase = TitleGlobals.getBreakpoints(self.titleId)[self.rank] if self.titleNameFrame: self.titleNameFrame['text'] = TitleGlobals.getTitleRankName( self.titleId, self.expPoints) if self.expMeter: value = 0 if self.rank < self.maxRank and self.expTarget - self.expBase > 0: value = int((self.expPoints - self.expBase) * 100 / (self.expTarget - self.expBase)) self.expMeter['value'] = value if self.expMeterText: if self.rank >= self.maxRank: self.expBase = 0 self.expTarget = 0 text = '0 / 0' if self.rank < self.maxRank and self.expTarget - self.expBase > 0: text = '%s / %s' % (self.expPoints - self.expBase, self.expTarget - self.expBase) self.expMeterText['text'] = text if self.iconFrame: icName = TitleGlobals.getIconName(self.titleId, self.rank) if icName: img = self.iconModel.find('**/' + icName) else: img = None self.iconFrame['image'] = img imgScale = TitleGlobals.getScale(self.titleId) self.iconFrame['image_scale'] = (0.065000000000000002 * imgScale, 1, 0.065000000000000002 * imgScale) titleOnOff = [PLocalizer.TitleOff, PLocalizer.TitleOn] if self.rank != origRank: if self.landActive: self.titlesPage.setLandActive(self.panelIndex, self.landActive) if self.seaActive: self.titlesPage.setSeaActive(self.panelIndex, self.seaActive) if self.rank == 0 or not Freebooter.getPaidStatus(localAvatar.doId): self.landButton.hide() self.seaButton.hide() else: self.landButton.show() self.seaButton.show()