本文整理汇总了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)))
示例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.
"""
#.........这里部分代码省略.........
示例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)
#.........这里部分代码省略.........