当前位置: 首页>>代码示例>>Python>>正文


Python CooldownHelper.start方法代码示例

本文整理汇总了Python中gui.shared.view_helpers.CooldownHelper.start方法的典型用法代码示例。如果您正苦于以下问题:Python CooldownHelper.start方法的具体用法?Python CooldownHelper.start怎么用?Python CooldownHelper.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gui.shared.view_helpers.CooldownHelper的用法示例。


在下文中一共展示了CooldownHelper.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _RefreshBtnStateController

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class _RefreshBtnStateController(object):
    __coolDownRequests = [CLAN_REQUESTED_DATA_TYPE.CREATE_APPLICATIONS,
     CLAN_REQUESTED_DATA_TYPE.CREATE_INVITES,
     CLAN_REQUESTED_DATA_TYPE.ACCEPT_APPLICATION,
     CLAN_REQUESTED_DATA_TYPE.ACCEPT_INVITE,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_APPLICATION,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITE,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITES]

    def __init__(self, view):
        super(_RefreshBtnStateController, self).__init__()
        self.__view = weakref.proxy(view)
        self.__cooldown = CooldownHelper(self.__coolDownRequests, self._onCooldownHandle, CoolDownEvent.CLAN)
        self.__isEnabled = False
        self.__tooltip = None
        self.__isInCooldown = False
        return

    def start(self):
        self.__cooldown.start()

    def stop(self):
        self.__cooldown.stop()
        self.__cooldown = None
        return

    def setEnabled(self, enable, toolTip = None):
        self.__isEnabled = enable
        self.__tooltip = toolTip
        if not self.__isInCooldown:
            self._updateState()

    def _onCooldownHandle(self, isInCooldown):
        self.__isInCooldown = isInCooldown
        self._updateState()

    def _updateState(self):
        if self.__isEnabled:
            self.__view.as_updateButtonRefreshStateS(not self.__cooldown.isInCooldown(), makeTooltip(body=_ms(self.__tooltip or CLANS.CLANINVITESWINDOW_TOOLTIPS_REFRESHBUTTON_ENABLED)))
        else:
            self.__view.as_updateButtonRefreshStateS(False, makeTooltip(body=_ms(self.__tooltip or CLANS.CLANINVITESWINDOW_TOOLTIPS_REFRESHBUTTON_DISABLED)))
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:43,代码来源:claninviteswindowabstracttabview.py

