本文整理匯總了Python中tutorial.control.context.GlobalStorage.setFlags方法的典型用法代碼示例。如果您正苦於以下問題:Python GlobalStorage.setFlags方法的具體用法?Python GlobalStorage.setFlags怎麽用?Python GlobalStorage.setFlags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tutorial.control.context.GlobalStorage
的用法示例。
在下文中一共展示了GlobalStorage.setFlags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from tutorial.control.context import GlobalStorage [as 別名]
# 或者: from tutorial.control.context.GlobalStorage import setFlags [as 別名]
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
示例2: run
# 需要導入模塊: from tutorial.control.context import GlobalStorage [as 別名]
# 或者: from tutorial.control.context.GlobalStorage import setFlags [as 別名]
def run(self, settingsID, state = None):
"""
Try to run tutorial.
:param settingsID: string containing settings ID of required tutorial.
:param state: dict(
reloadIfRun : bool - just reload tutorial if it's running,
afterBattle : bool - tutorial should load scenario that is played
when player left battle,
initialChapter : str - name of initial chapter,
restoreIfRun: bool - current tutorial will be started again
if required tutorial stop.
globalFlags : dict(GLOBAL_FLAG.* : bool,)
)
:return: True if tutorial has started, otherwise - False.
"""
settings = self.__settings.getSettings(settingsID)
if settings is None:
LOG_ERROR('Can not find settings', settingsID)
return False
else:
if state is None:
state = {}
reloadIfRun = state.pop('reloadIfRun', False)
restoreIfRun = state.pop('restoreIfRun', False)
isStopForced = state.pop('isStopForced', False)
if self.__tutorial is not None and not self.__tutorial.isStopped():
isCurrent = self.__tutorial.getID() == settings.id
if reloadIfRun and isCurrent:
if isStopForced:
self.__doStop()
else:
GlobalStorage.setFlags(state.get('globalFlags', {}))
self.__tutorial.invalidateFlags()
return True
elif restoreIfRun and not isCurrent:
self.__restoreID = self.__tutorial.getID()
self.__doStop()
else:
LOG_ERROR('Tutorial already is running', self.__tutorial.getID())
return False
if self.__dispatcher is None:
self.__setDispatcher(settings.dispatcher)
cache = _cache.TutorialCache(BigWorld.player().name)
cache.read()
state.setdefault('isAfterBattle', self.__afterBattle)
state.setdefault('restart', True)
result = self.__doRun(settings, RunCtx(cache, **state), byRequest=True)
if not result:
self.__restoreID = None
return result