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


Python PrbCtrlRequestCtx.clear方法代碼示例

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


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

示例1: AccountQueueFunctional

# 需要導入模塊: from gui.prb_control.context import PrbCtrlRequestCtx [as 別名]
# 或者: from gui.prb_control.context.PrbCtrlRequestCtx import clear [as 別名]
class AccountQueueFunctional(PreQueueFunctional):

    def __init__(self, queueType, subscriber, flags = FUNCTIONAL_FLAG.UNDEFINED):
        super(AccountQueueFunctional, self).__init__(queueType, subscriber, flags)
        self._requestCtx = PrbCtrlRequestCtx()

    def init(self, ctx = None):
        return super(AccountQueueFunctional, self).init(ctx)

    def fini(self, woEvents = False):
        self._requestCtx.clear()
        super(AccountQueueFunctional, self).fini(woEvents)

    def doAction(self, action = None):
        if not self.isInQueue():
            self.queue(self._makeQueueCtxByAction(action))
        else:
            self.dequeue(pre_queue_ctx.DequeueCtx(waitingID='prebattle/leave'))
        return True

    def queue(self, ctx, callback = None):
        if ctx is None:
            ctx = self._makeQueueCtxByAction()
        if self._requestCtx.isProcessing():
            LOG_ERROR('Request is processing', self._requestCtx)
            if callback is not None:
                callback(False)
            return
        elif self.isInQueue():
            LOG_ERROR('Player already is in the queue', self._requestCtx)
            if callback is not None:
                callback(False)
            return
        elif self._validateParentControl():
            if callback is not None:
                callback(False)
            return
        else:
            self._requestCtx = ctx
            self._requestCtx.startProcessing(callback)
            try:
                self._doQueue(ctx)
            except (AttributeError, TypeError, NotImplementedError):
                LOG_CURRENT_EXCEPTION()
                self._requestCtx.stopProcessing(False)

            return

    def dequeue(self, ctx, callback = None):
        if self._requestCtx.isProcessing():
            LOG_ERROR('Request is processing', self._requestCtx)
            if callback:
                callback(False)
            return
        elif not self.isInQueue():
            LOG_ERROR('Player is not in the queue', ctx)
            if callback is not None:
                callback(False)
            return
        else:
            self._requestCtx = ctx
            self._requestCtx.startProcessing(callback)
            try:
                self._doDequeue(ctx)
            except (AttributeError, TypeError, NotImplementedError):
                LOG_CURRENT_EXCEPTION()
                self._requestCtx.stopProcessing(False)

            return

    def onEnqueued(self, *args):
        self._requestCtx.stopProcessing(True)
        super(AccountQueueFunctional, self).onEnqueued(*args)

    def onDequeued(self, *args):
        self._requestCtx.stopProcessing(True)
        super(AccountQueueFunctional, self).onDequeued(*args)

    def onEnqueueError(self, *args):
        self._requestCtx.stopProcessing(False)
        super(AccountQueueFunctional, self).onEnqueueError(*args)

    def onKickedFromQueue(self, *args):
        self._requestCtx.stopProcessing(True)
        super(AccountQueueFunctional, self).onKickedFromQueue(*args)

    def onKickedFromArena(self, *args):
        self._requestCtx.stopProcessing(True)
        super(AccountQueueFunctional, self).onKickedFromArena(*args)

    def _doQueue(self, ctx):
        raise NotImplementedError('Routine _doQueue must be overridden')

    def _doDequeue(self, ctx):
        raise NotImplementedError('Routine _doDequeue must be overridden')

    def _makeQueueCtxByAction(self, action = None):
        raise NotImplementedError('Routine _makeDefQueueCtx must be overridden')

    def _validateParentControl(self):
#.........這裏部分代碼省略.........
開發者ID:webiumsk,項目名稱:WOT-0.9.15-CT,代碼行數:103,代碼來源:prequeue.py

示例2: _PrebattleDispatcher

