def __init__(self, data, position): super(_StaticObjectMarker3D, self).__init__() path = data.get('path') offset = data.get('offset', Math.Vector3(0, 0, 0)) self.__model = None if path is not None: try: self.__model = BigWorld.Model(path) self.__model.position = Math.Vector3(position[:]) + offset self.__model.castsShadow = False except ValueError: LOG_CURRENT_EXCEPTION() LOG_ERROR('Model not found', path) return except AttributeError: LOG_CURRENT_EXCEPTION() return BigWorld.addModel(self.__model) action = data.get('action') if action is not None and len(action): try: self.__model.action(action)() except ValueError: LOG_ERROR('Action not found', path, action) return
def __read(self): cacheFile = None if TutorialCache.__internal is not None: LOG_WARNING('Cache retrieved from internal property. Record to file is denied.', TutorialCache.__internal) self.__cache.update(TutorialCache.__internal) return else: try: if not os.path.isfile(self.__cacheFileName): return cacheFile = open(self.__cacheFileName, 'rb') self.__version, cache = cPickle.load(cacheFile) if self.__version != TUTORIAL_VERSION: self.__version = TUTORIAL_VERSION else: self.__cache.setdefault(self.__space, {}) self.__cache.update(cache) except (IOError, cPickle.PickleError): LOG_CURRENT_EXCEPTION() if TutorialCache.__internal is not None: self.__cache.update(TutorialCache.__internal) finally: if cacheFile is not None: cacheFile.close() return
def getGuiRoot(self): try: root = GUIProxy.windowsManager().battleWindow except AttributeError: LOG_CURRENT_EXCEPTION() root = None return root
def getGuiRoot(self): try: root = g_appLoader.getDefBattleApp() except AttributeError: LOG_CURRENT_EXCEPTION() root = None return root
def _getDirectionIndicator(self): indicator = None try: indicator = _DirectionIndicator() except AttributeError: LOG_CURRENT_EXCEPTION() return indicator
def _resolveGuiRoot(self): proxy = None try: window = GUIProxy.windowsManager().window self._guiRef = weakref.ref(window) proxy = window.proxy except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def loadChapterData(chapter, chapterParser, afterBattle=False, initial=False): if chapter is not None and not chapter.isValid(): try: parser = settings.createTutorialElement(chapterParser) parser.parse(chapter, afterBattle=afterBattle, initial=initial) except Exception: LOG_CURRENT_EXCEPTION() return return chapter
def invoke(self, ui, cmdData): ns, method = self._py_searchMethod(ui, cmdData) if method is not None and callable(method): try: method(*cmdData.args[:]) except Exception: LOG_CURRENT_EXCEPTION() else: LOG_ERROR('GUI method not found', ui, cmdData)
def loadChapterData(chapter, afterBattle=False, initial=False): if chapter is not None and not chapter.isValid(): try: ChapterParser().parse(chapter, afterBattle=afterBattle, initial=initial) except Exception: LOG_CURRENT_EXCEPTION() return return chapter
def _resolveGuiRoot(self): proxy = None try: app = g_appLoader.getDefBattleApp() if not app: return self._guiRef = weakref.ref(app) proxy = weakref.proxy(app) except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def _resolveGuiRoot(self): proxy = None try: window = GUIProxy.windowsManager().battleWindow self._guiRef = weakref.ref(window) proxy = window.proxy dispatcher = self.getDispatcher() if dispatcher is not None and proxy is not None: dispatcher.populateUI(proxy) except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def loadDescriptorData(filePath, exParsers=None, clearCache=False): try: if exParsers is not None: imported = __import__(exParsers, globals(), locals(), ['init']) getattr(imported, 'init')() if clearCache: ResMgr.purge(filePath) return DescriptorParser().parse(filePath) except Exception: LOG_CURRENT_EXCEPTION() return return
def __init__(self, uiHolder): super(MinimapDefaultSizeAspect, self).__init__() minimap = getattr(uiHolder, 'minimap', None) if minimap: setSize = getattr(minimap, 'onSetSize', None) if setSize and callable(setSize): try: setSize(0, AccountSettings.getSettingsDefault('minimapSize')) except TypeError: LOG_CURRENT_EXCEPTION() else: LOG_ERROR('Minimap method "onSetSize" is not found', minimap)
def invoke(self, ui, cmdData): _, method = self._py_searchMethod(ui, cmdData) if method is not None and callable(method): try: if isinstance(cmdData.args, dict): method(**cmdData.args) else: method(*cmdData.args[:]) except Exception: LOG_CURRENT_EXCEPTION() else: LOG_ERROR('GUI method not found', ui, cmdData) return
def __init__(self, data, position): super(_StaticObjectMarker3D, self).__init__() path = data.get('path') offset = data.get('offset', Math.Vector3(0, 0, 0)) self.__model = None self.__animator = None if path is not None: try: self.__model = BigWorld.Model(path) self.__model.position = Math.Vector3(position[:]) + offset self.__model.castsShadow = False except ValueError: LOG_CURRENT_EXCEPTION() LOG_ERROR('Model not found', path) return except AttributeError: LOG_CURRENT_EXCEPTION() return BigWorld.addModel(self.__model) action = data.get('action') if action: try: clipResource = self.__model.deprecatedGetAnimationClipResource( action) spaceID = BigWorld.player().spaceID loader = AnimationSequence.Loader(clipResource, spaceID) animator = loader.loadSync() animator.bindTo( AnimationSequence.ModelWrapperContainer( self.__model, spaceID)) animator.start() self.__animator = animator except ValueError: LOG_ERROR('Action not found', path, action) return
def write(self): output = None try: if not os.path.isdir(self.__cacheDir): os.makedirs(self.__cacheDir) output = open(self.__cacheFileName, 'wb') cPickle.dump((self.__version, self.__cache), output, -1) except (IOError, cPickle.PickleError): LOG_CURRENT_EXCEPTION() TutorialCache.__internal = self.__cache.copy() finally: if output is not None: output.close() return
def _resolveGuiRoot(self): proxy = None try: app = g_appLoader.getDefBattleApp() if not app: return proxy = weakref.proxy(app) self._guiRef = weakref.ref(app) dispatcher = self.getDispatcher() if dispatcher is not None and proxy is not None: dispatcher.populateUI(proxy) except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def loadDescriptorData(setting, exParsers=None, clearCache=False): try: if exParsers is not None: imported = __import__(exParsers, globals(), locals(), ['init']) getattr(imported, 'init')() if clearCache: ResMgr.purge(setting.descriptorPath) classPath = setting.descriptorParser parser = settings.createTutorialElement(classPath) return parser.parse(setting.descriptorPath) except Exception: LOG_CURRENT_EXCEPTION() return return
def loadChapterData(chapter, chapterParser, afterBattle=False, initial=False): if chapter is not None and not chapter.isValid(): try: imported = __import__(chapterParser.module, globals(), locals(), [chapterParser.clazz]) if not imported: raise ValueError( 'Can not find class {0.module} in {0.clazz}'.format( chapterParser)) clazz = getattr(imported, chapterParser.clazz) clazz().parse(chapter, afterBattle=afterBattle, initial=initial) except Exception: LOG_CURRENT_EXCEPTION() return return chapter
def loadDescriptorData(setting, exParsers=None, clearCache=False): try: if exParsers is not None: imported = __import__(exParsers, globals(), locals(), ['init']) getattr(imported, 'init')() if clearCache: ResMgr.purge(setting.descriptorPath) classPath = setting.descriptorParser imported = __import__(classPath.module, globals(), locals(), [classPath.clazz]) if not imported: raise ValueError( 'Can not find class {0.module} in {0.clazz}'.format(classPath)) clazz = getattr(imported, classPath.clazz) return clazz().parse(setting.descriptorPath) except Exception: LOG_CURRENT_EXCEPTION() return
def invoke(self, content, varID): self._gui.showWaiting('request-item-params') itemCD = self.getVar(varID) if itemCD is None: return itemTypeID, nationID, compTypeID = vehicles.parseIntCompactDescr(itemCD) assert itemTypeID != ITEM_TYPE_NAMES[1] try: guiItem = InventoryItem(itemTypeName=ITEM_TYPE_NAMES[itemTypeID], compactDescr=itemCD) content['itemTypeName'] = guiItem.itemTypeName content['itemLevel'] = guiItem.level params = guiItem.getParams(g_currentVehicle.item) itemParams = [] for param in params['parameters']: itemParams.extend(param) content['itemParams'] = itemParams except Exception: LOG_CURRENT_EXCEPTION() self._gui.hideWaiting('request-item-params')
def invoke(self, content, varID): self._gui.showWaiting('request-item-params') itemCD = self.getVar(varID) if itemCD is None: return else: itemTypeID, nationID, compTypeID = vehicles.parseIntCompactDescr( itemCD) raise itemTypeID != ITEM_TYPE_NAMES[1] or AssertionError try: guiItem = game_vars.getItemByIntCD(itemCD) content['itemTypeName'] = guiItem.itemTypeName content['itemLevel'] = guiItem.level params = guiItem.getParams(g_currentVehicle.item).get( 'parameters', dict()) content['itemParams'] = formatters.getFormattedParamsList( g_currentVehicle.item.descriptor, params) except Exception: LOG_CURRENT_EXCEPTION() self._gui.hideWaiting('request-item-params') return