def __init__(self):
     super(SessionStatsSettings, self).__init__()
     self.__sessionStatsSettings = SessionStatsSettingsController()
     self.__currentSettings = self.__sessionStatsSettings.getSettings()
     self.onShowStats = Event.Event()
     self.__lastChangedIdentifier = None
     return
 def __onSessionStatsBtnOnlyOnceHintHidden(self, record=False):
     if record:
         sessionStatsSettings = SessionStatsSettingsController(
         ).getSettings()
         sessionStatsSettings[
             SESSION_STATS.ONLY_ONCE_HINT_SHOWN_FIELD] = True
         SessionStatsSettingsController().setSettings(sessionStatsSettings)
     self.__sessionStatsBtnOnlyOnceHintShow = False
     self.__updateSessionStatsHint(self.__sessionStatsBtnOnlyOnceHintShow)
示例#3
0
def packBattleEfficiencyData(data, parameters):
    settings = SessionStatsSettingsController().getSettings()
    view = []
    for parameter in parameters:
        for idEfficientData, efficient in _EFFICIENT_DATA.iteritems():
            if efficient['settings'] == parameter and settings[efficient['settings']]:
                view.append({'icon': backport.image(efficient['icon']),
                 'label': text_styles.main(backport.text(efficient['label'])),
                 'value': text_styles.stats(efficient['currentValue'](data)),
                 'delta': getDeltaAsData(efficient['delta'](data)),
                 'id': idEfficientData})

    return view
 def _populate(self):
     super(MessengerBar, self)._populate()
     self.__compareBasketCtrl = _CompareBasketListener(self)
     self._referralCtrl.onReferralProgramEnabled += self.__onReferralProgramEnabled
     self._referralCtrl.onReferralProgramDisabled += self.__onReferralProgramDisabled
     self._referralCtrl.onReferralProgramUpdated += self.__onReferralProgramUpdated
     self._lobbyContext.getServerSettings(
     ).onServerSettingsChange += self.__onServerSettingChanged
     self.addListener(events.FightButtonEvent.FIGHT_BUTTON_UPDATE,
                      self.__handleFightButtonUpdated,
                      scope=EVENT_BUS_SCOPE.LOBBY)
     self.startGlobalListening()
     self.as_setInitDataS({
         'channelsHtmlIcon':
         _formatIcon('iconChannels'),
         'isReferralEnabled':
         isReferralProgramEnabled(),
         'referralCounter':
         self._referralCtrl.getBubbleCount(),
         'isReferralFirstIndication':
         self._referralCtrl.isFirstIndication(),
         'referralHtmlIcon':
         _formatIcon('iconReferral',
                     width=38,
                     height=29,
                     path='html_templates:lobby/referralButton'),
         'referralTooltip':
         TOOLTIPS.LOBY_MESSENGER_REFERRAL_BUTTON,
         'contactsHtmlIcon':
         _formatIcon('iconContacts', width=16),
         'vehicleCompareHtmlIcon':
         _formatIcon('iconComparison'),
         'contactsTooltip':
         TOOLTIPS.LOBY_MESSENGER_CONTACTS_BUTTON,
         'vehicleCompareTooltip':
         TOOLTIPS.LOBY_MESSENGER_VEHICLE_COMPARE_BUTTON,
         'sessionStatsHtmlIcon':
         _formatIcon('iconSessionStats')
     })
     sessionStatsSettings = SessionStatsSettingsController().getSettings()
     self.__sessionStatsBtnOnlyOnceHintShow = not sessionStatsSettings[
         SESSION_STATS.ONLY_ONCE_HINT_SHOWN_FIELD]
     self.__updateSessionStatsBtn()
示例#5
0
def packTotalData(data):
    settings = SessionStatsSettingsController().getSettings()
    isViewWithSpending = settings[SESSION_STATS.ECONOMIC_BLOCK_VIEW] == SESSION_STATS.ECONOMIC_BLOCK_VIEW_WITH_SPENDING
    result = []
    if isViewWithSpending:
        for idWithSpending in _VIEW_ECONOMIC_DATA_WITH_SPENIDNG:
            economicData = _ECONOMIC_DATA[idWithSpending]
            result.append({'label': backport.text(economicData['label']),
             'icon': backport.image(economicData['smallIcon']),
             'value': economicData['value'](data),
             'id': idWithSpending})

    else:
        for idWithoutSpending in _VIEW_ECONOMIC_DATA_WITHOUT_SPENIDNG:
            economicData = _ECONOMIC_DATA[idWithoutSpending]
            result.append({'label': text_styles.main(backport.text(economicData['label'])),
             'icon': backport.image(economicData['smallIcon']),
             'value': economicData['value'](data),
             'tooltip': economicData['tooltip'](data)})

    return result
