Esempio n. 1
0
def RegisterEventHandler(eventName, eventHandler):
    """Register a method that will receive all ui events.  The method will be
       invoked with two arguments; the eventType and an array of strings."""
    global _uiEventHandlers
    if eventName == 'UiEvent':
        if eventHandler in _uiEventHandlers:
            ClientAPI.LogError("Duplicate add of event handler")
        _uiEventHandlers.append(eventHandler)
    else:
        ClientAPI.LogError(
            "Invalid event name '%s' passed to Interface.RegisterEventHandler"
            % str(eventName))
Esempio n. 2
0
def DispatchEvent(eventType, eventArgs):
    # First dispatch to the global handlers
    # note that a few events are not inserted this way, and will not be
    # handled by the global handlers, since they come from client C# code.
    global _uiEventHandlers
    for handler in _uiEventHandlers:
        try:
            handler(eventType, eventArgs)
        except Exception, e:
            ClientAPI.LogError("UiEvent Handler Error: " + str(e))
Esempio n. 3
0
def RemoveEventHandler(eventName, eventHandler):
    """Remove a method that was previously registered to receive all ui
       events."""
    global _uiEventHandlers
    if eventName == 'UiEvent':
        if eventHandler in _uiEventHandlers:
            _uiEventHandlers.remove(eventHandler)
    else:
        ClientAPI.LogError(
            "Invalid event name '%s' passed to Interface.RemoveEventHandler" %
            str(eventName))
Esempio n. 4
0
 def RemoveEventHandler(self, eventName, eventHandler):
     if eventName == 'WorldInitialized':
         Multiverse.Base.ClientAPI.WorldInitialized -= eventHandler
     elif eventName == 'ObjectAdded':
         del self._objectAddedHandlers[_objectAddedHandlers.index(eventHandler)]
     elif eventName == 'ObjectRemoved':
         del self._objectRemovedHandlers[_objectRemovedHandlers.index(eventHandler)]
     elif eventName == 'AmbientLightChanged':
         self._sceneManager.AmbientLightChanged -= eventHandler
     elif eventName == 'LightAdded':
         self._sceneManager.LightAdded -= eventHandler
     elif eventName == 'LightRemoved':
         self._sceneManager.LightRemoved -= eventHandler
     elif eventName == 'LoadingStateChanged':
         self._worldManager.OnLoadingStateChange -= eventHandler
     else:
         ClientAPI.LogError("Invalid event name '%s' passed to World.RemoveEventHandler" % str(eventName))