From 1e4c9fc4df1d376f125d8239fa1af68a2d68ed71 Mon Sep 17 00:00:00 2001 From: klonfish Date: Wed, 28 Dec 2016 00:12:13 +0100 Subject: [PATCH] Game menu refreshes periodically to prevent other clients from painting --- gamemenu.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gamemenu.py b/gamemenu.py index d1b5be7..932d0c6 100755 --- a/gamemenu.py +++ b/gamemenu.py @@ -204,7 +204,7 @@ class TestInput(AbstractInput): pygame = self.__pygame for event in pygame.event.get(): if event.type == pygame.KEYDOWN: - if self.control.get(event.key, None) == InputEvent.STEP_ON: + if self.controls.get(event.key, None) == InputEvent.STEP_ON: self.player_present = True return self.controls.get(event.key, None) return None @@ -342,12 +342,17 @@ if __name__ == '__main__': games = Game.__subclasses__() game_idx = 0 old_idx = -1 + lastrefresh = 0 while True: if old_idx != game_idx: gamecls = games[game_idx] game = gamecls() - out.sendFrame(create_menu_frame(dim, game)) old_idx = game_idx + lastrefresh = 0 + + if time.time() >= lastrefresh+1: + out.sendFrame(create_menu_frame(dim, game)) + lastrefresh = time.time() evt = inp1.get_event() if evt == InputEvent.LEFT: