Skip to content
Snippets Groups Projects
Select Git revision
  • 034774148302a9c369c02192c83d49e3958932cd
  • main default protected
  • v1.1
  • v1.0
4 results

loading.py

Blame
  • loading.py 1.21 KiB
    from st3m.input import InputController
    from st3m.ui.view import BaseView, ViewManager, ViewTransitionSwipeLeft, ViewTransitionBlend
    from st3m.application import Application, ApplicationContext
    import gc
    
    import song
    
    class LoadingView(BaseView):
        def __init__(self, app, song, difficulty):
            super().__init__()
            self.app = app
            self.song = song
            self.difficulty = difficulty
            self.delay = 500
            self.view = None
    
        def draw(self, ctx: Context) -> None:
            # Paint the background black
            ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill()
            ctx.font = "Camp Font 3"
            ctx.font_size = 32
            ctx.text_align = ctx.CENTER
            ctx.text_baseline = ctx.MIDDLE
            ctx.move_to (0, 0)
            ctx.gray(1.0)
            ctx.text("Loading...")
    
        def think(self, ins: InputState, delta_ms: int) -> None:
            if delta_ms > 100:
                delta_ms = 0
            self.delay -= delta_ms
            if self.delay < 0:
                if self.view:
                    self.vm.replace(self.view, ViewTransitionBlend())
                else:
                    gc.collect()
                    self.view = song.SongView(self.app, self.song, self.difficulty)
                self.delay = 500