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')
|
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,6 +47,7 @@ class Game:
|
|||||||
self._timeouts.remove(timeout)
|
self._timeouts.remove(timeout)
|
||||||
|
|
||||||
# Game update
|
# Game update
|
||||||
|
if not self._haltUpdate:
|
||||||
self.update()
|
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):
|
||||||
|
"""
|
||||||
|
Pops up a dialogue box.
|
||||||
|
|
||||||
# TODO: Add popup method
|
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