def run(self, ctx): self._cache = ctx.cache if self._cache is None: LOG_ERROR('Cache is not init.') return else: self._bonuses = self._ctrlFactory.createBonuses(ctx.bonusCompleted) self._sound = self._ctrlFactory.createSoundPlayer() if not self._tutorialStopped: LOG_ERROR('Tutorial is already running.') return self._gui = TUTORIAL_SETTINGS.factory(self._settings.gui) self._gui.onGUILoaded += self.__onGUILoaded if not self._gui.init(): self._gui.onGUILoaded -= self.__onGUILoaded LOG_ERROR('GUI can not init. Tutorial is stopping.') return LOG_DEBUG('Start training', ctx) self._tutorialStopped = False proxy = weakref.proxy(self) setTutorialProxy(proxy) if self.__resolveInitialChapter(ctx): self._gui.setPlayerXPLevel(self._cache.getPlayerXPLevel()) self._gui.setTrainingRunMode() self._gui.loadConfig(self._descriptor.getGuiFilePath()) self._gui.onMouseClicked += self.__onMouseClicked self._gui.onPageChanging += self.__onPageChanging self.__tryRunFirstState(INITIAL_FLAG.CHAPTER_RESOLVED) return
def run(self, dispatcher, ctx): self._cache = ctx.cache if self._cache is None: LOG_ERROR('Cache is not init.') return False else: self._bonuses = self._ctrlFactory.createBonuses(ctx.bonusCompleted) self._sound = self._ctrlFactory.createSoundPlayer() GlobalStorage.setFlags(ctx.globalFlags) if not self._stopped: LOG_ERROR('Tutorial is already running.') return False self._gui = createTutorialElement(self._settings.gui) self._gui.setDispatcher(dispatcher) self._gui.onGUILoaded += self.__onGUILoaded if not self._gui.init(): self._gui.onGUILoaded -= self.__onGUILoaded self._gui.setDispatcher(None) LOG_ERROR('GUI can not init. Tutorial is stopping.') return False LOG_DEBUG('Start training', ctx) self._stopped = False proxy = weakref.proxy(self) setTutorialProxy(proxy) if self.__resolveInitialChapter(ctx): self._gui.loadConfig(self._descriptor.getGuiFilePath()) self._gui.onGUIInput += self.__onGUIInput self._gui.onPageChanging += self.__onPageChanging self._gui.onItemFound += self.__onItemFound self._gui.onItemLost += self.__onItemLost self.__tryRunFirstState(INITIAL_FLAG.CHAPTER_RESOLVED) self.onStarted() return True
def run(self, ctx): self._cache = ctx.cache if self._cache is None: LOG_ERROR('Cache is not init.') return else: self._bonuses = self._ctrlFactory.createBonuses(ctx.bonusCompleted) self._sound = self._ctrlFactory.createSoundPlayer() if not self._tutorialStopped: LOG_ERROR('Tutorial is already running.') return self._gui = TUTORIAL_SETTINGS.factory(self._settings.gui) self._gui.onGUILoaded += self.__onGUILoaded if not self._gui.init(): self._gui.onGUILoaded -= self.__onGUILoaded LOG_ERROR('GUI can not init. Tutorial is stopping.') return LOG_DEBUG('Start training', ctx) self._tutorialStopped = False proxy = weakref.proxy(self) setTutorialProxy(proxy) if self.__resolveInitialChapter(): self._gui.setPlayerXPLevel(self._cache.getPlayerXPLevel()) self._gui.setTrainingRunMode() self._gui.loadConfig(self._descriptor.getGuiFilePath()) self._gui.onMouseClicked += self.__onMouseClicked self._gui.onPageChanging += self.__onPageChanging self.__tryRunFirstState(INITIAL_FLAG.CHAPTER_RESOLVED) return
def run(self, dispatcher, ctx): self._cache = ctx.cache if self._cache is None: LOG_ERROR('Cache is not init.') return False self._bonuses = self._ctrlFactory.createBonuses(ctx.bonusCompleted) self._sound = self._ctrlFactory.createSoundPlayer() GlobalStorage.setFlags(ctx.globalFlags) if not self._stopped: LOG_ERROR('Tutorial is already running.') return False self._gui = createTutorialElement(self._settings.gui) self._gui.setDispatcher(dispatcher) self._gui.onGUILoaded += self.__onGUILoaded if not self._gui.init(): self._gui.onGUILoaded -= self.__onGUILoaded self._gui.setDispatcher(None) LOG_ERROR('GUI can not init. Tutorial is stopping.') return False LOG_DEBUG('Start training', ctx) self._stopped = False proxy = weakref.proxy(self) setTutorialProxy(proxy) if self.__resolveInitialChapter(ctx): self._gui.loadConfig(self._descriptor.getGuiFilePath()) self._gui.onGUIInput += self.__onGUIInput self._gui.onPageChanging += self.__onPageChanging self._gui.onItemFound += self.__onItemFound self._gui.onItemLost += self.__onItemLost self.__tryRunFirstState(INITIAL_FLAG.CHAPTER_RESOLVED) self.onStarted() return True