removed atlas for the texture to avoid issue

This commit is contained in:
Faraphel 2023-02-25 14:01:09 +01:00
parent 25a3c0fa86
commit a3df2f6c2c

View file

@ -15,19 +15,16 @@ class Style(ABC):
""" """
def __init_subclass__(cls, **kwargs): def __init_subclass__(cls, **kwargs):
atlas = pyglet.image.atlas.TextureAtlas(10000, 10000) # TODO: calculer la taille
for name, args in cls.__dict__.items(): for name, args in cls.__dict__.items():
if name.startswith("_"): continue if name.startswith("_"): continue
if isinstance(args, Path): # if this is a normal path for a normal image if isinstance(args, Path): # if this is a normal path for a normal image
path = args path = args
texture = atlas.add(pyglet.image.load(path)) texture = pyglet.image.load(path)
elif isinstance(args, tuple): # if this is a tuple for an animation elif isinstance(args, tuple) and len(args) == 3: # if this is a tuple for an animation
paths, duration, loop = args paths, duration, loop = args
textures = map(pyglet.image.load, paths)
textures = map(lambda path: atlas.add(pyglet.image.load(path)), paths)
texture = pyglet.image.Animation.from_image_sequence(textures, duration, loop) texture = pyglet.image.Animation.from_image_sequence(textures, duration, loop)
else: else:
@ -35,8 +32,6 @@ class Style(ABC):
setattr(cls, name, texture) setattr(cls, name, texture)
setattr(cls, "_atlas", atlas)
@classmethod @classmethod
def get(cls, item: str, default: Any = None) -> Optional[pyglet.image.AbstractImage]: def get(cls, item: str, default: Any = None) -> Optional[pyglet.image.AbstractImage]:
return getattr(cls, item, default) return getattr(cls, item, default)