def handlePicking(self):
     messenger.send('wakeup')
     fullName = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     if self.isWilted():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmWiltedFlower % {'plant': fullName}, command=self.confirmCallback)
     elif not self.isFruiting():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmUnbloomingFlower % {'plant': fullName}, command=self.confirmCallback)
     elif base.localAvatar.isFlowerBasketFull():
         self.confirmDialog = TTDialog.TTDialog(style=TTDialog.CancelOnly, text=TTLocalizer.ConfirmBasketFull, command=self.confirmCallback)
     else:
         shovel = base.localAvatar.shovel
         skill = base.localAvatar.shovelSkill
         shovelPower = GardenGlobals.getShovelPower(shovel, skill)
         giveSkillUp = True
         beansRequired = GardenGlobals.getNumBeansRequired(self.species, self.variety)
         if not shovelPower == beansRequired:
             giveSkillUp = False
         if giveSkillUp:
             if skill == GardenGlobals.getMaxShovelSkill():
                 text = (TTLocalizer.ConfirmMaxedSkillFlower % {'plant': fullName},)
             else:
                 text = TTLocalizer.ConfirmSkillupFlower % {'plant': fullName}
             self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=text, command=self.confirmCallback)
         else:
             self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.ConfirmNoSkillupFlower % {'plant': fullName}, command=self.confirmCallback)
     self.confirmDialog.show()
     base.localAvatar.setInGardenAction(self)
     base.cr.playGame.getPlace().detectedGardenPlotUse()
 def getRequestPurchaseErrorText(self, retcode):
     retval = CatalogItem.CatalogItem.getRequestPurchaseErrorText(self, retcode)
     origText = retval
     if retval == TTLocalizer.CatalogPurchaseItemAvailable or retval == TTLocalizer.CatalogPurchaseItemOnOrder:
         recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(self.gardenIndex)
         if not recipeKey == -1:
             retval += GardenGlobals.getPlantItWithString(self.gardenIndex)
             if self.gardenIndex == GardenGlobals.GardenAcceleratorSpecial:
                 if GardenGlobals.ACCELERATOR_USED_FROM_SHTIKER_BOOK:
                     retval = origText
                     retval += TTLocalizer.UseFromSpecialsTab
                 retval += TTLocalizer.MakeSureWatered
     return retval
 def handlePicking(self):
     messenger.send('wakeup')
     fullName = GardenGlobals.getFlowerVarietyName(self.species,
                                                   self.variety)
     if self.isWilted():
         self.confirmDialog = TTDialog.TTDialog(
             style=TTDialog.YesNo,
             text=TTLocalizer.ConfirmWiltedFlower % {'plant': fullName},
             command=self.confirmCallback)
     elif not self.isFruiting():
         self.confirmDialog = TTDialog.TTDialog(
             style=TTDialog.YesNo,
             text=TTLocalizer.ConfirmUnbloomingFlower % {'plant': fullName},
             command=self.confirmCallback)
     elif base.localAvatar.isFlowerBasketFull():
         self.confirmDialog = TTDialog.TTDialog(
             style=TTDialog.CancelOnly,
             text=TTLocalizer.ConfirmBasketFull,
             command=self.confirmCallback)
     else:
         shovel = base.localAvatar.shovel
         skill = base.localAvatar.shovelSkill
         shovelPower = GardenGlobals.getShovelPower(shovel, skill)
         giveSkillUp = True
         beansRequired = GardenGlobals.getNumBeansRequired(
             self.species, self.variety)
         if not shovelPower == beansRequired:
             giveSkillUp = False
         if giveSkillUp:
             if skill == GardenGlobals.getMaxShovelSkill():
                 text = (TTLocalizer.ConfirmMaxedSkillFlower % {
                     'plant': fullName
                 }, )
             else:
                 text = TTLocalizer.ConfirmSkillupFlower % {
                     'plant': fullName
                 }
             self.confirmDialog = TTDialog.TTDialog(
                 style=TTDialog.YesNo,
                 text=text,
                 command=self.confirmCallback)
         else:
             self.confirmDialog = TTDialog.TTDialog(
                 style=TTDialog.YesNo,
                 text=TTLocalizer.ConfirmNoSkillupFlower %
                 {'plant': fullName},
                 command=self.confirmCallback)
     self.confirmDialog.show()
     base.localAvatar.setInGardenAction(self)
     base.cr.playGame.getPlace().detectedGardenPlotUse()