class SessionStatsSettings(SessionStatsSettingsMeta):
    def __init__(self):
        super(SessionStatsSettings, self).__init__()
        self.__sessionStatsSettings = SessionStatsSettingsController()
        self.__currentSettings = self.__sessionStatsSettings.getSettings()
        self.onShowStats = Event.Event()
        self.__lastChangedIdentifier = None
        return

    def _populate(self):
        super(SessionStatsSettings, self)._populate()
        self.__sessionStatsSettings.start()
        self.__setSettings()

    def _dispose(self):
        self.__sessionStatsSettings.stop()
        self.__sessionStatsSettings = None
        super(SessionStatsSettings, self)._dispose()
        return

    def onClickResetBtn(self):
        self.__currentSettings = self.__sessionStatsSettings.getDefaultSettings(
        )
        self.__setSettings()
        self.as_setControlsStateS(self.__getControlsData())

    def onClickApplyBtn(self):
        if not self.__currentSettings[
                SESSION_STATS.IS_NEEDED_SAVE_CURRENT_TAB]:
            self.__currentSettings[
                SESSION_STATS.CURRENT_TAB] = SESSION_STATS.BATTLES_TAB
        self.__sessionStatsSettings.setSettings(self.__currentSettings)
        self.as_setControlsStateS(self.__getControlsData())
        self.onShowStats()

    def onClickBackBtn(self):
        self.onShowStats()

    def onSettingsInputChanged(self, identifier, value):
        self.__lastChangedIdentifier = identifier
        self.__currentSettings[identifier] = value
        self.__setBattleSettingsStatus()
        self.__setSettings()

    def __setSettings(self):
        data = {
            'header': self.__getHeader(),
            'common': self.__getCommonBlocks(),
            'economics': self.__getEconomicsBlock(),
            'battle': self.__getBattlesBlock()
        }
        self.as_setDataS(data)
        self.as_setControlsStateS(self.__getControlsData())
        self.__setBattleSettingsStatus()

    def __getHeader(self):
        enableResetBtn = self.__currentSettings != self.__sessionStatsSettings.getDefaultSettings(
        )
        return {
            'title':
            text_styles.promoSubTitle(
                backport.text(R.strings.session_stats.settings.header())),
            'resetBtnIcon':
            RES_ICONS.MAPS_ICONS_STATISTIC_ICON_BUTTON_REFRESH_093,
            'resetBtnTooltip':
            makeTooltip(header=backport.text(
                R.strings.session_stats.tooltip.settings.resetBtn.header()),
                        body=backport.text(R.strings.session_stats.tooltip.
                                           settings.resetBtn.body())),
            'resetBtnEnabled':
            enableResetBtn
        }

    def __getCommonBlocks(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getCommonBlock():
            inputs.append({
                'id': key,
                'label': _COMMON_BLOCK[key]['label'],
                'tooltip': _COMMON_BLOCK[key]['tooltip'],
                'selected': bool(settings[key])
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(
                    R.strings.session_stats.settings.commonSettings.header())),
            'inputs':
            inputs
        }

    def __getEconomicsBlock(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getEconomicBlockView():
            inputs.append({
                'id': str(key),
                'label': _ECONOMIC_BLOCK_VIEW[key]['label']
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(
                    R.strings.session_stats.settings.economicBlock.header())),
            'selectedRadioIndex':
            settings[SESSION_STATS.ECONOMIC_BLOCK_VIEW],
            'id':
            SESSION_STATS.ECONOMIC_BLOCK_VIEW,
            'inputs':
            inputs
        }

    def __getBattlesBlock(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getEfficiencyBlock():
            if key in SESSION_STATS.getImmutableEfficiencyBlockParameters():
                continue
            inputs.append({
                'id': key,
                'label': _EFFICIENCY_BLOCK[key]['label'],
                'tooltip': _EFFICIENCY_BLOCK[key]['tooltip'],
                'selected': bool(settings[key])
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(R.strings.session_stats.settings.efficiencyBlock.
                              header())),
            'inputs':
            inputs
        }

    def __getControlsData(self):
        enableApplyBtn = self.__sessionStatsSettings.validateSettings(
            self.__currentSettings)
        warning = {}
        if not enableApplyBtn:
            maxStats = MAX_STATS - len(
                SESSION_STATS.getImmutableEfficiencyBlockParameters())
            text = backport.text(
                R.strings.session_stats.settings.efficiencyBlock.error(),
                max=maxStats)
            warning['text'] = text_styles.alert(text)
            warning['icon'] = backport.image(
                R.images.gui.maps.icons.library.alertBigIcon())
        else:
            enableApplyBtn = self.__currentSettings != self.__sessionStatsSettings.getSettings(
            )
        return {
            'warning':
            warning,
            'states': [{
                'btnEnabled':
                enableApplyBtn,
                'btnLabel':
                backport.text(
                    R.strings.session_stats.settings.controls.applyBtn())
            }, {
                'btnEnabled':
                True,
                'btnLabel':
                backport.text(
                    R.strings.session_stats.settings.controls.backBtn())
            }]
        }

    def __setBattleSettingsStatus(self):
        if self.__sessionStatsSettings.validateSettings(
                self.__currentSettings):
            textStyle = text_styles.neutral
            warningFlag = False
        else:
            textStyle = text_styles.error
            warningFlag = self.__lastChangedIdentifier in SESSION_STATS.getEfficiencyBlock(
            )
        parameters = list(SESSION_STATS.getEfficiencyBlock())
        for parameter in SESSION_STATS.getImmutableEfficiencyBlockParameters():
            parameters.remove(parameter)

        maxSelectedItems = MAX_STATS - len(
            SESSION_STATS.getImmutableEfficiencyBlockParameters())
        numberSelectedItems = sum(
            [self.__currentSettings[key] for key in parameters])
        self.as_setBattleSettingsStatusS(
            text_styles.main(
                backport.text(
                    R.strings.session_stats.settings.efficiencyBlock.subheader(
                    ),
                    selected=textStyle(toIntegral(numberSelectedItems)),
                    max=text_styles.main(toIntegral(maxSelectedItems)))),
            warningFlag)