示例#1
0
    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
示例#2
0
    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
示例#3
0
    def getGuiRoot(self):
        try:
            root = GUIProxy.windowsManager().battleWindow
        except AttributeError:
            LOG_CURRENT_EXCEPTION()
            root = None

        return root
示例#4
0
    def getGuiRoot(self):
        try:
            root = g_appLoader.getDefBattleApp()
        except AttributeError:
            LOG_CURRENT_EXCEPTION()
            root = None

        return root
示例#5
0
    def _getDirectionIndicator(self):
        indicator = None
        try:
            indicator = _DirectionIndicator()
        except AttributeError:
            LOG_CURRENT_EXCEPTION()

        return indicator
示例#6
0
    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
示例#7
0
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
示例#8
0
    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)
示例#9
0
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
示例#10
0
    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
示例#11
0
    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
示例#12
0
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
示例#13
0
    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)
示例#14
0
    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
示例#15
0
    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
示例#16
0
    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
示例#17
0
    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
示例#18
0
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
示例#19
0
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
示例#20
0
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
示例#21
0
    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')
示例#22
0
    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