made robot gold; shuffled tile backgrounds
[naja.git] / naja / events.py
index e34f74043b31209fc690eb95f357860d3fbfecf6..158672611d3b57e9735a716dc1b6f8f11fb5a8e3 100644 (file)
@@ -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"