From 0c99eb7bfd1a529c96fdd09c455c48edf1340aa6 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak <dos@dosowisko.net> Date: Wed, 27 Sep 2023 06:36:38 +0200 Subject: [PATCH] Song info on loading screen --- difficulty.py | 2 +- loading.py | 20 ++++++++++++++++++-- select.py | 2 +- song.py | 3 ++- songinfo.py | 6 +++--- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/difficulty.py b/difficulty.py index 3acedb4..e73443d 100644 --- a/difficulty.py +++ b/difficulty.py @@ -65,7 +65,7 @@ class DifficultyView(BaseView): else: ctx.gray(0.5 + min(abs(distance / 2), 0.5)) - if abs(distance) <= 3: + if abs(distance) < 3: xpos = 0.0 ctx.font_size = 24 - abs(distance) * 3 if target and (width := ctx.text_width(str(diff))) > 220: diff --git a/loading.py b/loading.py index 05f0bfb..dc05c52 100644 --- a/loading.py +++ b/loading.py @@ -15,12 +15,28 @@ class LoadingView(BaseView): 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.font = "Camp Font 3" + + ctx.font_size = 32 + while ctx.text_width(self.song.name) > 220: + ctx.font_size -= 1 ctx.move_to (0, 0) ctx.gray(1.0) + ctx.text(self.song.name) + + name_size = ctx.font_size + ctx.font_size = min(22, name_size) + while ctx.text_width(self.song.artist) > 220: + ctx.font_size -= 1 + ctx.move_to (0, -name_size) + ctx.gray(0.75) + ctx.text(self.song.artist) + + ctx.font_size = 18 + ctx.move_to (0, 60) + ctx.gray(0.5) ctx.text("Loading...") def think(self, ins: InputState, delta_ms: int) -> None: diff --git a/select.py b/select.py index 8578583..b3a8e94 100644 --- a/select.py +++ b/select.py @@ -183,7 +183,7 @@ class SelectView(BaseView): else: ctx.gray(0.5 + min(abs(distance / 2), 0.5)) - if abs(distance) <= 3: + if abs(distance) < 3: song.load() xpos = 0.0 ctx.font_size = 24 - abs(distance) * 3 diff --git a/song.py b/song.py index 13597a3..f7b4403 100644 --- a/song.py +++ b/song.py @@ -298,7 +298,8 @@ class SongView(BaseView): media.think(delta_ms) if self.input.buttons.os.middle.pressed and not self.is_active(): - self.vm.pop(ViewTransitionSwipeRight()) + while not self.vm.is_active(self.app): + self.vm.pop(ViewTransitionSwipeRight()) if not self.is_active(): return diff --git a/songinfo.py b/songinfo.py index af60a8a..d5d362e 100644 --- a/songinfo.py +++ b/songinfo.py @@ -82,9 +82,9 @@ class SongInfo(object): diffs = f.read(10) for b in diffs: self._difficulties.append(difficulties[int(b)]) - if not self._difficulties: - #os.unlink(diffFileName) # unlink's broken - raise Exception + #if not self._difficulties: + # os.unlink(diffFileName) # unlink's broken + # raise Exception self._difficulties.sort(key = lambda a: a.id, reverse=True) return self._difficulties except Exception as e: -- GitLab