def _initRewardsList(self):
        with self.getViewModel().transaction() as tx:
            rewardsList = tx.rewardsList.getItems()
            if self._quest is not None:
                bonuses = getMissionInfoData(
                    self._quest).getSubstituteBonuses()
                bonuses.sort(key=self._keySortOrder)
                formatter = PackRentVehiclesAwardComposer(
                    ADDITIONAL_AWARDS_COUNT, getPackRentVehiclesAwardPacker())
                for index, bonus in enumerate(
                        formatter.getFormattedBonuses(bonuses)):
                    rendererModel = RewardRendererModel()
                    with rendererModel.transaction() as rewardTx:
                        rewardTx.setIcon(bonus.get('imgSource', ''))
                        labelStr = bonus.get('label', '') or ''
                        rewardTx.setLabelStr(labelStr)
                        rewardTx.setTooltipId(index)
                    rewardsList.addViewModel(rendererModel)
                    self.__items[index] = TooltipData(
                        tooltip=bonus.get('tooltip', None),
                        isSpecial=bonus.get('isSpecial', False),
                        specialAlias=bonus.get('specialAlias', ''),
                        specialArgs=bonus.get('specialArgs', None))

            tx.setShowRewards(bool(self.__items))
        return
Пример #2
0
def getRewardsBonuses(rewards,
                      size='big',
                      awardsCount=_DEFAULT_DISPLAYED_AWARDS_COUNT):
    formatter = BonusNameQuestsBonusComposer(awardsCount,
                                             getPackRentVehiclesAwardPacker())
    bonuses = []
    if rewards:
        for bonusType, bonusValue in rewards.iteritems():
            if bonusType == 'vehicles' and isinstance(bonusValue, list):
                for vehicleData in bonusValue:
                    bonuses.extend(getNonQuestBonuses(bonusType, vehicleData))

            bonus = getNonQuestBonuses(bonusType, bonusValue)
            bonuses.extend(bonus)

    formattedBonuses = formatter.getFormattedBonuses(bonuses, size)
    return formattedBonuses
Пример #3
0
 def _getAwardComposer(self):
     return PackRentVehiclesAwardComposer(_ADDITIONAL_AWARDS_COUNT,
                                          getPackRentVehiclesAwardPacker())