示例2: CyberSportUnitsListView

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class CyberSportUnitsListView(CyberSportUnitsListMeta, UnitListener, ClubListener, ClubEmblemsHelper):

    def __init__(self):
        super(CyberSportUnitsListView, self).__init__()
        self._isBackButtonClicked = False
        self._section = 'selectedListVehicles'
        self._selectedVehicles = self.unitFunctional.getSelectedVehicles(self._section)
        self._unitTypeFlags = UNIT_BROWSER_TYPE.ALL
        self._cooldown = CooldownHelper(self.getCoolDownRequests(), self._onCooldownHandle, events.CoolDownEvent.PREBATTLE)

    def onUnitFunctionalInited(self):
        self.unitFunctional.setEntityType(PREBATTLE_TYPE.UNIT)

    def getPyDataProvider(self):
        return ManualSearchDataProvider()

    def getCoolDownRequests(self):
        return [REQUEST_TYPE.UNITS_LIST]

    def canBeClosed(self, callback):
        self._isBackButtonClicked = True
        callback(True)

    def updateSelectedVehicles(self):
        maxLevel = self.unitFunctional.getRosterSettings().getMaxLevel()
        vehiclesCount = len(self._selectedVehicles)
        availableVehiclesCount = len([ k for k, v in g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY).items() if v.level <= maxLevel ])
        if vehiclesCount > 0 and vehiclesCount != availableVehiclesCount:
            infoText = makeHtmlString('html_templates:lobby/cyberSport/vehicle', 'selectedValid', {'count': vehiclesCount})
        else:
            infoText = CYBERSPORT.BUTTON_CHOOSEVEHICLES_SELECT
        self.as_setSelectedVehiclesInfoS(infoText, vehiclesCount)

    def setTeamFilters(self, showOnlyStatic):
        self._unitTypeFlags = UNIT_BROWSER_TYPE.RATED_CLUBS if showOnlyStatic else UNIT_BROWSER_TYPE.ALL
        self.__recenterList()

    def filterVehicles(self):
        levelsRange = self.unitFunctional.getRosterSettings().getLevelsRange()
        if self._selectedVehicles is not None and len(self._selectedVehicles) > 0:
            selectedVehicles = self._selectedVehicles
        else:
            selectedVehicles = [ k for k, v in g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY).items() if v.level in levelsRange ]
        self.fireEvent(events.LoadViewEvent(CYBER_SPORT_ALIASES.VEHICLE_SELECTOR_POPUP_PY, ctx={'isMultiSelect': True,
         'infoText': CYBERSPORT.WINDOW_VEHICLESELECTOR_INFO_SEARCH,
         'selectedVehicles': selectedVehicles,
         'section': 'cs_list_view_vehicle',
         'levelsRange': levelsRange}), scope=EVENT_BUS_SCOPE.LOBBY)
        return

    def loadPrevious(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_NAV_LEFT)

    def loadNext(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_NAV_RIGHT)

    def refreshTeams(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_REFRESH)

    def getRallyDetails(self, index):
        cfdUnitID, vo = self._searchDP.getRally(index)
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.setSelectedID(cfdUnitID)
        self.__setDetailsData(cfdUnitID, vo)

    def showRallyProfile(self, clubDBID):
        club_events.showClubProfile(clubDBID)

    def _populate(self):
        super(CyberSportUnitsListView, self)._populate()
        self._cooldown.start()
        self.addListener(CSVehicleSelectEvent.VEHICLE_SELECTED, self.__onVehiclesSelectedTeams)
        self.startUnitListening()
        if self.unitFunctional.getEntityType() != PREBATTLE_TYPE.NONE:
            self.unitFunctional.setEntityType(PREBATTLE_TYPE.UNIT)
        self.updateSelectedVehicles()
        unit_ext.initListReq(self._unitTypeFlags).start(self.__onUnitsListUpdated)
        g_clientUpdateManager.addCallbacks({'inventory.1': self.__onVehiclesChanged})
        self.as_setSearchResultTextS(_ms(CYBERSPORT.WINDOW_UNITLISTVIEW_FOUNDTEAMS), '', self.__getFiltersData())
        headerDescription = CYBERSPORT.WINDOW_UNITLISTVIEW_DESCRIPTION
        headerTitle = CYBERSPORT.WINDOW_UNITLISTVIEW_TITLE
        self.as_setHeaderS({'title': headerTitle,
         'description': headerDescription,
         'createBtnLabel': CYBERSPORT.WINDOW_UNITLISTVIEW_CREATE_BTN,
         'createBtnTooltip': None,
         'createBtnEnabled': True,
         'columnHeaders': self.__getColumnHeaders()})
        return

    def _dispose(self):
        self._cooldown.stop()
        self._cooldown = None
        if self._isBackButtonClicked:
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:103,代码来源:cybersportunitslistview.py

