]> git.mar77i.info Git - elevator/commitdiff
door button glow frame for call_queue
authormar77i <mar77i@protonmail.ch>
Wed, 21 Aug 2024 08:11:45 +0000 (10:11 +0200)
committermar77i <mar77i@protonmail.ch>
Wed, 21 Aug 2024 08:11:45 +0000 (10:11 +0200)
elevator.py

index 487121a1fad4a66ff1061e04bb6bbfb8e53bc645..2ffc1deefe86890b2e3351a9a1c42abc262d70a2 100755 (executable)
@@ -93,6 +93,7 @@ class Door:
     BACKGROUND = "black"
     FOREGROUND = "brown"
     BUTTON_COLOR = "black"
+    BUTTON_GLOW_COLOR = "red"
     DOOR_MARGIN = (0.01, 0.05)
     PADDING = Vec(0.014, 0.022)
     WIDTH = 0.3
@@ -206,6 +207,14 @@ class Door:
             self.button_rect.center,
             self.button_rect.height // 2,
         )
+        if self.level in {*self.elevator.call_queue, self.elevator.destination}:
+            pygame.draw.circle(
+                surf,
+                self.BUTTON_GLOW_COLOR,
+                self.button_rect.center,
+                self.button_rect.height // 2,
+                2,
+            )
 
 
 class Elevator:
@@ -326,16 +335,19 @@ class Elevator:
         If we are at the destination and the door is open, disregard
         If level is not already a destination, add it to the call_queue
         """
-        if self.doors[call_level].state == Door.OPEN:
+        current = self.get_whole_level()
+        if call_level == current and self.doors[call_level].state == Door.OPEN:
             return
         level_queue = {
-            self.get_whole_level(),
+            current,
             *self.call_queue,
             self.queued_dest,
             self.destination,
         }
         if call_level not in level_queue:
             self.call_queue.append(call_level)
+        elif call_level == current:
+            self.doors[call_level].open()
 
     def open(self):
         """
@@ -455,6 +467,7 @@ class ElevatorApp:
         for i, door in enumerate(self.elevator.doors):
             if door.button_rect.collidepoint(pos):
                 self.elevator.call_from(i)
+                self.dirty = True
                 return
         for i, button in enumerate(self.elevator_panel.buttons):
             if button.collidepoint(pos):