X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fevents.py;h=158672611d3b57e9735a716dc1b6f8f11fb5a8e3;hb=ba6874da203fc7eec66a6efffb9747a4f5706d86;hp=e34f74043b31209fc690eb95f357860d3fbfecf6;hpb=2a9f5c76556f00f631ea10a6cba44a92bdd27512;p=naja.git diff --git a/naja/events.py b/naja/events.py index e34f740..1586726 100644 --- a/naja/events.py +++ b/naja/events.py @@ -6,8 +6,15 @@ import pygame.event as pge import pygame.locals as pgl -class NajaEvent(object): +def finish_event(handled=True, events=(), skip_invalidate=False): + for event in events: + event.post() + if not skip_invalidate: + InvalidateTheWorld.post() + return handled + +class NajaEvent(object): TYPE = "UNKNOWN" @classmethod @@ -32,24 +39,17 @@ class SceneChangeEvent(NajaEvent): class QuitGameEvent(NajaEvent): TYPE = "QUIT_GAME" - @classmethod - def post(cls): - super(QuitGameEvent, cls).post() - class InvalidateTheWorld(NajaEvent): # This is used to signal to all the widgets that the world has changed # and cached state may need to be recreated TYPE = "INVALIDATE" - @classmethod - def post(cls): - super(InvalidateTheWorld, cls).post() - class SelectEvent(NajaEvent): TYPE = "SELECT" - @classmethod - def post(cls): - super(SelectEvent, cls).post() + +class PlayerMoved(NajaEvent): + # This is used to signal to widgets that care that the player has moved. + TYPE = "PLAYER_MOVED"