Ejemplo n.º 1
0
 def _populate(self):
     super(NY_Break, self)._populate()
     NYSoundEvents.playSound(NYSoundEvents.ON_OPEN_BREAK)
     NYSoundEvents.setState(NYSoundEvents.STATE_ON_BREAK)
     self.resetFilters()
     self.__selectedToys.clear()
     self.__gain = 0
     self.__inDispose = False
     self.__inBreakDlg = False
     toys, total, sortedTotal = self.__updateShownToysAndSelection()
     initData = {
         'cancelBtnLabel': NY.BREAKSCREEN_CANCELBTN_LABEL,
         'backBtnDescrLabel': NY.BREAKSCREEN_BACKBTN_TO_HANGAR,
         'breakToyFragmentTitle': NY.BREAKSCREEN_BREAKTOYFRAGMENT_TITLE,
         'lackToyFragmentTitle': NY.BREAKSCREEN_LACKTOYFRAGMENT_TITLE,
         'balanceToyFragmentTitle': NY.BREAKSCREEN_BALANCETOYFRAGMENT_TITLE,
         'enoughToyFragmentTitle': NY.BREAKSCREEN_ENOUGHTOYFRAGMENT_TITLE,
         'dummyVO': self._getDummy(),
         'dummyFilterVO': self._getDummyFilter(),
         'decorationsAmountText': formatSortString(total, sortedTotal),
         'title': NY.BREAKSCREEN_TITLE
     }
     self.as_setInitDataS(initData)
     self.as_setToysS(toys)
     self.as_setBalanceToyFragmentS(
         BigWorld.wg_getIntegralFormat(
             self._newYearController.getToyFragments()))
     self.__updateSelectedToyPrice()
     self.__updateBreakButton()
     self._newYearController.onToyFragmentsChanged += self.__onToyFragmentsChanged
     self._newYearController.onToysBreak += self.__showOnToysBreakAnimation
     self._newYearController.onToysBreakFailed += self.__onToysBreakFailed
     self._newYearController.onInventoryUpdated += self.__updateToys
     self.newYearUIManager.onCraftPopoverFilterChanged += self.__updateToys
Ejemplo n.º 2
0
    def _populate(self):
        super(NYCollections, self)._populate()
        levelSettings = self._newYearUIManager.getSelectedCollectionLevels()
        if levelSettings:
            self.__navigation = levelSettings
        else:
            for toyId in self._newYearController.receivedToysCollection:
                toy = g_cache.toys[toyId]
                self.__navigation[toy.setting] = max(
                    toy.rank - 1, self.__navigation[toy.setting])

            self._newYearUIManager.setSelectedCollectionLevels(
                self.__navigation)
        data = _DEF_DATA
        data['selectedSettings'] = self.__selectedSetting
        data['selectedLevel'] = [{
            'nation': nation,
            'selectedLevel': level
        } for nation, level in self.__navigation.iteritems()]
        data['nationOrder'] = sorted(NATIONAL_SETTINGS,
                                     key=lambda s: self._newYearController.
                                     getSettingIndexInNationsOrder(s))
        self.as_setDataS(data)
        self._newYearController.onToyCollectionChanged += self.__onToyCollectionChanged
        self.__updateDataByLevel(self.__navigation[self.__selectedSetting] + 1)
        NYSoundEvents.setBoxSwitch(self.__selectedSetting)
Ejemplo n.º 3
0
    def __onBoxesCountChanged(self, _, __, addedInfo):
        descrs = self._newYearController.boxStorage.getDescriptors()
        for bId, count in addedInfo.iteritems():
            if self.__setting == (descrs[bId].setting
                                  or ny_common.NO_SETTING_BOX_ID):
                self.__rewardsTotal += count
                NYSoundEvents.playSound(NYSoundEvents.ON_BOX_IS_GOT)

        self.__updateData()
Ejemplo n.º 4
0
 def _dispose(self):
     self.__selectedToys.clear()
     NYSoundEvents.playSound(NYSoundEvents.ON_CLOSE_BREAK)
     self._newYearController.onToyFragmentsChanged -= self.__onToyFragmentsChanged
     self._newYearController.onToysBreak -= self.__showOnToysBreakAnimation
     self._newYearController.onToysBreakFailed -= self.__onToysBreakFailed
     self._newYearController.onInventoryUpdated -= self.__updateToys
     self.newYearUIManager.onCraftPopoverFilterChanged -= self.__updateToys
     super(NY_Break, self)._dispose()
