2025-04-02 21:27:14 +02:00
|
|
|
from .fonts import *
|
|
|
|
|
from .colors import *
|
2025-04-02 22:59:01 +02:00
|
|
|
import pygame
|
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
MAX_COUNT = 9
|
2025-04-02 21:27:14 +02:00
|
|
|
|
|
|
|
|
class Athmos:
|
|
|
|
|
|
|
|
|
|
def __init__(self, screen):
|
2025-04-02 22:59:01 +02:00
|
|
|
self.index = 0
|
|
|
|
|
self.filenames = []
|
2025-04-02 21:27:14 +02:00
|
|
|
self.screen = screen
|
2025-04-02 22:59:01 +02:00
|
|
|
self.show_list = True
|
2025-04-02 23:42:32 +02:00
|
|
|
self.surface = pygame.Surface((0,0), pygame.SRCALPHA)
|
2025-08-03 18:01:18 +02:00
|
|
|
self.max_name_width = 350
|
2025-04-02 23:42:32 +02:00
|
|
|
|
|
|
|
|
def set_filenames(self,filenames):
|
|
|
|
|
self.filenames = filenames
|
|
|
|
|
self.surface = pygame.Surface(
|
|
|
|
|
(self.screen.get_width()*2/3, self.get_display_count()*40),
|
|
|
|
|
pygame.SRCALPHA)
|
2025-04-02 22:59:01 +02:00
|
|
|
|
|
|
|
|
def get_display_count(self):
|
|
|
|
|
return min(MAX_COUNT, len(self.filenames))
|
2025-04-02 21:27:14 +02:00
|
|
|
|
|
|
|
|
def update(self):
|
2025-04-02 22:59:01 +02:00
|
|
|
if self.show_list:
|
2025-04-05 16:05:47 +02:00
|
|
|
self.surface.fill("black")
|
2025-04-02 22:59:01 +02:00
|
|
|
for i in range(self.get_display_count()):
|
2025-08-03 18:01:18 +02:00
|
|
|
text = self.filenames[(i+self.index-math.floor(self.get_display_count()/2))%len(self.filenames)]
|
|
|
|
|
if len(text)> math.floor(self.max_name_width/10):
|
|
|
|
|
text = text[0:math.floor(self.max_name_width/10)-2]
|
|
|
|
|
text += '...'
|
|
|
|
|
#text = self.filenames[i]
|
|
|
|
|
if i == math.floor(self.get_display_count()/2):
|
|
|
|
|
#if i == self.index:
|
2025-04-02 22:59:01 +02:00
|
|
|
text_surface = font_helvetica16.render(text, False, color_primary_light)
|
2025-08-03 18:01:18 +02:00
|
|
|
else:
|
|
|
|
|
text_surface = font_helvetica16.render(text, False, color_primary)
|
|
|
|
|
opacity = -20 + math.floor((i+1) * 2 * 255 / MAX_COUNT
|
2025-04-02 23:42:32 +02:00
|
|
|
if i < MAX_COUNT/2
|
|
|
|
|
else (MAX_COUNT-i) * 2 * 255 / MAX_COUNT)
|
2025-08-03 18:01:18 +02:00
|
|
|
text_surface.set_alpha(opacity)
|
|
|
|
|
#if text_surface.get_width() > self.max_name_width: self.max_name_width = text_surface.get_width()
|
|
|
|
|
self.surface.blit(text_surface, ((10, self.surface.get_height()/self.get_display_count()*i)))
|
|
|
|
|
pygame.draw.rect(self.surface, color_primary_light, (0, self.surface.get_height()/2-25, self.max_name_width+20, 40), 2)
|
|
|
|
|
|
|
|
|
|
self.screen.blit(self.surface, ((self.screen.get_width()-self.max_name_width)/2,
|
2025-04-05 16:05:47 +02:00
|
|
|
(self.screen.get_height() - self.surface.get_height())/2))
|