示例3: BattleMessengerView

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class BattleMessengerView(BattleMessengerMeta, IBattleChannelView, IContactsAndPersonalInvitationsController):

    def __init__(self):
        super(BattleMessengerView, self).__init__()
        self.__controllers = {}
        self.__receivers = []
        self.__receiverIndex = 0
        self.__isEnabled = False
        self.__isFocused = False
        self._battleCtx = None
        self._arenaVisitor = None
        self._accDbID = 0
        self._toxicPanelMsgID = 0
        self._addedMsgIDs = set()
        self._ignoreActionCooldown = CooldownHelper((CLIENT_ACTION_ID.ADD_IGNORED, CLIENT_ACTION_ID.REMOVE_IGNORED), self._onIgnoreActionCooldownHandle, CoolDownEvent.XMPP)
        return

    @storage_getter('users')
    def usersStorage(self):
        return None

    @proto_getter(PROTO_TYPE.MIGRATION)
    def protoMigration(self):
        return None

    @proto_getter(PROTO_TYPE.BW_CHAT2)
    def protoBwChat2(self):
        return None

    def getControllerID(self):
        return BATTLE_CTRL_ID.GUI

    def startControl(self, battleCtx, arenaVisitor):
        """Starts to controlling data of arena.
        
        :param battleCtx: proxy to battle context.
        :param arenaVisitor: proxy to arena visitor.
        """
        self._battleCtx = battleCtx
        self._arenaVisitor = arenaVisitor

    def stopControl(self):
        self._battleCtx = None
        self._arenaVisitor = None
        return

    def getToxicStatus(self, accountDbID):
        """
        Invoked by the view at runtime to get VO of buttons panel.
        
        :param accountDbID: Message ID that corresponds to player database ID.
        :return: dict
        """
        vo = None
        accountDbID = long(accountDbID)
        if 0 < accountDbID != self._accDbID:
            vo = self.__buildToxicStateVO(accountDbID)
        if vo is not None:
            self._toxicPanelMsgID = accountDbID
        return vo

    def updateToxicStatus(self, accountDbID):
        self.as_updateToxicPanelS(accountDbID, self.__buildToxicStateVO(accountDbID))

    def onToxicButtonClicked(self, accountDbID, actionID):
        """
        Callback on user's action. Note that the same callback is invoked for all 'toxic' buttons.
        To determine which button is pressed, action ID is used. Action ID corresponds to the
        following constants from BATTLE_MESSAGES_CONSTS enum.
        
        :param accountDbID: Message ID that corresponds to player database ID.
        :param actionID: Action ID.
        """
        accDbID = long(accountDbID)
        if accDbID > 0:
            needUpdateUI = True
            if actionID == BATTLE_MESSAGES_CONSTS.ADD_IN_BLACKLIST:
                if not self._ignoreActionCooldown.isInCooldown():
                    self.protoMigration.contacts.addTmpIgnored(accDbID, self._battleCtx.getPlayerName(accID=accDbID))
            elif actionID == BATTLE_MESSAGES_CONSTS.REMOVE_FROM_BLACKLIST:
                if not self._ignoreActionCooldown.isInCooldown():
                    self.protoMigration.contacts.removeTmpIgnored(accDbID)
            else:
                needUpdateUI = False
            if needUpdateUI:
                self._invalidateToxicPanel(accDbID)

    def onToxicPanelClosed(self, messageID):
        """
        Callback on toxic panel close event.
        
        :param messageID: Message ID that corresponds to player database ID.
        """
        if 0 < self._toxicPanelMsgID == messageID:
            self._toxicPanelMsgID = 0

    def invalidateUsersTags(self):
        """
        New list of chat rosters has been received.
        """
#.........这里部分代码省略.........
开发者ID:aevitas,项目名称:wotsdk,代码行数:103,代码来源:battlemessenger_view.py

