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
150c4f6b
Commit
150c4f6b
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Fix when resizing and switching to fullscreen
parent
17c3eddd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!55
Resolve "Second window"
Pipeline
#45929
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
overcooked_simulator/gui_2d_vis/overcooked_gui.py
+38
-8
38 additions, 8 deletions
overcooked_simulator/gui_2d_vis/overcooked_gui.py
with
38 additions
and
8 deletions
overcooked_simulator/gui_2d_vis/overcooked_gui.py
+
38
−
8
View file @
150c4f6b
...
...
@@ -151,6 +151,8 @@ class PyGameGUI:
self
.
kitchen_height
=
1
self
.
kitchen_aspect_ratio
=
1
self
.
two_windows
=
False
def
get_window_sizes
(
self
,
state
:
dict
):
self
.
kitchen_width
=
state
[
"
kitchen
"
][
"
width
"
]
self
.
kitchen_height
=
state
[
"
kitchen
"
][
"
height
"
]
...
...
@@ -317,14 +319,27 @@ class PyGameGUI:
(
0
,
0
),
(
self
.
buttons_width
,
self
.
buttons_height
)
)
fullscreen_button_rect
.
topright
=
(
0
,
self
.
buttons_height
)
self
.
fullscreen_button
_rect
=
pygame_gui
.
elements
.
UIButton
(
self
.
fullscreen_button
=
pygame_gui
.
elements
.
UIButton
(
relative_rect
=
fullscreen_button_rect
,
text
=
"
Fullscreen
"
,
manager
=
self
.
manager
,
object_id
=
"
#fullscreen_button
"
,
anchors
=
{
"
right
"
:
"
right
"
,
"
top
"
:
"
top
"
},
)
self
.
fullscreen_button_rect
.
can_hover
()
self
.
fullscreen_button
.
can_hover
()
second_window_button_rect
=
pygame
.
Rect
(
(
0
,
0
),
(
self
.
buttons_width
,
self
.
buttons_height
)
)
second_window_button_rect
.
topright
=
(
0
,
2
*
self
.
buttons_height
)
self
.
second_window_button
=
pygame_gui
.
elements
.
UIButton
(
relative_rect
=
second_window_button_rect
,
text
=
"
Second window
"
,
manager
=
self
.
manager
,
object_id
=
"
#fullscreen_button
"
,
anchors
=
{
"
right
"
:
"
right
"
,
"
top
"
:
"
top
"
},
)
self
.
second_window_button
.
can_hover
()
self
.
reset_button
=
pygame_gui
.
elements
.
UIButton
(
relative_rect
=
pygame
.
Rect
(
...
...
@@ -650,7 +665,8 @@ class PyGameGUI:
self
.
window_width
,
self
.
window_height
,
),
flags
=
flags
|
pygame
.
RESIZABLE
,
flags
=
flags
,
display
=
0
,
)
def
reset_window_size
(
self
):
...
...
@@ -1000,6 +1016,17 @@ class PyGameGUI:
self
.
update_selection_elements
()
# second_win = Window(
# "Player Two",
# resizable=True,
# size=(
# self.window_width_windowed,
# self.window_height_windowed,
# ),
# )
# second_window_renderer = Renderer(second_win)
# second_win.hide()
# Game loop
self
.
running
=
True
while
self
.
running
:
...
...
@@ -1014,7 +1041,7 @@ class PyGameGUI:
elif
event
.
type
==
pygame
.
VIDEORESIZE
:
# scrsize = event.size
self
.
window_width_windowed
=
event
.
w
self
.
window
ed
_height_windowed
=
event
.
h
self
.
window_height_windowed
=
event
.
h
self
.
recalc_game_size
()
self
.
set_window_size
()
...
...
@@ -1073,11 +1100,14 @@ class PyGameGUI:
case
self
.
xbox_controller_button
:
print
(
"
xbox_controller_button pressed.
"
)
case
self
.
fullscreen_button
_rect
:
case
self
.
fullscreen_button
:
self
.
fullscreen
=
not
self
.
fullscreen
if
not
self
.
fullscreen
:
self
.
window_width_windowed
=
self
.
min_width
self
.
windowed_height_windowed
=
self
.
min_height
if
self
.
fullscreen
:
self
.
window_width
=
self
.
window_width_fullscreen
self
.
window_height
=
self
.
window_height_fullscreen
else
:
self
.
window_width
=
self
.
window_width_windowed
self
.
window_height
=
self
.
window_height_windowed
self
.
recalc_game_size
()
self
.
set_window_size
()
self
.
init_ui_elements
()
...
...
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