summaryrefslogtreecommitdiff
path: root/src/sliceitoff/menu/show.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-04-27 16:26:22 +0300
committerViljami Ilola <+@hix.fi>2024-04-27 16:26:22 +0300
commit9f8247dc4da89219b6eede08d58d96964391a077 (patch)
treea6f7dc46275a3988fc528072f5e70caba461fae0 /src/sliceitoff/menu/show.py
parentd64c6b122eacd7b33bbda3a62093b492c786b1f9 (diff)
refactor menus and screen showing under menu subpkg
Diffstat (limited to 'src/sliceitoff/menu/show.py')
-rw-r--r--src/sliceitoff/menu/show.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sliceitoff/menu/show.py b/src/sliceitoff/menu/show.py
new file mode 100644
index 0000000..5c122d8
--- /dev/null
+++ b/src/sliceitoff/menu/show.py
@@ -0,0 +1,24 @@
+""" menu.show - Sprite group that show sprites and skips if key is pressed """
+from .anykey import anykey
+from .explodeout import ExplodeOutGroup
+
+class Show(ExplodeOutGroup):
+ """ To show some sprites and quit on any key """
+ def __init__(self, sprites = None, active = True):
+ super().__init__(active = active)
+ self.add(sprites)
+ self.timeout = 15_000
+
+ def update(self, dt = 0, **kwargs):
+ """ First timeout then fadeout and then inactivity """
+ if not super().update(dt = dt, **kwargs):
+ return
+ if anykey():
+ self.do_fadeout()
+ if self.timeout <= 0:
+ self.do_fadeout()
+ self.timeout -= dt
+
+ def sprites(self):
+ """ Return sprites only when active """
+ return super().sprites() if self.active else []