Ejemplo n.º 5
0
 def __restartAnimation(self):
     setting_id = self.__getOpeningBoxSettingID()
     if setting_id is not None:
         LOG_DEBUG('Box "{}" animation restarting.'.format(setting_id))
         animMapping = BOX_ANIM_MAPPING_LOW if self.__isNeedLowQualityAnim(
         ) else BOX_ANIM_MAPPING
         self.as_restartAnimationS(animMapping.get(setting_id))
         NYSoundEvents.setBoxSwitch(setting_id)
     return
Ejemplo n.º 6
0
 def _populate(self):
     super(NYRewards, self)._populate()
     self.__nyLevel, self.__nyMaxLevel, _, _ = self._newYearController.getProgress(
     )
     self.__updateData()
     NYSoundEvents.playSound(NYSoundEvents.ON_OPEN_REWARDS)
     NYSoundEvents.setState(NYSoundEvents.STATE_ON_REWARDS)
     self._newYearController.onProgressChanged += self.__onNYProgressChanged
     self._newYearController.vehDiscountsStorage.onUpdated += self.__onStoragesUpdated
     self._newYearController.tankmanDiscountsStorage.onUpdated += self.__onStoragesUpdated
Ejemplo n.º 7
0
 def onTabButtonClick(self, tabID):
     if tabID == self.__currentTabId:
         return
     self.__currentTabId = tabID
     self.as_enableBtnsS(False)
     NYSoundEvents.playSound(NYSoundEvents.ON_TAB_CLICK)
     if tabID in Mappings.ID_TO_ANCHOR:
         newState = Mappings.ID_TO_ANCHOR[tabID]
         if self._customizableObjMgr.state != newState:
             self._customizableObjMgr.switchTo(Mappings.ID_TO_ANCHOR[tabID], partial(self.__showViewById, tabID))
         else:
             self.__showViewById(tabID)
Ejemplo n.º 8
0
 def onSlotClick(self, toyID, toyIndex):
     LOG_DEBUG('toyIndex: ' + str(toyIndex))
     toyID = int(toyID)
     placedToy = self.newYearController.getPlacedToy(self.__slotID)
     if placedToy.id == toyID and toyIndex == _PLACED_TOY_INDEX:
         toyID = INVALID_TOY_ID
     else:
         objectName = g_cache.slots[self.__slotID].object
         toyDescr = g_cache.toys.get(toyID, None)
         if toyDescr is not None and toyDescr.type == NY_CONSTANTS.SLOT_TYPE_LAMP and objectName == AnchorNames.HOUSE:
             NYSoundEvents.playSound(NYSoundEvents.ON_HOUSE_LAMP_SET)
         else:
             NYSoundEvents.playSound(NYSoundEvents.ON_TOY_HANG.get(objectName, None))
     if self.newYearController.placeToy(toyID, self.__slotID):
         self._updateToysData()
     self.destroy()
     return
Ejemplo n.º 9
0
 def _populate(self):
     super(NYScreen, self)._populate()
     self._newYearController.boxStorage.onCountChanged += self.__onBoxCountChanged
     self._newYearController.onProgressChanged += self.__onProgressUpdated
     self._newYearController.onToyFragmentsChanged += self.__onToyFragmentsChanged
     self._newYearController.onInventoryUpdated += self.__onInventoryUpdated
     self._newYearController.onToysBreakStarted += self._onToysBreakStarted
     self._newYearController.onToysBreak += self._onToysBreak
     self._newYearController.onToysBreakFailed += self._onToysBreakFailed
     self.__linkCameraWithMouseEvents()
     NYSoundEvents.playOpenCustomization(self.__currentTabId)
     data, awardsCounter, progress = self.__makeVO()
     self.as_initS(data)
     self.as_updateNYAwardsCounterS(awardsCounter)
     self.__updateCounter()
     self.as_updateNYProgressS(progress)
     self.__onInventoryUpdated()
Ejemplo n.º 10
0
 def onAwardsButtonClick(self):
     NYSoundEvents.playCloseCustomization(Mappings.ID_TO_ANCHOR[self.__currentTabId])
     self._switchToRewards(previewAlias=VIEW_ALIAS.LOBBY_NY_SCREEN)