예제 #4
0
 def getRequestPurchaseErrorText(self, retcode):
     retval = CatalogItem.CatalogItem.getRequestPurchaseErrorText(
         self, retcode)
     origText = retval
     if retval == TTLocalizer.CatalogPurchaseItemAvailable or retval == TTLocalizer.CatalogPurchaseItemOnOrder:
         recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(
             self.gardenIndex)
         if not recipeKey == -1:
             retval += GardenGlobals.getPlantItWithString(self.gardenIndex)
             if self.gardenIndex == GardenGlobals.GardenAcceleratorSpecial:
                 if GardenGlobals.ACCELERATOR_USED_FROM_SHTIKER_BOOK:
                     retval = origText
                     retval += TTLocalizer.UseFromSpecialsTab
                 retval += TTLocalizer.MakeSureWatered
     return retval
예제 #5
0
    def __init__(self, parent, recipe, **kw):
        left = 0
        right = 0.445
        bottom = 0
        top = 0.08
        borderWidth = 0.01
        optiondefs = [('relief', DGG.RIDGE, None),
         ('state', 'normal', None),
         ('pos', (0, 0, 0), None),
         ('frameSize', (left,
           right,
           bottom,
           top), None),
         ('borderWidth', (borderWidth, borderWidth), self.setBorderWidth)]
        self.defineoptions(kw, optiondefs)
        DirectFrame.__init__(self, parent)
        self.initialiseoptions(BeanRecipeGui)
        self.jellyBeanBoxList = []
        xIncrement = 0.052
        for i in xrange(len(recipe)):
            beanIndex = GardenGlobals.BeanColorLetters.index(recipe[i])
            self.createJellyBeanBox(beanIndex, borderWidth + xIncrement * i, borderWidth)

        for j in xrange(len(recipe), GardenGlobals.getNumberOfShovelBoxes()):
            self.createEmptyBeanBox(borderWidth + xIncrement * j, borderWidth)

        return
 def __init__(self, doneEvent, specialBoxActive = False):
     if specialBoxActive:
         instructions = TTLocalizer.GardeningChooseBeansItem
         instructionsPos = (0, 0.4)
     else:
         instructions = TTLocalizer.GardeningChooseBeans
         instructionsPos = (0, 0.35)
     DirectFrame.__init__(self, relief=None, state='normal', geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1.5, 1.0, 1.0), frameSize=(-1, 1, -1, 1), pos=(0, 0, 0), text=instructions, text_wordwrap=20, text_scale=0.08, text_pos=instructionsPos)
     self.initialiseoptions(PlantingGUI)
     self.doneEvent = doneEvent
     buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
     okImageList = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr'))
     cancelImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr'))
     resetImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr'))
     self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, pos=(-0.3, 0, -0.35), text=TTLocalizer.PlantingGuiCancel, text_scale=0.06, text_pos=(0, -0.1), command=self.__cancel)
     self.okButton = DirectButton(parent=self, relief=None, image=okImageList, pos=(0.3, 0, -0.35), text=TTLocalizer.PlantingGuiOk, text_scale=0.06, text_pos=(0, -0.1), command=self.__doPlant)
     self.resetButton = DirectButton(parent=self, relief=None, image=resetImageList, pos=(0.0, 0, -0.35), text=TTLocalizer.PlantingGuiReset, text_scale=0.06, text_pos=(0, -0.1), command=self.__reset)
     buttons.removeNode()
     self.availableBoxes = base.localAvatar.getBoxCapability()
     self.maxBoxes = GardenGlobals.getNumberOfShovelBoxes()
     self.activeBoxesList = []
     self.specialBox = None
     self.specialBoxActive = specialBoxActive
     self.boxList = []
     self.jellyBeanPicker = None
     self.jellyBeanPickerInterval = None
     self.createBoxes()
     guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
     self.beanBank = DirectLabel(self, relief=None, image=guiItems.find('**/bean_bank'), text=str(base.localAvatar.getMoney() + base.localAvatar.getBankMoney()), text_align=TextNode.ARight, text_scale=0.11, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.75, -0.81), text_font=ToontownGlobals.getSignFont(), pos=(-0.85, 0, 0.2), scale=0.5)
     self.matchBoxesToAvailableMoney()
     if PICKER_ALWAYS_UP:
         self.spiffyBeanBoxClicked(0)
     return
 def doResultDialog(self):
     self.startInteraction()
     flowerName = GardenGlobals.getFlowerVarietyName(
         self.species, self.variety)
     stringToShow = TTLocalizer.getResultPlantedSomethingSentence(
         flowerName)
     self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge,
                                           text=stringToShow,
                                           command=self.resultsCallback)
 def isSkillTooLow(self, avatar):
     recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(self.gardenIndex)
     recipe = GardenGlobals.Recipes[recipeKey]
     numBeansRequired = len(recipe['beans'])
     canPlant = avatar.getBoxCapability()
     result = False
     if canPlant < numBeansRequired:
         result = True
     if not result and self.gardenIndex in GardenGlobals.Specials and 'minSkill' in GardenGlobals.Specials[self.gardenIndex]:
         minSkill = GardenGlobals.Specials[self.gardenIndex]['minSkill']
         if avatar.shovelSkill < minSkill:
             result = True
         else:
             result = False
     return result
