Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
84fda205
Commit
84fda205
authored
6 months ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Fixed overlapping button
parent
819a1a3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!110
V1.2.0 changes
,
!106
Visual layout selection
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cooperative_cuisine/pygame_2d_vis/gui.py
+20
-18
20 additions, 18 deletions
cooperative_cuisine/pygame_2d_vis/gui.py
with
20 additions
and
18 deletions
cooperative_cuisine/pygame_2d_vis/gui.py
+
20
−
18
View file @
84fda205
...
@@ -223,7 +223,7 @@ class PyGameGUI:
...
@@ -223,7 +223,7 @@ class PyGameGUI:
self
.
layout_file_paths
=
sorted
(
list
(
self
.
layout_file_paths_dict
.
keys
()))
self
.
layout_file_paths
=
sorted
(
list
(
self
.
layout_file_paths_dict
.
keys
()))
self
.
current_layout_idx
=
0
self
.
current_layout_idx
=
0
self
.
selected_layout
_path
=
self
.
layout_file_paths_dict
[
"
basic.layout
"
]
self
.
selected_layout
=
"
basic.layout
"
self
.
last_state
:
StateRepresentation
self
.
last_state
:
StateRepresentation
...
@@ -595,24 +595,22 @@ class PyGameGUI:
...
@@ -595,24 +595,22 @@ class PyGameGUI:
object_id
=
"
#players
"
,
object_id
=
"
#players
"
,
anchors
=
{
"
bottom
"
:
"
bottom
"
,
"
centerx
"
:
"
centerx
"
},
anchors
=
{
"
bottom
"
:
"
bottom
"
,
"
centerx
"
:
"
centerx
"
},
)
)
rect
=
pygame
.
Rect
((
0
,
0
),
(
190
,
50
))
multiple_keysets_button_rect
=
pygame
.
Rect
((
0
,
0
),
(
190
,
50
))
self
.
multiple_keysets_button
=
pygame_gui
.
elements
.
UIButton
(
self
.
multiple_keysets_button
=
pygame_gui
.
elements
.
UIButton
(
relative_rect
=
multiple_keysets_button_
rect
,
relative_rect
=
rect
,
manager
=
self
.
manager
,
manager
=
self
.
manager
,
container
=
self
.
player_selection_container
,
container
=
self
.
player_selection_container
,
text
=
"
not set
"
,
text
=
"
not set
"
,
anchors
=
{
"
left
"
:
"
left
"
,
"
centery
"
:
"
centery
"
},
anchors
=
{
"
centerx
"
:
"
centerx
"
,
"
centery
"
:
"
centery
"
},
object_id
=
"
#multiple_keysets_button
"
,
object_id
=
"
#multiple_keysets_button
"
,
)
)
split_players_button_rect
=
pygame
.
Rect
((
0
,
0
),
(
190
,
50
))
split_players_button_rect
=
pygame
.
Rect
((
0
,
0
),
(
190
,
50
))
self
.
split_players_button
=
pygame_gui
.
elements
.
UIButton
(
self
.
split_players_button
=
pygame_gui
.
elements
.
UIButton
(
relative_rect
=
split_players_button_rect
,
relative_rect
=
split_players_button_rect
,
manager
=
self
.
manager
,
manager
=
self
.
manager
,
container
=
self
.
player_selection_container
,
container
=
self
.
player_selection_container
,
text
=
"
not set
"
,
text
=
"
not set
"
,
anchors
=
{
"
center
x
"
:
"
center
x
"
,
"
centery
"
:
"
centery
"
},
anchors
=
{
"
center
y
"
:
"
center
y
"
,
"
left_target
"
:
self
.
multiple_keysets_button
},
object_id
=
"
#split_players_button
"
,
object_id
=
"
#split_players_button
"
,
)
)
...
@@ -1123,11 +1121,14 @@ class PyGameGUI:
...
@@ -1123,11 +1121,14 @@ class PyGameGUI:
if
not
self
.
CONNECT_WITH_STUDY_SERVER
:
if
not
self
.
CONNECT_WITH_STUDY_SERVER
:
self
.
start_screen_elements
.
append
(
self
.
scroll_space_layouts
)
self
.
start_screen_elements
.
append
(
self
.
scroll_space_layouts
)
self
.
start_screen_elements
.
append
(
self
.
selected_layout_label
)
self
.
game_screen_elements
.
append
(
self
.
return_to_main_button
)
self
.
game_screen_elements
.
append
(
self
.
return_to_main_button
)
self
.
other_elements
.
append
(
self
.
layout_selection
)
self
.
other_elements
.
append
(
self
.
layout_selection
)
else
:
else
:
self
.
other_elements
.
append
(
self
.
scroll_space_layouts
)
self
.
other_elements
.
append
(
self
.
scroll_space_layouts
)
self
.
other_elements
.
append
(
self
.
return_to_main_button
)
self
.
other_elements
.
append
(
self
.
return_to_main_button
)
self
.
other_elements
.
append
(
self
.
selected_layout_label
)
self
.
other_elements
.
append
(
self
.
layout_selection
)
self
.
other_elements
.
append
(
self
.
layout_selection
)
self
.
postgame_screen_elements
=
[
self
.
postgame_screen_elements
=
[
...
@@ -1259,7 +1260,7 @@ class PyGameGUI:
...
@@ -1259,7 +1260,7 @@ class PyGameGUI:
anchors
=
{
"
centerx
"
:
"
centerx
"
,
"
centery
"
:
"
centery
"
},
anchors
=
{
"
centerx
"
:
"
centerx
"
,
"
centery
"
:
"
centery
"
},
)
)
button
.
update_theming
(
button
.
update_theming
(
'
{
"
colours
"
: {
"
normal_bg
"
:
"
rgba(0, 0, 0, 0)
"
}}
'
'
{
"
colours
"
: {
"
normal_bg
"
:
"
rgba(0, 0, 0, 0)
"
,
"
active_bg
"
:
"
rgba(255, 255, 255, 255)
"
}}
'
)
)
self
.
layout_buttons
[
button
]
=
layout_name
self
.
layout_buttons
[
button
]
=
layout_name
...
@@ -1301,6 +1302,8 @@ class PyGameGUI:
...
@@ -1301,6 +1302,8 @@ class PyGameGUI:
self
.
show_screen_elements
(
self
.
start_screen_elements
)
self
.
show_screen_elements
(
self
.
start_screen_elements
)
if
self
.
CONNECT_WITH_STUDY_SERVER
:
if
self
.
CONNECT_WITH_STUDY_SERVER
:
self
.
bot_number_container
.
hide
()
self
.
bot_number_container
.
hide
()
# else:
# self.setup_layout_selection()
self
.
update_selection_elements
()
self
.
update_selection_elements
()
case
MenuStates
.
Tutorial
:
case
MenuStates
.
Tutorial
:
self
.
setup_tutorial_screen
()
self
.
setup_tutorial_screen
()
...
@@ -1347,7 +1350,6 @@ class PyGameGUI:
...
@@ -1347,7 +1350,6 @@ class PyGameGUI:
state: The game state returned by the environment, containing served meals and score.
state: The game state returned by the environment, containing served meals and score.
"""
"""
score
=
state
[
"
score
"
]
score
=
state
[
"
score
"
]
# self.score_conclusion.set_text(f"Your final score is {score}. Hurray!")
self
.
score_conclusion
.
set_text
(
self
.
score_conclusion
.
set_text
(
"
translations.final_score
"
,
text_kwargs
=
{
"
score
"
:
str
(
score
)}
"
translations.final_score
"
,
text_kwargs
=
{
"
score
"
:
str
(
score
)}
)
)
...
@@ -1648,7 +1650,7 @@ class PyGameGUI:
...
@@ -1648,7 +1650,7 @@ class PyGameGUI:
environment_config_path
=
ROOT_DIR
/
"
configs
"
/
"
tutorial_env_config.yaml
"
environment_config_path
=
ROOT_DIR
/
"
configs
"
/
"
tutorial_env_config.yaml
"
else
:
else
:
environment_config_path
=
ROOT_DIR
/
"
configs
"
/
"
environment_config.yaml
"
environment_config_path
=
ROOT_DIR
/
"
configs
"
/
"
environment_config.yaml
"
layout_path
=
self
.
selected_layout
_path
layout_path
=
self
.
layout_file_paths_dict
[
self
.
selected_layout
]
# layout_path = self.layout_file_paths[self.current_layout_idx]
# layout_path = self.layout_file_paths[self.current_layout_idx]
item_info_path
=
ROOT_DIR
/
"
configs
"
/
"
item_info.yaml
"
item_info_path
=
ROOT_DIR
/
"
configs
"
/
"
item_info.yaml
"
...
@@ -1698,7 +1700,7 @@ class PyGameGUI:
...
@@ -1698,7 +1700,7 @@ class PyGameGUI:
disjunct
=
self
.
split_players
,
disjunct
=
self
.
split_players
,
)
)
self
.
level_info
=
env_info
self
.
level_info
=
env_info
self
.
level_info
[
"
name
"
]
=
self
.
layout_selection
.
selected_option
self
.
level_info
[
"
name
"
]
=
self
.
selected_layout
.
replace
(
"
.layout
"
,
""
)
self
.
level_info
[
"
number_players
"
]
=
num_players
self
.
level_info
[
"
number_players
"
]
=
num_players
def
update_pregame_screen
(
self
):
def
update_pregame_screen
(
self
):
...
@@ -1992,7 +1994,7 @@ class PyGameGUI:
...
@@ -1992,7 +1994,7 @@ class PyGameGUI:
self
.
init_ui_elements
()
self
.
init_ui_elements
()
self
.
set_game_size
()
self
.
set_game_size
()
self
.
update_screen_elements
()
self
.
update_screen_elements
()
self
.
setup_layout_selection
()
#
self.setup_layout_selection()
def
reset_gui_values
(
self
):
def
reset_gui_values
(
self
):
"""
Reset the values of the GUI elements to their default values. Default values are defined here.
"""
"""
Reset the values of the GUI elements to their default values. Default values are defined here.
"""
...
@@ -2059,6 +2061,11 @@ class PyGameGUI:
...
@@ -2059,6 +2061,11 @@ class PyGameGUI:
else
:
else
:
self
.
start_button
.
enable
()
self
.
start_button
.
enable
()
self
.
selected_layout_path
=
self
.
layout_file_paths_dict
[
self
.
selected_layout
]
self
.
selected_layout_label
.
set_text
(
"
translations.selected_layout
"
,
text_kwargs
=
{
"
layout
"
:
self
.
selected_layout
.
replace
(
"
.layout
"
,
""
)}
)
def
send_action
(
self
,
action
:
Action
):
def
send_action
(
self
,
action
:
Action
):
"""
Sends an action to the game environment.
"""
Sends an action to the game environment.
...
@@ -2232,12 +2239,7 @@ class PyGameGUI:
...
@@ -2232,12 +2239,7 @@ class PyGameGUI:
self
.
split_players
=
not
self
.
split_players
self
.
split_players
=
not
self
.
split_players
case
other
:
case
other
:
if
button
in
self
.
layout_buttons
:
if
button
in
self
.
layout_buttons
:
selected_layout
=
self
.
layout_buttons
[
button
]
self
.
selected_layout
=
self
.
layout_buttons
[
button
]
self
.
selected_layout_path
=
self
.
layout_file_paths_dict
[
selected_layout
]
print
(
"
SELECTED LAYOUT
"
,
self
.
selected_layout_path
)
self
.
selected_layout_label
.
set_text
(
"
translations.selected_layout
"
,
text_kwargs
=
{
"
layout
"
:
selected_layout
}
)
############################################
############################################
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment