From cde504640e1b812321a72cff1b8b3c32a6d674e9 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sun, 29 Oct 2023 20:20:27 +0100 Subject: [PATCH] Ajout des noms des dossiers --- src/scenes/directory_search.py | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/scenes/directory_search.py b/src/scenes/directory_search.py index d684062..e43efe7 100644 --- a/src/scenes/directory_search.py +++ b/src/scenes/directory_search.py @@ -12,6 +12,8 @@ from engine import ( Order, Position, Scene, + Text, + TextSize, Texture, Vec2, World, @@ -59,6 +61,15 @@ class DirectoryPosition: return False +class DirectoryName: + """ + Composant qui marque une entité comme étant le nom d'un dossier. + """ + + def __init__(self, entity: Entity): + self.entity = entity + + def __initialize_world(world: World): """ Initialise le monde de la scène. @@ -66,7 +77,7 @@ def __initialize_world(world: World): world[State] = State.WAITING for y in range(__LINES): for x in range(__COLUMNS): - world.create_entity( + entity = world.create_entity( Position(0, 0), Order(1), Centered(), @@ -75,6 +86,15 @@ def __initialize_world(world: World): DirectoryPosition(x, y), ) + world.create_entity( + Position(0, 0), + Order(1), + Centered(), + Text("Nom du dossier"), + TextSize(25), + DirectoryName(entity), + ) + def __move_directories(world: World): """ @@ -169,6 +189,16 @@ def __update_positions(world: World): entity[Order] = Order(position.y + 1) +def __update_directory_names(world: World): + """ + Met à jour la position des noms des dossiers. + """ + for entity in world.query(DirectoryName): + directory_entity = entity[DirectoryName].entity + entity[Position] = Position(directory_entity[Position] + Vec2(0, 75)) + entity[Order] = directory_entity[Order] + + SCENE = ( Scene( [__initialize_world], @@ -176,4 +206,9 @@ SCENE = ( [], ) + smooth.PLUGIN + + Scene( + [], + [__update_directory_names], + [], + ) )