Started to implement popup()
This commit is contained in:
@ -23,6 +23,11 @@ class Game:
|
||||
self.pm = NoPELib.PlayersManager(self.cfg['name'], playersPath='../players.json')
|
||||
# Holds all the timeouts that haven't been fired yet
|
||||
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):
|
||||
"""
|
||||
@ -42,7 +47,8 @@ class Game:
|
||||
self._timeouts.remove(timeout)
|
||||
|
||||
# Game update
|
||||
self.update()
|
||||
if not self._haltUpdate:
|
||||
self.update()
|
||||
|
||||
# TODO: Draw things like debug menu, etc.
|
||||
|
||||
@ -102,8 +108,19 @@ class Game:
|
||||
ID on the stack, False otherwise.
|
||||
"""
|
||||
|
||||
return any([timeout.timeoutID == id for timeout in self._timeouts])
|
||||
|
||||
# TODO: Add popup method
|
||||
def popup(self, title: str, text: str, haltUpdate: bool=False, haltEvents: bool=True):
|
||||
"""
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user