Ejemplo n.º 11
0
 def onToyObtained(self, level):
     NYSoundEvents.setRTPC(NYSoundEvents.RTPC_TOYS, int(level))
Ejemplo n.º 12
0
 def onToyFragmentButtonClick(self):
     NYSoundEvents.playSound(NYSoundEvents.ON_TOY_FRAGMENT_CLICK)
     self._switchToBreak(previewAlias=VIEW_ALIAS.LOBBY_NY_SCREEN)
Ejemplo n.º 13
0
 def _dispose(self):
     NYSoundEvents.playSound(NYSoundEvents.ON_CLOSE_REWARDS)
     self._newYearController.onProgressChanged -= self.__onNYProgressChanged
     self._newYearController.vehDiscountsStorage.onUpdated -= self.__onStoragesUpdated
     self._newYearController.tankmanDiscountsStorage.onUpdated -= self.__onStoragesUpdated
     super(NYRewards, self)._dispose()
Ejemplo n.º 14
0
 def onCraftButtonClick(self):
     NYSoundEvents.playSound(NYSoundEvents.ON_CRAFT_CLICK)
     self._switchToCraft(previewAlias=VIEW_ALIAS.LOBBY_NY_SCREEN)
Ejemplo n.º 15
0
 def onCollectionButtonClick(self):
     NYSoundEvents.playCloseCustomization(Mappings.ID_TO_ANCHOR[self.__currentTabId])
     self._switchToGroups(previewAlias=VIEW_ALIAS.LOBBY_NY_SCREEN, tabId=self.__currentTabId)
Ejemplo n.º 16
0
 def onClose(self):
     NYSoundEvents.playSound(NYSoundEvents.ON_CLOSE_COLLECTION_GROUPS)
     self._switchToNYMain(previewAlias=VIEW_ALIAS.LOBBY_NY_COLLECTIONS)
Ejemplo n.º 17
0
 def onFilterChange(self, type, index):
     oldPrice = self._newYearController.getPriceForCraft(
         self.__toyType, self.__toyNation, self.__toyLevel)
     if type == NY_CONSTANTS.TYPES_SECTION:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_TYPE_OR_LEVEL)
         self.__toyType = toyTypeByIndex(index)
     elif type == NY_CONSTANTS.LEVELS_SECTION:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_TYPE_OR_LEVEL)
         self.__toyLevel = toyLevelByIndex(index)
     elif type == NY_CONSTANTS.NATIONS_SECTION:
         self.__toyNation = toyNationByIndex(index)
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_SETTING)
         NYSoundEvents.setBoxSwitch(self.__toyNation)
     newPrice = self._newYearController.getPriceForCraft(
         self.__toyType, self.__toyNation, self.__toyLevel)
     fragments = self._newYearController.getToyFragments()
     if newPrice > fragments >= oldPrice:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_COST_SAME)
     if newPrice != oldPrice:
         NYSoundEvents.playSound(
             NYSoundEvents.CRAFT_COST_INCREASED
             if newPrice > oldPrice else NYSoundEvents.CRAFT_COST_DECREASED)
     NYSoundEvents.playSound(NYSoundEvents.CRAFT_MACHINE_ANIMATION)
     selectedToy = {
         'type': self.__toyType,
         'level': self.__toyLevel,
         'nation': self.__toyNation
     }
     self.newYearUIManager.setSelectedCraftToy(selectedToy)
     self.__updatePrice()
Ejemplo n.º 18
0
 def _populate(self):
     super(NYMissionRewardWindow, self)._populate()
     self._newYearController.boxStorage.onCountChanged += self.__onBoxesCountChanged
     self._newYearController.onStateChanged += self.__onNyStateChanged
     self.__updateData()
     NYSoundEvents.playSound(NYSoundEvents.ON_BOX_IS_GOT)
Ejemplo n.º 19
0
 def onCraft(self):
     NYSoundEvents.playSound(NYSoundEvents.CRAFT_BUTTON_PRESSED_CRAFT)
     self._newYearController.craftToy(self.__toyType, self.__toyNation,
                                      self.__toyLevel)
Ejemplo n.º 20
0
 def onPlaySound(self, soundType):
     NYSoundEvents.playSound(soundType)
