Skip to content
Snippets Groups Projects

Resolve "Second window"

Merged Fabian Heinrich requested to merge 88-second-window into main
@@ -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.windowed_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()
Loading