示例4: ClanPersonalInvitesView

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class ClanPersonalInvitesView(ClanPersonalInvitesViewMeta, ClanListener):
    __coolDownRequests = [CLAN_REQUESTED_DATA_TYPE.ACCEPT_APPLICATION,
     CLAN_REQUESTED_DATA_TYPE.ACCEPT_INVITE,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_APPLICATION,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITE,
     CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITES]

    def __init__(self):
        super(ClanPersonalInvitesView, self).__init__()
        self._paginator = ClanPersonalInvitesPaginator(g_clanCtrl, getPlayerDatabaseID(), [CLAN_INVITE_STATES.ACTIVE])
        self._cooldown = CooldownHelper(self.__coolDownRequests, self._onCooldownHandle, CoolDownEvent.CLAN)

    def declineAllSelectedInvites(self):
        self._paginator.declineList(self.dataProvider.getCheckedIDs())

    def acceptInvite(self, dbID):
        self._paginator.accept(int(dbID))

    def declineInvite(self, dbID):
        self._paginator.decline(int(dbID))

    def showMore(self):
        if not self._paginator.isInProgress():
            self.showWaiting(True)
            self._paginator.right()

    def setSelectAllInvitesCheckBoxSelected(self, checked):
        self.dataProvider.setSelectAll(checked)
        self._updateDeclineSelectedGroup()

    def setInviteSelected(self, dbID, checked):
        self.dataProvider.setCheckedID(dbID, checked)
        self._updateDeclineSelectedGroup()

    def onSortChanged(self, dataProvider, sort):
        order = sort[0][1]
        secondSort = tuple(((item, order) for item in self._getSecondSortFields()))
        if not self._paginator.isInProgress():
            self.showWaiting(True)
            self._paginator.sort(sort + secondSort)

    def onAccountInvitesReceived(self, invites):
        super(ClanPersonalInvitesView, self).onAccountInvitesReceived(invites)
        self._enableRefreshBtn(True)

    def showWaiting(self, show):
        if show:
            self._parentWnd.as_showWaitingS(CLANS.CLANPERSONALINVITESWINDOW_LOADING, {})
        elif not self._paginator.isInProgress():
            self._parentWnd.as_hideWaitingS()

    def refreshTable(self):
        self._enableRefreshBtn(False)
        self.showWaiting(True)
        self._paginator.refresh()

    def _createSearchDP(self):
        return PersonalInvitesDataProvider(self)

    def _onAttachedToWindow(self):
        super(ClanPersonalInvitesView, self)._onAttachedToWindow()
        self.showWaiting(True)
        self.setSelectAllInvitesCheckBoxSelected(False)
        self._updateDeclineSelectedText(0)
        self._cooldown.start()
        self._paginator.onListUpdated += self._onListUpdated
        self._paginator.onListItemsUpdated += self._onListItemsUpdated
        self._paginator.reset()

    def _populate(self):
        super(ClanPersonalInvitesView, self)._populate()
        self.startClanListening()

    def _dispose(self):
        self._paginator.onListUpdated -= self._onListUpdated
        self._paginator.onListItemsUpdated -= self._onListItemsUpdated
        self._cooldown.stop()
        self._cooldown = None
        self.stopClanListening()
        g_clanCtrl.clearClanCommonDataCache()
        super(ClanPersonalInvitesView, self)._dispose()
        return

    def _onCooldownHandle(self, isInCooldown):
        self.showWaiting(isInCooldown)

    def _onListUpdated(self, selectedID, isFullUpdate, isReqInCoolDown, result):
        self._updateSortField(self._paginator.getLastSort())
        status, data = result
        if status is True:
            self._enableRefreshBtn(False)
            if len(data) == 0:
                self.as_showDummyS(CLANS_ALIASES.INVITE_WINDOW_DUMMY_NO_PERSONAL_INVITES)
                self.dataProvider.rebuildList(None, False)
            else:
                g_clanCtrl.updateClanCommonDataCache([ ClanCommonData.fromClanPersonalInviteWrapper(item) for item in data ])
                self.dataProvider.rebuildList(data, self._paginator.canMoveRight())
                self.as_hideDummyS()
        else:
            self._enableRefreshBtn(True, toolTip=CLANS.CLANINVITESWINDOW_TOOLTIPS_REFRESHBUTTON_ENABLEDTRYTOREFRESH)
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:103,代码来源:clanpersonalinvitesview.py