예제 #9
0
 def isSkillTooLow(self, avatar):
     recipeKey = GardenGlobals.getRecipeKeyUsingSpecial(self.gardenIndex)
     recipe = GardenGlobals.Recipes[recipeKey]
     numBeansRequired = len(recipe['beans'])
     canPlant = avatar.getBoxCapability()
     result = False
     if canPlant < numBeansRequired:
         result = True
     if not result and self.gardenIndex in GardenGlobals.Specials and 'minSkill' in GardenGlobals.Specials[
             self.gardenIndex]:
         minSkill = GardenGlobals.Specials[self.gardenIndex]['minSkill']
         if avatar.shovelSkill < minSkill:
             result = True
         else:
             result = False
     return result
 def awardedTrophy(self, avId):
     if base.localAvatar.doId == avId:
         base.cr.playGame.getPlace().detectedGardenPlotUse()
         msg = TTLocalizer.GardenTrophyAwarded % (len(base.localAvatar.getFlowerCollection()), GardenGlobals.getNumberOfFlowerVarieties())
         self.awardDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=msg, command=self.closedAwardDialog)
예제 #11
0
 def __init__(self, doneEvent, specialBoxActive=False):
     if specialBoxActive:
         instructions = TTLocalizer.GardeningChooseBeansItem
         instructionsPos = (0, 0.4)
     else:
         instructions = TTLocalizer.GardeningChooseBeans
         instructionsPos = (0, 0.35)
     DirectFrame.__init__(self,
                          relief=None,
                          state='normal',
                          geom=DGG.getDefaultDialogGeom(),
                          geom_color=ToontownGlobals.GlobalDialogColor,
                          geom_scale=(1.5, 1.0, 1.0),
                          frameSize=(-1, 1, -1, 1),
                          pos=(0, 0, 0),
                          text=instructions,
                          text_wordwrap=20,
                          text_scale=0.08,
                          text_pos=instructionsPos)
     self.initialiseoptions(PlantingGUI)
     self.doneEvent = doneEvent
     buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
     okImageList = (buttons.find('**/ChtBx_OKBtn_UP'),
                    buttons.find('**/ChtBx_OKBtn_DN'),
                    buttons.find('**/ChtBx_OKBtn_Rllvr'))
     cancelImageList = (buttons.find('**/CloseBtn_UP'),
                        buttons.find('**/CloseBtn_DN'),
                        buttons.find('**/CloseBtn_Rllvr'))
     resetImageList = (buttons.find('**/CloseBtn_UP'),
                       buttons.find('**/CloseBtn_DN'),
                       buttons.find('**/CloseBtn_Rllvr'))
     self.cancelButton = DirectButton(parent=self,
                                      relief=None,
                                      image=cancelImageList,
                                      pos=(-0.3, 0, -0.35),
                                      text=TTLocalizer.PlantingGuiCancel,
                                      text_scale=0.06,
                                      text_pos=(0, -0.1),
                                      command=self.__cancel)
     self.okButton = DirectButton(parent=self,
                                  relief=None,
                                  image=okImageList,
                                  pos=(0.3, 0, -0.35),
                                  text=TTLocalizer.PlantingGuiOk,
                                  text_scale=0.06,
                                  text_pos=(0, -0.1),
                                  command=self.__doPlant)
     self.resetButton = DirectButton(parent=self,
                                     relief=None,
                                     image=resetImageList,
                                     pos=(0.0, 0, -0.35),
                                     text=TTLocalizer.PlantingGuiReset,
                                     text_scale=0.06,
                                     text_pos=(0, -0.1),
                                     command=self.__reset)
     buttons.removeNode()
     self.availableBoxes = base.localAvatar.getBoxCapability()
     self.maxBoxes = GardenGlobals.getNumberOfShovelBoxes()
     self.activeBoxesList = []
     self.specialBox = None
     self.specialBoxActive = specialBoxActive
     self.boxList = []
     self.jellyBeanPicker = None
     self.jellyBeanPickerInterval = None
     self.createBoxes()
     guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
     self.beanBank = DirectLabel(self,
                                 relief=None,
                                 image=guiItems.find('**/bean_bank'),
                                 text=str(base.localAvatar.getMoney() +
                                          base.localAvatar.getBankMoney()),
                                 text_align=TextNode.ARight,
                                 text_scale=0.11,
                                 text_fg=(0.95, 0.95, 0, 1),
                                 text_shadow=(0, 0, 0, 1),
                                 text_pos=(0.75, -0.81),
                                 text_font=ToontownGlobals.getSignFont(),
                                 pos=(-0.85, 0, 0.2),
                                 scale=0.5)
     self.matchBoxesToAvailableMoney()
     if PICKER_ALWAYS_UP:
         self.spiffyBeanBoxClicked(0)
     return
 def doResultDialog(self):
     self.startInteraction()
     flowerName = GardenGlobals.getFlowerVarietyName(self.species, self.variety)
     stringToShow = TTLocalizer.getResultPlantedSomethingSentence(flowerName)
     self.resultDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=stringToShow, command=self.resultsCallback)
