def updateList(self): self.recipeList.removeAndDestroyAllItems() self.buttons = [] self.inactiveButtons = [] playerLevel = self.potionGame.dist.getPlayerPotionLevel() notNew_list = self.potionGame.dist.getPlayerNotNewFlags() for recipe in self.potionGame.recipes: if playerLevel >= recipe.level: recipe.enabled = True else: recipe.enabled = False if recipe.enabled: recipe.haveMade = recipe.potionID not in notNew_list and False else: recipe.haveMade = True self.potionGame.recipes.sort() for recipe in self.potionGame.recipes: if recipe.questOnly: if localAvatar.getInventory(): class brewable(Exception): __module__ = __name__ try: for currQuest in localAvatar.getInventory( ).getQuestList(): bonusComplete = currQuest.isComplete(bonus=True) primaryComplete = currQuest.isComplete() if not bonusComplete or not primaryComplete: tasks = currQuest.getQuestDNA().getTaskDNAs() for currTask in tasks: if isinstance(currTask, PotionsTaskDNA): raise (PotionGlobals.getPotionItemID( recipe.potionID) == currTask.potionType and not primaryComplete or PotionGlobals.getPotionItemID( recipe.potionID) == currTask.potionTypeBonus and not bonusComplete) and brewable except brewable: pass else: continue if recipe.level - playerLevel > 3: if not recipe.questOnly: continue buttonImage = None recipe.loadIngredients() buttonImageScale = 0.0 text = recipe.name helptext = recipe.desc if not recipe.haveMade: if len(recipe.ingredients) > 0: iconText = recipe.questOnly and PLocalizer.PotionGui[ 'QuestLabel'] iconTextColor = PiratesGuiGlobals.TextFG13 else: iconText = PLocalizer.PotionGui['NewLabel'] iconTextColor = PiratesGuiGlobals.TextFG1 guiAssets = loader.loadModel( 'models/minigames/pir_m_gui_pot_textureCard') buttonImage = guiAssets.find( '**/pir_t_gui_pot_seal').copyTo(NodePath()) buttonImageScale = 0.08 buttonText = DirectLabel( parent=buttonImage, relief=None, text=iconText, text_scale=PiratesGuiGlobals.TextScaleLarge / buttonImageScale, text_font=PiratesGlobals.getPirateOutlineFont(), text_align=TextNode.ACenter, text_fg=iconTextColor, text_shadow=PiratesGuiGlobals.TextFG14, hpr=(0, 0, 20), pos=(-0.25, 0, 0), textMayChange=0) guiAssets.removeNode() cmd = ((Freebooter.getPaidStatus(localAvatar.doId) or recipe.isFree) and self).potionGame.selectRecipe buttonGeom = None buttonGeomScale = 1 buttonGeomPos = (0, 0, 0) args = None else: gui = loader.loadModel('models/gui/toplevel_gui') buttonGeom = gui.find('**/pir_t_gui_gen_key_subscriber') buttonGeomScale = 0.16 buttonGeomPos = (-0.05, 0, 0.01) cmd = base.localAvatar.guiMgr.showNonPayer args = ['Restricted_Potion_Crafting_Recipe', 9] gui.removeNode() button = recipe.enabled and recipe.available and GuiButton.GuiButton( text=(text, text, text, text), canReposition=True, text_wordwrap=0, image_scale=buttonImageScale, image_pos=(-0.04, 0.0, 0.01), image=(buttonImage, buttonImage, buttonImage, buttonImage), geom=buttonGeom, geom_scale=buttonGeomScale, geom_pos=buttonGeomPos, text0_fg=PotionGlobals.TextColor, text1_fg=PiratesGuiGlobals.TextFG0, text2_fg=PiratesGuiGlobals.TextFG15, text3_fg=PotionGlobals.TextColorDisabled, text_align=TextNode.ALeft, text_shadow=None, text_scale=PiratesGuiGlobals.TextScaleExtraLarge, command=cmd, state=DGG.NORMAL, extraArgs=[recipe]) button.bind(DGG.ENTER, recipe.showDetails) button.bind(DGG.EXIT, recipe.hideDetails) if button['image'][0]: button['image_pos'] = (button.getBounds()[1] + 0.075, 0, 0.01) self.buttons.append(button) else: button = GuiButton.GuiButton( text=(text, text, text, text), canReposition=True, text_wordwrap=0, image_scale=buttonImageScale, image_pos=(-0.04, 0.0, 0.01), image=(buttonImage, buttonImage, buttonImage, buttonImage), geom=buttonGeom, geom_scale=buttonGeomScale, geom_pos=buttonGeomPos, text0_fg=PotionGlobals.TextColorDisabled, text1_fg=PotionGlobals.TextColorDisabled, text2_fg=PotionGlobals.TextColorDisabled, text3_fg=PotionGlobals.TextColorDisabled, text_shadow=None, text_scale=PiratesGuiGlobals.TextScaleExtraLarge, text_align=TextNode.ALeft, state=DGG.NORMAL, extraArgs=[recipe]) button.bind(DGG.ENTER, recipe.showDetails) button.bind(DGG.EXIT, recipe.hideDetails) if button['image'][0]: button['image_pos'] = (button.getBounds()[1] + 0.075, 0, 0.01) self.inactiveButtons.append(button) self.recipeList.addItem(button) self.recipeList.refresh() self.lastIncButtonState = self.recipeList.incButton['state'] self.lastDecButtonState = self.recipeList.decButton['state'] self.recipeList.incButton['command'] = self.recipeList.scrollBy self.recipeList.incButton['extraArgs'] = [1] self.recipeList.decButton['command'] = self.recipeList.scrollBy self.recipeList.decButton['extraArgs'] = [-1] return
def updateList(self): self.recipeList.removeAndDestroyAllItems() self.buttons = [] self.inactiveButtons = [] playerLevel = self.potionGame.dist.getPlayerPotionLevel() notNew_list = self.potionGame.dist.getPlayerNotNewFlags() for recipe in self.potionGame.recipes: if playerLevel >= recipe.level: recipe.enabled = True else: recipe.enabled = False if recipe.enabled and recipe.potionID not in notNew_list: recipe.haveMade = False recipe.haveMade = True self.potionGame.recipes.sort() for recipe in self.potionGame.recipes: if recipe.questOnly and localAvatar.getInventory(): class brewable(Exception): pass try: for currQuest in localAvatar.getInventory().getQuestList(): bonusComplete = currQuest.isComplete(bonus = True) primaryComplete = currQuest.isComplete() if not bonusComplete or not primaryComplete: tasks = currQuest.getQuestDNA().getTaskDNAs() for currTask in tasks: if isinstance(currTask, PotionsTaskDNA): if (PotionGlobals.getPotionItemID(recipe.potionID) == currTask.potionType or not primaryComplete or PotionGlobals.getPotionItemID(recipe.potionID) == currTask.potionTypeBonus) and not bonusComplete: raise brewable except brewable: pass if recipe.level - playerLevel > 3 and not (recipe.questOnly): buttonImage = None recipe.loadIngredients() buttonImageScale = 0.0 text = recipe.name helptext = recipe.desc if not (recipe.haveMade) and len(recipe.ingredients) > 0: if recipe.questOnly: iconText = PLocalizer.PotionGui['QuestLabel'] iconTextColor = PiratesGuiGlobals.TextFG13 else: iconText = PLocalizer.PotionGui['NewLabel'] iconTextColor = PiratesGuiGlobals.TextFG1 guiAssets = loader.loadModel('models/minigames/pir_m_gui_pot_textureCard') buttonImage = guiAssets.find('**/pir_t_gui_pot_seal').copyTo(NodePath()) buttonImageScale = 0.080000000000000002 buttonText = DirectLabel(parent = buttonImage, relief = None, text = iconText, text_scale = PiratesGuiGlobals.TextScaleLarge / buttonImageScale, text_font = PiratesGlobals.getPirateOutlineFont(), text_align = TextNode.ACenter, text_fg = iconTextColor, text_shadow = PiratesGuiGlobals.TextFG14, hpr = (0, 0, 20), pos = (-0.25, 0, 0), textMayChange = 0) guiAssets.removeNode() if Freebooter.getPaidStatus(localAvatar.doId) or recipe.isFree: cmd = self.potionGame.selectRecipe buttonGeom = None buttonGeomScale = 1 buttonGeomPos = (0, 0, 0) args = None else: gui = loader.loadModel('models/gui/toplevel_gui') buttonGeom = gui.find('**/pir_t_gui_gen_key_subscriber') buttonGeomScale = 0.16 buttonGeomPos = (-0.050000000000000003, 0, 0.01) cmd = base.localAvatar.guiMgr.showNonPayer args = [ 'Restricted_Potion_Crafting_Recipe', 9] gui.removeNode() if recipe.enabled and recipe.available: button = GuiButton.GuiButton(text = (text, text, text, text), canReposition = True, text_wordwrap = 0, image_scale = buttonImageScale, image_pos = (-0.040000000000000001, 0.0, 0.01), image = (buttonImage, buttonImage, buttonImage, buttonImage), geom = buttonGeom, geom_scale = buttonGeomScale, geom_pos = buttonGeomPos, text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, text_align = TextNode.ALeft, text_shadow = None, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, command = cmd, state = DGG.NORMAL, extraArgs = [ recipe]) button.bind(DGG.ENTER, recipe.showDetails) button.bind(DGG.EXIT, recipe.hideDetails) if button['image'][0]: button['image_pos'] = (button.getBounds()[1] + 0.074999999999999997, 0, 0.01) self.buttons.append(button) else: button = GuiButton.GuiButton(text = (text, text, text, text), canReposition = True, text_wordwrap = 0, image_scale = buttonImageScale, image_pos = (-0.040000000000000001, 0.0, 0.01), image = (buttonImage, buttonImage, buttonImage, buttonImage), geom = buttonGeom, geom_scale = buttonGeomScale, geom_pos = buttonGeomPos, text0_fg = PotionGlobals.TextColorDisabled, text1_fg = PotionGlobals.TextColorDisabled, text2_fg = PotionGlobals.TextColorDisabled, text3_fg = PotionGlobals.TextColorDisabled, text_shadow = None, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ALeft, state = DGG.NORMAL, extraArgs = [ recipe]) button.bind(DGG.ENTER, recipe.showDetails) button.bind(DGG.EXIT, recipe.hideDetails) if button['image'][0]: button['image_pos'] = (button.getBounds()[1] + 0.074999999999999997, 0, 0.01) self.inactiveButtons.append(button) self.recipeList.addItem(button) self.recipeList.refresh() self.lastIncButtonState = self.recipeList.incButton['state'] self.lastDecButtonState = self.recipeList.decButton['state'] self.recipeList.incButton['command'] = self.recipeList.scrollBy self.recipeList.incButton['extraArgs'] = [ 1] self.recipeList.decButton['command'] = self.recipeList.scrollBy self.recipeList.decButton['extraArgs'] = [ -1]