示例5: ClanSearchWindow

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class ClanSearchWindow(ClanSearchWindowMeta, ClanListener):
    __coolDownRequests = [CLAN_REQUESTED_DATA_TYPE.CLAN_RATINGS, CLAN_REQUESTED_DATA_TYPE.SEARCH_CLANS, CLAN_REQUESTED_DATA_TYPE.GET_RECOMMENDED_CLANS]
    MIN_CHARS_FOR_SEARCH = 2

    def __init__(self, ctx):
        super(ClanSearchWindow, self).__init__()
        self.__clanFinder = ClanFinder(g_clanCtrl, None, _SEARCH_LIMIT)
        self.__clanFinder.init()
        self._cooldown = CooldownHelper(self.__coolDownRequests, self._onCooldownHandle, CoolDownEvent.CLAN)
        self.__isFirstPageRequested = False
        self.__invitesLimitReached = False
        return

    def onWindowClose(self):
        self.destroy()

    def onClanStateChanged(self, oldStateID, newStateID):
        if not self.clansCtrl.isEnabled():
            self.onWindowClose()
        if not self.clansCtrl.isAvailable():
            pass

    def search(self, text):
        if len(text) < self.MIN_CHARS_FOR_SEARCH:
            self._showDummy(True)
            self._setDummyData(CLANS.SEARCH_REQUESTTOOSHORT_HEADER, CLANS.SEARCH_REQUESTTOOSHORT_BODY, None, self.__clanFinder.hasSuccessRequest(), _ms(CLANS.SEARCH_REQUESTTOOSHORT_BUTTON), CLANS.SEARCH_REQUESTTOOSHORT_BUTTON_TOOLTIP_HEADER)
        else:
            self.__clanFinder.setRecommended(False)
            self.__doSearch(text)
        return

    def previousPage(self):
        self.as_showWaitingS(WAITING.PREBATTLE_AUTO_SEARCH, {})
        self.__clanFinder.left()

    def nextPage(self):
        self.as_showWaitingS(WAITING.PREBATTLE_AUTO_SEARCH, {})
        self.__clanFinder.right()

    def isInvitesLimitReached(self):
        return self.__invitesLimitReached

    def setInvitesLimitReached(self):
        return self.__invitesLimitReached

    def _populate(self):
        super(ClanSearchWindow, self)._populate()
        self._searchDP = _ClanSearchDataProvider()
        self._searchDP.setFlashObject(self.as_getDPS())
        self.startClanListening()
        self.__clanFinder.onListUpdated += self._onClansListUpdated
        self.__initControls()
        self._updateControlsState()
        self._cooldown.start()
        if not g_clanCtrl.getAccountProfile().isSynced():
            g_clanCtrl.getAccountProfile().resync()
        self.__clanFinder.setRecommended(True)
        self.__doSearch('')

    def _dispose(self):
        self._cooldown.stop()
        self._cooldown = None
        self.stopClanListening()
        self.__clanFinder.onListUpdated -= self._onClansListUpdated
        g_clanCtrl.clearClanCommonDataCache()
        self._searchDP.fini()
        self._searchDP = None
        super(ClanSearchWindow, self)._dispose()
        return

    def getClanInfo(self, clanID):
        return self.__clanFinder.getItemByID(clanID)

    def _onRegisterFlashComponent(self, viewPy, alias):
        super(ClanSearchWindow, self)._onRegisterFlashComponent(viewPy, alias)
        if alias == CLANS_ALIASES.CLAN_SEARCH_INFO_PY:
            viewPy.bindDataProvider(self)

    def dummyButtonPress(self):
        self.as_showWaitingS(WAITING.PREBATTLE_AUTO_SEARCH, {})
        self._searchDP.rebuildList(None)
        self.__clanFinder.requestLastSuccess()
        return

    def _onCooldownHandle(self, isInCooldown):
        self._updateControlsState()

    def _onClansListUpdated(self, selectedID, isFullUpdate, isReqInCoolDown, result):
        status, data = result
        self._processSearchResponse(status, data, self.__isFirstPageRequested)
        self.__isFirstPageRequested = False
        self.as_hideWaitingS()

    def _processSearchResponse(self, status, data, isInitial = False):
        if status:
            if len(data) > 0:
                self.__applyFoundData(data)
            elif isInitial:
                self._searchDP.rebuildList(None)
                self._showDummy(True)
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:103,代码来源:clansearchwindow.py

示例6: CyberSportUnitsListView

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class CyberSportUnitsListView(CyberSportUnitsListMeta, UnitListener, ClubListener, ClubEmblemsHelper):

    def __init__(self):
        super(CyberSportUnitsListView, self).__init__()
        self._isBackButtonClicked = False
        self._unitTypeFlags = UNIT_BROWSER_TYPE.ALL
        self._cooldown = CooldownHelper(self.getCoolDownRequests(), self._onCooldownHandle, events.CoolDownEvent.PREBATTLE)
        self.__currentEmblem = None
        return

    def onUnitFunctionalInited(self):
        self.unitFunctional.setEntityType(PREBATTLE_TYPE.UNIT)

    def getPyDataProvider(self):
        return ManualSearchDataProvider()

    def getCoolDownRequests(self):
        return [REQUEST_TYPE.UNITS_LIST]

    def canBeClosed(self, callback):
        self._isBackButtonClicked = True
        callback(True)

    def setTeamFilters(self, showOnlyStatic):
        self._unitTypeFlags = UNIT_BROWSER_TYPE.RATED_CLUBS if showOnlyStatic else UNIT_BROWSER_TYPE.ALL
        self.__recenterList()

    def loadPrevious(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_NAV_LEFT)

    def loadNext(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_NAV_RIGHT)

    def refreshTeams(self):
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.request(req=REQUEST_TYPE.UNITS_REFRESH)

    def getRallyDetails(self, index):
        if index != self._searchDP.selectedRallyIndex:
            self.__currentEmblem = None
        cfdUnitID, vo = self._searchDP.getRally(index)
        listReq = unit_ext.getListReq()
        if listReq:
            listReq.setSelectedID(cfdUnitID)
        self.__setDetailsData(cfdUnitID, vo)
        return

    def showRallyProfile(self, clubDBID):
        club_events.showClubProfile(clubDBID)

    def _populate(self):
        super(CyberSportUnitsListView, self)._populate()
        self._cooldown.start()
        self.startUnitListening()
        if self.unitFunctional.getEntityType() != PREBATTLE_TYPE.NONE:
            self.unitFunctional.setEntityType(PREBATTLE_TYPE.UNIT)
        unit_ext.initListReq(self._unitTypeFlags).start(self.__onUnitsListUpdated)
        self.as_setSearchResultTextS(_ms(CYBERSPORT.WINDOW_UNITLISTVIEW_FOUNDTEAMS), '', self.__getFiltersData())
        headerDescription = CYBERSPORT.WINDOW_UNITLISTVIEW_DESCRIPTION
        headerTitle = CYBERSPORT.WINDOW_UNITLISTVIEW_TITLE
        self.as_setHeaderS({'title': headerTitle,
         'description': headerDescription,
         'createBtnLabel': CYBERSPORT.WINDOW_UNITLISTVIEW_CREATE_BTN,
         'createBtnTooltip': None,
         'createBtnEnabled': True,
         'columnHeaders': self.__getColumnHeaders()})
        return

    def _dispose(self):
        self._cooldown.stop()
        self._cooldown = None
        if self._isBackButtonClicked:
            unit_ext.destroyListReq()
            self._isBackButtonClicked = False
        else:
            listReq = unit_ext.getListReq()
            if listReq:
                listReq.stop()
        self.stopUnitListening()
        super(CyberSportUnitsListView, self)._dispose()
        return

    def _onUserActionReceived(self, _, user):
        self.__updateView(user)

    def _doEnableNavButtons(self, isEnabled):
        self.as_updateNavigationBlockS({'previousVisible': True,
         'previousEnabled': isEnabled,
         'nextVisible': True,
         'nextEnabled': isEnabled,
         'icon': RES_ICONS.MAPS_ICONS_STATISTIC_RATING24})

    def _onCooldownHandle(self, isInCooldown):
        self._doEnableNavButtons(not isInCooldown)

#.........这里部分代码省略.........
开发者ID:aevitas,项目名称:wotsdk,代码行数:103,代码来源:cybersportcybersportunitslistview.py