예제 #13
0
    def updatePage(self):
        if hasattr(self, 'collectedTotal'):
            self.collectedTotal['text'] = TTLocalizer.GardenPageCollectedTotal % (len(base.localAvatar.flowerCollection), GardenGlobals.getNumberOfFlowerVarieties())
        if hasattr(self, 'shovelBar'):
            shovel = base.localAvatar.shovel
            shovelName = TTLocalizer.ShovelNameDict[shovel]
            curShovelSkill = base.localAvatar.shovelSkill
            maxShovelSkill = GardenGlobals.ShovelAttributes[shovel]['skillPts']
            if shovel == GardenGlobals.MAX_SHOVELS - 1:
                maxShovelSkill -= 1
            wateringCan = base.localAvatar.wateringCan
            wateringCanName = TTLocalizer.WateringCanNameDict[wateringCan]
            curWateringCanSkill = base.localAvatar.wateringCanSkill
            maxWateringCanSkill = GardenGlobals.WateringCanAttributes[wateringCan]['skillPts']
            if wateringCan == GardenGlobals.MAX_WATERING_CANS - 1:
                maxWateringCanSkill -= 1
            textToUse = TTLocalizer.GardenPageShovelInfo % (shovelName, curShovelSkill, maxShovelSkill)
            self.shovelBar['text'] = textToUse
            self.shovelBar['value'] = float(curShovelSkill) / float(maxShovelSkill) * self.barLength + self.FUDGE_FACTOR
            textToUse = TTLocalizer.GardenPageWateringCanInfo % (wateringCanName, curWateringCanSkill, maxWateringCanSkill)
            self.wateringCanBar['text'] = textToUse
            self.wateringCanBar['value'] = float(curWateringCanSkill) / float(maxWateringCanSkill) * self.barLength + self.FUDGE_FACTOR
        else:
            print 'no shovel bar'
        if self.mode == GardenPage_Collection:
            if hasattr(self, 'browser'):
                self.browser.update()
        elif self.mode == GardenPage_Basket:
            if hasattr(self, 'picker'):
                newBasketFlower = base.localAvatar.flowerBasket.getFlower()
                self.picker.update(newBasketFlower)
        elif self.mode == GardenPage_Trophy:
            if hasattr(self, 'trophies'):
                for trophy in self.trophies:
                    trophy.setLevel(-1)

                for trophyId in base.localAvatar.getGardenTrophies():
                    self.trophies[trophyId].setLevel(trophyId)

        elif self.mode == GardenPage_Specials:
            self.createGardenSpecialsList()
            if not base.cr.playGame.getPlace().getState() == 'stickerBook':
                self.specialsPhoto.hide()