Ejemplo n.º 21
0
 def onGetShards(self):
     NYSoundEvents.playSound(NYSoundEvents.CRAFT_TO_BREAK)
     self._switchToBreak(previewAlias=VIEW_ALIAS.LOBBY_NY_CRAFT)
Ejemplo n.º 22
0
 def _populate(self):
     super(NYCraft, self)._populate()
     self._newYearController.clearCraftedToys()
     selectedToy = self.newYearUIManager.getSelectedCraftToy()
     self.__toyType = selectedToy.get('type', None) if selectedToy else None
     self.__toyLevel = selectedToy.get('level',
                                       None) if selectedToy else None
     self.__toyNation = selectedToy.get('nation',
                                        None) if selectedToy else None
     initData = {
         'shardsBtnLabel':
         NY.CRAFTSCREEN_BUTTONS_SHARDSBTN,
         'craftBtnLabel':
         NY.CRAFTSCREEN_BUTTONS_CRAFTBTN,
         'title':
         NY.CRAFTSCREEN_TITLE,
         'shardsDescription':
         NY.CRAFTSCREEN_DESCRIPTION,
         'toyFragmentCount':
         BigWorld.wg_getIntegralFormat(
             self._newYearController.getToyFragments()),
         'nationsBlock': {
             'title':
             NY.CRAFTSCREEN_NATIONSLIDER_TITLE,
             'selectedId':
             indexByToyNation(self.__toyNation),
             'typeId':
             NY_CONSTANTS.NATIONS_SECTION,
             'tooltips': [
                 NY.CRAFTSCREEN_NATIONSLIDER_TOOLTIP_ANY,
                 NY.CRAFTSCREEN_NATIONSLIDER_TOOLTIP_SOVIET,
                 NY.CRAFTSCREEN_NATIONSLIDER_TOOLTIP_MODERNWESTERN,
                 NY.CRAFTSCREEN_NATIONSLIDER_TOOLTIP_TRADITIONALWESTERN,
                 NY.CRAFTSCREEN_NATIONSLIDER_TOOLTIP_ASIAN
             ]
         },
         'typesBlock': {
             'title':
             NY.CRAFTSCREEN_TYPESLIDER_TITLE,
             'selectedId':
             indexByToyType(self.__toyType),
             'typeId':
             NY_CONSTANTS.TYPES_SECTION,
             'tooltips': [
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_ANY,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_TOP,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_HANGING,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_GARLAND,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_GIFT,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_SNOWMAN,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_HOUSE_DECORATION,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_HOUSE_LAMP,
                 NY.CRAFTSCREEN_TYPESLIDER_TOOLTIP_STREET_GARLAND
             ]
         },
         'levelsBlock': {
             'title':
             NY.CRAFTSCREEN_LEVELSLIDER_TITLE,
             'selectedId':
             indexByToyLevel(self.__toyLevel),
             'typeId':
             NY_CONSTANTS.LEVELS_SECTION,
             'tooltips': [
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_ANY,
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_1,
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_2,
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_3,
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_4,
                 NY.CRAFTSCREEN_LEVELSLIDER_TOOLTIP_5
             ]
         },
         'carouselData':
         self.__getToysVO()
     }
     self.as_setInitDataS(initData)
     self.__updatePrice()
     NYSoundEvents.playSound(NYSoundEvents.ON_OPEN_CRAFT)
     NYSoundEvents.setState(NYSoundEvents.STATE_ON_CRAFT)
     self._newYearController.onToyFragmentsChanged += self.__onToyFragmentsChanged
     self._newYearController.onCraftedToysChanged += self.__onCraftedToysChanged
     return
Ejemplo n.º 23
0
 def _dispose(self):
     NYSoundEvents.playSound(NYSoundEvents.ON_CLOSE_CRAFT)
     self._newYearController.onToyFragmentsChanged -= self.__onToyFragmentsChanged
     self._newYearController.onCraftedToysChanged -= self.__onCraftedToysChanged
     super(NYCraft, self)._dispose()
Ejemplo n.º 24
0
 def onToyCreatePlaySound(self, level):
     NYSoundEvents.playSound(NYSoundEvents.CRAFT_TOY_CRAFTED)
     NYSoundEvents.setRTPC(NYSoundEvents.RTPC_TOYS, int(level))