comparison gamelib/state.py @ 443:3dab4984cbd7

Redo way of reaching end screen
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 29 Aug 2010 00:24:40 +0200
parents 19aff54b2e73
children af2a23b9787d
comparison
equal deleted inserted replaced
442:05d15be39377 443:3dab4984cbd7
16 DEBUG_RECTS = False 16 DEBUG_RECTS = False
17 17
18 class Result(object): 18 class Result(object):
19 """Result of interacting with a thing""" 19 """Result of interacting with a thing"""
20 20
21 def __init__(self, message=None, soundfile=None, detail_view=None, style=None, close_detail=False): 21 def __init__(self, message=None, soundfile=None, detail_view=None, style=None, close_detail=False, end_game=False):
22 self.message = message 22 self.message = message
23 self.sound = None 23 self.sound = None
24 if soundfile: 24 if soundfile:
25 self.sound = get_sound(soundfile) 25 self.sound = get_sound(soundfile)
26 self.detail_view = detail_view 26 self.detail_view = detail_view
27 self.style = style 27 self.style = style
28 self.close_detail = close_detail 28 self.close_detail = close_detail
29 self.end_game = end_game
29 30
30 def process(self, scene_widget): 31 def process(self, scene_widget):
31 """Helper function to do the right thing with a result object""" 32 """Helper function to do the right thing with a result object"""
32 if self.sound: 33 if self.sound:
33 self.sound.play() 34 self.sound.play()
35 scene_widget.show_message(self.message, self.style) 36 scene_widget.show_message(self.message, self.style)
36 if self.detail_view: 37 if self.detail_view:
37 scene_widget.show_detail(self.detail_view) 38 scene_widget.show_detail(self.detail_view)
38 if self.close_detail and hasattr(scene_widget, 'parent') and hasattr(scene_widget.parent, 'clear_detail'): 39 if self.close_detail and hasattr(scene_widget, 'parent') and hasattr(scene_widget.parent, 'clear_detail'):
39 scene_widget.parent.clear_detail() 40 scene_widget.parent.clear_detail()
41 if self.end_game:
42 scene_widget.end_game()
40 43
41 44
42 def handle_result(result, scene_widget): 45 def handle_result(result, scene_widget):
43 """Handle dealing with result or result sequences""" 46 """Handle dealing with result or result sequences"""
44 if result: 47 if result: