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
19de1cb7
Commit
19de1cb7
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
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
1 year ago
Stage: test
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cooperative_cuisine/pygame_2d_vis/drawing.py
+15
-0
15 additions, 0 deletions
cooperative_cuisine/pygame_2d_vis/drawing.py
cooperative_cuisine/pygame_2d_vis/gui.py
+33
-22
33 additions, 22 deletions
cooperative_cuisine/pygame_2d_vis/gui.py
with
48 additions
and
22 deletions
cooperative_cuisine/pygame_2d_vis/drawing.py
+
15
−
0
View file @
19de1cb7
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/pygame_2d_vis/gui.py
+
33
−
22
View file @
19de1cb7
...
@@ -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
(
...
...
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