diff pyntnclick/state.py @ 693:c8b683dd56d3 pyntnclick

Better modal message and result handling.
author Jeremy Thurgood <firxen@gmail.com>
date Tue, 14 Feb 2012 15:36:28 +0200
parents d6ded808cc33
children b773e9f42ba3
line wrap: on
line diff
--- a/pyntnclick/state.py	Tue Feb 14 13:39:05 2012 +0200
+++ b/pyntnclick/state.py	Tue Feb 14 15:36:28 2012 +0200
@@ -28,34 +28,22 @@
         self.close_detail = close_detail
         self.end_game = end_game
 
-    def play_sound(self, scene_widget):
+    def play_sound(self, screen):
         if self.soundfile:
-            sound = scene_widget.game.gd.sound.get_sound(self.soundfile)
+            sound = screen.gd.sound.get_sound(self.soundfile)
             sound.play()
 
-    def process(self, scene_widget):
+    def process(self, screen):
         """Helper function to do the right thing with a result object"""
-        self.play_sound(scene_widget)
+        self.play_sound(screen)
         if self.widget:
-            scene_widget.queue_widget(self.widget)
+            screen.queue_widget(self.widget)
         if self.message:
-            scene_widget.show_message(self.message)
+            screen.show_message(self.message)
         if self.detail_view:
-            scene_widget.game.show_detail(self.detail_view)
+            screen.game.show_detail(self.detail_view)
         if self.end_game:
-            scene_widget.end_game()
-
-
-def handle_result(result, scene_widget):
-    """Handle dealing with result or result sequences"""
-    if result:
-        if hasattr(result, 'process'):
-            result.process(scene_widget)
-        else:
-            for res in result:
-                if res:
-                    # List may contain None's
-                    res.process(scene_widget)
+            screen.end_game()
 
 
 class GameState(dict):
@@ -188,6 +176,7 @@
     def cancel_doodah(self, screen):
         if self.tool:
             self.set_tool(None)
+        
         # XXX: Needs to be tweaked to work with the new
         # scene stuff
         #elif self.current_detail: