當前位置: 首頁>>代碼示例>>Python>>正文


Python CooldownHelper.isInCooldown方法代碼示例

本文整理匯總了Python中gui.shared.view_helpers.CooldownHelper.isInCooldown方法的典型用法代碼示例。如果您正苦於以下問題:Python CooldownHelper.isInCooldown方法的具體用法?Python CooldownHelper.isInCooldown怎麽用?Python CooldownHelper.isInCooldown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gui.shared.view_helpers.CooldownHelper的用法示例。


在下文中一共展示了CooldownHelper.isInCooldown方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _RefreshBtnStateController

# 需要導入模塊: from gui.shared.view_helpers import CooldownHelper [as 別名]
# 或者: from gui.shared.view_helpers.CooldownHelper import isInCooldown [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: BattleMessengerView

# 需要導入模塊: from gui.shared.view_helpers import CooldownHelper [as 別名]
# 或者: from gui.shared.view_helpers.CooldownHelper import isInCooldown [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

示例3: ClanSearchWindow

# 需要導入模塊: from gui.shared.view_helpers import CooldownHelper [as 別名]
# 或者: from gui.shared.view_helpers.CooldownHelper import isInCooldown [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


注:本文中的gui.shared.view_helpers.CooldownHelper.isInCooldown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。