summaryrefslogtreecommitdiff
path: root/src/sliceitoff/images
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/images')
-rw-r--r--src/sliceitoff/images/__init__.py2
-rw-r--r--src/sliceitoff/images/images.py22
2 files changed, 17 insertions, 7 deletions
diff --git a/src/sliceitoff/images/__init__.py b/src/sliceitoff/images/__init__.py
index 16d361a..d87dfa0 100644
--- a/src/sliceitoff/images/__init__.py
+++ b/src/sliceitoff/images/__init__.py
@@ -1 +1 @@
-from .images import images, load_images
+from .images import Images
diff --git a/src/sliceitoff/images/images.py b/src/sliceitoff/images/images.py
index b2d93a2..999d92b 100644
--- a/src/sliceitoff/images/images.py
+++ b/src/sliceitoff/images/images.py
@@ -5,10 +5,12 @@ from display import Scaling
DEBUG = os.getenv("DEBUG")
-images = {}
+class Images:
+ surfaces = {}
-def load_images():
- if not images:
+ @staticmethod
+ def reload_images():
+ __class__.surfaces = {}
with open("assets/images.lst") as image_list_file:
for line in image_list_file:
name, *path = line.strip().split()
@@ -16,6 +18,14 @@ def load_images():
if DEBUG:
print(f"Loading images {name = }, {filename = }")
image = pygame.image.load(filename)
- images[name] = pygame.transform.smoothscale_by(
- pygame.Surface.convert_alpha(image),
- Scaling.factor)
+ rgba = pygame.Surface.convert_alpha(image)
+ scaled = pygame.transform.smoothscale_by(rgba, Scaling.factor)
+ __class__.surfaces[name] = scaled
+ return True
+
+ @staticmethod
+ def load_images():
+ if __class__.surfaces:
+ return False
+ return __class__.reload_images()
+ \ No newline at end of file