def handle(self, element, module, clazz, dll): dll = BugDll.decode(dll) if self.isDllOkay(element, dll): BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs) else: BugUtil.info( "BugConfig - ignoring <%s> from %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll))
def handle(self, element, module, clazz, dll): dll = BugDll.decode(dll) if self.isDllOkay(element, dll): BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs) else: BugUtil.info( "BugConfig - ignoring <%s> from %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll), )
def handle(self, element, root, tag, key, parents, module, clazz): if root: element.setState("config-handler", getHandler(root)) else: if isRegistered(key): BugUtil.warn("BugConfig - <%s>.key %s handler already registered, ignoring", element.tag, key) else: handler = BugUtil.callFunction(module, clazz) registerHandler(tag, handler) # automatically include in enclosing <config> handler parent = element.getState("config-handler") if parent: parentHandlers = [parent] else: parentHandlers = [] # add listed parents if parents: for parent in parents.split(): if parent == "-": parentHandlers = [] else: parentHandlers.append(getHandler(parent)) # place in bug handler if none specified if not parentHandlers: parentHandlers.append(g_bugHandler) # register with each parent handler for parent in parentHandlers: parent.addValidChild(tag) #parent.addChildHandler(handler) element.setState("config-handler", handler)
def handle(self, element, screenId, module, clazz, id): if screenId: screen = BugCore.game._getScreen(screenId) else: screen = element.getState("options-screen") if not screen: raise BugUtil.ConfigError("Element <%s> %s must be in <screen> or have screen attribute", id, element.tag) screen.addTab(id) tab = BugUtil.callFunction(module, clazz, g_optionsScreen) g_optionsScreen.addTab(tab)
def handle(self, element, module, clazz, handlers, listeners, override, log, dll): override = self.isTrue(override) dll = BugDll.decode(dll) if self.isDllOkay(element, dll): if clazz: utils = BugUtil.callFunction(module, clazz) element.setState("gameutils", utils) if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.bindFunction(utils, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): func = None if not listener.endswith(LISTENER_SUFFIX): try: func = BugUtil.bindFunction( utils, listener + LISTENER_SUFFIX) except BugUtil.ConfigError: pass if not func: try: func = BugUtil.bindFunction( utils, listener) except BugUtil.ConfigError: raise BugUtil.ConfigError( "Game utils %s.%s must define function %s or %s", module, clazz, listener, listener + "Listener") addListener(func, log) else: addClassUtils(utils, override, log) else: if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.lookupFunction(module, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): addListener( BugUtil.lookupFunction(module, listener), log) else: addModuleUtils(BugUtil.lookupModule(module), override, log) else: BugUtil.info( "BugGameUtils - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll))
def createTab(self, screenId, id, module, clazz=None, attrs=None): # TODO: add args if screenId: screen = self.game._getScreen(screenId) else: screen = self.screen if not screen: raise BugUtil.ConfigError("<tab> must be in <screen> or have screenId") if not clazz: clazz = module tab = BugUtil.callFunction(module, clazz, self.optionsScreen) tab.attrs = attrs screen.addTab(tab) self.optionsScreen.addTab(tab) return tab
def handle(self, element, module, clazz, handlers, listeners, override, log, dll): override = self.isTrue(override) if clazz: utils = BugUtil.callFunction(module, clazz) element.setState("gameutils", utils) if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.bindFunction(utils, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): func = None if not listener.endswith("Listener"): try: func = BugUtil.bindFunction( utils, listener + "Listener") except BugUtil.ConfigError: pass if not func: try: func = BugUtil.bindFunction(utils, listener) except BugUtil.ConfigError: raise BugUtil.ConfigError( "Game utils %s.%s must define function %s or %s", module, clazz, listener, listener + "Listener") addListener(func, log) else: addClassUtils(utils, override, log) else: if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.lookupFunction(module, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): addListener(BugUtil.lookupFunction(module, listener), log) else: addModuleUtils(BugUtil.lookupModule(module), override, log)
def handle(self, element, module, clazz, handlers, listeners, override, log, dll): override = self.isTrue(override) dll = BugDll.decode(dll) if self.isDllOkay(element, dll): if clazz: utils = BugUtil.callFunction(module, clazz) element.setState("gameutils", utils) if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.bindFunction(utils, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): func = None if not listener.endswith(LISTENER_SUFFIX): try: func = BugUtil.bindFunction(utils, listener + LISTENER_SUFFIX) except BugUtil.ConfigError: pass if not func: try: func = BugUtil.bindFunction(utils, listener) except BugUtil.ConfigError: raise BugUtil.ConfigError("Game utils %s.%s must define function %s or %s", module, clazz, listener, listener + "Listener") addListener(func, log) else: addClassUtils(utils, override, log) else: if handlers or listeners: if handlers: for handler in handlers.replace(",", " ").split(): addHandler(BugUtil.lookupFunction(module, handler), override, log) if listeners: for listener in listeners.replace(",", " ").split(): addListener(BugUtil.lookupFunction(module, listener), log) else: addModuleUtils(BugUtil.lookupModule(module), override, log) else: BugUtil.info("BugGameUtils - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll))
def handle(self, element, module, clazz, dll): BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs)
def createEvents(self, module, function=None, args=(), kwargs={}, attrs=None): if not function: function = module return BugUtil.callFunction(module, function, self.eventManager, *args, **kwargs)
def createBuilder(self, module, clazz=None, attrs=None): if not clazz: clazz = module return BugUtil.callFunction(module, clazz, self.game, attrs)