From 8181885c84ef90cb1a936c1abe159f64a409da31 Mon Sep 17 00:00:00 2001 From: Faraphel Date: Fri, 17 Feb 2023 16:09:49 +0100 Subject: [PATCH] fixed an issue with gl context when connected --- source/gui/scene/__init__.py | 4 ++-- source/gui/window/Window.py | 2 +- source/network/Client.py | 5 ++++- source/network/Host.py | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/gui/scene/__init__.py b/source/gui/scene/__init__.py index 6ac122e..ca9e8a8 100644 --- a/source/gui/scene/__init__.py +++ b/source/gui/scene/__init__.py @@ -1,6 +1,6 @@ +from .Game import Game +from .Settings import Settings from .RoomCreate import RoomCreate from .RoomJoin import RoomJoin -from .Settings import Settings -from .Game import Game from .MainMenu import MainMenu diff --git a/source/gui/window/Window.py b/source/gui/window/Window.py index 1f07740..ac78683 100644 --- a/source/gui/window/Window.py +++ b/source/gui/window/Window.py @@ -72,7 +72,7 @@ class Window(pyglet.window.Window): # NOQA def _event_wrapper(self, item: str) -> Callable: """ Un wrapper permettant d'appeler l'événement de toutes les scènes attachées. - :param name: nom de la fonction à appeler dans la scène. + :param item: nom de la fonction à appeler dans la scène. :return: une fonction appelant l'événement original ainsi que ceux des scènes. """ diff --git a/source/network/Client.py b/source/network/Client.py index cdce1ad..26c75a5 100644 --- a/source/network/Client.py +++ b/source/network/Client.py @@ -1,6 +1,8 @@ import socket from threading import Thread +import pyglet.clock + from source.gui.scene import Game @@ -20,4 +22,5 @@ class Client(Thread): print(f"[Client] Connecté avec {s}") - self.window.set_scene(Game) + pyglet.clock.schedule_once(lambda dt: self.window.set_scene(Game), 0) + diff --git a/source/network/Host.py b/source/network/Host.py index 4f91721..6a3a964 100644 --- a/source/network/Host.py +++ b/source/network/Host.py @@ -1,6 +1,8 @@ import socket from threading import Thread +import pyglet + from source.gui.scene import Game @@ -21,4 +23,4 @@ class Host(Thread): print(f"[Serveur] Connecté avec {address}") - self.window.set_scene(Game) + pyglet.clock.schedule_once(lambda dt: self.window.set_scene(Game), 0)