Exemple #1
0
    def _updateViewModel(self):
        _logger.debug('DailyQuests::UpdatingViewModel')
        newCountdownVal = EventInfoModel.getDailyProgressResetTimeDelta()
        quests = sorted(self.eventsCache.getDailyQuests().values(), key=dailyQuestsSortFunc)
        if not needToUpdateQuestsInModel(quests, self.getViewModel().getQuests()):
            return
        else:
            with self.getViewModel().transaction() as tx:
                tx.setCountdown(newCountdownVal)
                modelQuests = tx.getQuests()
                modelQuests.clear()
                modelQuests.reserve(len(quests))
                for quest in quests:
                    questUIPacker = getEventUIDataPacker(quest)
                    fullQuestModel = questUIPacker.pack()
                    questModel = WidgetQuestModel()
                    preFormattedConditionModel = self._getFirstConditionModelFromQuestModel(fullQuestModel)
                    if preFormattedConditionModel is not None:
                        questModel.setCurrentProgress(preFormattedConditionModel.getCurrent())
                        questModel.setTotalProgress(preFormattedConditionModel.getTotal())
                        questModel.setEarned(preFormattedConditionModel.getEarned())
                        questModel.setDescription(preFormattedConditionModel.getDescrData())
                    questModel.setId(fullQuestModel.getId())
                    questModel.setIcon(fullQuestModel.getIcon())
                    questModel.setCompleted(fullQuestModel.getStatus() == MISSIONS_STATES.COMPLETED)
                    modelQuests.addViewModel(questModel)
                    fullQuestModel.unbind()

                modelQuests.invalidate()
                self.__updateQuestsToBeIndicatedCompleted(tx, quests, self.viewModel.getVisible())
            return
Exemple #2
0
 def __packDescription(self, quests, season, isLeagues, isAnyPrimeNow,
                       isAnyPrimeLeftTotal):
     resShortCut = R.strings.ranked_battles.questsTooltip
     isAllCompleted = all((q.isCompleted() for q in quests))
     isAnyPrimeLeftNextDay = self.__rankedController.hasPrimeTimesNextDayLeft(
     )
     icon = icons.markerBlocked()
     timeDelta = time_utils.getTimeDeltaFromNowInLocal(
         time_utils.makeLocalServerTime(season.getEndDate()))
     timeDeltaStr = text_styles.stats(
         backport.getTillTimeStringByRClass(timeDelta,
                                            resShortCut.available))
     text = text_styles.main(
         backport.text(resShortCut.available(), timeDelta=timeDeltaStr))
     if not isAnyPrimeLeftTotal:
         text = text_styles.error(
             backport.getTillTimeStringByRClass(
                 timeDelta, resShortCut.unavailable.seasonEnd))
     elif not isLeagues:
         text = text_styles.error(
             backport.text(resShortCut.unavailable.notInLeagues()))
     elif not isAllCompleted:
         if isAnyPrimeNow:
             icon = icons.inProgress(vspace=-3)
         else:
             text = text_styles.error(
                 backport.text(resShortCut.unavailable.allServersPrime()))
     elif not isAnyPrimeLeftNextDay:
         icon = icons.inProgress(vspace=-3)
     else:
         icon = icons.clockGold()
         timeDelta = EventInfoModel.getDailyProgressResetTimeDelta()
         text = text_styles.tutorial(
             backport.getTillTimeStringByRClass(timeDelta,
                                                resShortCut.cooldown))
     return text_styles.concatStylesWithSpace(icon, text)
Exemple #3
0
 def _updateCountdownUntilNextDay(self, model):
     dailyResetTimeDelta = EventInfoModel.getDailyProgressResetTimeDelta()
     model.setCountDown(int(dailyResetTimeDelta))
 def _populate(self):
     super(DailyQuestWidget, self)._populate()
     self.__addListeners()
     self.__timer = CallbackDelayer()
     self.__showOrHide()
     self.__updateHideCallback(EventInfoModel.getDailyProgressResetTimeDelta())
Exemple #5
0
 def _onClientMainWindowStateChanged(self, isWindowVisible):
     if isWindowVisible:
         with self.viewModel.transaction() as tx:
             newCountdownVal = EventInfoModel.getDailyProgressResetTimeDelta()
             tx.setCountdown(newCountdownVal)