# 需要導入模塊: from gui.prb_control.context import PrbCtrlRequestCtx [as 別名]
# 或者: from gui.prb_control.context.PrbCtrlRequestCtx import clear [as 別名]
class _PrebattleDispatcher(object):

    def __init__(self):
        super(_PrebattleDispatcher, self).__init__()
        self.__requestCtx = None
        self.__collection = FunctionalCollection()
        self.__factories = ControlFactoryDecorator()
        self.__nextPrbFunctional = None
        self._globalListeners = set()
        return

    def __del__(self):
        LOG_DEBUG('_PrebattleDispatcher deleted')

    def start(self, ctx):
        g_eventDispatcher.init(self)
        self.__requestCtx = PrbCtrlRequestCtx()
        result = self.__factories.start(self, CreateFunctionalCtx(CTRL_ENTITY_TYPE.UNKNOWN, create={'queueType': ctx.getQueueType(),
         'settings': ctx.prbSettings}))
        self._startListening()
        functional.initDevFunctional()
        if result & FUNCTIONAL_INIT_RESULT.LOAD_PAGE == 0:
            BigWorld.callback(0.001, lambda : g_eventDispatcher.loadHangar())
        g_eventDispatcher.updateUI()
        if GUI_SETTINGS.specPrebatlesVisible and not areSpecBattlesHidden():
            g_eventDispatcher.addSpecBattlesToCarousel()

    def stop(self):
        self.__nextPrbFunctional = None
        self._stopListening()
        functional.finiDevFunctional()
        self._clear(woEvents=True)
        g_eventDispatcher.fini()
        return

    def getPrbFunctional(self):
        return self.__collection.getItem(CTRL_ENTITY_TYPE.PREBATTLE)

    def getUnitFunctional(self):
        return self.__collection.getItem(CTRL_ENTITY_TYPE.UNIT)

    def getPreQueueFunctional(self):
        return self.__collection.getItem(CTRL_ENTITY_TYPE.PREQUEUE)

    def getFunctional(self, ctrlType):
        return self.__collection.getItem(ctrlType)

    def getFunctionalCollection(self):
        return self.__collection

    def getControlFactories(self):
        return self.__factories

    def hasModalEntity(self):
        return self.__collection.hasModalEntity()

    def getFunctionalState(self):
        return self.__collection.getState(self.__factories)

    @async
    @process
    def create(self, ctx, callback = None):
        if ctx.getRequestType() == REQUEST_TYPE.CREATE:
            if not self.__requestCtx.isProcessing():
                result = yield self.unlock(ctx.getFuncExit(), True)
                if result:
                    entry = self.__factories.createEntry(ctx)
                    if entry:
                        LOG_DEBUG('Request to create', ctx)
                        self.__requestCtx = ctx
                        entry.create(ctx, callback=callback)
                    else:
                        LOG_ERROR('Entry not found', ctx)
                        if callback:
                            callback(False)
                elif callback:
                    callback(False)
            else:
                LOG_ERROR('Request is processing', self.__requestCtx)
                if callback:
                    callback(False)
                yield lambda callback = None: callback
        else:
            LOG_ERROR('Invalid context to create', ctx)
            if callback:
                callback(False)
            yield lambda callback = None: callback
        return

    @async
    @process
    def join(self, ctx, callback = None):
        if self._validateJoinOp(ctx):
            result = yield self.unlock(ctx.getFuncExit(), ctx.isForced())
            ctx.setForced(result)
            if result:
                entry = self.__factories.createEntry(ctx)
                if entry:
                    LOG_DEBUG('Request to join', ctx)
                    self.__requestCtx = ctx
#.........這裏部分代碼省略.........
開發者ID:webiumsk,項目名稱:WOT-0.9.12-CT,代碼行數:103,代碼來源:dispatcher.py

示例3: _PrebattleDispatcher

# 需要導入模塊: from gui.prb_control.context import PrbCtrlRequestCtx [as 別名]
# 或者: from gui.prb_control.context.PrbCtrlRequestCtx import clear [as 別名]
class _PrebattleDispatcher(ListenersCollection):
    def __init__(self):
        super(_PrebattleDispatcher, self).__init__()
        self.__requestCtx = None
        self.__collection = FunctionalCollection()
        self.__factories = ControlFactoryDecorator()
        self.__nextPrbFunctional = None
        self._setListenerClass(IGlobalListener)
        return

    def __del__(self):
        LOG_DEBUG("_PrebattleDispatcher deleted")

    def start(self):
        g_eventDispatcher.init(self)
        result = self.__setFunctional(CreateFunctionalCtx())
        self.__requestCtx = PrbCtrlRequestCtx()
        self.__startListening()
        functional.initDevFunctional()
        if result & FUNCTIONAL_FLAG.LOAD_PAGE == 0:
            BigWorld.callback(0.001, lambda: g_eventDispatcher.loadHangar())
        g_eventDispatcher.updateUI()
        if GUI_SETTINGS.specPrebatlesVisible and not prb_getters.areSpecBattlesHidden():
            g_eventDispatcher.addSpecBattlesToCarousel()

    def stop(self):
        self.__nextPrbFunctional = None
        self.__stopListening()
        functional.finiDevFunctional()
        self.__clear(woEvents=True)
        g_eventDispatcher.fini()
        return

    def getPrbFunctional(self):
        return self.__collection.getItem(_CTRL_TYPE.PREBATTLE)

    def getUnitFunctional(self):
        return self.__collection.getItem(_CTRL_TYPE.UNIT)

    def getPreQueueFunctional(self):
        return self.__collection.getItem(_CTRL_TYPE.PREQUEUE)

    def getFunctional(self, ctrlType):
        return self.__collection.getItem(ctrlType)

    def getFunctionalCollection(self):
        return self.__collection

    def getControlFactories(self):
        return self.__factories

    def hasModalEntity(self):
        return self.__collection.hasModalEntity()

    def getFunctionalState(self):
        return self.__collection.getState(self.__factories)

    @async
    @process
    def create(self, ctx, callback=None):
        if ctx.getRequestType() == _RQ_TYPE.CREATE:
            if not self.__requestCtx.isProcessing():
                result = yield self.unlock(ctx)
                if result:
                    entry = self.__factories.createEntry(ctx)
                    if entry:
                        LOG_DEBUG("Request to create", ctx)
                        self.__requestCtx = ctx
                        entry.create(ctx, callback=callback)
                    else:
                        LOG_ERROR("Entry not found", ctx)
                        if callback is not None:
                            callback(False)
                elif callback is not None:
                    callback(False)
            else:
                LOG_ERROR("Request is processing", self.__requestCtx)
                if callback is not None:
                    callback(False)
                yield lambda callback=None: callback
        else:
            LOG_ERROR("Invalid context to create", ctx)
            if callback is not None:
                callback(False)
            yield lambda callback=None: callback
        return

    @async
    @process
    def join(self, ctx, callback=None):
        if self.__validateJoinOp(ctx):
            result = yield self.unlock(ctx)
            ctx.setForced(result)
            if result:
                entry = self.__factories.createEntry(ctx)
                if entry:
                    LOG_DEBUG("Request to join", ctx)
                    self.__requestCtx = ctx
                    entry.join(ctx, callback=callback)
                else:
#.........這裏部分代碼省略.........
開發者ID:aevitas,項目名稱:wotsdk,代碼行數:103,代碼來源:prb_controldispatcher.py


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