Skip to content
Snippets Groups Projects
Commit 542a4e99 authored by Florian Schröder's avatar Florian Schröder
Browse files

Update layout file handling in Overcooked GUI

Refactored the way layout file paths are stored and accessed within the Overcooked simulator GUI. Now, layout file paths are stored in a dictionary which allows for more efficient and flexible usage when setting up the environment. The drop-down menu now initializes with 'basic.layout' as the default option, if it exists, otherwise a random layout is chosen.
parent 6d057372
No related branches found
No related tags found
1 merge request!35Resolve "Drawing order of counters and things on top"
Pipeline #44924 passed
......@@ -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()
......
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