示例7: ClanInvitesWindow

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class ClanInvitesWindow(ClanInvitesWindowMeta, ClanListener, ClanEmblemsHelper):
    __coolDownRequests = [CLAN_REQUESTED_DATA_TYPE.CLAN_APPLICATIONS, CLAN_REQUESTED_DATA_TYPE.CLAN_INVITES]

    def __init__(self, *args):
        super(ClanInvitesWindow, self).__init__()
        self.__actualRequestsCount = '0'
        self.__processedInvitesCount = '0'
        self._cooldown = CooldownHelper(self.__coolDownRequests, self._onCooldownHandle, CoolDownEvent.CLAN)
        self.__clanDbID = self.clanProfile.getClanDbID()
        self.__clanDossier = weakref.proxy(self.clansCtrl.getClanDossier(self.__clanDbID))
        self.__pagiatorsController = _PaginatorsController(self.__clanDbID)

    def onClanStateChanged(self, oldStateID, newStateID):
        if not self.clansCtrl.isEnabled():
            self.onWindowClose()
        if not self.clansCtrl.isAvailable():
            pass

    def onAccountClanProfileChanged(self, profile):
        if not profile.isInClan() or not profile.getMyClanPermissions().canHandleClanInvites():
            self.destroy()

    def onClanInfoReceived(self, clanDbID, clanInfo):
        if clanDbID == self.__clanDbID:
            self._updateClanInfo()
            self._updateHeaderState()

    def onInvitesButtonClick(self):
        showClanSendInviteWindow(self.clanProfile.getClanDbID())

    def onWindowClose(self):
        self.destroy()

    def onClanEmblem128x128Received(self, clanDbID, emblem):
        self.as_setClanEmblemS(self.getMemoryTexturePath(emblem))

    @property
    def clanProfile(self):
        return self.clansCtrl.getAccountProfile()

    @property
    def paginatorsController(self):
        return self.__pagiatorsController

    @property
    def clanInfo(self):
        return self.__clanDossier.getClanInfo()

    def resyncClanInfo(self, force = False):
        self.__clanDossier.resyncClanInfo(force=force)

    def showWaiting(self, show):
        if show:
            self.as_showWaitingS(WAITING.LOADINGDATA, {})
        elif not self.paginatorsController.isInProgress():
            self.as_hideWaitingS()

    def formatInvitesCount(self, paginator):
        return formatters.formatInvitesCount(paginator.getTotalCount())

    def _populate(self):
        self.showWaiting(True)
        super(ClanInvitesWindow, self)._populate()
        self.__initControls()
        self._cooldown.start()
        self.startClanListening()
        self.__pagiatorsController.setCallback(self._onPaginatorListChanged)
        self.resyncClanInfo()
        self.__pagiatorsController.getPanginator(CLANS_ALIASES.CLAN_PROFILE_REQUESTS_VIEW_ALIAS, CLANS_ALIASES.INVITE_WINDOW_FILTER_ACTUAL).reset()
        self.__pagiatorsController.getPanginator(CLANS_ALIASES.CLAN_PROFILE_INVITES_VIEW_ALIAS, CLANS_ALIASES.INVITE_WINDOW_FILTER_PROCESSED).reset()

    def _dispose(self):
        self.stopClanListening()
        self.__pagiatorsController.removeCallbacks()
        self._cooldown.stop()
        self._cooldown = None
        super(ClanInvitesWindow, self)._dispose()
        return

    def _onRegisterFlashComponent(self, viewPy, alias):
        super(ClanInvitesWindow, self)._onRegisterFlashComponent(viewPy, alias)
        viewPy.setParentWindow(self)

    def _onCooldownHandle(self, isInCooldown):
        self.showWaiting(isInCooldown)

    def _onPaginatorListChanged(self, alias, filter, selectedID, isFullUpdate, isReqInCoolDown, result):
        paginator = self.__pagiatorsController.getPanginator(alias, filter)
        if alias == CLANS_ALIASES.CLAN_PROFILE_REQUESTS_VIEW_ALIAS:
            if filter == CLANS_ALIASES.INVITE_WINDOW_FILTER_ACTUAL:
                self.__actualRequestsCount = self.formatInvitesCount(paginator)
                self._updateTabsState()
            elif filter == CLANS_ALIASES.INVITE_WINDOW_FILTER_EXPIRED:
                pass
            elif filter == CLANS_ALIASES.INVITE_WINDOW_FILTER_PROCESSED:
                pass
            else:
                LOG_DEBUG('Unexpected behaviour: unknown filter {} for alias {}'.format(filter, alias))
        elif alias == CLANS_ALIASES.CLAN_PROFILE_INVITES_VIEW_ALIAS:
            if filter == CLANS_ALIASES.INVITE_WINDOW_FILTER_ALL:
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:103,代码来源:claninviteswindow.py

示例8: ClanRequestsView

