diff --git a/overcooked_simulator/gui_2d_vis/overcooked_gui.py b/overcooked_simulator/gui_2d_vis/overcooked_gui.py index b6843fc61b72f315fd2e573d149e973c84037576..6a46629274fdb535c25023beb7abcb021a6d6d19 100644 --- a/overcooked_simulator/gui_2d_vis/overcooked_gui.py +++ b/overcooked_simulator/gui_2d_vis/overcooked_gui.py @@ -298,11 +298,11 @@ class PyGameGUI: object_id="#score_label", ) - layout_file_paths = [ - str(p.name) + self.layout_file_paths = { + str(p.name): p for p in (ROOT_DIR / "game_content" / "layouts").glob("*.layout") - ] - assert len(layout_file_paths) != 0, "No layout files." + } + assert len(self.layout_file_paths) != 0, "No layout files." dropdown_width, dropdown_height = 200, 40 self.layout_selection = pygame_gui.elements.UIDropDownMenu( relative_rect=pygame.Rect( @@ -313,8 +313,10 @@ class PyGameGUI: (dropdown_width, dropdown_height), ), manager=self.manager, - options_list=layout_file_paths, - starting_option=layout_file_paths[-1], + options_list=list(self.layout_file_paths.keys()), + starting_option="basic.layout" + if "basic.layout" in self.layout_file_paths + else random.choice(list(self.layout_file_paths.keys())), ) self.timer_label = pygame_gui.elements.UILabel( text="GAMETIME", @@ -439,7 +441,7 @@ class PyGameGUI: def setup_environment(self): environment_config_path = ROOT_DIR / "game_content" / "environment_config.yaml" - layout_path = ROOT_DIR / "game_content" / "layouts" / "basic.layout" + layout_path = self.layout_file_paths[self.layout_selection.selected_option] item_info_path = ROOT_DIR / "game_content" / "item_info_debug.yaml" with open(item_info_path, "r") as file: item_info = file.read()