Skip to content
Snippets Groups Projects
Commit 19de1cb7 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Press a button image not shown when not enabled, x positions of recipe graphs replaced by linspace

parent 0def69a2
No related branches found
No related tags found
No related merge requests found
Pipeline #49866 passed
...@@ -924,7 +924,22 @@ class Visualizer: ...@@ -924,7 +924,22 @@ class Visualizer:
self, screen: pygame.Surface, graph_dict, width, height, grid_size self, screen: pygame.Surface, graph_dict, width, height, grid_size
) -> None: ) -> None:
# screen.fill(self.config["GameWindow"]["background_color"]) # screen.fill(self.config["GameWindow"]["background_color"])
positions_dict = graph_dict["layout"] 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 = np.array(list(positions_dict.values()))
positions = positions - positions.min(axis=0) positions = positions - positions.min(axis=0)
positions[positions == 0] = 0.000001 positions[positions == 0] = 0.000001
......
...@@ -537,24 +537,30 @@ class PyGameGUI: ...@@ -537,24 +537,30 @@ class PyGameGUI:
object_id="#start_button", object_id="#start_button",
) )
img = pygame.image.load( if self.visualization_config["Gui"]["press_button_to_continue"]:
ROOT_DIR / "pygame_2d_vis" / "gui_images" / f"continue_{self.language}.png" img = pygame.image.load(
).convert_alpha() ROOT_DIR
/ "pygame_2d_vis"
image_rect = img.get_rect() / "gui_images"
img_width = self.buttons_width * 1.5 / f"continue_{self.language}.png"
img_height = img_width * (image_rect.height / image_rect.width) ).convert_alpha()
new_dims = (img_width, img_height)
img = pygame.transform.smoothscale(img, new_dims) image_rect = img.get_rect()
image_rect = img.get_rect() img_width = self.buttons_width * 1.5
img_height = img_width * (image_rect.height / image_rect.width)
image_rect.centery += 80 new_dims = (img_width, img_height)
self.press_a_image = pygame_gui.elements.UIImage( img = pygame.transform.smoothscale(img, new_dims)
image_rect, image_rect = img.get_rect()
img,
manager=self.manager, image_rect.centery += 80
anchors={"centerx": "centerx", "centery": "centery"}, 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) # self.press_a_image.set_dimensions(new_dims)
if not self.CONNECT_WITH_STUDY_SERVER: if not self.CONNECT_WITH_STUDY_SERVER:
...@@ -1094,9 +1100,11 @@ class PyGameGUI: ...@@ -1094,9 +1100,11 @@ class PyGameGUI:
+ self.other_elements + self.other_elements
) )
for element in all_elements: for element in all_elements:
element.hide() if element:
element.hide()
for element in elements + self.on_all_screens: for element in elements + self.on_all_screens:
element.show() if element:
element.show()
def setup_tutorial_screen(self): def setup_tutorial_screen(self):
"""Updates the tutorial screen with the current tutorial image and the continue button.""" """Updates the tutorial screen with the current tutorial image and the continue button."""
...@@ -1575,8 +1583,11 @@ class PyGameGUI: ...@@ -1575,8 +1583,11 @@ class PyGameGUI:
meal = re.sub(r"(?<!^)(?=[A-Z])", " ", meal) meal = re.sub(r"(?<!^)(?=[A-Z])", " ", meal)
positions = np.array(list(rg["layout"].values())) 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_height = height * 0.9
graph_surface = pygame.Surface( graph_surface = pygame.Surface(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment