Started to implement popup()

This commit is contained in:
2025-06-24 06:07:23 +01:00
parent 8893fd90c6
commit c7156112dc

View File

@ -23,6 +23,11 @@ class Game:
self.pm = NoPELib.PlayersManager(self.cfg['name'], playersPath='../players.json') self.pm = NoPELib.PlayersManager(self.cfg['name'], playersPath='../players.json')
# Holds all the timeouts that haven't been fired yet # Holds all the timeouts that haven't been fired yet
self._timeouts = [] self._timeouts = []
# The following are used by self.popup() to halt some events
self._haltUpdate = False
self._haltEvents = False
# Will become a pygame.Surface with the popup contents
self._popupMenu = None
def update(self): def update(self):
""" """
@ -42,7 +47,8 @@ class Game:
self._timeouts.remove(timeout) self._timeouts.remove(timeout)
# Game update # Game update
self.update() if not self._haltUpdate:
self.update()
# TODO: Draw things like debug menu, etc. # TODO: Draw things like debug menu, etc.
@ -102,8 +108,19 @@ class Game:
ID on the stack, False otherwise. ID on the stack, False otherwise.
""" """
return any([timeout.timeoutID == id for timeout in self._timeouts]) def popup(self, title: str, text: str, haltUpdate: bool=False, haltEvents: bool=True):
"""
# TODO: Add popup method Pops up a dialogue box.
Args:
title (str): The big "title" text to be displayed.
text (str): The main body text to be displayed.
haltUpdate (bool): If True, the games update() method will not be called until
the popup is dismissed. Default: False.
haltEvents (bool): If True, the games onEvent() method will not be called until
the popup is dismissed. Default: True.
"""
self._haltUpdate = haltUpdate
self._haltEvents = haltEvents
# TODO: add punish(player, intensity)