Example #1
0
    def input(self, key):
        key = key.replace('control-', '')
        key = key.replace('shift-', '')
        key = key.replace('alt-', '')

        if key in self._input_name_changes:
            key = self._input_name_changes[key]

        if key in input_handler.rebinds:
            key = input_handler.rebinds[key]

        try:
            input_handler.input(key)
        except:
            pass
        if not application.paused:
            if hasattr(__main__, 'input'):
                __main__.input(key)

        for entity in scene.entities:
            if entity.enabled == False or entity.ignore or entity.ignore_input:
                continue
            if application.paused and entity.ignore_paused == False:
                continue

            if hasattr(entity, 'input') and callable(entity.input):
                entity.input(key)

            if hasattr(entity, 'scripts'):
                for script in entity.scripts:
                    if script.enabled and hasattr(
                            script, 'input') and callable(script.input):
                        script.input(key)

        try:
            mouse.input(key)
        except:
            pass

        if key == 'f12':
            window.editor_ui.enabled = not window.editor_ui.enabled

        if key == 'f11':
            window.fullscreen = not window.fullscreen

        if key == 'f10':
            i = window.render_modes.index(window.render_mode)
            i += 1
            if i >= len(window.render_modes):
                i = 0

            window.render_mode = window.render_modes[i]

        if key == 'f9':
            window.render_mode = 'default'
Example #2
0
    def input(self, key):
        if not isinstance(key, str):
            if key.repeat:
                self.input_hold(key.key)
                return
            key = key.key

        # print('------------', key)
        key = key.lower()
        if key in self._input_name_changes:
            key = self._input_name_changes[key]

        key = key.replace('control-', '')
        key = key.replace('shift-', '')
        key = key.replace('alt-', '')

        if key in input_handler.rebinds:
            key = input_handler.rebinds[key]

        try:
            input_handler.input(key)
        except:
            pass
        if not application.paused:
            if hasattr(__main__, 'input'):
                __main__.input(key)

        for entity in scene.entities:
            if entity.enabled:
                if hasattr(entity, 'input'):
                    entity.input(key)

                if hasattr(entity, 'scripts'):
                    for script in entity.scripts:
                        if hasattr(script, 'input'):
                            script.input(key)