diff --git a/cooperative_cuisine/pygame_2d_vis/drawing.py b/cooperative_cuisine/pygame_2d_vis/drawing.py index c18691a6503d3d3613e3ec7db4043ba8a5e09fcb..c416278e8fcc0259bdef231b5db85ab01f42614b 100644 --- a/cooperative_cuisine/pygame_2d_vis/drawing.py +++ b/cooperative_cuisine/pygame_2d_vis/drawing.py @@ -924,7 +924,22 @@ class Visualizer: self, screen: pygame.Surface, graph_dict, width, height, grid_size ) -> None: # screen.fill(self.config["GameWindow"]["background_color"]) + positions_dict = graph_dict["layout"] + + positions = np.array(list(positions_dict.values())) + unique_x_vals = np.unique(positions[:, 0]) + new_positions_unique = np.linspace( + start=0, + stop=np.max(positions[:, 0]), + num=len(unique_x_vals), + ) + replace_map = { + unique_x_vals[i]: new_positions_unique[i] for i in range(len(unique_x_vals)) + } + for k, v in graph_dict["layout"].items(): + graph_dict["layout"][k] = (replace_map[v[0]], v[1]) + positions = np.array(list(positions_dict.values())) positions = positions - positions.min(axis=0) positions[positions == 0] = 0.000001 diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index b46340e0cb1c02d8b13520b9a524ce2583af9723..a245e5fe375920e17e1ac4df1798441961568662 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -537,24 +537,30 @@ class PyGameGUI: object_id="#start_button", ) - img = pygame.image.load( - ROOT_DIR / "pygame_2d_vis" / "gui_images" / f"continue_{self.language}.png" - ).convert_alpha() - - image_rect = img.get_rect() - img_width = self.buttons_width * 1.5 - img_height = img_width * (image_rect.height / image_rect.width) - new_dims = (img_width, img_height) - img = pygame.transform.smoothscale(img, new_dims) - image_rect = img.get_rect() - - image_rect.centery += 80 - self.press_a_image = pygame_gui.elements.UIImage( - image_rect, - img, - manager=self.manager, - anchors={"centerx": "centerx", "centery": "centery"}, - ) + if self.visualization_config["Gui"]["press_button_to_continue"]: + img = pygame.image.load( + ROOT_DIR + / "pygame_2d_vis" + / "gui_images" + / f"continue_{self.language}.png" + ).convert_alpha() + + image_rect = img.get_rect() + img_width = self.buttons_width * 1.5 + img_height = img_width * (image_rect.height / image_rect.width) + new_dims = (img_width, img_height) + img = pygame.transform.smoothscale(img, new_dims) + image_rect = img.get_rect() + + image_rect.centery += 80 + self.press_a_image = pygame_gui.elements.UIImage( + image_rect, + img, + manager=self.manager, + anchors={"centerx": "centerx", "centery": "centery"}, + ) + else: + self.press_a_image = None # self.press_a_image.set_dimensions(new_dims) if not self.CONNECT_WITH_STUDY_SERVER: @@ -1094,9 +1100,11 @@ class PyGameGUI: + self.other_elements ) for element in all_elements: - element.hide() + if element: + element.hide() for element in elements + self.on_all_screens: - element.show() + if element: + element.show() def setup_tutorial_screen(self): """Updates the tutorial screen with the current tutorial image and the continue button.""" @@ -1575,8 +1583,11 @@ class PyGameGUI: meal = re.sub(r"(?<!^)(?=[A-Z])", " ", meal) positions = np.array(list(rg["layout"].values())) - unique_vals = np.unique(positions[:, 1]) - height = row_height * len(unique_vals) + + unique_x_vals = np.unique(positions[:, 0]) + + + height = row_height * len(np.unique(positions[:, 1])) graph_height = height * 0.9 graph_surface = pygame.Surface(