def __doRun(self, settings, state): if not settings.enabled: return False else: reqs = _settings.createTutorialElement(settings.reqs) if not reqs.isEnabled(): return False descriptor = loadDescriptorData(settings, settings.exParsers) if descriptor is None: LOG_ERROR('Descriptor is not valid. Tutorial is not available', settings) return False cache = _cache.TutorialCache(BigWorld.player().name) cache.read() cache.setSpace(settings.space) if state.get('byRequest', False): cache.setRefused(False) runCtx = RunCtx(cache, **state) reqs.prepare(runCtx) if not reqs.process(descriptor, runCtx): return False self.clear() if self.__dispatcher is None: self.__setDispatcher(settings.dispatcher) tutorial = Tutorial(settings, descriptor) result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx) if result: self.__tutorial = tutorial self.__tutorial.onStopped += self.__onTutorialStopped return result
def __doRun(self, settings, runCtx, byRequest = False): if not settings.enabled: return False reqs = _settings.createTutorialElement(settings.reqs) if not reqs.isEnabled(): return False descriptor = loadDescriptorData(settings, settings.exParsers) if descriptor is None: LOG_ERROR('Descriptor is not valid. Tutorial is not available', settings) return False runCtx.cache.setSpace(settings.space) if byRequest: runCtx.cache.setRefused(False) reqs.prepare(runCtx) if not reqs.process(descriptor, runCtx): return False self.clear() tutorial = Tutorial(settings, descriptor) result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx) if result: self.__tutorial = tutorial self.__tutorial.onStopped += self.__onTutorialStopped return result
def __doRun(self, settings, runCtx, byRequest=False): if not settings.enabled: return False reqs = _settings.createTutorialElement(settings.reqs) if not reqs.isEnabled(): return False descriptor = loadDescriptorData(settings, settings.exParsers) if descriptor is None: LOG_ERROR('Descriptor is not valid. Tutorial is not available', settings) return False runCtx.cache.setSpace(settings.space) if byRequest: runCtx.cache.setRefused(False) reqs.prepare(runCtx) if not reqs.process(descriptor, runCtx): return False self.clear() tutorial = Tutorial(settings, descriptor) result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx) if result: self.__tutorial = tutorial self.__tutorial.onStopped += self.__onTutorialStopped return result
class _TutorialLoader(object): def __init__(self): super(_TutorialLoader, self).__init__() self.__loggedDBIDs = set() self.__afterBattle = False self.__tutorial = None self.__dispatcher = None return def init(self): g_playerEvents.onGuiCacheSyncCompleted += self.__pe_onGuiCacheSyncCompleted g_playerEvents.onAvatarBecomePlayer += self.__pe_onAvatarBecomePlayer connectionManager.onDisconnected += self.__cm_onDisconnected windowsManager = GUIProxy.windowsManager() windowsManager.onInitBattleGUI += self.__wm_onInitBattleGUI windowsManager.onDestroyBattleGUI += self.__wm_onDestroyBattleGUI def fini(self): g_playerEvents.onGuiCacheSyncCompleted -= self.__pe_onGuiCacheSyncCompleted g_playerEvents.onAvatarBecomePlayer -= self.__pe_onAvatarBecomePlayer connectionManager.onDisconnected -= self.__cm_onDisconnected windowsManager = GUIProxy.windowsManager() windowsManager.onInitBattleGUI -= self.__wm_onInitBattleGUI windowsManager.onDestroyBattleGUI -= self.__wm_onDestroyBattleGUI if self.__tutorial is not None: self.__dispatcher.stop() self.__tutorial.stop() self.__loggedDBIDs.clear() return def _clear(self): self.__tutorial = None return @property def tutorial(self): return self.__tutorial @property def isAfterBattle(self): return self.__afterBattle def tryingToRun(self, runCtx): settings = TUTORIAL_SETTINGS.getSettings(runCtx.settings) if not settings.enabled: return else: runCtx.cache = TutorialCache.TutorialCache(BigWorld.player().name, settings.space) reqs = TUTORIAL_SETTINGS.factory(settings.reqs, init=(weakref.proxy(self), runCtx)) if reqs.isEnabled(): if self.__tutorial is None or self.__tutorial._settings.id != settings.id: self.__tutorial = Tutorial(settings) if self.__tutorial._descriptor is None: LOG_ERROR('Tutorial descriptor is not valid. Tutorial is not available.') return if self.__dispatcher is not None: self.__dispatcher.stop() self.__dispatcher = None self.__dispatcher = TUTORIAL_SETTINGS.factory(settings.dispatcher) self.__dispatcher.start(runCtx) self.__tutorial.setDispatcher(weakref.proxy(self.__dispatcher)) reqs.process() return def refuse(self): if self.__tutorial is not None: self.__tutorial.refuse() return def restart(self, afterBattle = False): self.__afterBattle = afterBattle self.tryingToRun(RunCtx(restart=True)) def reload(self, afterBattle = False): if self.__tutorial: result = self.__tutorial.reload(afterBattle=afterBattle) else: result = False return result def _doRun(self, ctx): if ctx.isInPrebattle: self.__tutorial.pause(ctx) else: self.__tutorial.run(ctx) def _doStop(self, reason = TUTORIAL_STOP_REASON.DEFAULT): if self.__tutorial is not None: self.__tutorial.stop(reason=reason) if self.__dispatcher is not None: self.__dispatcher.stop() return def __pe_onGuiCacheSyncCompleted(self, ctx): ctx = RunCtx(**ctx) ctx.isFirstStart = ctx.databaseID not in self.__loggedDBIDs self.__loggedDBIDs.add(ctx.databaseID) self.tryingToRun(ctx) def __pe_onAvatarBecomePlayer(self): self.__afterBattle = True self._doStop() def __cm_onDisconnected(self): self.__afterBattle = False self._doStop(reason=TUTORIAL_STOP_REASON.DISCONNECT) def __wm_onInitBattleGUI(self): self.tryingToRun(RunCtx(settings='BATTLE')) def __wm_onDestroyBattleGUI(self): self._doStop()
class _TutorialLoader(object): def __init__(self): super(_TutorialLoader, self).__init__() self.__afterBattle = False self.__tutorial = None self.__dispatcher = None return def init(self): g_playerEvents.onAccountShowGUI += self.__pe_onAccountShowGUI g_playerEvents.onAvatarBecomePlayer += self.__pe_onAvatarBecomePlayer connectionManager.onDisconnected += self.__cm_onDisconnected windowsManager = GUIProxy.windowsManager() windowsManager.onInitBattleGUI += self.__wm_onInitBattleGUI windowsManager.onDestroyBattleGUI += self.__wm_onDestroyBattleGUI def fini(self): g_playerEvents.onAccountShowGUI -= self.__pe_onAccountShowGUI g_playerEvents.onAvatarBecomePlayer -= self.__pe_onAvatarBecomePlayer connectionManager.onDisconnected -= self.__cm_onDisconnected windowsManager = GUIProxy.windowsManager() windowsManager.onInitBattleGUI -= self.__wm_onInitBattleGUI windowsManager.onDestroyBattleGUI -= self.__wm_onDestroyBattleGUI if self.__tutorial is not None: self.__dispatcher.stop() self.__tutorial.stop() return def _clear(self): self.__tutorial = None return @property def tutorial(self): return self.__tutorial @property def isAfterBattle(self): return self.__afterBattle def tryingToRun(self, runCtx): settings = TUTORIAL_SETTINGS.getSettings(runCtx.settings) if not settings.enabled: return else: runCtx.cache = TutorialCache.TutorialCache(BigWorld.player().name, settings.space) reqs = TUTORIAL_SETTINGS.factory(settings.reqs, init=(weakref.proxy(self), runCtx)) if reqs.isEnabled(): if self.__tutorial is None or self.__tutorial._settings.id != settings.id: self.__tutorial = Tutorial(settings) if self.__tutorial._descriptor is None: LOG_ERROR( 'Tutorial descriptor is not valid. Tutorial is not available.' ) return if self.__dispatcher is not None: self.__dispatcher.stop() self.__dispatcher = None self.__dispatcher = TUTORIAL_SETTINGS.factory( settings.dispatcher) self.__dispatcher.start(runCtx) self.__tutorial.setDispatcher(weakref.proxy(self.__dispatcher)) reqs.process() return def refuse(self): if self.__tutorial is not None: self.__tutorial.refuse() return def restart(self, afterBattle=False): self.__afterBattle = afterBattle self.tryingToRun(RunCtx(restart=True)) def _doRun(self, ctx): if ctx.isInPrebattle: self.__tutorial.pause(ctx) else: self.__tutorial.run(ctx) def _doStop(self): if self.__tutorial is not None: self.__tutorial.stop() if self.__dispatcher is not None: self.__dispatcher.stop() return def __pe_onAccountShowGUI(self, ctx): self.tryingToRun(RunCtx(**ctx)) def __pe_onAvatarBecomePlayer(self): self.__afterBattle = True self._doStop() def __cm_onDisconnected(self): self.__afterBattle = False self._doStop() def __wm_onInitBattleGUI(self): self.tryingToRun(RunCtx(settings='BATTLE')) def __wm_onDestroyBattleGUI(self): self._doStop()