Example #1
0
    def block_fx():
        """Block fx_blockable() for a short time."""
        global _play_repeat_sfx
        _play_repeat_sfx = False
        TK_ROOT.after(50, _reset_fx_blockable)

    def ticker() -> None:
        """We need to constantly trigger pyglet.clock.tick().

        Instead of re-registering this, cache off the command name.
        """
        tick()
        TK_ROOT.tk.call(ticker_cmd)

    ticker_cmd = ('after', 150, TK_ROOT.register(ticker))
    TK_ROOT.tk.call(ticker_cmd)

    class SamplePlayer:
        """Handles playing a single audio file, and allows toggling it on/off."""
        def __init__(
            self,
            start_callback: Callable[[], None],
            stop_callback: Callable[[], None],
            system: FileSystemChain,
        ) -> None:
            """Initialise the sample-playing manager.
            """
            self.sample: Optional[Source] = None
            self.start_time: float = 0  # If set, the time to start the track at.
            self.after: Optional[str] = None