From 05af345c669e78cac691f76b54fbfc489a088475 Mon Sep 17 00:00:00 2001
From: fheinrich <fheinrich@techfak.uni-bielefeld.de>
Date: Mon, 25 Mar 2024 09:55:11 +0100
Subject: [PATCH] Screen margin relative to window size, order size dependent
 on screen_margin

---
 cooperative_cuisine/pygame_2d_vis/gui.py             | 12 +++++++-----
 cooperative_cuisine/pygame_2d_vis/visualization.yaml |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py
index c74bf0f4..8d3b49c5 100644
--- a/cooperative_cuisine/pygame_2d_vis/gui.py
+++ b/cooperative_cuisine/pygame_2d_vis/gui.py
@@ -173,7 +173,6 @@ class PyGameGUI:
 
         self.FPS = self.visualization_config["GameWindow"]["FPS"]
 
-        self.screen_margin = self.visualization_config["GameWindow"]["screen_margin"]
         self.min_width = self.visualization_config["GameWindow"]["min_width"]
         self.min_height = self.visualization_config["GameWindow"]["min_height"]
         self.buttons_width = self.visualization_config["GameWindow"]["buttons_width"]
@@ -428,6 +427,9 @@ class PyGameGUI:
             self.window_width = self.window_width_windowed
             self.window_height = self.window_height_windowed
 
+        self.screen_margin = self.visualization_config["GameWindow"][
+            "screen_margin_proportion"
+        ] * min(self.window_width, self.window_height)
         self.main_window = pygame.display.set_mode(
             (
                 self.window_width,
@@ -1330,7 +1332,7 @@ class PyGameGUI:
         self.vis.draw_orders(
             screen=self.orders_image.image,
             state=state,
-            grid_size=self.buttons_height,
+            grid_size=self.screen_margin * 0.68,
             width=self.orders_container_width,
             height=self.screen_margin,
             config=self.visualization_config,
@@ -1434,21 +1436,21 @@ class PyGameGUI:
         duration_color_change = 90
         if score > self.last_score:
             self.score_label.update_theming(
-                '{"colours": {"normal_text": "#03b706"}, "font": { "size": 22, "bold": 1}}'
+                '{"colours": {"normal_text": "#03b706"}, "font": { "size": 20, "bold": 1}}'
             )
 
             self.count_frames_score_label = 0
             self.switch_score_color = True
         elif score < self.last_score:
             self.score_label.update_theming(
-                '{"colours": {"normal_text": "#e22312"}, "font": { "size": 22, "bold": 1}}'
+                '{"colours": {"normal_text": "#e22312"}, "font": { "size": 20, "bold": 1}}'
             )
             self.count_frames_score_label = 0
             self.switch_score_color = True
         elif self.switch_score_color:
             if self.count_frames_score_label >= duration_color_change:
                 self.score_label.update_theming(
-                    '{"colours": {"normal_text": "#000000"}, "font": { "size": 20, "bold": 0}}'
+                    '{"colours": {"normal_text": "#000000"}, "font": { "size": 20, "bold": 1}}'
                 )
                 self.count_frames_score_label = 0
                 self.switch_score_color = False
diff --git a/cooperative_cuisine/pygame_2d_vis/visualization.yaml b/cooperative_cuisine/pygame_2d_vis/visualization.yaml
index 6f1fbe54..6cccb65b 100644
--- a/cooperative_cuisine/pygame_2d_vis/visualization.yaml
+++ b/cooperative_cuisine/pygame_2d_vis/visualization.yaml
@@ -7,7 +7,7 @@ Gui:
   show_counter_centers: False
 
 GameWindow:
-  screen_margin: 100
+  screen_margin_proportion: 0.15
   min_width: 900
   min_height: 600
   buttons_width: 180
-- 
GitLab