# 需要导入模块: from gui.shared.view_helpers import CooldownHelper [as 别名]
# 或者: from gui.shared.view_helpers.CooldownHelper import start [as 别名]
class ClanRequestsView(ClanRequestsViewMeta):

    def __init__(self):
        super(ClanRequestsView, self).__init__()
        self._cooldown = CooldownHelper([CLAN_REQUESTED_DATA_TYPE.CREATE_APPLICATIONS,
         CLAN_REQUESTED_DATA_TYPE.CREATE_INVITES,
         CLAN_REQUESTED_DATA_TYPE.ACCEPT_APPLICATION,
         CLAN_REQUESTED_DATA_TYPE.ACCEPT_INVITE,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_APPLICATION,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITE,
         CLAN_REQUESTED_DATA_TYPE.DECLINE_INVITES,
         CLAN_REQUESTED_DATA_TYPE.CLAN_INVITES,
         CLAN_REQUESTED_DATA_TYPE.CLAN_MEMBERS_RATING], self._onCooldownHandle, CoolDownEvent.CLAN)

    @property
    def actualRequestsPaginator(self):
        return self._getPaginatorByFilterName(CLANS_ALIASES.INVITE_WINDOW_FILTER_ACTUAL)

    @property
    def expiredRequestsPaginator(self):
        return self._getPaginatorByFilterName(CLANS_ALIASES.INVITE_WINDOW_FILTER_EXPIRED)

    @property
    def processedRequestsPaginator(self):
        return self._getPaginatorByFilterName(CLANS_ALIASES.INVITE_WINDOW_FILTER_PROCESSED)

    def acceptRequest(self, applicationID):
        applicationID = int(applicationID)
        ctx = AcceptApplicationCtx(applicationID)
        self._getCurrentPaginator().accept(applicationID, ctx)

    def declineRequest(self, applicationID):
        applicationID = int(applicationID)
        ctx = DeclineApplicationCtx(applicationID)
        self._getCurrentPaginator().decline(applicationID, ctx)

    def sendInvite(self, dbId):
        dbId = int(dbId)
        paginator = self._getCurrentPaginator()
        requestWrapper = paginator.getInviteByDbID(dbId)
        ctx = CreateInviteCtx(requestWrapper.getClanDbID(), [requestWrapper.getAccountDbID()])
        self._getCurrentPaginator().resend(dbId, ctx)
        self._enableRefreshBtn(True)

    def onClanAppsCountReceived(self, clanDbID, appsCount):
        super(ClanRequestsView, self).onClanAppsCountReceived(clanDbID, appsCount)
        if self.actualRequestsPaginator.isSynced():
            self._enableRefreshBtn(True)

    def _populate(self):
        super(ClanRequestsView, self)._populate()

    def _onAttachedToWindow(self):
        super(ClanRequestsView, self)._onAttachedToWindow()
        self._cooldown.start()
        self.actualRequestsPaginator.onListUpdated += self._onListUpdated
        self.actualRequestsPaginator.onListItemsUpdated += self._onListItemsUpdated
        self.expiredRequestsPaginator.onListUpdated += self._onListUpdated
        self.expiredRequestsPaginator.onListItemsUpdated += self._onListItemsUpdated
        self.processedRequestsPaginator.onListUpdated += self._onListUpdated
        self.processedRequestsPaginator.onListItemsUpdated += self._onListItemsUpdated
        self.filterBy(self.currentFilterName)

    def _dispose(self):
        self.actualRequestsPaginator.onListUpdated -= self._onListUpdated
        self.actualRequestsPaginator.onListItemsUpdated -= self._onListItemsUpdated
        self.expiredRequestsPaginator.onListUpdated -= self._onListUpdated
        self.expiredRequestsPaginator.onListItemsUpdated -= self._onListItemsUpdated
        self.processedRequestsPaginator.onListUpdated -= self._onListUpdated
        self.processedRequestsPaginator.onListItemsUpdated -= self._onListItemsUpdated
        self._cooldown.stop()
        self._cooldown = None
        super(ClanRequestsView, self)._dispose()
        return

    def _onCooldownHandle(self, isInCooldown):
        self.dataProvider.allowActions(not isInCooldown)

    def _getViewAlias(self):
        return CLANS_ALIASES.CLAN_PROFILE_REQUESTS_VIEW_ALIAS

    def _showDummyByFilterName(self, filterName):
        if filterName == CLANS_ALIASES.INVITE_WINDOW_FILTER_ACTUAL:
            self._showDummy(CLANS.CLANINVITESWINDOW_DUMMY_NOACTUALREQUESTS_TITLE)
        elif filterName == CLANS_ALIASES.INVITE_WINDOW_FILTER_EXPIRED:
            self._showDummy(CLANS.CLANINVITESWINDOW_DUMMY_NOEXPIREDREQUESTS_TITLE)
        elif filterName == CLANS_ALIASES.INVITE_WINDOW_FILTER_PROCESSED:
            self._showDummy(CLANS.CLANINVITESWINDOW_DUMMY_NOPROCESSEDREQUESTS_TITLE)
        else:
            LOG_DEBUG('Unexpected behaviour: no dummy for filter', filterName)
            self._showDummy(CLANS.CLANINVITESWINDOW_DUMMY_NOACTUALREQUESTS_TITLE)

    def _getDefaultFilterName(self):
        return CLANS_ALIASES.INVITE_WINDOW_FILTER_ACTUAL

    def _getDefaultSortFields(self):
        return (('status', False),)

    def _getSecondSortFields(self):
        if self.currentFilterName == CLANS_ALIASES.INVITE_WINDOW_FILTER_PROCESSED:
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:103,代码来源:clanrequestsview.py


注:本文中的gui.shared.view_helpers.CooldownHelper.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。